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

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

Issue 8687013: Get the examples to run in aura_shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
« 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/examples/example_base.h" 5 #include "ui/views/examples/example_base.h"
6 6
7 #include <stdarg.h> 7 #include <stdarg.h>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "ui/views/examples/examples_main.h" 11 #include "ui/views/examples/examples_window.h"
12 #include "views/view.h"
13
14 namespace views {
15 namespace examples {
16
17 // Logs the specified string to the status area of the examples window.
18 // This function can only be called if there is a visible examples window.
19 void LogStatus(const std::string& status);
12 20
13 namespace { 21 namespace {
14 22
15 // Some of GTK based view classes require NativeWidgetGtk in the view 23 // Some of GTK based view classes require NativeWidgetGtk in the view
16 // parent chain. This class is used to defer the creation of such 24 // parent chain. This class is used to defer the creation of such
17 // views until a NativeWidgetGtk is added to the view hierarchy. 25 // views until a NativeWidgetGtk is added to the view hierarchy.
18 class ContainerView : public views::View { 26 class ContainerView : public View {
19 public: 27 public:
20 explicit ContainerView(examples::ExampleBase* base) 28 explicit ContainerView(examples::ExampleBase* base)
21 : example_view_created_(false), 29 : example_view_created_(false),
22 example_base_(base) { 30 example_base_(base) {
23 } 31 }
24 32
25 private: 33 private:
26 // Overridden from views::View: 34 // Overridden from View:
27 virtual void ViewHierarchyChanged(bool is_add, 35 virtual void ViewHierarchyChanged(bool is_add,
28 views::View* parent, 36 View* parent,
29 views::View* child) OVERRIDE { 37 View* child) OVERRIDE {
30 views::View::ViewHierarchyChanged(is_add, parent, child); 38 View::ViewHierarchyChanged(is_add, parent, child);
31 // We're not using child == this because a Widget may not be 39 // We're not using child == this because a Widget may not be
32 // availalbe when this is added to the hierarchy. 40 // available when this is added to the hierarchy.
33 if (is_add && GetWidget() && !example_view_created_) { 41 if (is_add && GetWidget() && !example_view_created_) {
34 example_view_created_ = true; 42 example_view_created_ = true;
35 example_base_->CreateExampleView(this); 43 example_base_->CreateExampleView(this);
36 } 44 }
37 } 45 }
38 46
39 // True if the example view has already been created, or false otherwise. 47 // True if the example view has already been created, or false otherwise.
40 bool example_view_created_; 48 bool example_view_created_;
41 49
42 examples::ExampleBase* example_base_; 50 examples::ExampleBase* example_base_;
43 51
44 DISALLOW_COPY_AND_ASSIGN(ContainerView); 52 DISALLOW_COPY_AND_ASSIGN(ContainerView);
45 }; 53 };
46 54
47 } // namespace 55 } // namespace
48 56
49 namespace examples {
50
51 ExampleBase::~ExampleBase() {} 57 ExampleBase::~ExampleBase() {}
52 58
53 ExampleBase::ExampleBase(ExamplesMain* main, const char* title) 59 ExampleBase::ExampleBase(const char* title) : example_title_(title) {
54 : main_(main), example_title_(title) {
55 container_ = new ContainerView(this); 60 container_ = new ContainerView(this);
56 } 61 }
57 62
58 // Prints a message in the status area, at the bottom of the window. 63 // Prints a message in the status area, at the bottom of the window.
59 void ExampleBase::PrintStatus(const char* format, ...) { 64 void ExampleBase::PrintStatus(const char* format, ...) {
60 va_list ap; 65 va_list ap;
61 va_start(ap, format); 66 va_start(ap, format);
62 std::string msg; 67 std::string msg;
63 base::StringAppendV(&msg, format, ap); 68 base::StringAppendV(&msg, format, ap);
64 main_->SetStatus(msg); 69 LogStatus(msg);
65 } 70 }
66 71
67 } // namespace examples 72 } // namespace examples
73 } // 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