Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: views/view_win.cc

Issue 141013: Relanding focus manager refactoring (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/view_unittest.cc ('k') | views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "views/view.h" 5 #include "views/view.h"
6 6
7 #include "app/drag_drop_types.h" 7 #include "app/drag_drop_types.h"
8 #include "app/gfx/canvas.h" 8 #include "app/gfx/canvas.h"
9 #include "app/gfx/path.h" 9 #include "app/gfx/path.h"
10 #include "app/os_exchange_data.h" 10 #include "app/os_exchange_data.h"
11 #include "base/scoped_handle.h" 11 #include "base/scoped_handle.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "views/accessibility/view_accessibility_wrapper.h" 13 #include "views/accessibility/view_accessibility_wrapper.h"
14 #include "views/border.h" 14 #include "views/border.h"
15 #include "views/widget/root_view.h" 15 #include "views/widget/root_view.h"
16 #include "views/widget/widget.h" 16 #include "views/widget/widget.h"
17 17
18 namespace views { 18 namespace views {
19 19
20 FocusManager* View::GetFocusManager() {
21 Widget* widget = GetWidget();
22 if (!widget)
23 return NULL;
24
25 HWND hwnd = widget->GetNativeView();
26 if (!hwnd)
27 return NULL;
28
29 return FocusManager::GetFocusManager(hwnd);
30 }
31
32 void View::DoDrag(const MouseEvent& e, int press_x, int press_y) { 20 void View::DoDrag(const MouseEvent& e, int press_x, int press_y) {
33 int drag_operations = GetDragOperations(press_x, press_y); 21 int drag_operations = GetDragOperations(press_x, press_y);
34 if (drag_operations == DragDropTypes::DRAG_NONE) 22 if (drag_operations == DragDropTypes::DRAG_NONE)
35 return; 23 return;
36 24
37 scoped_refptr<OSExchangeData> data = new OSExchangeData; 25 scoped_refptr<OSExchangeData> data = new OSExchangeData;
38 WriteDragData(press_x, press_y, data.get()); 26 WriteDragData(press_x, press_y, data.get());
39 27
40 // Message the RootView to do the drag and drop. That way if we're removed 28 // Message the RootView to do the drag and drop. That way if we're removed
41 // the RootView can detect it and avoid calling us back. 29 // the RootView can detect it and avoid calling us back.
42 RootView* root_view = GetRootView(); 30 RootView* root_view = GetRootView();
43 root_view->StartDragForViewFromMouseEvent(this, data, drag_operations); 31 root_view->StartDragForViewFromMouseEvent(this, data, drag_operations);
44 } 32 }
45 33
46 ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() { 34 ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() {
47 if (accessibility_.get() == NULL) { 35 if (accessibility_.get() == NULL) {
48 accessibility_.reset(new ViewAccessibilityWrapper(this)); 36 accessibility_.reset(new ViewAccessibilityWrapper(this));
49 } 37 }
50 return accessibility_.get(); 38 return accessibility_.get();
51 } 39 }
52 40
53 void View::Focus() { 41 void View::Focus() {
54 // Set the native focus to the root view window so it receives the keyboard 42 // Set the native focus to the root view window so it receives the keyboard
55 // messages. 43 // messages.
56 FocusManager* focus_manager = GetFocusManager(); 44 FocusManager* focus_manager = GetFocusManager();
57 if (focus_manager) 45 if (focus_manager)
58 focus_manager->FocusHWND(GetRootView()->GetWidget()->GetNativeView()); 46 focus_manager->FocusNativeView(GetRootView()->GetWidget()->GetNativeView());
59 } 47 }
60 48
61 int View::GetHorizontalDragThreshold() { 49 int View::GetHorizontalDragThreshold() {
62 static int threshold = -1; 50 static int threshold = -1;
63 if (threshold == -1) 51 if (threshold == -1)
64 threshold = GetSystemMetrics(SM_CXDRAG) / 2; 52 threshold = GetSystemMetrics(SM_CXDRAG) / 2;
65 return threshold; 53 return threshold;
66 } 54 }
67 55
68 int View::GetVerticalDragThreshold() { 56 int View::GetVerticalDragThreshold() {
69 static int threshold = -1; 57 static int threshold = -1;
70 if (threshold == -1) 58 if (threshold == -1)
71 threshold = GetSystemMetrics(SM_CYDRAG) / 2; 59 threshold = GetSystemMetrics(SM_CYDRAG) / 2;
72 return threshold; 60 return threshold;
73 } 61 }
74 62
75 } // namespace views 63 } // namespace views
OLDNEW
« no previous file with comments | « views/view_unittest.cc ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698