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