| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 namespace views { | 12 namespace views { |
| 13 class View; | 13 class View; |
| 14 | 14 |
| 15 namespace examples { | 15 namespace examples { |
| 16 | 16 |
| 17 class ExampleBase { | 17 class ExampleBase { |
| 18 public: | 18 public: |
| 19 virtual ~ExampleBase(); | 19 virtual ~ExampleBase(); |
| 20 | 20 |
| 21 // Sub-classes should creates and add the views to the given parent. | 21 // Sub-classes should creates and add the views to the given parent. |
| 22 virtual void CreateExampleView(View* parent) = 0; | 22 virtual void CreateExampleView(View* parent) = 0; |
| 23 | 23 |
| 24 const std::string& example_title() const { return example_title_; } | 24 const std::string& example_title() const { return example_title_; } |
| 25 View* example_view() { return container_; } | 25 View* example_view() { return container_; } |
| 26 | 26 |
| 27 protected: | 27 protected: |
| 28 explicit ExampleBase(const char* title); | 28 explicit ExampleBase(const char* title); |
| 29 | 29 |
| 30 View* container() { return container_; } |
| 31 |
| 30 // Prints a message in the status area, at the bottom of the window. | 32 // Prints a message in the status area, at the bottom of the window. |
| 31 void PrintStatus(const char* format, ...); | 33 void PrintStatus(const char* format, ...); |
| 32 | 34 |
| 33 // Converts an boolean value to "on" or "off". | 35 // Converts an boolean value to "on" or "off". |
| 34 const char* BoolToOnOff(bool value) { | 36 const char* BoolToOnOff(bool value) { |
| 35 return value ? "on" : "off"; | 37 return value ? "on" : "off"; |
| 36 } | 38 } |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 // Name of the example - used as title in the combobox list. | 41 // Name of the example - used as title in the combobox list. |
| 40 std::string example_title_; | 42 std::string example_title_; |
| 41 | 43 |
| 42 // The view that contains the views example. | 44 // The view that contains the views example. |
| 43 View* container_; | 45 View* container_; |
| 44 | 46 |
| 45 DISALLOW_COPY_AND_ASSIGN(ExampleBase); | 47 DISALLOW_COPY_AND_ASSIGN(ExampleBase); |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 } // namespace examples | 50 } // namespace examples |
| 49 } // namespace views | 51 } // namespace views |
| 50 | 52 |
| 51 #endif // UI_VIEWS_EXAMPLES_EXAMPLE_BASE_H_ | 53 #endif // UI_VIEWS_EXAMPLES_EXAMPLE_BASE_H_ |
| OLD | NEW |