OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "ui/views/controls/button/text_button.h" | 12 #include "ui/views/controls/button/text_button.h" |
msw
2013/05/13 01:37:22
nit: try to remove this and CheckboxNativeThemeBor
tfarina
2013/05/13 01:47:12
Done.
| |
13 #include "ui/views/controls/button/label_button.h" | |
13 | 14 |
14 namespace views { | 15 namespace views { |
15 | 16 |
16 // A border with zero left inset. | 17 // A border with zero left inset. |
17 class VIEWS_EXPORT CheckboxNativeThemeBorder | 18 class VIEWS_EXPORT CheckboxNativeThemeBorder |
18 : public TextButtonNativeThemeBorder { | 19 : public TextButtonNativeThemeBorder { |
19 public: | 20 public: |
20 explicit CheckboxNativeThemeBorder(views::NativeThemeDelegate* delegate) | 21 explicit CheckboxNativeThemeBorder(views::NativeThemeDelegate* delegate) |
21 : TextButtonNativeThemeBorder(delegate), | 22 : TextButtonNativeThemeBorder(delegate), |
22 use_custom_insets_(false) {} | 23 use_custom_insets_(false) {} |
(...skipping 16 matching lines...) Expand all Loading... | |
39 gfx::Insets custom_insets_; | 40 gfx::Insets custom_insets_; |
40 | 41 |
41 // Whether |custom_insets_| should be used in |GetInsets()|. | 42 // Whether |custom_insets_| should be used in |GetInsets()|. |
42 bool use_custom_insets_; | 43 bool use_custom_insets_; |
43 | 44 |
44 DISALLOW_COPY_AND_ASSIGN(CheckboxNativeThemeBorder); | 45 DISALLOW_COPY_AND_ASSIGN(CheckboxNativeThemeBorder); |
45 }; | 46 }; |
46 | 47 |
47 // A native themed class representing a checkbox. This class does not use | 48 // A native themed class representing a checkbox. This class does not use |
48 // platform specific objects to replicate the native platforms looks and feel. | 49 // platform specific objects to replicate the native platforms looks and feel. |
49 class VIEWS_EXPORT Checkbox : public TextButtonBase { | 50 class VIEWS_EXPORT Checkbox : public LabelButton { |
50 public: | 51 public: |
51 static const char kViewClassName[]; | 52 static const char kViewClassName[]; |
52 | 53 |
53 explicit Checkbox(const string16& label); | 54 explicit Checkbox(const string16& label); |
54 virtual ~Checkbox(); | 55 virtual ~Checkbox(); |
55 | 56 |
56 // Sets a listener for this checkbox. Checkboxes aren't required to have them | 57 // Sets a listener for this checkbox. Checkboxes aren't required to have them |
57 // since their state can be read independently of them being toggled. | 58 // since their state can be read independently of them being toggled. |
58 void set_listener(ButtonListener* listener) { listener_ = listener; } | 59 void set_listener(ButtonListener* listener) { listener_ = listener; } |
59 | 60 |
60 // Sets/Gets whether or not the checkbox is checked. | 61 // Sets/Gets whether or not the checkbox is checked. |
msw
2013/05/13 01:37:22
Add STATE_TOGGLED to LabelButton, use that for che
tfarina
2013/05/13 02:28:31
Done.
| |
61 virtual void SetChecked(bool checked); | 62 virtual void SetChecked(bool checked); |
62 bool checked() const { return checked_; } | 63 bool checked() const { return checked_; } |
63 | 64 |
64 protected: | 65 protected: |
65 // Overridden from View: | 66 // Overridden from View: |
66 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
67 virtual const char* GetClassName() const OVERRIDE; | 67 virtual const char* GetClassName() const OVERRIDE; |
68 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 68 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
69 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | |
70 | 69 |
71 private: | 70 private: |
72 // Overridden from Button: | 71 // Overridden from Button: |
73 virtual void NotifyClick(const ui::Event& event) OVERRIDE; | 72 virtual void NotifyClick(const ui::Event& event) OVERRIDE; |
74 | 73 |
75 // Overridden from TextButtonBase: | |
76 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; | |
77 virtual gfx::Rect GetThemePaintRect() const OVERRIDE; | |
78 virtual void GetExtraParams( | |
79 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | |
80 virtual gfx::Rect GetTextBounds() const OVERRIDE; | |
81 | |
82 // True if the checkbox is checked. | 74 // True if the checkbox is checked. |
83 bool checked_; | 75 bool checked_; |
84 | 76 |
85 DISALLOW_COPY_AND_ASSIGN(Checkbox); | 77 DISALLOW_COPY_AND_ASSIGN(Checkbox); |
86 }; | 78 }; |
87 | 79 |
88 } // namespace views | 80 } // namespace views |
89 | 81 |
90 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ | 82 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ |
OLD | NEW |