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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 Widget* widget_; | 59 Widget* widget_; |
60 const Event* event_; | 60 const Event* event_; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(ScopedEvent); | 62 DISALLOW_COPY_AND_ASSIGN(ScopedEvent); |
63 }; | 63 }; |
64 | 64 |
65 // A default implementation of WidgetDelegate, used by Widget when no | 65 // A default implementation of WidgetDelegate, used by Widget when no |
66 // WidgetDelegate is supplied. | 66 // WidgetDelegate is supplied. |
67 class DefaultWidgetDelegate : public WidgetDelegate { | 67 class DefaultWidgetDelegate : public WidgetDelegate { |
68 public: | 68 public: |
69 explicit DefaultWidgetDelegate(Widget* widget) : widget_(widget) {} | 69 DefaultWidgetDelegate(Widget* widget, const Widget::InitParams& params) |
| 70 : widget_(widget), |
| 71 can_activate_(params.type != Widget::InitParams::TYPE_POPUP) { |
| 72 } |
70 virtual ~DefaultWidgetDelegate() {} | 73 virtual ~DefaultWidgetDelegate() {} |
71 | 74 |
72 // Overridden from WidgetDelegate: | 75 // Overridden from WidgetDelegate: |
73 virtual void DeleteDelegate() OVERRIDE { | 76 virtual void DeleteDelegate() OVERRIDE { |
74 delete this; | 77 delete this; |
75 } | 78 } |
76 virtual Widget* GetWidget() { | 79 virtual Widget* GetWidget() { |
77 return widget_; | 80 return widget_; |
78 } | 81 } |
79 virtual const Widget* GetWidget() const { | 82 virtual const Widget* GetWidget() const { |
80 return widget_; | 83 return widget_; |
81 } | 84 } |
82 | 85 |
| 86 virtual bool CanActivate() const { |
| 87 return can_activate_; |
| 88 } |
| 89 |
83 private: | 90 private: |
84 Widget* widget_; | 91 Widget* widget_; |
| 92 bool can_activate_; |
85 | 93 |
86 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); | 94 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); |
87 }; | 95 }; |
88 | 96 |
89 //////////////////////////////////////////////////////////////////////////////// | 97 //////////////////////////////////////////////////////////////////////////////// |
90 // Widget, InitParams: | 98 // Widget, InitParams: |
91 | 99 |
92 Widget::InitParams::InitParams() | 100 Widget::InitParams::InitParams() |
93 : type(TYPE_WINDOW), | 101 : type(TYPE_WINDOW), |
94 delegate(NULL), | 102 delegate(NULL), |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // static | 286 // static |
279 bool Widget::IsDebugPaintEnabled() { | 287 bool Widget::IsDebugPaintEnabled() { |
280 return debug_paint; | 288 return debug_paint; |
281 } | 289 } |
282 | 290 |
283 void Widget::Init(const InitParams& params) { | 291 void Widget::Init(const InitParams& params) { |
284 is_top_level_ = params.top_level || | 292 is_top_level_ = params.top_level || |
285 (!params.child && | 293 (!params.child && |
286 params.type != InitParams::TYPE_CONTROL && | 294 params.type != InitParams::TYPE_CONTROL && |
287 params.type != InitParams::TYPE_TOOLTIP); | 295 params.type != InitParams::TYPE_TOOLTIP); |
288 widget_delegate_ = | 296 widget_delegate_ = params.delegate ? |
289 params.delegate ? params.delegate : new DefaultWidgetDelegate(this); | 297 params.delegate : new DefaultWidgetDelegate(this, params); |
290 ownership_ = params.ownership; | 298 ownership_ = params.ownership; |
291 native_widget_ = params.native_widget ? | 299 native_widget_ = params.native_widget ? |
292 params.native_widget->AsNativeWidgetPrivate() : | 300 params.native_widget->AsNativeWidgetPrivate() : |
293 internal::NativeWidgetPrivate::CreateNativeWidget(this); | 301 internal::NativeWidgetPrivate::CreateNativeWidget(this); |
294 GetRootView(); | 302 GetRootView(); |
295 default_theme_provider_.reset(new DefaultThemeProvider); | 303 default_theme_provider_.reset(new DefaultThemeProvider); |
296 if (params.type == InitParams::TYPE_MENU) { | 304 if (params.type == InitParams::TYPE_MENU) { |
297 is_mouse_button_pressed_ = | 305 is_mouse_button_pressed_ = |
298 internal::NativeWidgetPrivate::IsMouseButtonDown(); | 306 internal::NativeWidgetPrivate::IsMouseButtonDown(); |
299 } | 307 } |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 | 1142 |
1135 //////////////////////////////////////////////////////////////////////////////// | 1143 //////////////////////////////////////////////////////////////////////////////// |
1136 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1144 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1137 | 1145 |
1138 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1146 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1139 return this; | 1147 return this; |
1140 } | 1148 } |
1141 | 1149 |
1142 } // namespace internal | 1150 } // namespace internal |
1143 } // namespace views | 1151 } // namespace views |
OLD | NEW |