OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |