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

Unified 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: rm dcheck 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/button.h ('k') | ui/views/controls/button/checkbox.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/checkbox.h
diff --git a/ui/views/controls/button/checkbox.h b/ui/views/controls/button/checkbox.h
index 3c739306eca578aa396955bfec4275dce73fe5b0..05d0d92c2ac5ad3643b248dd5aa05fcb9dc6f2b8 100644
--- a/ui/views/controls/button/checkbox.h
+++ b/ui/views/controls/button/checkbox.h
@@ -9,44 +9,13 @@
#include "base/compiler_specific.h"
#include "base/string16.h"
-#include "ui/views/controls/button/text_button.h"
+#include "ui/views/controls/button/label_button.h"
namespace views {
-// A border with zero left inset.
-class VIEWS_EXPORT CheckboxNativeThemeBorder
- : public TextButtonNativeThemeBorder {
- public:
- explicit CheckboxNativeThemeBorder(views::NativeThemeDelegate* delegate)
- : TextButtonNativeThemeBorder(delegate),
- use_custom_insets_(false) {}
- virtual ~CheckboxNativeThemeBorder() {}
-
- // The insets apply to the whole view (checkbox + text), not just the square
- // with the checkmark in it. The insets do not visibly affect the checkbox,
- // except to ensure that there is enough padding between this and other
- // elements.
- virtual gfx::Insets GetInsets() const OVERRIDE;
-
- // Use the |custom_insets_| provided instead of those from the theme.
- void SetCustomInsets(const gfx::Insets& custom_insets);
-
- // Use the default insets and ignore any |custom_insets_| that may be set.
- void UseDefaultInsets();
-
- private:
- // Only used if |use_custom_insets_| is true.
- gfx::Insets custom_insets_;
-
- // Whether |custom_insets_| should be used in |GetInsets()|.
- bool use_custom_insets_;
-
- DISALLOW_COPY_AND_ASSIGN(CheckboxNativeThemeBorder);
-};
-
// A native themed class representing a checkbox. This class does not use
// platform specific objects to replicate the native platforms looks and feel.
-class VIEWS_EXPORT Checkbox : public TextButtonBase {
+class VIEWS_EXPORT Checkbox : public LabelButton {
public:
static const char kViewClassName[];
@@ -62,26 +31,35 @@ class VIEWS_EXPORT Checkbox : public TextButtonBase {
bool checked() const { return checked_; }
protected:
- // Overridden from View:
- virtual gfx::Size GetPreferredSize() OVERRIDE;
+ // Overridden from LabelButton:
+ virtual void Layout() OVERRIDE;
virtual const char* GetClassName() const OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
- virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
+ virtual void OnFocus() OVERRIDE;
+ virtual void OnBlur() OVERRIDE;
+ virtual const gfx::ImageSkia& GetImage(ButtonState for_state) OVERRIDE;
+
+ // Set the image shown for each button state depending on whether it is
+ // [checked] or [focused].
+ void SetCustomImage(bool checked,
+ bool focused,
+ ButtonState for_state,
+ const gfx::ImageSkia& image);
private:
// Overridden from Button:
virtual void NotifyClick(const ui::Event& event) OVERRIDE;
- // Overridden from TextButtonBase:
virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE;
- virtual gfx::Rect GetThemePaintRect() const OVERRIDE;
virtual void GetExtraParams(
ui::NativeTheme::ExtraParams* params) const OVERRIDE;
- virtual gfx::Rect GetTextBounds() const OVERRIDE;
// True if the checkbox is checked.
bool checked_;
+ // The images for each button state.
+ gfx::ImageSkia images_[2][2][STATE_COUNT];
+
DISALLOW_COPY_AND_ASSIGN(Checkbox);
};
« no previous file with comments | « ui/views/controls/button/button.h ('k') | ui/views/controls/button/checkbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698