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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 void SetMultiLine(bool multi_line); | 163 void SetMultiLine(bool multi_line); |
164 | 164 |
165 // Return whether the button text can wrap on multiple lines. | 165 // Return whether the button text can wrap on multiple lines. |
166 bool multi_line() const { return multi_line_; } | 166 bool multi_line() const { return multi_line_; } |
167 | 167 |
168 // TextButton remembers the maximum display size of the text passed to | 168 // TextButton remembers the maximum display size of the text passed to |
169 // SetText. This method resets the cached maximum display size to the | 169 // SetText. This method resets the cached maximum display size to the |
170 // current size. | 170 // current size. |
171 void ClearMaxTextSize(); | 171 void ClearMaxTextSize(); |
172 | 172 |
| 173 void set_min_width(int min_width) { min_width_ = min_width; } |
| 174 void set_min_height(int min_height) { min_height_ = min_height; } |
173 void set_max_width(int max_width) { max_width_ = max_width; } | 175 void set_max_width(int max_width) { max_width_ = max_width; } |
174 void SetFont(const gfx::Font& font); | 176 void SetFont(const gfx::Font& font); |
175 // Return the font used by this button. | 177 // Return the font used by this button. |
176 gfx::Font font() const { return font_; } | 178 gfx::Font font() const { return font_; } |
177 | 179 |
178 void SetEnabledColor(SkColor color); | 180 void SetEnabledColor(SkColor color); |
179 void SetDisabledColor(SkColor color); | 181 void SetDisabledColor(SkColor color); |
180 void SetHighlightColor(SkColor color); | 182 void SetHighlightColor(SkColor color); |
181 void SetHoverColor(SkColor color); | 183 void SetHoverColor(SkColor color); |
182 void SetTextHaloColor(SkColor color); | 184 void SetTextHaloColor(SkColor color); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 SkColor text_halo_color_; | 273 SkColor text_halo_color_; |
272 bool has_text_halo_; | 274 bool has_text_halo_; |
273 | 275 |
274 // Optional shadow text colors for active and inactive widget states. | 276 // Optional shadow text colors for active and inactive widget states. |
275 SkColor active_text_shadow_color_; | 277 SkColor active_text_shadow_color_; |
276 SkColor inactive_text_shadow_color_; | 278 SkColor inactive_text_shadow_color_; |
277 bool has_shadow_; | 279 bool has_shadow_; |
278 // Space between text and shadow. Defaults to (1,1). | 280 // Space between text and shadow. Defaults to (1,1). |
279 gfx::Point shadow_offset_; | 281 gfx::Point shadow_offset_; |
280 | 282 |
| 283 // The dimensions of the button will be at least these values. |
| 284 int min_width_; |
| 285 int min_height_; |
| 286 |
281 // The width of the button will never be larger than this value. A value <= 0 | 287 // The width of the button will never be larger than this value. A value <= 0 |
282 // indicates the width is not constrained. | 288 // indicates the width is not constrained. |
283 int max_width_; | 289 int max_width_; |
284 | 290 |
285 // Whether or not to show the hot and pushed icon states. | 291 // Whether or not to show the hot and pushed icon states. |
286 bool show_multiple_icon_states_; | 292 bool show_multiple_icon_states_; |
287 | 293 |
288 // Whether or not the button appears and behaves as the default button in its | 294 // Whether or not the button appears and behaves as the default button in its |
289 // current context. | 295 // current context. |
290 bool is_default_; | 296 bool is_default_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // ICON_CENTERED works only when |text_| is empty. | 343 // ICON_CENTERED works only when |text_| is empty. |
338 DCHECK((icon_placement != ICON_CENTERED) || text_.empty()); | 344 DCHECK((icon_placement != ICON_CENTERED) || text_.empty()); |
339 icon_placement_ = icon_placement; | 345 icon_placement_ = icon_placement; |
340 } | 346 } |
341 | 347 |
342 void set_ignore_minimum_size(bool ignore_minimum_size); | 348 void set_ignore_minimum_size(bool ignore_minimum_size); |
343 | 349 |
344 // Overridden from View: | 350 // Overridden from View: |
345 virtual gfx::Size GetPreferredSize() OVERRIDE; | 351 virtual gfx::Size GetPreferredSize() OVERRIDE; |
346 virtual std::string GetClassName() const OVERRIDE; | 352 virtual std::string GetClassName() const OVERRIDE; |
347 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | |
348 | 353 |
349 // Overridden from TextButtonBase: | 354 // Overridden from TextButtonBase: |
350 virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) OVERRIDE; | 355 virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) OVERRIDE; |
351 | 356 |
352 protected: | 357 protected: |
353 gfx::ImageSkia icon() const { return icon_; } | 358 gfx::ImageSkia icon() const { return icon_; } |
354 | 359 |
355 virtual const gfx::ImageSkia& GetImageToPaint() const; | 360 virtual const gfx::ImageSkia& GetImageToPaint() const; |
356 | 361 |
357 // Overridden from NativeThemeDelegate: | 362 // Overridden from NativeThemeDelegate: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 // | 401 // |
397 //////////////////////////////////////////////////////////////////////////////// | 402 //////////////////////////////////////////////////////////////////////////////// |
398 class VIEWS_EXPORT NativeTextButton : public TextButton { | 403 class VIEWS_EXPORT NativeTextButton : public TextButton { |
399 public: | 404 public: |
400 // The button's class name. | 405 // The button's class name. |
401 static const char kViewClassName[]; | 406 static const char kViewClassName[]; |
402 | 407 |
403 explicit NativeTextButton(ButtonListener* listener); | 408 explicit NativeTextButton(ButtonListener* listener); |
404 NativeTextButton(ButtonListener* listener, const string16& text); | 409 NativeTextButton(ButtonListener* listener, const string16& text); |
405 | 410 |
406 // Overridden from View: | |
407 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | |
408 | |
409 // Overridden from TextButton: | 411 // Overridden from TextButton: |
410 virtual gfx::Size GetMinimumSize() OVERRIDE; | 412 virtual gfx::Size GetMinimumSize() OVERRIDE; |
411 virtual std::string GetClassName() const OVERRIDE; | 413 virtual std::string GetClassName() const OVERRIDE; |
412 | 414 |
413 private: | 415 private: |
414 void Init(); | 416 void Init(); |
415 | 417 |
416 // Overridden from TextButton: | 418 // Overridden from TextButton: |
417 virtual void GetExtraParams( | 419 virtual void GetExtraParams( |
418 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 420 ui::NativeTheme::ExtraParams* params) const OVERRIDE; |
419 | 421 |
420 DISALLOW_COPY_AND_ASSIGN(NativeTextButton); | 422 DISALLOW_COPY_AND_ASSIGN(NativeTextButton); |
421 }; | 423 }; |
422 | 424 |
423 } // namespace views | 425 } // namespace views |
424 | 426 |
425 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ | 427 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ |
OLD | NEW |