OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "gfx/canvas.h" | 9 #include "gfx/canvas.h" |
10 #include "gfx/path.h" | 10 #include "gfx/path.h" |
11 #include "views/accessibility/view_accessibility.h" | 11 #include "views/accessibility/view_accessibility.h" |
12 #include "views/accessibility/view_accessibility_wrapper.h" | 12 #include "views/accessibility/view_accessibility_wrapper.h" |
13 #include "views/border.h" | 13 #include "views/border.h" |
14 #include "views/views_delegate.h" | |
15 #include "views/widget/root_view.h" | 14 #include "views/widget/root_view.h" |
16 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
17 #include "views/widget/widget_win.h" | 16 #include "views/widget/widget_win.h" |
18 | 17 |
19 namespace views { | 18 namespace views { |
20 | 19 |
21 // static | 20 // static |
22 int View::GetDoubleClickTimeMS() { | 21 int View::GetDoubleClickTimeMS() { |
23 return ::GetDoubleClickTime(); | 22 return ::GetDoubleClickTime(); |
24 } | 23 } |
25 | 24 |
26 // static | 25 // static |
27 int View::GetMenuShowDelay() { | 26 int View::GetMenuShowDelay() { |
28 static DWORD delay = 0; | 27 static DWORD delay = 0; |
29 if (!delay && !SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &delay, 0)) | 28 if (!delay && !SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &delay, 0)) |
30 delay = View::kShowFolderDropMenuDelay; | 29 delay = View::kShowFolderDropMenuDelay; |
31 return delay; | 30 return delay; |
32 } | 31 } |
33 | 32 |
| 33 // Notifies accessibility clients of the event_type on this view. |
| 34 // Clients will call get_accChild found in ViewAccessibility with the supplied |
| 35 // child id we generate here to retrieve the IAccessible associated with this |
| 36 // view. |
34 void View::NotifyAccessibilityEvent(AccessibilityTypes::Event event_type) { | 37 void View::NotifyAccessibilityEvent(AccessibilityTypes::Event event_type) { |
35 NotifyAccessibilityEvent(event_type, true); | 38 WidgetWin* view_widget = static_cast<WidgetWin*>(GetWidget()); |
36 } | 39 int child_id = view_widget->AddAccessibilityViewEvent(this); |
37 | 40 ::NotifyWinEvent(ViewAccessibility::MSAAEvent(event_type), |
38 void View::NotifyAccessibilityEvent(AccessibilityTypes::Event event_type, | 41 view_widget->GetNativeView(), OBJID_CLIENT, child_id); |
39 bool send_native_event) { | |
40 // Send the notification to the delegate. | |
41 if (ViewsDelegate::views_delegate) | |
42 ViewsDelegate::views_delegate->NotifyAccessibilityEvent(this, event_type); | |
43 | |
44 // Now call the Windows-specific method to notify MSAA clients of this | |
45 // event. The widget gives us a temporary unique child ID to associate | |
46 // with this view so that clients can call get_accChild in ViewAccessibility | |
47 // to retrieve the IAccessible associated with this view. | |
48 if (send_native_event) { | |
49 WidgetWin* view_widget = static_cast<WidgetWin*>(GetWidget()); | |
50 int child_id = view_widget->AddAccessibilityViewEvent(this); | |
51 ::NotifyWinEvent(ViewAccessibility::MSAAEvent(event_type), | |
52 view_widget->GetNativeView(), OBJID_CLIENT, child_id); | |
53 } | |
54 } | 42 } |
55 | 43 |
56 ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() { | 44 ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() { |
57 if (accessibility_.get() == NULL) { | 45 if (accessibility_.get() == NULL) { |
58 accessibility_.reset(new ViewAccessibilityWrapper(this)); | 46 accessibility_.reset(new ViewAccessibilityWrapper(this)); |
59 } | 47 } |
60 return accessibility_.get(); | 48 return accessibility_.get(); |
61 } | 49 } |
62 | 50 |
63 int View::GetHorizontalDragThreshold() { | 51 int View::GetHorizontalDragThreshold() { |
64 static int threshold = -1; | 52 static int threshold = -1; |
65 if (threshold == -1) | 53 if (threshold == -1) |
66 threshold = GetSystemMetrics(SM_CXDRAG) / 2; | 54 threshold = GetSystemMetrics(SM_CXDRAG) / 2; |
67 return threshold; | 55 return threshold; |
68 } | 56 } |
69 | 57 |
70 int View::GetVerticalDragThreshold() { | 58 int View::GetVerticalDragThreshold() { |
71 static int threshold = -1; | 59 static int threshold = -1; |
72 if (threshold == -1) | 60 if (threshold == -1) |
73 threshold = GetSystemMetrics(SM_CYDRAG) / 2; | 61 threshold = GetSystemMetrics(SM_CYDRAG) / 2; |
74 return threshold; | 62 return threshold; |
75 } | 63 } |
76 | 64 |
77 } // namespace views | 65 } // namespace views |
OLD | NEW |