OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ | 5 #ifndef VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ |
6 #define VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ | 6 #define VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 virtual ~Checkbox(); | 23 virtual ~Checkbox(); |
24 | 24 |
25 // Sets a listener for this checkbox. Checkboxes aren't required to have them | 25 // Sets a listener for this checkbox. Checkboxes aren't required to have them |
26 // since their state can be read independently of them being toggled. | 26 // since their state can be read independently of them being toggled. |
27 void set_listener(ButtonListener* listener) { listener_ = listener; } | 27 void set_listener(ButtonListener* listener) { listener_ = listener; } |
28 | 28 |
29 // Sets/Gets whether or not the checkbox is checked. | 29 // Sets/Gets whether or not the checkbox is checked. |
30 virtual void SetChecked(bool checked); | 30 virtual void SetChecked(bool checked); |
31 bool checked() const { return checked_; } | 31 bool checked() const { return checked_; } |
32 | 32 |
33 void SetLabel(const std::wstring& label) { | |
34 SetText(label); | |
35 } | |
36 | |
37 protected: | 33 protected: |
38 // Overridden from View: | 34 // Overridden from View: |
39 virtual gfx::Size GetPreferredSize() OVERRIDE; | 35 virtual gfx::Size GetPreferredSize() OVERRIDE; |
40 virtual std::string GetClassName() const OVERRIDE; | 36 virtual std::string GetClassName() const OVERRIDE; |
41 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 37 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
42 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | 38 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; |
43 | 39 |
44 private: | 40 private: |
45 // Overridden from Button: | 41 // Overridden from Button: |
46 virtual void NotifyClick(const views::Event& event) OVERRIDE; | 42 virtual void NotifyClick(const views::Event& event) OVERRIDE; |
47 | 43 |
48 // Overridden from TextButtonBase: | 44 // Overridden from TextButtonBase: |
49 virtual gfx::NativeTheme::Part GetThemePart() const OVERRIDE; | 45 virtual gfx::NativeTheme::Part GetThemePart() const OVERRIDE; |
50 virtual gfx::Rect GetThemePaintRect() const OVERRIDE; | 46 virtual gfx::Rect GetThemePaintRect() const OVERRIDE; |
51 virtual void GetExtraParams( | 47 virtual void GetExtraParams( |
52 gfx::NativeTheme::ExtraParams* params) const OVERRIDE; | 48 gfx::NativeTheme::ExtraParams* params) const OVERRIDE; |
53 virtual gfx::Rect GetTextBounds() const OVERRIDE; | 49 virtual gfx::Rect GetTextBounds() const OVERRIDE; |
54 | 50 |
55 // True if the checkbox is checked. | 51 // True if the checkbox is checked. |
56 bool checked_; | 52 bool checked_; |
57 | 53 |
58 DISALLOW_COPY_AND_ASSIGN(Checkbox); | 54 DISALLOW_COPY_AND_ASSIGN(Checkbox); |
59 }; | 55 }; |
60 | 56 |
61 } // namespace views | 57 } // namespace views |
62 | 58 |
63 #endif // VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ | 59 #endif // VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ |
OLD | NEW |