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 #include "ui/views/examples/example_base.h"
9 #include "base/compiler_specific.h"
10 #include "base/strings/stringprintf.h"
11 #include "ui/views/view.h"
16 // Logs the specified string to the status area of the examples window.
17 // This function can only be called if there is a visible examples window.
18 void LogStatus(const std::string& status);
22 // TODO(oshima): Check if this special container is still necessary.
23 class ContainerView : public View {
25 explicit ContainerView(ExampleBase* base)
26 : example_view_created_(false),
31 // Overridden from View:
32 virtual void ViewHierarchyChanged(
33 const ViewHierarchyChangedDetails& details) OVERRIDE {
34 View::ViewHierarchyChanged(details);
35 // We're not using child == this because a Widget may not be
36 // available when this is added to the hierarchy.
37 if (details.is_add && GetWidget() && !example_view_created_) {
38 example_view_created_ = true;
39 example_base_->CreateExampleView(this);
43 // True if the example view has already been created, or false otherwise.
44 bool example_view_created_;
46 ExampleBase* example_base_;
48 DISALLOW_COPY_AND_ASSIGN(ContainerView);
53 ExampleBase::~ExampleBase() {}
55 ExampleBase::ExampleBase(const char* title) : example_title_(title) {
56 container_ = new ContainerView(this);
59 // Prints a message in the status area, at the bottom of the window.
60 void ExampleBase::PrintStatus(const char* format, ...) {
64 base::StringAppendV(&msg, format, ap);
68 } // namespace examples