| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/views/view.h" | 5 #include "chrome/views/view.h" |
| 6 | 6 |
| 7 #include "base/scoped_handle.h" | 7 #include "base/scoped_handle.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/common/drag_drop_types.h" |
| 9 #include "chrome/common/gfx/chrome_canvas.h" | 10 #include "chrome/common/gfx/chrome_canvas.h" |
| 10 #include "chrome/common/gfx/path.h" | 11 #include "chrome/common/gfx/path.h" |
| 11 #include "chrome/common/os_exchange_data.h" | 12 #include "chrome/common/os_exchange_data.h" |
| 12 #include "chrome/views/accessibility/accessible_wrapper.h" | 13 #include "chrome/views/accessibility/accessible_wrapper.h" |
| 13 #include "chrome/views/border.h" | 14 #include "chrome/views/border.h" |
| 14 #include "chrome/views/root_view.h" | 15 #include "chrome/views/root_view.h" |
| 15 #include "chrome/views/widget.h" | 16 #include "chrome/views/widget.h" |
| 16 | 17 |
| 17 namespace views { | 18 namespace views { |
| 18 | 19 |
| 19 FocusManager* View::GetFocusManager() { | 20 FocusManager* View::GetFocusManager() { |
| 20 Widget* widget = GetWidget(); | 21 Widget* widget = GetWidget(); |
| 21 if (!widget) | 22 if (!widget) |
| 22 return NULL; | 23 return NULL; |
| 23 | 24 |
| 24 HWND hwnd = widget->GetNativeView(); | 25 HWND hwnd = widget->GetNativeView(); |
| 25 if (!hwnd) | 26 if (!hwnd) |
| 26 return NULL; | 27 return NULL; |
| 27 | 28 |
| 28 return FocusManager::GetFocusManager(hwnd); | 29 return FocusManager::GetFocusManager(hwnd); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void View::DoDrag(const MouseEvent& e, int press_x, int press_y) { | 32 void View::DoDrag(const MouseEvent& e, int press_x, int press_y) { |
| 33 int drag_operations = GetDragOperations(press_x, press_y); |
| 34 if (drag_operations == DragDropTypes::DRAG_NONE) |
| 35 return; |
| 36 |
| 32 scoped_refptr<OSExchangeData> data = new OSExchangeData; | 37 scoped_refptr<OSExchangeData> data = new OSExchangeData; |
| 33 WriteDragData(press_x, press_y, data.get()); | 38 WriteDragData(press_x, press_y, data.get()); |
| 34 | 39 |
| 35 // Message the RootView to do the drag and drop. That way if we're removed | 40 // Message the RootView to do the drag and drop. That way if we're removed |
| 36 // the RootView can detect it and avoid calling us back. | 41 // the RootView can detect it and avoid calling us back. |
| 37 RootView* root_view = GetRootView(); | 42 RootView* root_view = GetRootView(); |
| 38 root_view->StartDragForViewFromMouseEvent( | 43 root_view->StartDragForViewFromMouseEvent(this, data, drag_operations); |
| 39 this, data, GetDragOperations(press_x, press_y)); | |
| 40 } | 44 } |
| 41 | 45 |
| 42 AccessibleWrapper* View::GetAccessibleWrapper() { | 46 AccessibleWrapper* View::GetAccessibleWrapper() { |
| 43 if (accessibility_.get() == NULL) { | 47 if (accessibility_.get() == NULL) { |
| 44 accessibility_.reset(new AccessibleWrapper(this)); | 48 accessibility_.reset(new AccessibleWrapper(this)); |
| 45 } | 49 } |
| 46 return accessibility_.get(); | 50 return accessibility_.get(); |
| 47 } | 51 } |
| 48 | 52 |
| 49 bool View::HitTest(const gfx::Point& l) const { | 53 bool View::HitTest(const gfx::Point& l) const { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 86 } |
| 83 | 87 |
| 84 int View::GetVerticalDragThreshold() { | 88 int View::GetVerticalDragThreshold() { |
| 85 static int threshold = -1; | 89 static int threshold = -1; |
| 86 if (threshold == -1) | 90 if (threshold == -1) |
| 87 threshold = GetSystemMetrics(SM_CYDRAG) / 2; | 91 threshold = GetSystemMetrics(SM_CYDRAG) / 2; |
| 88 return threshold; | 92 return threshold; |
| 89 } | 93 } |
| 90 | 94 |
| 91 } // namespace views | 95 } // namespace views |
| OLD | NEW |