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/widget.h" | 5 #include "views/widget/widget.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "ui/base/l10n/l10n_font_util.h" | 10 #include "ui/base/l10n/l10n_font_util.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 Widget* widget_; | 53 Widget* widget_; |
54 const Event* event_; | 54 const Event* event_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(ScopedEvent); | 56 DISALLOW_COPY_AND_ASSIGN(ScopedEvent); |
57 }; | 57 }; |
58 | 58 |
59 // A default implementation of WidgetDelegate, used by Widget when no | 59 // A default implementation of WidgetDelegate, used by Widget when no |
60 // WidgetDelegate is supplied. | 60 // WidgetDelegate is supplied. |
61 class DefaultWidgetDelegate : public WidgetDelegate { | 61 class DefaultWidgetDelegate : public WidgetDelegate { |
62 public: | 62 public: |
63 DefaultWidgetDelegate() {} | 63 explicit DefaultWidgetDelegate(Widget* widget) : widget_(widget) {} |
64 virtual ~DefaultWidgetDelegate() {} | 64 virtual ~DefaultWidgetDelegate() {} |
65 | 65 |
66 // Overridden from WidgetDelegate: | 66 // Overridden from WidgetDelegate: |
67 virtual void DeleteDelegate() OVERRIDE { | 67 virtual void DeleteDelegate() OVERRIDE { |
68 delete this; | 68 delete this; |
69 } | 69 } |
| 70 virtual Widget* GetWidget() { |
| 71 return widget_; |
| 72 } |
| 73 virtual const Widget* GetWidget() const { |
| 74 return widget_; |
| 75 } |
70 | 76 |
71 private: | 77 private: |
| 78 Widget* widget_; |
| 79 |
72 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); | 80 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); |
73 }; | 81 }; |
74 | 82 |
75 //////////////////////////////////////////////////////////////////////////////// | 83 //////////////////////////////////////////////////////////////////////////////// |
76 // Widget, InitParams: | 84 // Widget, InitParams: |
77 | 85 |
78 Widget::InitParams::InitParams() | 86 Widget::InitParams::InitParams() |
79 : type(TYPE_WINDOW), | 87 : type(TYPE_WINDOW), |
80 delegate(NULL), | 88 delegate(NULL), |
81 child(false), | 89 child(false), |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 247 |
240 // static | 248 // static |
241 gfx::Size Widget::GetLocalizedContentsSize(int col_resource_id, | 249 gfx::Size Widget::GetLocalizedContentsSize(int col_resource_id, |
242 int row_resource_id) { | 250 int row_resource_id) { |
243 return gfx::Size(GetLocalizedContentsWidth(col_resource_id), | 251 return gfx::Size(GetLocalizedContentsWidth(col_resource_id), |
244 GetLocalizedContentsHeight(row_resource_id)); | 252 GetLocalizedContentsHeight(row_resource_id)); |
245 } | 253 } |
246 | 254 |
247 void Widget::Init(const InitParams& params) { | 255 void Widget::Init(const InitParams& params) { |
248 widget_delegate_ = | 256 widget_delegate_ = |
249 params.delegate ? params.delegate : new DefaultWidgetDelegate; | 257 params.delegate ? params.delegate : new DefaultWidgetDelegate(this); |
250 ownership_ = params.ownership; | 258 ownership_ = params.ownership; |
251 native_widget_ = params.native_widget ? | 259 native_widget_ = params.native_widget ? |
252 params.native_widget->AsNativeWidgetPrivate() : | 260 params.native_widget->AsNativeWidgetPrivate() : |
253 internal::NativeWidgetPrivate::CreateNativeWidget(this); | 261 internal::NativeWidgetPrivate::CreateNativeWidget(this); |
254 GetRootView(); | 262 GetRootView(); |
255 default_theme_provider_.reset(new DefaultThemeProvider); | 263 default_theme_provider_.reset(new DefaultThemeProvider); |
256 if (params.type == InitParams::TYPE_MENU) | 264 if (params.type == InitParams::TYPE_MENU) |
257 is_mouse_button_pressed_ = native_widget_->IsMouseButtonDown(); | 265 is_mouse_button_pressed_ = native_widget_->IsMouseButtonDown(); |
258 native_widget_->InitNativeWidget(params); | 266 native_widget_->InitNativeWidget(params); |
259 if (params.type == InitParams::TYPE_WINDOW) { | 267 if (params.type == InitParams::TYPE_WINDOW) { |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 | 988 |
981 //////////////////////////////////////////////////////////////////////////////// | 989 //////////////////////////////////////////////////////////////////////////////// |
982 // internal::NativeWidgetPrivate, NativeWidget implementation: | 990 // internal::NativeWidgetPrivate, NativeWidget implementation: |
983 | 991 |
984 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 992 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
985 return this; | 993 return this; |
986 } | 994 } |
987 | 995 |
988 } // namespace internal | 996 } // namespace internal |
989 } // namespace views | 997 } // namespace views |
OLD | NEW |