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 "views/widget/native_widget_views.h" | 5 #include "views/widget/native_widget_views.h" |
6 | 6 |
7 #include "ui/gfx/canvas.h" | |
8 #include "views/view.h" | 7 #include "views/view.h" |
| 8 #include "views/widget/native_widget_view.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
11 | 11 |
12 //////////////////////////////////////////////////////////////////////////////// | 12 //////////////////////////////////////////////////////////////////////////////// |
13 // NativeWidgetViews::NativeWidgetView: | |
14 | |
15 class NativeWidgetViews::NativeWidgetView : public View { | |
16 public: | |
17 NativeWidgetView() {} | |
18 virtual ~NativeWidgetView() {} | |
19 | |
20 // Overridden from View: | |
21 virtual void OnPaint(gfx::Canvas* canvas) { | |
22 canvas->FillRectInt(SK_ColorRED, 0, 0, width(), height()); | |
23 } | |
24 | |
25 private: | |
26 DISALLOW_COPY_AND_ASSIGN(NativeWidgetView); | |
27 }; | |
28 | |
29 //////////////////////////////////////////////////////////////////////////////// | |
30 // NativeWidgetViews, public: | 13 // NativeWidgetViews, public: |
31 | 14 |
32 NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) | 15 NativeWidgetViews::NativeWidgetViews(View* host, |
| 16 internal::NativeWidgetDelegate* delegate) |
33 : delegate_(delegate), | 17 : delegate_(delegate), |
| 18 host_view_(host), |
34 view_(NULL), | 19 view_(NULL), |
35 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)) { | 20 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)) { |
36 } | 21 } |
37 | 22 |
38 NativeWidgetViews::~NativeWidgetViews() { | 23 NativeWidgetViews::~NativeWidgetViews() { |
39 } | 24 } |
40 | 25 |
41 View* NativeWidgetViews::GetView() { | 26 View* NativeWidgetViews::GetView() { |
42 return view_; | 27 return view_; |
43 } | 28 } |
44 | 29 |
45 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
46 // NativeWidgetViews, NativeWidget implementation: | 31 // NativeWidgetViews, NativeWidget implementation: |
47 | 32 |
48 void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { | 33 void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { |
49 view_ = new NativeWidgetView; | 34 view_ = new internal::NativeWidgetView(this); |
| 35 host_view_->AddChildView(view_); |
50 | 36 |
51 // TODO(beng): handle parenting. | 37 // TODO(beng): handle parenting. |
52 // TODO(beng): SetInitParams(). | 38 // TODO(beng): SetInitParams(). |
53 } | 39 } |
54 | 40 |
55 Widget* NativeWidgetViews::GetWidget() { | 41 Widget* NativeWidgetViews::GetWidget() { |
56 return delegate_->AsWidget(); | 42 return delegate_->AsWidget(); |
57 } | 43 } |
58 | 44 |
59 const Widget* NativeWidgetViews::GetWidget() const { | 45 const Widget* NativeWidgetViews::GetWidget() const { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 NativeWidget* NativeWidgetViews::GetParentNativeWidget() { | 213 NativeWidget* NativeWidgetViews::GetParentNativeWidget() { |
228 return view_->GetWidget()->native_widget(); | 214 return view_->GetWidget()->native_widget(); |
229 } | 215 } |
230 | 216 |
231 const NativeWidget* NativeWidgetViews::GetParentNativeWidget() const { | 217 const NativeWidget* NativeWidgetViews::GetParentNativeWidget() const { |
232 return view_->GetWidget()->native_widget(); | 218 return view_->GetWidget()->native_widget(); |
233 } | 219 } |
234 | 220 |
235 } // namespace views | 221 } // namespace views |
236 | 222 |
OLD | NEW |