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

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

Issue 2026833003: MD - update checkbox and radio buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "ui/views/controls/button/label_button.h" 13 #include "ui/views/controls/button/label_button.h"
14 14
15 class SkPaint;
16
15 namespace views { 17 namespace views {
16 18
17 // A native themed class representing a checkbox. This class does not use 19 // A native themed class representing a checkbox. This class does not use
18 // platform specific objects to replicate the native platforms looks and feel. 20 // platform specific objects to replicate the native platforms looks and feel.
19 class VIEWS_EXPORT Checkbox : public LabelButton { 21 class VIEWS_EXPORT Checkbox : public LabelButton {
20 public: 22 public:
21 static const char kViewClassName[]; 23 static const char kViewClassName[];
24 // Returns whether MD is enabled; exists for the sake of brevity.
25 static bool UseMd();
sky 2016/06/01 03:28:23 Move to protected section as only subclasses shoul
Evan Stade 2016/06/01 21:01:11 Done.
22 26
23 explicit Checkbox(const base::string16& label); 27 explicit Checkbox(const base::string16& label);
24 ~Checkbox() override; 28 ~Checkbox() override;
25 29
26 // Sets a listener for this checkbox. Checkboxes aren't required to have them 30 // Sets a listener for this checkbox. Checkboxes aren't required to have them
27 // since their state can be read independently of them being toggled. 31 // since their state can be read independently of them being toggled.
28 void set_listener(ButtonListener* listener) { listener_ = listener; } 32 void set_listener(ButtonListener* listener) { listener_ = listener; }
29 33
30 // Sets/Gets whether or not the checkbox is checked. 34 // Sets/Gets whether or not the checkbox is checked.
31 virtual void SetChecked(bool checked); 35 virtual void SetChecked(bool checked);
32 bool checked() const { return checked_; } 36 bool checked() const { return checked_; }
33 37
34 protected: 38 protected:
35 // Overridden from LabelButton: 39 // Overridden from LabelButton:
36 void Layout() override; 40 void Layout() override;
37 const char* GetClassName() const override; 41 const char* GetClassName() const override;
38 void GetAccessibleState(ui::AXViewState* state) override; 42 void GetAccessibleState(ui::AXViewState* state) override;
43 void OnPaint(gfx::Canvas* canvas) override;
39 void OnFocus() override; 44 void OnFocus() override;
40 void OnBlur() override; 45 void OnBlur() override;
41 const gfx::ImageSkia& GetImage(ButtonState for_state) override; 46 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
47 gfx::ImageSkia GetImage(ButtonState for_state) const override;
42 48
43 // Set the image shown for each button state depending on whether it is 49 // Set the image shown for each button state depending on whether it is
44 // [checked] or [focused]. 50 // [checked] or [focused].
45 void SetCustomImage(bool checked, 51 void SetCustomImage(bool checked,
46 bool focused, 52 bool focused,
47 ButtonState for_state, 53 ButtonState for_state,
48 const gfx::ImageSkia& image); 54 const gfx::ImageSkia& image);
49 55
56 // Paints a focus indicator for the view.
57 virtual void PaintFocusRing(gfx::Canvas* canvas, const SkPaint& paint);
58
50 private: 59 private:
51 // Overridden from Button: 60 // Overridden from Button:
52 void NotifyClick(const ui::Event& event) override; 61 void NotifyClick(const ui::Event& event) override;
53 62
54 ui::NativeTheme::Part GetThemePart() const override; 63 ui::NativeTheme::Part GetThemePart() const override;
55 void GetExtraParams(ui::NativeTheme::ExtraParams* params) const override; 64 void GetExtraParams(ui::NativeTheme::ExtraParams* params) const override;
56 65
57 // True if the checkbox is checked. 66 // True if the checkbox is checked.
58 bool checked_; 67 bool checked_;
59 68
60 // The images for each button state. 69 // The images for each button state.
61 gfx::ImageSkia images_[2][2][STATE_COUNT]; 70 gfx::ImageSkia images_[2][2][STATE_COUNT];
62 71
63 DISALLOW_COPY_AND_ASSIGN(Checkbox); 72 DISALLOW_COPY_AND_ASSIGN(Checkbox);
64 }; 73 };
65 74
66 } // namespace views 75 } // namespace views
67 76
68 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ 77 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698