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 20 matching lines...) Expand all Loading... |
31 LabelButton(ButtonListener* listener, const base::string16& text); | 31 LabelButton(ButtonListener* listener, const base::string16& text); |
32 virtual ~LabelButton(); | 32 virtual ~LabelButton(); |
33 | 33 |
34 // Get or set the image shown for the specified button state. | 34 // Get or set the image shown for the specified button state. |
35 // GetImage returns the image for STATE_NORMAL if the state's image is empty. | 35 // GetImage returns the image for STATE_NORMAL if the state's image is empty. |
36 virtual const gfx::ImageSkia& GetImage(ButtonState for_state); | 36 virtual const gfx::ImageSkia& GetImage(ButtonState for_state); |
37 void SetImage(ButtonState for_state, const gfx::ImageSkia& image); | 37 void SetImage(ButtonState for_state, const gfx::ImageSkia& image); |
38 | 38 |
39 // Get or set the text shown on the button. | 39 // Get or set the text shown on the button. |
40 const base::string16& GetText() const; | 40 const base::string16& GetText() const; |
41 void SetText(const base::string16& text); | 41 virtual void SetText(const base::string16& text); |
42 | 42 |
43 // Set the text color shown for the specified button state. | 43 // Set the text color shown for the specified button state. |
44 void SetTextColor(ButtonState for_state, SkColor color); | 44 void SetTextColor(ButtonState for_state, SkColor color); |
45 | 45 |
| 46 // Sets a halo color on the label. |
| 47 void SetHaloColor(SkColor color); |
| 48 |
46 // Get or set the text's multi-line property to break on '\n', etc. | 49 // Get or set the text's multi-line property to break on '\n', etc. |
47 bool GetTextMultiLine() const; | 50 bool GetTextMultiLine() const; |
48 void SetTextMultiLine(bool text_multi_line); | 51 void SetTextMultiLine(bool text_multi_line); |
49 | 52 |
50 // Get or set the font list used by this button. | 53 // Get or set the font list used by this button. |
51 const gfx::FontList& GetFontList() const; | 54 const gfx::FontList& GetFontList() const; |
52 void SetFontList(const gfx::FontList& font_list); | 55 void SetFontList(const gfx::FontList& font_list); |
53 | 56 |
54 // Set the elide behavior of this button. | 57 // Set the elide behavior of this button. |
55 void SetElideBehavior(gfx::ElideBehavior elide_behavior); | 58 void SetElideBehavior(gfx::ElideBehavior elide_behavior); |
56 | 59 |
57 // Get or set the horizontal alignment used for the button; reversed in RTL. | 60 // Get or set the horizontal alignment used for the button; reversed in RTL. |
58 // The optional image will lead the text, unless the button is right-aligned. | 61 // The optional image will lead the text, unless the button is right-aligned. |
59 gfx::HorizontalAlignment GetHorizontalAlignment() const; | 62 gfx::HorizontalAlignment GetHorizontalAlignment() const; |
60 void SetHorizontalAlignment(gfx::HorizontalAlignment alignment); | 63 void SetHorizontalAlignment(gfx::HorizontalAlignment alignment); |
61 | 64 |
62 // Call set_min_size(gfx::Size()) to clear the monotonically increasing size. | 65 // Call set_min_size(gfx::Size()) to clear the monotonically increasing size. |
63 void set_min_size(const gfx::Size& min_size) { min_size_ = min_size; } | 66 void set_min_size(const gfx::Size& min_size) { min_size_ = min_size; } |
64 void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; } | 67 void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; } |
65 | 68 |
66 // Get or set the option to handle the return key; false by default. | 69 // Get or set the option to handle the return key; false by default. |
67 bool is_default() const { return is_default_; } | 70 bool is_default() const { return is_default_; } |
68 void SetIsDefault(bool is_default); | 71 void SetIsDefault(bool is_default); |
69 | 72 |
70 // Get or set the button's overall style; the default is |STYLE_TEXTBUTTON|. | 73 // Get or set the button's overall style; the default is |STYLE_TEXTBUTTON|. |
71 ButtonStyle style() const { return style_; } | 74 ButtonStyle style() const { return style_; } |
72 void SetStyle(ButtonStyle style); | 75 void SetStyle(ButtonStyle style); |
73 | 76 |
74 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 77 void SetFocusPainter(scoped_ptr<Painter> focus_painter); |
| 78 Painter* focus_painter() { return focus_painter_.get(); } |
75 | 79 |
76 // View: | 80 // View: |
77 virtual void SetBorder(scoped_ptr<Border> border) OVERRIDE; | 81 virtual void SetBorder(scoped_ptr<Border> border) OVERRIDE; |
78 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 82 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
79 virtual void Layout() OVERRIDE; | 83 virtual void Layout() OVERRIDE; |
80 virtual const char* GetClassName() const OVERRIDE; | 84 virtual const char* GetClassName() const OVERRIDE; |
81 | 85 |
82 protected: | 86 protected: |
83 ImageView* image() const { return image_; } | 87 ImageView* image() const { return image_; } |
84 Label* label() const { return label_; } | 88 Label* label() const { return label_; } |
85 | 89 |
| 90 // Returns the available area for the label and image. Subclasses can change |
| 91 // these bounds if they need room to do manual painting. |
| 92 virtual gfx::Rect GetChildAreaBounds(); |
| 93 |
86 // View: | 94 // View: |
87 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 95 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
88 virtual void OnFocus() OVERRIDE; | 96 virtual void OnFocus() OVERRIDE; |
89 virtual void OnBlur() OVERRIDE; | 97 virtual void OnBlur() OVERRIDE; |
90 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; | 98 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; |
91 | 99 |
92 // Fill |params| with information about the button. | 100 // Fill |params| with information about the button. |
93 virtual void GetExtraParams(ui::NativeTheme::ExtraParams* params) const; | 101 virtual void GetExtraParams(ui::NativeTheme::ExtraParams* params) const; |
94 | 102 |
95 // Resets colors from the NativeTheme, explicitly set colors are unchanged. | 103 // Resets colors from the NativeTheme, explicitly set colors are unchanged. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 bool border_is_themed_border_; | 172 bool border_is_themed_border_; |
165 | 173 |
166 scoped_ptr<Painter> focus_painter_; | 174 scoped_ptr<Painter> focus_painter_; |
167 | 175 |
168 DISALLOW_COPY_AND_ASSIGN(LabelButton); | 176 DISALLOW_COPY_AND_ASSIGN(LabelButton); |
169 }; | 177 }; |
170 | 178 |
171 } // namespace views | 179 } // namespace views |
172 | 180 |
173 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 181 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
OLD | NEW |