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

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: sky review 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
« no previous file with comments | « ui/gfx/vector_icons/radio_button_normal.icon ('k') | ui/views/controls/button/checkbox.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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[];
22 24
23 explicit Checkbox(const base::string16& label); 25 explicit Checkbox(const base::string16& label);
24 ~Checkbox() override; 26 ~Checkbox() override;
25 27
26 // Sets a listener for this checkbox. Checkboxes aren't required to have them 28 // 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. 29 // since their state can be read independently of them being toggled.
28 void set_listener(ButtonListener* listener) { listener_ = listener; } 30 void set_listener(ButtonListener* listener) { listener_ = listener; }
29 31
30 // Sets/Gets whether or not the checkbox is checked. 32 // Sets/Gets whether or not the checkbox is checked.
31 virtual void SetChecked(bool checked); 33 virtual void SetChecked(bool checked);
32 bool checked() const { return checked_; } 34 bool checked() const { return checked_; }
33 35
34 protected: 36 protected:
37 // Returns whether MD is enabled; exists for the sake of brevity.
38 static bool UseMd();
39
35 // Overridden from LabelButton: 40 // Overridden from LabelButton:
36 void Layout() override; 41 void Layout() override;
37 const char* GetClassName() const override; 42 const char* GetClassName() const override;
38 void GetAccessibleState(ui::AXViewState* state) override; 43 void GetAccessibleState(ui::AXViewState* state) override;
44 void OnPaint(gfx::Canvas* canvas) override;
39 void OnFocus() override; 45 void OnFocus() override;
40 void OnBlur() override; 46 void OnBlur() override;
41 const gfx::ImageSkia& GetImage(ButtonState for_state) override; 47 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
48 gfx::ImageSkia GetImage(ButtonState for_state) const override;
42 49
43 // Set the image shown for each button state depending on whether it is 50 // Set the image shown for each button state depending on whether it is
44 // [checked] or [focused]. 51 // [checked] or [focused].
45 void SetCustomImage(bool checked, 52 void SetCustomImage(bool checked,
46 bool focused, 53 bool focused,
47 ButtonState for_state, 54 ButtonState for_state,
48 const gfx::ImageSkia& image); 55 const gfx::ImageSkia& image);
49 56
57 // Paints a focus indicator for the view.
58 virtual void PaintFocusRing(gfx::Canvas* canvas, const SkPaint& paint);
59
50 private: 60 private:
51 // Overridden from Button: 61 // Overridden from Button:
52 void NotifyClick(const ui::Event& event) override; 62 void NotifyClick(const ui::Event& event) override;
53 63
54 ui::NativeTheme::Part GetThemePart() const override; 64 ui::NativeTheme::Part GetThemePart() const override;
55 void GetExtraParams(ui::NativeTheme::ExtraParams* params) const override; 65 void GetExtraParams(ui::NativeTheme::ExtraParams* params) const override;
56 66
57 // True if the checkbox is checked. 67 // True if the checkbox is checked.
58 bool checked_; 68 bool checked_;
59 69
60 // The images for each button state. 70 // The images for each button state.
61 gfx::ImageSkia images_[2][2][STATE_COUNT]; 71 gfx::ImageSkia images_[2][2][STATE_COUNT];
62 72
63 DISALLOW_COPY_AND_ASSIGN(Checkbox); 73 DISALLOW_COPY_AND_ASSIGN(Checkbox);
64 }; 74 };
65 75
66 } // namespace views 76 } // namespace views
67 77
68 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ 78 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
OLDNEW
« no previous file with comments | « ui/gfx/vector_icons/radio_button_normal.icon ('k') | ui/views/controls/button/checkbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698