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 explicit DefaultWidgetDelegate( |
sadrul
2011/08/26 16:21:36
'explicit' not needed.
oshima
2011/08/26 17:20:28
Done.
| |
70 Widget* widget, const Widget::InitParams& params) | |
71 : widget_(widget), | |
72 can_activate_(params.type != Widget::InitParams::TYPE_POPUP) { | |
73 } | |
70 virtual ~DefaultWidgetDelegate() {} | 74 virtual ~DefaultWidgetDelegate() {} |
71 | 75 |
72 // Overridden from WidgetDelegate: | 76 // Overridden from WidgetDelegate: |
73 virtual void DeleteDelegate() OVERRIDE { | 77 virtual void DeleteDelegate() OVERRIDE { |
74 delete this; | 78 delete this; |
75 } | 79 } |
76 virtual Widget* GetWidget() { | 80 virtual Widget* GetWidget() { |
77 return widget_; | 81 return widget_; |
78 } | 82 } |
79 virtual const Widget* GetWidget() const { | 83 virtual const Widget* GetWidget() const { |
80 return widget_; | 84 return widget_; |
81 } | 85 } |
82 | 86 |
87 virtual bool CanActivate() const { | |
88 return can_activate_; | |
oshima
2011/08/25 22:55:53
CanActivate is used only in native_widget_win.cc,
Ben Goodger (Google)
2011/08/25 23:12:44
Shouldn't do.
oshima
2011/08/26 17:20:28
ok
| |
89 } | |
90 | |
83 private: | 91 private: |
84 Widget* widget_; | 92 Widget* widget_; |
93 bool can_activate_; | |
85 | 94 |
86 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); | 95 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); |
87 }; | 96 }; |
88 | 97 |
89 //////////////////////////////////////////////////////////////////////////////// | 98 //////////////////////////////////////////////////////////////////////////////// |
90 // Widget, InitParams: | 99 // Widget, InitParams: |
91 | 100 |
92 Widget::InitParams::InitParams() | 101 Widget::InitParams::InitParams() |
93 : type(TYPE_WINDOW), | 102 : type(TYPE_WINDOW), |
94 delegate(NULL), | 103 delegate(NULL), |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 // static | 287 // static |
279 bool Widget::IsDebugPaintEnabled() { | 288 bool Widget::IsDebugPaintEnabled() { |
280 return debug_paint; | 289 return debug_paint; |
281 } | 290 } |
282 | 291 |
283 void Widget::Init(const InitParams& params) { | 292 void Widget::Init(const InitParams& params) { |
284 is_top_level_ = params.top_level || | 293 is_top_level_ = params.top_level || |
285 (!params.child && | 294 (!params.child && |
286 params.type != InitParams::TYPE_CONTROL && | 295 params.type != InitParams::TYPE_CONTROL && |
287 params.type != InitParams::TYPE_TOOLTIP); | 296 params.type != InitParams::TYPE_TOOLTIP); |
288 widget_delegate_ = | 297 widget_delegate_ = params.delegate ? |
289 params.delegate ? params.delegate : new DefaultWidgetDelegate(this); | 298 params.delegate : new DefaultWidgetDelegate(this, params); |
290 ownership_ = params.ownership; | 299 ownership_ = params.ownership; |
291 native_widget_ = params.native_widget ? | 300 native_widget_ = params.native_widget ? |
292 params.native_widget->AsNativeWidgetPrivate() : | 301 params.native_widget->AsNativeWidgetPrivate() : |
293 internal::NativeWidgetPrivate::CreateNativeWidget(this); | 302 internal::NativeWidgetPrivate::CreateNativeWidget(this); |
294 GetRootView(); | 303 GetRootView(); |
295 default_theme_provider_.reset(new DefaultThemeProvider); | 304 default_theme_provider_.reset(new DefaultThemeProvider); |
296 if (params.type == InitParams::TYPE_MENU) { | 305 if (params.type == InitParams::TYPE_MENU) { |
297 is_mouse_button_pressed_ = | 306 is_mouse_button_pressed_ = |
298 internal::NativeWidgetPrivate::IsMouseButtonDown(); | 307 internal::NativeWidgetPrivate::IsMouseButtonDown(); |
299 } | 308 } |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1134 | 1143 |
1135 //////////////////////////////////////////////////////////////////////////////// | 1144 //////////////////////////////////////////////////////////////////////////////// |
1136 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1145 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1137 | 1146 |
1138 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1147 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1139 return this; | 1148 return this; |
1140 } | 1149 } |
1141 | 1150 |
1142 } // namespace internal | 1151 } // namespace internal |
1143 } // namespace views | 1152 } // namespace views |
OLD | NEW |