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_LABEL_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 // Set the spacing between the image and the text. Shrinking the spacing | 80 // Set the spacing between the image and the text. Shrinking the spacing |
81 // will not shrink the overall button size, as it is monotonically increasing. | 81 // will not shrink the overall button size, as it is monotonically increasing. |
82 // Call SetMinSize(gfx::Size()) to clear the size if needed. | 82 // Call SetMinSize(gfx::Size()) to clear the size if needed. |
83 void SetImageLabelSpacing(int spacing); | 83 void SetImageLabelSpacing(int spacing); |
84 | 84 |
85 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 85 void SetFocusPainter(scoped_ptr<Painter> focus_painter); |
86 Painter* focus_painter() { return focus_painter_.get(); } | 86 Painter* focus_painter() { return focus_painter_.get(); } |
87 | 87 |
88 // View: | 88 // View: |
89 virtual void SetBorder(scoped_ptr<Border> border) OVERRIDE; | 89 virtual void SetBorder(scoped_ptr<Border> border) override; |
90 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 90 virtual gfx::Size GetPreferredSize() const override; |
91 virtual int GetHeightForWidth(int w) const OVERRIDE; | 91 virtual int GetHeightForWidth(int w) const override; |
92 virtual void Layout() OVERRIDE; | 92 virtual void Layout() override; |
93 virtual const char* GetClassName() const OVERRIDE; | 93 virtual const char* GetClassName() const override; |
94 | 94 |
95 protected: | 95 protected: |
96 ImageView* image() const { return image_; } | 96 ImageView* image() const { return image_; } |
97 Label* label() const { return label_; } | 97 Label* label() const { return label_; } |
98 | 98 |
99 // Returns the available area for the label and image. Subclasses can change | 99 // Returns the available area for the label and image. Subclasses can change |
100 // these bounds if they need room to do manual painting. | 100 // these bounds if they need room to do manual painting. |
101 virtual gfx::Rect GetChildAreaBounds(); | 101 virtual gfx::Rect GetChildAreaBounds(); |
102 | 102 |
103 // View: | 103 // View: |
104 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 104 virtual void OnPaint(gfx::Canvas* canvas) override; |
105 virtual void OnFocus() OVERRIDE; | 105 virtual void OnFocus() override; |
106 virtual void OnBlur() OVERRIDE; | 106 virtual void OnBlur() override; |
107 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; | 107 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
108 | 108 |
109 // Fill |params| with information about the button. | 109 // Fill |params| with information about the button. |
110 virtual void GetExtraParams(ui::NativeTheme::ExtraParams* params) const; | 110 virtual void GetExtraParams(ui::NativeTheme::ExtraParams* params) const; |
111 | 111 |
112 // Resets colors from the NativeTheme, explicitly set colors are unchanged. | 112 // Resets colors from the NativeTheme, explicitly set colors are unchanged. |
113 virtual void ResetColorsFromNativeTheme(); | 113 virtual void ResetColorsFromNativeTheme(); |
114 | 114 |
115 // Creates the default border for this button. This can be overridden by | 115 // Creates the default border for this button. This can be overridden by |
116 // subclasses or by LinuxUI. | 116 // subclasses or by LinuxUI. |
117 virtual scoped_ptr<LabelButtonBorder> CreateDefaultBorder() const; | 117 virtual scoped_ptr<LabelButtonBorder> CreateDefaultBorder() const; |
118 | 118 |
119 // Updates the image view to contain the appropriate button state image. | 119 // Updates the image view to contain the appropriate button state image. |
120 void UpdateImage(); | 120 void UpdateImage(); |
121 | 121 |
122 // Updates the border as per the NativeTheme, unless a different border was | 122 // Updates the border as per the NativeTheme, unless a different border was |
123 // set with SetBorder. | 123 // set with SetBorder. |
124 void UpdateThemedBorder(); | 124 void UpdateThemedBorder(); |
125 | 125 |
126 // NativeThemeDelegate: | 126 // NativeThemeDelegate: |
127 virtual gfx::Rect GetThemePaintRect() const OVERRIDE; | 127 virtual gfx::Rect GetThemePaintRect() const override; |
128 | 128 |
129 private: | 129 private: |
130 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init); | 130 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init); |
131 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Label); | 131 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Label); |
132 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Image); | 132 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Image); |
133 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage); | 133 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage); |
134 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, FontList); | 134 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, FontList); |
135 | 135 |
136 // CustomButton: | 136 // CustomButton: |
137 virtual void StateChanged() OVERRIDE; | 137 virtual void StateChanged() override; |
138 | 138 |
139 // View: | 139 // View: |
140 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 140 virtual void ChildPreferredSizeChanged(View* child) override; |
141 | 141 |
142 // NativeThemeDelegate: | 142 // NativeThemeDelegate: |
143 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; | 143 virtual ui::NativeTheme::Part GetThemePart() const override; |
144 virtual ui::NativeTheme::State GetThemeState( | 144 virtual ui::NativeTheme::State GetThemeState( |
145 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 145 ui::NativeTheme::ExtraParams* params) const override; |
146 virtual const gfx::Animation* GetThemeAnimation() const OVERRIDE; | 146 virtual const gfx::Animation* GetThemeAnimation() const override; |
147 virtual ui::NativeTheme::State GetBackgroundThemeState( | 147 virtual ui::NativeTheme::State GetBackgroundThemeState( |
148 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 148 ui::NativeTheme::ExtraParams* params) const override; |
149 virtual ui::NativeTheme::State GetForegroundThemeState( | 149 virtual ui::NativeTheme::State GetForegroundThemeState( |
150 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 150 ui::NativeTheme::ExtraParams* params) const override; |
151 | 151 |
152 // Resets |cached_preferred_size_| and marks |cached_preferred_size_valid_| | 152 // Resets |cached_preferred_size_| and marks |cached_preferred_size_valid_| |
153 // as false. | 153 // as false. |
154 void ResetCachedPreferredSize(); | 154 void ResetCachedPreferredSize(); |
155 | 155 |
156 // The image and label shown in the button. | 156 // The image and label shown in the button. |
157 ImageView* image_; | 157 ImageView* image_; |
158 Label* label_; | 158 Label* label_; |
159 | 159 |
160 // The cached font lists in the normal and bold style. | 160 // The cached font lists in the normal and bold style. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 int image_label_spacing_; | 192 int image_label_spacing_; |
193 | 193 |
194 scoped_ptr<Painter> focus_painter_; | 194 scoped_ptr<Painter> focus_painter_; |
195 | 195 |
196 DISALLOW_COPY_AND_ASSIGN(LabelButton); | 196 DISALLOW_COPY_AND_ASSIGN(LabelButton); |
197 }; | 197 }; |
198 | 198 |
199 } // namespace views | 199 } // namespace views |
200 | 200 |
201 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 201 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
OLD | NEW |