| 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_EXAMPLE_BASE_H_ | 5 #ifndef VIEWS_EXAMPLES_EXAMPLE_BASE_H_ |
| 6 #define VIEWS_EXAMPLES_EXAMPLE_BASE_H_ | 6 #define VIEWS_EXAMPLES_EXAMPLE_BASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "views/examples/examples_main.h" | |
| 12 #include "views/window/window_delegate.h" | |
| 13 | 11 |
| 14 namespace views { | 12 namespace views { |
| 15 class View; | 13 class View; |
| 16 } // namespace views | 14 } // namespace views |
| 17 | 15 |
| 18 namespace examples { | 16 namespace examples { |
| 19 | 17 |
| 18 class ExamplesMain; |
| 19 |
| 20 class ExampleBase { | 20 class ExampleBase { |
| 21 public: |
| 22 // Returns the view containing this example controls. |
| 23 // This view is added as a tab to the example application. |
| 24 views::View* GetExampleView() { |
| 25 return container_; |
| 26 } |
| 27 |
| 28 // Sub-classes should creates and add the views to the given parent. |
| 29 virtual void CreateExampleView(views::View* parent) = 0; |
| 30 |
| 21 protected: | 31 protected: |
| 22 explicit ExampleBase(ExamplesMain* main) : main_(main) {} | 32 explicit ExampleBase(ExamplesMain* main); |
| 23 virtual ~ExampleBase() {} | 33 virtual ~ExampleBase() {} |
| 24 | 34 |
| 25 // Sub-classes should return the name of this test. | 35 // Sub-classes should return the name of this test. |
| 26 // It is used as the title of the tab displaying this test's controls. | 36 // It is used as the title of the tab displaying this test's controls. |
| 27 virtual std::wstring GetExampleTitle() = 0; | 37 virtual std::wstring GetExampleTitle() = 0; |
| 28 | 38 |
| 29 // Sub-classes should return the view containing this example controls. | |
| 30 // This view is added as a tab to the example application. | |
| 31 virtual views::View* GetExampleView() = 0; | |
| 32 | |
| 33 // Prints a message in the status area, at the bottom of the window. | 39 // Prints a message in the status area, at the bottom of the window. |
| 34 void PrintStatus(const wchar_t* format, ...); | 40 void PrintStatus(const wchar_t* format, ...); |
| 35 | 41 |
| 36 // Converts an integer/boolean to wchat "on"/"off". | 42 // Converts an integer/boolean to wchat "on"/"off". |
| 37 static const wchar_t* IntToOnOff(int value) { | 43 static const wchar_t* IntToOnOff(int value) { |
| 38 return value ? L"on" : L"off"; | 44 return value ? L"on" : L"off"; |
| 39 } | 45 } |
| 40 | 46 |
| 41 private: | 47 private: |
| 42 // The runner actually running this test. | 48 // The runner actually running this test. |
| 43 ExamplesMain* main_; | 49 ExamplesMain* main_; |
| 44 | 50 |
| 51 // The view containing example views. |
| 52 views::View* container_; |
| 53 |
| 45 DISALLOW_COPY_AND_ASSIGN(ExampleBase); | 54 DISALLOW_COPY_AND_ASSIGN(ExampleBase); |
| 46 }; | 55 }; |
| 47 | 56 |
| 48 } // namespace examples | 57 } // namespace examples |
| 49 | 58 |
| 50 #endif // VIEWS_EXAMPLES_EXAMPLE_BASE_H_ | 59 #endif // VIEWS_EXAMPLES_EXAMPLE_BASE_H_ |
| 51 | 60 |
| OLD | NEW |