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