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