Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: ui/views/controls/button/checkbox.h

Issue 15061006: views: Switch Checkbox over to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: override GetImage + SetCheckedImage Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/label_button.h"
13 13
14 namespace views { 14 namespace views {
15 15
16 // A border with zero left inset.
17 class VIEWS_EXPORT CheckboxNativeThemeBorder
18 : public TextButtonNativeThemeBorder {
19 public:
20 explicit CheckboxNativeThemeBorder(views::NativeThemeDelegate* delegate)
21 : TextButtonNativeThemeBorder(delegate),
22 use_custom_insets_(false) {}
23 virtual ~CheckboxNativeThemeBorder() {}
24
25 // The insets apply to the whole view (checkbox + text), not just the square
26 // with the checkmark in it. The insets do not visibly affect the checkbox,
27 // except to ensure that there is enough padding between this and other
28 // elements.
29 virtual gfx::Insets GetInsets() const OVERRIDE;
30
31 // Use the |custom_insets_| provided instead of those from the theme.
32 void SetCustomInsets(const gfx::Insets& custom_insets);
33
34 // Use the default insets and ignore any |custom_insets_| that may be set.
35 void UseDefaultInsets();
36
37 private:
38 // Only used if |use_custom_insets_| is true.
39 gfx::Insets custom_insets_;
40
41 // Whether |custom_insets_| should be used in |GetInsets()|.
42 bool use_custom_insets_;
43
44 DISALLOW_COPY_AND_ASSIGN(CheckboxNativeThemeBorder);
45 };
46
47 // A native themed class representing a checkbox. This class does not use 16 // A native themed class representing a checkbox. This class does not use
48 // platform specific objects to replicate the native platforms looks and feel. 17 // platform specific objects to replicate the native platforms looks and feel.
49 class VIEWS_EXPORT Checkbox : public TextButtonBase { 18 class VIEWS_EXPORT Checkbox : public LabelButton {
50 public: 19 public:
51 static const char kViewClassName[]; 20 static const char kViewClassName[];
52 21
53 explicit Checkbox(const string16& label); 22 explicit Checkbox(const string16& label);
54 virtual ~Checkbox(); 23 virtual ~Checkbox();
55 24
56 // 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
57 // since their state can be read independently of them being toggled. 26 // since their state can be read independently of them being toggled.
58 void set_listener(ButtonListener* listener) { listener_ = listener; } 27 void set_listener(ButtonListener* listener) { listener_ = listener; }
59 28
60 // Sets/Gets whether or not the checkbox is checked. 29 // Sets/Gets whether or not the checkbox is checked.
61 virtual void SetChecked(bool checked); 30 virtual void SetChecked(bool checked);
62 bool checked() const { return checked_; } 31 bool checked() const { return checked_; }
63 32
64 protected: 33 protected:
65 // Overridden from View: 34 // Overridden from View:
66 virtual gfx::Size GetPreferredSize() OVERRIDE;
67 virtual const char* GetClassName() const OVERRIDE; 35 virtual const char* GetClassName() const OVERRIDE;
68 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 36 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
69 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; 37
38 virtual const gfx::ImageSkia& GetImage(ButtonState for_state) OVERRIDE;
msw 2013/05/18 03:46:30 group this with the functions above and change the
tfarina 2013/05/18 18:43:23 Done.
39 void SetCheckedImage(ButtonState for_state, const gfx::ImageSkia& image);
msw 2013/05/18 03:46:30 Add a blank line and this comment above: // Set th
tfarina 2013/05/18 18:43:23 Done.
70 40
71 private: 41 private:
72 // Overridden from Button: 42 // Overridden from Button:
73 virtual void NotifyClick(const ui::Event& event) OVERRIDE; 43 virtual void NotifyClick(const ui::Event& event) OVERRIDE;
74 44
75 // Overridden from TextButtonBase:
76 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; 45 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE;
77 virtual gfx::Rect GetThemePaintRect() const OVERRIDE;
78 virtual void GetExtraParams( 46 virtual void GetExtraParams(
79 ui::NativeTheme::ExtraParams* params) const OVERRIDE; 47 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
80 virtual gfx::Rect GetTextBounds() const OVERRIDE;
81 48
82 // True if the checkbox is checked. 49 // True if the checkbox is checked.
83 bool checked_; 50 bool checked_;
84 51
52 gfx::ImageSkia checked_state_images_[STATE_COUNT];
msw 2013/05/18 03:46:30 Comment: // The images for each checked button sta
tfarina 2013/05/18 18:43:23 Done.
53
85 DISALLOW_COPY_AND_ASSIGN(Checkbox); 54 DISALLOW_COPY_AND_ASSIGN(Checkbox);
86 }; 55 };
87 56
88 } // namespace views 57 } // namespace views
89 58
90 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ 59 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698