OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 VIEWS_EXAMPLES_NATIVE_THEME_BUTTON_EXAMPLE_H_ | |
6 #define VIEWS_EXAMPLES_NATIVE_THEME_BUTTON_EXAMPLE_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "ui/gfx/native_theme.h" | |
11 #include "views/controls/button/custom_button.h" | |
12 #include "views/controls/combobox/combobox.h" | |
13 #include "views/examples/example_base.h" | |
14 #include "views/native_theme_delegate.h" | |
15 #include "views/native_theme_painter.h" | |
16 | |
17 namespace views { | |
18 class Combobox; | |
19 class NativeThemePainter; | |
20 } | |
21 | |
22 namespace examples { | |
23 | |
24 // A subclass of button to test native theme rendering. | |
25 class ExampleNativeThemeButton : public views::CustomButton, | |
26 public views::NativeThemeDelegate, | |
27 public views::Combobox::Listener { | |
28 public: | |
29 ExampleNativeThemeButton(views::ButtonListener* listener, | |
30 views::Combobox* cb_part, | |
31 views::Combobox* cb_state); | |
32 virtual ~ExampleNativeThemeButton(); | |
33 | |
34 std::string MessWithState(); | |
35 | |
36 private: | |
37 // Overridden from View: | |
38 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
39 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | |
40 | |
41 // Overridden from views::Combobox::Listener: | |
42 virtual void ItemChanged(views::Combobox* combo_box, | |
43 int prev_index, | |
44 int new_index) OVERRIDE; | |
45 | |
46 // Overridden from views::NativeThemePainter::Delegate: | |
47 virtual gfx::NativeTheme::Part GetThemePart() const OVERRIDE; | |
48 virtual gfx::Rect GetThemePaintRect() const OVERRIDE; | |
49 virtual gfx::NativeTheme::State GetThemeState( | |
50 gfx::NativeTheme::ExtraParams* params) const OVERRIDE; | |
51 virtual const ui::Animation* GetThemeAnimation() const OVERRIDE; | |
52 virtual gfx::NativeTheme::State GetBackgroundThemeState( | |
53 gfx::NativeTheme::ExtraParams* params) const OVERRIDE; | |
54 virtual gfx::NativeTheme::State GetForegroundThemeState( | |
55 gfx::NativeTheme::ExtraParams* params) const OVERRIDE; | |
56 | |
57 void GetExtraParams(gfx::NativeTheme::ExtraParams* params) const; | |
58 | |
59 scoped_ptr<views::NativeThemePainter> painter_; | |
60 views::Combobox* cb_part_; | |
61 views::Combobox* cb_state_; | |
62 int count_; | |
63 bool is_checked_; | |
64 bool is_indeterminate_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(ExampleNativeThemeButton); | |
67 }; | |
68 | |
69 // NativeThemeButtonExample shows how a View can use the NativeThemePainter | |
70 // to paints its background and get a native look. | |
71 class NativeThemeButtonExample : public ExampleBase, | |
72 public views::ButtonListener { | |
73 public: | |
74 explicit NativeThemeButtonExample(ExamplesMain* main); | |
75 virtual ~NativeThemeButtonExample(); | |
76 | |
77 // Overridden from ExampleBase: | |
78 virtual void CreateExampleView(views::View* container) OVERRIDE; | |
79 | |
80 private: | |
81 // Overridden from views::ButtonListener: | |
82 virtual void ButtonPressed(views::Button* sender, | |
83 const views::Event& event) OVERRIDE; | |
84 | |
85 // The only control in this test. | |
86 ExampleNativeThemeButton* button_; | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(NativeThemeButtonExample); | |
89 }; | |
90 | |
91 } // namespace examples | |
92 | |
93 #endif // VIEWS_EXAMPLES_NATIVE_THEME_BUTTON_EXAMPLE_H_ | |
OLD | NEW |