Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: ui/views/examples/example_base.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/examples/example_base.h ('k') | ui/views/examples/example_combobox_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "ui/views/examples/example_base.h"
6
7 #include <stdarg.h>
8
9 #include "base/strings/stringprintf.h"
10 #include "ui/views/view.h"
11
12 namespace views {
13 namespace examples {
14
15 // Logs the specified string to the status area of the examples window.
16 // This function can only be called if there is a visible examples window.
17 void LogStatus(const std::string& status);
18
19 namespace {
20
21 // TODO(oshima): Check if this special container is still necessary.
22 class ContainerView : public View {
23 public:
24 explicit ContainerView(ExampleBase* base)
25 : example_view_created_(false),
26 example_base_(base) {
27 }
28
29 private:
30 // View:
31 virtual void ViewHierarchyChanged(
32 const ViewHierarchyChangedDetails& details) override {
33 View::ViewHierarchyChanged(details);
34 // We're not using child == this because a Widget may not be
35 // available when this is added to the hierarchy.
36 if (details.is_add && GetWidget() && !example_view_created_) {
37 example_view_created_ = true;
38 example_base_->CreateExampleView(this);
39 }
40 }
41
42 // True if the example view has already been created, or false otherwise.
43 bool example_view_created_;
44
45 ExampleBase* example_base_;
46
47 DISALLOW_COPY_AND_ASSIGN(ContainerView);
48 };
49
50 } // namespace
51
52 ExampleBase::~ExampleBase() {}
53
54 ExampleBase::ExampleBase(const char* title) : example_title_(title) {
55 container_ = new ContainerView(this);
56 }
57
58 // Prints a message in the status area, at the bottom of the window.
59 void ExampleBase::PrintStatus(const char* format, ...) {
60 va_list ap;
61 va_start(ap, format);
62 std::string msg;
63 base::StringAppendV(&msg, format, ap);
64 LogStatus(msg);
65 }
66
67 } // namespace examples
68 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/example_base.h ('k') | ui/views/examples/example_combobox_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698