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

Side by Side Diff: views/aura_desktop/aura_desktop_main.cc

Issue 7744045: Show a Window in the aura views demo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | views/views.gyp » ('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 "aura/desktop.h" 5 #include "aura/desktop.h"
6 #include "aura/desktop_host.h" 6 #include "aura/desktop_host.h"
7 #include "aura/window.h" 7 #include "aura/window.h"
8 #include "aura/window_delegate.h" 8 #include "aura/window_delegate.h"
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/icu_util.h" 11 #include "base/i18n/icu_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "third_party/skia/include/core/SkXfermode.h" 14 #include "third_party/skia/include/core/SkXfermode.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/base/ui_base_paths.h" 16 #include "ui/base/ui_base_paths.h"
17 #include "ui/gfx/canvas.h" 17 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/canvas_skia.h" 18 #include "ui/gfx/canvas_skia.h"
19 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
20 #include "views/widget/widget.h" 20 #include "views/widget/widget.h"
21 #include "views/widget/widget_delegate.h"
21 22
22 namespace { 23 namespace {
23 24
24 // Trivial WindowDelegate implementation that draws a colored background. 25 // Trivial WindowDelegate implementation that draws a colored background.
25 class DemoWindowDelegate : public aura::WindowDelegate { 26 class DemoWindowDelegate : public aura::WindowDelegate {
26 public: 27 public:
27 explicit DemoWindowDelegate(SkColor color) : color_(color) {} 28 explicit DemoWindowDelegate(SkColor color) : color_(color) {}
28 29
29 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 30 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
30 canvas->AsCanvasSkia()->drawColor(color_, SkXfermode::kSrc_Mode); 31 canvas->AsCanvasSkia()->drawColor(color_, SkXfermode::kSrc_Mode);
(...skipping 12 matching lines...) Expand all
43 44
44 private: 45 private:
45 // Overridden from views::View: 46 // Overridden from views::View:
46 virtual void OnPaint(gfx::Canvas* canvas) { 47 virtual void OnPaint(gfx::Canvas* canvas) {
47 canvas->FillRectInt(SK_ColorYELLOW, 0, 0, width(), height()); 48 canvas->FillRectInt(SK_ColorYELLOW, 0, 0, width(), height());
48 } 49 }
49 50
50 DISALLOW_COPY_AND_ASSIGN(TestView); 51 DISALLOW_COPY_AND_ASSIGN(TestView);
51 }; 52 };
52 53
54 class TestWindowContents : public views::WidgetDelegateView {
55 public:
56 TestWindowContents() {}
57 virtual ~TestWindowContents() {}
58
59 private:
60 // Overridden from views::View:
61 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
62 canvas->FillRectInt(SK_ColorGRAY, 0, 0, width(), height());
63 }
64
65 // Overridden from views::WidgetDelegateView:
66 virtual std::wstring GetWindowTitle() const OVERRIDE {
67 return L"Test Window!";
68 }
69 virtual View* GetContentsView() OVERRIDE {
70 return this;
71 }
72
73 DISALLOW_COPY_AND_ASSIGN(TestWindowContents);
74 };
75
53 } // namespace 76 } // namespace
54 77
55 int main(int argc, char** argv) { 78 int main(int argc, char** argv) {
56 CommandLine::Init(argc, argv); 79 CommandLine::Init(argc, argv);
57 80
58 // The exit manager is in charge of calling the dtors of singleton objects. 81 // The exit manager is in charge of calling the dtors of singleton objects.
59 base::AtExitManager exit_manager; 82 base::AtExitManager exit_manager;
60 83
61 ui::RegisterPathProvider(); 84 ui::RegisterPathProvider();
62 icu_util::Initialize(); 85 icu_util::Initialize();
(...skipping 30 matching lines...) Expand all
93 window3.SetVisibility(aura::Window::VISIBILITY_SHOWN); 116 window3.SetVisibility(aura::Window::VISIBILITY_SHOWN);
94 window3.SetParent(&window2); 117 window3.SetParent(&window2);
95 118
96 views::Widget widget; 119 views::Widget widget;
97 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); 120 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
98 params.bounds = gfx::Rect(75, 75, 80, 80); 121 params.bounds = gfx::Rect(75, 75, 80, 80);
99 params.parent = &window2; 122 params.parent = &window2;
100 widget.Init(params); 123 widget.Init(params);
101 widget.SetContentsView(new TestView); 124 widget.SetContentsView(new TestView);
102 125
126 TestWindowContents* contents = new TestWindowContents;
127 views::Widget* views_window = views::Widget::CreateWindowWithParentAndBounds(
128 contents, &window2, gfx::Rect(120, 150, 200, 200));
129 views_window->Show();
130
103 aura::Desktop::GetInstance()->Run(); 131 aura::Desktop::GetInstance()->Run();
104 return 0; 132 return 0;
105 } 133 }
106 134
OLDNEW
« no previous file with comments | « no previous file | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698