| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/widget/widget.h" | 5 #include "ui/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/hit_test.h" | 10 #include "ui/base/hit_test.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #if !defined(OS_MACOSX) | 29 #if !defined(OS_MACOSX) |
| 30 #include "ui/views/controls/menu/menu_controller.h" | 30 #include "ui/views/controls/menu/menu_controller.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // Set to true if a pure Views implementation is preferred | 35 // Set to true if a pure Views implementation is preferred |
| 36 bool use_pure_views = false; | 36 bool use_pure_views = false; |
| 37 | 37 |
| 38 // True to enable debug paint that indicates where to be painted. | |
| 39 bool debug_paint = false; | |
| 40 | |
| 41 } // namespace | 38 } // namespace |
| 42 | 39 |
| 43 namespace views { | 40 namespace views { |
| 44 | 41 |
| 45 // This class is used to keep track of the event a Widget is processing, and | 42 // This class is used to keep track of the event a Widget is processing, and |
| 46 // restore any previously active event afterwards. | 43 // restore any previously active event afterwards. |
| 47 class ScopedEvent { | 44 class ScopedEvent { |
| 48 public: | 45 public: |
| 49 ScopedEvent(Widget* widget, const Event& event) | 46 ScopedEvent(Widget* widget, const Event& event) |
| 50 : widget_(widget), | 47 : widget_(widget), |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 } | 290 } |
| 294 | 291 |
| 295 // static | 292 // static |
| 296 gfx::Size Widget::GetLocalizedContentsSize(int col_resource_id, | 293 gfx::Size Widget::GetLocalizedContentsSize(int col_resource_id, |
| 297 int row_resource_id) { | 294 int row_resource_id) { |
| 298 return gfx::Size(GetLocalizedContentsWidth(col_resource_id), | 295 return gfx::Size(GetLocalizedContentsWidth(col_resource_id), |
| 299 GetLocalizedContentsHeight(row_resource_id)); | 296 GetLocalizedContentsHeight(row_resource_id)); |
| 300 } | 297 } |
| 301 | 298 |
| 302 // static | 299 // static |
| 303 void Widget::SetDebugPaintEnabled(bool enabled) { | |
| 304 debug_paint = enabled; | |
| 305 } | |
| 306 | |
| 307 // static | |
| 308 bool Widget::IsDebugPaintEnabled() { | |
| 309 return debug_paint; | |
| 310 } | |
| 311 | |
| 312 // static | |
| 313 bool Widget::RequiresNonClientView(InitParams::Type type) { | 300 bool Widget::RequiresNonClientView(InitParams::Type type) { |
| 314 return type == InitParams::TYPE_WINDOW || | 301 return type == InitParams::TYPE_WINDOW || |
| 315 type == InitParams::TYPE_PANEL || | 302 type == InitParams::TYPE_PANEL || |
| 316 type == InitParams::TYPE_BUBBLE; | 303 type == InitParams::TYPE_BUBBLE; |
| 317 } | 304 } |
| 318 | 305 |
| 319 void Widget::Init(const InitParams& params) { | 306 void Widget::Init(const InitParams& params) { |
| 320 is_top_level_ = params.top_level || | 307 is_top_level_ = params.top_level || |
| 321 (!params.child && | 308 (!params.child && |
| 322 params.type != InitParams::TYPE_CONTROL && | 309 params.type != InitParams::TYPE_CONTROL && |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 if (bounds->height() < minimum_size.height()) | 1260 if (bounds->height() < minimum_size.height()) |
| 1274 bounds->set_height(minimum_size.height()); | 1261 bounds->set_height(minimum_size.height()); |
| 1275 } | 1262 } |
| 1276 return true; | 1263 return true; |
| 1277 } | 1264 } |
| 1278 return false; | 1265 return false; |
| 1279 } | 1266 } |
| 1280 | 1267 |
| 1281 void Widget::ReplaceInputMethod(InputMethod* input_method) { | 1268 void Widget::ReplaceInputMethod(InputMethod* input_method) { |
| 1282 input_method_.reset(input_method); | 1269 input_method_.reset(input_method); |
| 1283 // TODO(oshima): Gtk's textfield doesn't need views InputMethod. | 1270 input_method->set_delegate(native_widget_); |
| 1284 // Remove this check once gtk is removed. | 1271 input_method->Init(this); |
| 1285 if (input_method) { | |
| 1286 input_method->set_delegate(native_widget_); | |
| 1287 input_method->Init(this); | |
| 1288 } | |
| 1289 } | 1272 } |
| 1290 | 1273 |
| 1291 namespace internal { | 1274 namespace internal { |
| 1292 | 1275 |
| 1293 //////////////////////////////////////////////////////////////////////////////// | 1276 //////////////////////////////////////////////////////////////////////////////// |
| 1294 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1277 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1295 | 1278 |
| 1296 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1279 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1297 return this; | 1280 return this; |
| 1298 } | 1281 } |
| 1299 | 1282 |
| 1300 } // namespace internal | 1283 } // namespace internal |
| 1301 } // namespace views | 1284 } // namespace views |
| OLD | NEW |