| 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/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; | 15 class SkPaint; |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 | 18 |
| 19 class InkDropHover; |
| 20 class InkDropRipple; |
| 21 |
| 19 // A native themed class representing a checkbox. This class does not use | 22 // A native themed class representing a checkbox. This class does not use |
| 20 // platform specific objects to replicate the native platforms looks and feel. | 23 // platform specific objects to replicate the native platforms looks and feel. |
| 21 class VIEWS_EXPORT Checkbox : public LabelButton { | 24 class VIEWS_EXPORT Checkbox : public LabelButton { |
| 22 public: | 25 public: |
| 23 static const char kViewClassName[]; | 26 static const char kViewClassName[]; |
| 24 | 27 |
| 25 explicit Checkbox(const base::string16& label); | 28 explicit Checkbox(const base::string16& label); |
| 26 ~Checkbox() override; | 29 ~Checkbox() override; |
| 27 | 30 |
| 28 // Sets a listener for this checkbox. Checkboxes aren't required to have them | 31 // Sets a listener for this checkbox. Checkboxes aren't required to have them |
| 29 // since their state can be read independently of them being toggled. | 32 // since their state can be read independently of them being toggled. |
| 30 void set_listener(ButtonListener* listener) { listener_ = listener; } | 33 void set_listener(ButtonListener* listener) { listener_ = listener; } |
| 31 | 34 |
| 32 // Sets/Gets whether or not the checkbox is checked. | 35 // Sets/Gets whether or not the checkbox is checked. |
| 33 virtual void SetChecked(bool checked); | 36 virtual void SetChecked(bool checked); |
| 34 bool checked() const { return checked_; } | 37 bool checked() const { return checked_; } |
| 35 | 38 |
| 36 protected: | 39 protected: |
| 37 // Returns whether MD is enabled; exists for the sake of brevity. | 40 // Returns whether MD is enabled; exists for the sake of brevity. |
| 38 static bool UseMd(); | 41 static bool UseMd(); |
| 39 | 42 |
| 40 // Overridden from LabelButton: | 43 // Overridden from LabelButton: |
| 41 void Layout() override; | 44 void Layout() override; |
| 42 const char* GetClassName() const override; | 45 const char* GetClassName() const override; |
| 43 void GetAccessibleState(ui::AXViewState* state) override; | 46 void GetAccessibleState(ui::AXViewState* state) override; |
| 44 void OnPaint(gfx::Canvas* canvas) override; | 47 void OnPaint(gfx::Canvas* canvas) override; |
| 45 void OnFocus() override; | 48 void OnFocus() override; |
| 46 void OnBlur() override; | 49 void OnBlur() override; |
| 47 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 50 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| 51 std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override; |
| 52 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override; |
| 53 SkColor GetInkDropBaseColor() const override; |
| 48 gfx::ImageSkia GetImage(ButtonState for_state) const override; | 54 gfx::ImageSkia GetImage(ButtonState for_state) const override; |
| 49 | 55 |
| 50 // Set the image shown for each button state depending on whether it is | 56 // Set the image shown for each button state depending on whether it is |
| 51 // [checked] or [focused]. | 57 // [checked] or [focused]. |
| 52 void SetCustomImage(bool checked, | 58 void SetCustomImage(bool checked, |
| 53 bool focused, | 59 bool focused, |
| 54 ButtonState for_state, | 60 ButtonState for_state, |
| 55 const gfx::ImageSkia& image); | 61 const gfx::ImageSkia& image); |
| 56 | 62 |
| 57 // Paints a focus indicator for the view. | 63 // Paints a focus indicator for the view. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 69 | 75 |
| 70 // The images for each button state. | 76 // The images for each button state. |
| 71 gfx::ImageSkia images_[2][2][STATE_COUNT]; | 77 gfx::ImageSkia images_[2][2][STATE_COUNT]; |
| 72 | 78 |
| 73 DISALLOW_COPY_AND_ASSIGN(Checkbox); | 79 DISALLOW_COPY_AND_ASSIGN(Checkbox); |
| 74 }; | 80 }; |
| 75 | 81 |
| 76 } // namespace views | 82 } // namespace views |
| 77 | 83 |
| 78 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ | 84 #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ |
| OLD | NEW |