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