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