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