Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / views / examples / example_base.h
blobf841eb920b111d2e6ac245d187d98740b4d29126
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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_EXAMPLES_EXAMPLE_BASE_H_
6 #define UI_VIEWS_EXAMPLES_EXAMPLE_BASE_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "ui/views/examples/views_examples_export.h"
13 namespace views {
14 class View;
16 namespace examples {
18 class VIEWS_EXAMPLES_EXPORT ExampleBase {
19 public:
20 virtual ~ExampleBase();
22 // Sub-classes should creates and add the views to the given parent.
23 virtual void CreateExampleView(View* parent) = 0;
25 const std::string& example_title() const { return example_title_; }
26 View* example_view() { return container_; }
28 protected:
29 explicit ExampleBase(const char* title);
31 View* container() { return container_; }
33 // Prints a message in the status area, at the bottom of the window.
34 void PrintStatus(const char* format, ...);
36 // Converts an boolean value to "on" or "off".
37 const char* BoolToOnOff(bool value) {
38 return value ? "on" : "off";
41 private:
42 // Name of the example - used as title in the combobox list.
43 std::string example_title_;
45 // The view that contains the views example.
46 View* container_;
48 DISALLOW_COPY_AND_ASSIGN(ExampleBase);
51 } // namespace examples
52 } // namespace views
54 #endif // UI_VIEWS_EXAMPLES_EXAMPLE_BASE_H_