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

Side by Side Diff: ui/views/controls/button/label_button.h

Issue 11068012: Add new views::LabelButton and LabelButtonBorder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove stray semicolon. Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/bubble/bubble_border.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
7
8 #include "base/compiler_specific.h"
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/gfx/image/image_skia.h"
11 #include "ui/views/controls/button/custom_button.h"
12 #include "ui/views/controls/image_view.h"
13 #include "ui/views/controls/label.h"
14 #include "ui/views/native_theme_delegate.h"
15
16 namespace views {
17
18 // LabelButton is an alternative to TextButton, it's not focusable by default.
19 class VIEWS_EXPORT LabelButton : public CustomButton,
20 public NativeThemeDelegate {
21 public:
22 LabelButton(ButtonListener* listener, const string16& text);
23 virtual ~LabelButton();
24
25 // Get or set the image shown for the specified button state.
26 // GetImage returns the image for BS_NORMAL if the state's image is empty.
27 const gfx::ImageSkia& GetImage(ButtonState for_state);
28 void SetImage(ButtonState for_state, const gfx::ImageSkia& image);
29
30 // Get or set the text shown on the button.
31 const string16& GetText() const;
32 void SetText(const string16& text);
33
34 // Set the text color shown for the specified button state.
35 void SetTextColor(ButtonState for_state, SkColor color);
36
37 // Get or set the text's multi-line property to break on '\n', etc.
38 bool GetTextMultiLine() const;
39 void SetTextMultiLine(bool text_multi_line);
40
41 // Get or set the horizontal alignment used for the button.
42 // The optional image will lead the text, unless the button is right-aligned.
43 Label::Alignment GetHorizontalAlignment() const;
44 void SetHorizontalAlignment(Label::Alignment alignment);
45
46 // Call set_min_size(gfx::Size()) to clear the monotonically increasing size.
47 void set_min_size(const gfx::Size& min_size) { min_size_ = min_size; }
48 void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; }
49
50 // Get or set the option to handle the return key; false by default.
51 bool default_button() const { return default_button_; }
52 void SetDefaultButton(bool default_button);
53
54 // Get or set the option to use a native button appearance; false by default.
55 bool native_theme() const { return native_theme_; }
56 void SetNativeTheme(bool native_theme);
57
58 // Overridden from CustomButton:
59 virtual void StateChanged() OVERRIDE;
60
61 // Overridden from View:
62 virtual gfx::Size GetPreferredSize() OVERRIDE;
63 virtual void Layout() OVERRIDE;
64 virtual std::string GetClassName() const OVERRIDE;
65 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
66
67 protected:
68 // Overridden from NativeThemeDelegate:
69 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE;
70 virtual gfx::Rect GetThemePaintRect() const OVERRIDE;
71 virtual ui::NativeTheme::State GetThemeState(
72 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
73 virtual const ui::Animation* GetThemeAnimation() const OVERRIDE;
74 virtual ui::NativeTheme::State GetBackgroundThemeState(
75 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
76 virtual ui::NativeTheme::State GetForegroundThemeState(
77 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
78
79 // Fill |params| with information about the button.
80 virtual void GetExtraParams(ui::NativeTheme::ExtraParams* params) const;
81
82 private:
83 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init);
84 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage);
85
86 // The image and label shown in the button.
87 ImageView* image_;
88 Label* label_;
89
90 // The images and colors for each button state.
91 gfx::ImageSkia button_state_images_[BS_COUNT];
92 SkColor button_state_colors_[BS_COUNT];
93
94 // |min_size_| increases monotonically with the preferred size.
95 gfx::Size min_size_;
96 // |max_size_| may be set to clamp the preferred size.
97 gfx::Size max_size_;
98
99 // Flag indicating default handling of the return key via an accelerator.
100 bool default_button_;
101
102 // Flag indicating native theme styling (or Views styling) of the button.
103 bool native_theme_;
104
105 DISALLOW_COPY_AND_ASSIGN(LabelButton);
106 };
107
108 } // namespace views
109
110 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_border.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698