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 12 namespace views { 13 class View; 14 15 namespace examples { 16 17 class 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 // Prints a message in the status area, at the bottom of the window. 31 void PrintStatus(const char* format, ...); 32 33 // Converts an boolean value to "on" or "off". 34 const char* BoolToOnOff(bool value) { 35 return value ? "on" : "off"; 36 } 37 38 private: 39 // Name of the example - used as title in the combobox list. 40 std::string example_title_; 41 42 // The view that contains the views example. 43 View* container_; 44 45 DISALLOW_COPY_AND_ASSIGN(ExampleBase); 46 }; 47 48 } // namespace examples 49 } // namespace views 50 51 #endif // UI_VIEWS_EXAMPLES_EXAMPLE_BASE_H_ 52