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_BORDER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_ |
7 | 7 |
8 #include "ui/gfx/image/image_skia.h" | 8 #include "ui/gfx/image/image_skia.h" |
9 #include "ui/views/border.h" | 9 #include "ui/views/border.h" |
10 #include "ui/views/controls/button/custom_button.h" | 10 #include "ui/views/controls/button/border_images.h" |
| 11 #include "ui/views/controls/button/label_button.h" |
11 | 12 |
12 namespace views { | 13 namespace views { |
13 | 14 |
14 class NativeThemeDelegate; | |
15 | |
16 // A Border that paints a LabelButton's background frame. | 15 // A Border that paints a LabelButton's background frame. |
17 class VIEWS_EXPORT LabelButtonBorder : public Border { | 16 class VIEWS_EXPORT LabelButtonBorder : public Border { |
18 public: | 17 public: |
19 explicit LabelButtonBorder(NativeThemeDelegate* delegate); | 18 LabelButtonBorder(); |
20 virtual ~LabelButtonBorder(); | 19 virtual ~LabelButtonBorder(); |
21 | 20 |
22 bool native_theme() const { return native_theme_; } | 21 bool native_theme() const { return native_theme_; } |
23 void set_native_theme(bool native_theme) { native_theme_ = native_theme; } | 22 void set_native_theme(bool native_theme) { native_theme_ = native_theme; } |
24 | 23 |
25 // Overridden from Border: | 24 // Overridden from Border: |
26 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE; | 25 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE; |
27 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; | 26 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; |
28 | 27 |
29 private: | |
30 struct BorderImages { | |
31 BorderImages(); | |
32 // |image_ids| must contain 9 image ids. | |
33 explicit BorderImages(const int image_ids[]); | |
34 ~BorderImages(); | |
35 | |
36 gfx::ImageSkia top_left; | |
37 gfx::ImageSkia top; | |
38 gfx::ImageSkia top_right; | |
39 gfx::ImageSkia left; | |
40 gfx::ImageSkia center; | |
41 gfx::ImageSkia right; | |
42 gfx::ImageSkia bottom_left; | |
43 gfx::ImageSkia bottom; | |
44 gfx::ImageSkia bottom_right; | |
45 }; | |
46 | |
47 // Set the images shown for the specified button state. | 28 // Set the images shown for the specified button state. |
48 void SetImages(CustomButton::ButtonState state, const BorderImages& images); | 29 void SetImages(CustomButton::ButtonState state, const BorderImages& images); |
49 | 30 |
50 // Paint the view-style images for the specified button state. | 31 private: |
51 void PaintImages(const View& view, | 32 // Paint the border image set or native-style button border and background. |
52 gfx::Canvas* canvas, | 33 void PaintImages(const LabelButton* button, gfx::Canvas* canvas) const; |
53 CustomButton::ButtonState state) const; | 34 void PaintNativeTheme(const LabelButton* button, gfx::Canvas* canvas) const; |
54 | |
55 // Paint the native-style button border and background. | |
56 void PaintNativeTheme(const View& view, gfx::Canvas* canvas) const; | |
57 | 35 |
58 // The images shown for each button state. | 36 // The images shown for each button state. |
59 BorderImages images_[CustomButton::BS_COUNT]; | 37 BorderImages images_[CustomButton::BS_COUNT]; |
60 | 38 |
61 // A delegate and flag controlling the native/Views theme styling. | 39 // A flag controlling native (true) or Views theme styling; false by default. |
62 NativeThemeDelegate* native_theme_delegate_; | |
63 bool native_theme_; | 40 bool native_theme_; |
64 | 41 |
65 DISALLOW_COPY_AND_ASSIGN(LabelButtonBorder); | 42 DISALLOW_COPY_AND_ASSIGN(LabelButtonBorder); |
66 }; | 43 }; |
67 | 44 |
68 } // namespace views | 45 } // namespace views |
69 | 46 |
70 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_ | 47 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_ |
OLD | NEW |