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_TEXT_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 public NativeThemeDelegate { | 105 public NativeThemeDelegate { |
106 public: | 106 public: |
107 // The menu button's class name. | 107 // The menu button's class name. |
108 static const char kViewClassName[]; | 108 static const char kViewClassName[]; |
109 | 109 |
110 virtual ~TextButtonBase(); | 110 virtual ~TextButtonBase(); |
111 | 111 |
112 // Call SetText once per string in your set of possible values at button | 112 // Call SetText once per string in your set of possible values at button |
113 // creation time, so that it can contain the largest of them and avoid | 113 // creation time, so that it can contain the largest of them and avoid |
114 // resizing the button when the text changes. | 114 // resizing the button when the text changes. |
115 virtual void SetText(const string16& text); | 115 virtual void SetText(const base::string16& text); |
116 const string16& text() const { return text_; } | 116 const base::string16& text() const { return text_; } |
117 | 117 |
118 enum TextAlignment { | 118 enum TextAlignment { |
119 ALIGN_LEFT, | 119 ALIGN_LEFT, |
120 ALIGN_CENTER, | 120 ALIGN_CENTER, |
121 ALIGN_RIGHT | 121 ALIGN_RIGHT |
122 }; | 122 }; |
123 | 123 |
124 void set_alignment(TextAlignment alignment) { alignment_ = alignment; } | 124 void set_alignment(TextAlignment alignment) { alignment_ = alignment; } |
125 | 125 |
126 const gfx::Animation* GetAnimation() const; | 126 const gfx::Animation* GetAnimation() const; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 virtual gfx::Size GetPreferredSize() OVERRIDE; | 178 virtual gfx::Size GetPreferredSize() OVERRIDE; |
179 virtual gfx::Size GetMinimumSize() OVERRIDE; | 179 virtual gfx::Size GetMinimumSize() OVERRIDE; |
180 virtual int GetHeightForWidth(int w) OVERRIDE; | 180 virtual int GetHeightForWidth(int w) OVERRIDE; |
181 virtual void OnEnabledChanged() OVERRIDE; | 181 virtual void OnEnabledChanged() OVERRIDE; |
182 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 182 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
183 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 183 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
184 virtual const char* GetClassName() const OVERRIDE; | 184 virtual const char* GetClassName() const OVERRIDE; |
185 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; | 185 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; |
186 | 186 |
187 protected: | 187 protected: |
188 TextButtonBase(ButtonListener* listener, const string16& text); | 188 TextButtonBase(ButtonListener* listener, const base::string16& text); |
189 | 189 |
190 // Called when enabled or disabled state changes, or the colors for those | 190 // Called when enabled or disabled state changes, or the colors for those |
191 // states change. | 191 // states change. |
192 virtual void UpdateColor(); | 192 virtual void UpdateColor(); |
193 | 193 |
194 // Updates text_size_ and max_text_size_ from the current text/font. This is | 194 // Updates text_size_ and max_text_size_ from the current text/font. This is |
195 // invoked when the font or text changes. | 195 // invoked when the font or text changes. |
196 void UpdateTextSize(); | 196 void UpdateTextSize(); |
197 | 197 |
198 // Calculate the size of the text size without setting any of the members. | 198 // Calculate the size of the text size without setting any of the members. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 virtual gfx::Rect GetTextBounds() const; | 233 virtual gfx::Rect GetTextBounds() const; |
234 | 234 |
235 int ComputeCanvasStringFlags() const; | 235 int ComputeCanvasStringFlags() const; |
236 | 236 |
237 // Calculate the bounds of the content of this button, including any extra | 237 // Calculate the bounds of the content of this button, including any extra |
238 // width needed on top of the text width. | 238 // width needed on top of the text width. |
239 gfx::Rect GetContentBounds(int extra_width) const; | 239 gfx::Rect GetContentBounds(int extra_width) const; |
240 | 240 |
241 // The text string that is displayed in the button. | 241 // The text string that is displayed in the button. |
242 string16 text_; | 242 base::string16 text_; |
243 | 243 |
244 // The size of the text string. | 244 // The size of the text string. |
245 gfx::Size text_size_; | 245 gfx::Size text_size_; |
246 | 246 |
247 // Track the size of the largest text string seen so far, so that | 247 // Track the size of the largest text string seen so far, so that |
248 // changing text_ will not resize the button boundary. | 248 // changing text_ will not resize the button boundary. |
249 gfx::Size max_text_size_; | 249 gfx::Size max_text_size_; |
250 | 250 |
251 // The alignment of the text string within the button. | 251 // The alignment of the text string within the button. |
252 TextAlignment alignment_; | 252 TextAlignment alignment_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 | 304 |
305 // A button which displays text and/or and icon that can be changed in response | 305 // A button which displays text and/or and icon that can be changed in response |
306 // to actions. TextButton reserves space for the largest string passed to | 306 // to actions. TextButton reserves space for the largest string passed to |
307 // SetText. To reset the cached max size invoke ClearMaxTextSize. | 307 // SetText. To reset the cached max size invoke ClearMaxTextSize. |
308 class VIEWS_EXPORT TextButton : public TextButtonBase { | 308 class VIEWS_EXPORT TextButton : public TextButtonBase { |
309 public: | 309 public: |
310 // The button's class name. | 310 // The button's class name. |
311 static const char kViewClassName[]; | 311 static const char kViewClassName[]; |
312 | 312 |
313 TextButton(ButtonListener* listener, const string16& text); | 313 TextButton(ButtonListener* listener, const base::string16& text); |
314 virtual ~TextButton(); | 314 virtual ~TextButton(); |
315 | 315 |
316 void set_icon_text_spacing(int icon_text_spacing) { | 316 void set_icon_text_spacing(int icon_text_spacing) { |
317 icon_text_spacing_ = icon_text_spacing; | 317 icon_text_spacing_ = icon_text_spacing; |
318 } | 318 } |
319 | 319 |
320 // Sets the icon. | 320 // Sets the icon. |
321 virtual void SetIcon(const gfx::ImageSkia& icon); | 321 virtual void SetIcon(const gfx::ImageSkia& icon); |
322 virtual void SetHoverIcon(const gfx::ImageSkia& icon); | 322 virtual void SetHoverIcon(const gfx::ImageSkia& icon); |
323 virtual void SetPushedIcon(const gfx::ImageSkia& icon); | 323 virtual void SetPushedIcon(const gfx::ImageSkia& icon); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // True if the button should ignore the minimum size for the platform. Default | 381 // True if the button should ignore the minimum size for the platform. Default |
382 // is true. Set to false to prevent narrower buttons. | 382 // is true. Set to false to prevent narrower buttons. |
383 bool ignore_minimum_size_; | 383 bool ignore_minimum_size_; |
384 | 384 |
385 DISALLOW_COPY_AND_ASSIGN(TextButton); | 385 DISALLOW_COPY_AND_ASSIGN(TextButton); |
386 }; | 386 }; |
387 | 387 |
388 } // namespace views | 388 } // namespace views |
389 | 389 |
390 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ | 390 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ |
OLD | NEW |