| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ | 5 #ifndef VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ |
| 6 #define VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ | 6 #define VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ |
| 7 | 7 |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "views/controls/button/text_button.h" | 9 #include "views/controls/button/text_button.h" |
| 10 #include "views/examples/example_base.h" | 10 #include "views/examples/example_base.h" |
| 11 #include "views/fill_layout.h" |
| 12 #include "views/view.h" |
| 11 | 13 |
| 12 namespace examples { | 14 namespace examples { |
| 13 | 15 |
| 14 // ButtonExample simply counts the number of clicks. | 16 // ButtonExample simply counts the number of clicks. |
| 15 class ButtonExample : protected ExampleBase, private views::ButtonListener { | 17 class ButtonExample : public ExampleBase, public views::ButtonListener { |
| 16 public: | 18 public: |
| 17 explicit ButtonExample(ExamplesMain* main) : ExampleBase(main), count_(0) { | 19 explicit ButtonExample(ExamplesMain* main) : ExampleBase(main), count_(0) { |
| 18 button_ = new views::TextButton(this, L"Button"); | 20 button_ = new views::TextButton(this, L"Button"); |
| 19 } | 21 } |
| 20 | 22 |
| 21 virtual ~ButtonExample() {} | 23 virtual ~ButtonExample() {} |
| 22 | 24 |
| 23 virtual std::wstring GetExampleTitle() { | 25 virtual std::wstring GetExampleTitle() { |
| 24 return L"Text Button"; | 26 return L"Text Button"; |
| 25 } | 27 } |
| 26 | 28 |
| 27 virtual views::View* GetExampleView() { | 29 virtual void CreateExampleView(views::View* container) { |
| 28 return button_; | 30 container->SetLayoutManager(new views::FillLayout); |
| 31 container->AddChildView(button_); |
| 29 } | 32 } |
| 30 | 33 |
| 31 private: | 34 private: |
| 32 // ButtonListner implementation. | 35 // ButtonListner implementation. |
| 33 virtual void ButtonPressed(views::Button* sender, const views::Event& event) { | 36 virtual void ButtonPressed(views::Button* sender, const views::Event& event) { |
| 34 PrintStatus(L"Pressed! count:%d", ++count_); | 37 PrintStatus(L"Pressed! count:%d", ++count_); |
| 35 } | 38 } |
| 36 | 39 |
| 37 // The only control in this test. | 40 // The only control in this test. |
| 38 views::TextButton* button_; | 41 views::TextButton* button_; |
| 39 | 42 |
| 40 // The number of times the button is pressed. | 43 // The number of times the button is pressed. |
| 41 int count_; | 44 int count_; |
| 42 | 45 |
| 43 DISALLOW_COPY_AND_ASSIGN(ButtonExample); | 46 DISALLOW_COPY_AND_ASSIGN(ButtonExample); |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 } // namespace examples | 49 } // namespace examples |
| 47 | 50 |
| 48 #endif // VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ | 51 #endif // VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ |
| 49 | 52 |
| OLD | NEW |