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 #ifndef UI_UI_CONTROLS_UI_CONTROLS_H_ | 5 #ifndef UI_UI_CONTROLS_UI_CONTROLS_H_ |
6 #define UI_UI_CONTROLS_UI_CONTROLS_H_ | 6 #define UI_UI_CONTROLS_UI_CONTROLS_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
12 #include "ui/base/ui_export.h" | |
13 | 12 |
14 namespace ui_controls { | 13 namespace ui_controls { |
15 | 14 |
16 // Many of the functions in this class include a variant that takes a Closure. | 15 // Many of the functions in this class include a variant that takes a Closure. |
17 // The version that takes a Closure waits until the generated event is | 16 // The version that takes a Closure waits until the generated event is |
18 // processed. Once the generated event is processed the Closure is Run (and | 17 // processed. Once the generated event is processed the Closure is Run (and |
19 // deleted). Note that this is a somewhat fragile process in that any event of | 18 // deleted). Note that this is a somewhat fragile process in that any event of |
20 // the correct type (key down, mouse click, etc.) will trigger the Closure to be | 19 // the correct type (key down, mouse click, etc.) will trigger the Closure to be |
21 // run. Hence a usage such as | 20 // run. Hence a usage such as |
22 // | 21 // |
23 // SendKeyPress(...); | 22 // SendKeyPress(...); |
24 // SendKeyPressNotifyWhenDone(..., task); | 23 // SendKeyPressNotifyWhenDone(..., task); |
25 // | 24 // |
26 // might trigger |task| early. | 25 // might trigger |task| early. |
27 // | 26 // |
28 // Note: Windows does not currently do anything with the |window| argument for | 27 // Note: Windows does not currently do anything with the |window| argument for |
29 // these functions, so passing NULL is ok. | 28 // these functions, so passing NULL is ok. |
30 | 29 |
31 // Send a key press with/without modifier keys. | 30 // Send a key press with/without modifier keys. |
32 // | 31 // |
33 // If you're writing a test chances are you want the variant in ui_test_utils. | 32 // If you're writing a test chances are you want the variant in ui_test_utils. |
34 // See it for details. | 33 // See it for details. |
35 UI_EXPORT bool SendKeyPress(gfx::NativeWindow window, | 34 bool SendKeyPress(gfx::NativeWindow window, |
36 ui::KeyboardCode key, | 35 ui::KeyboardCode key, |
37 bool control, | 36 bool control, |
38 bool shift, | 37 bool shift, |
39 bool alt, | 38 bool alt, |
40 bool command); | 39 bool command); |
41 UI_EXPORT bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, | 40 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, |
42 ui::KeyboardCode key, | 41 ui::KeyboardCode key, |
43 bool control, | 42 bool control, |
44 bool shift, | 43 bool shift, |
45 bool alt, | 44 bool alt, |
46 bool command, | 45 bool command, |
47 const base::Closure& task); | 46 const base::Closure& task); |
48 | 47 |
49 // Simulate a mouse move. (x,y) are absolute screen coordinates. | 48 // Simulate a mouse move. (x,y) are absolute screen coordinates. |
50 UI_EXPORT bool SendMouseMove(long x, long y); | 49 bool SendMouseMove(long x, long y); |
51 UI_EXPORT bool SendMouseMoveNotifyWhenDone(long x, | 50 bool SendMouseMoveNotifyWhenDone(long x, |
52 long y, | 51 long y, |
53 const base::Closure& task); | 52 const base::Closure& task); |
54 | 53 |
55 enum MouseButton { | 54 enum MouseButton { |
56 LEFT = 0, | 55 LEFT = 0, |
57 MIDDLE, | 56 MIDDLE, |
58 RIGHT, | 57 RIGHT, |
59 }; | 58 }; |
60 | 59 |
61 // Used to indicate the state of the button when generating events. | 60 // Used to indicate the state of the button when generating events. |
62 enum MouseButtonState { | 61 enum MouseButtonState { |
63 UP = 1, | 62 UP = 1, |
64 DOWN = 2 | 63 DOWN = 2 |
65 }; | 64 }; |
66 | 65 |
67 // Sends a mouse down and/or up message. The click will be sent to wherever | 66 // Sends a mouse down and/or up message. The click will be sent to wherever |
68 // the cursor currently is, so be sure to move the cursor before calling this | 67 // the cursor currently is, so be sure to move the cursor before calling this |
69 // (and be sure the cursor has arrived!). | 68 // (and be sure the cursor has arrived!). |
70 UI_EXPORT bool SendMouseEvents(MouseButton type, int state); | 69 bool SendMouseEvents(MouseButton type, int state); |
71 UI_EXPORT bool SendMouseEventsNotifyWhenDone(MouseButton type, | 70 bool SendMouseEventsNotifyWhenDone(MouseButton type, |
72 int state, | 71 int state, |
73 const base::Closure& task); | 72 const base::Closure& task); |
74 | 73 |
75 // Same as SendMouseEvents with UP | DOWN. | 74 // Same as SendMouseEvents with UP | DOWN. |
76 UI_EXPORT bool SendMouseClick(MouseButton type); | 75 bool SendMouseClick(MouseButton type); |
77 | 76 |
78 #if defined(TOOLKIT_VIEWS) | 77 #if defined(TOOLKIT_VIEWS) |
79 // Runs |closure| after processing all pending ui events. | 78 // Runs |closure| after processing all pending ui events. |
80 UI_EXPORT void RunClosureAfterAllPendingUIEvents(const base::Closure& closure); | 79 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure); |
81 #endif | 80 #endif |
82 | 81 |
83 #if defined(USE_AURA) | 82 #if defined(USE_AURA) |
84 class UIControlsAura; | 83 class UIControlsAura; |
85 UI_EXPORT void InstallUIControlsAura(UIControlsAura* instance); | 84 void InstallUIControlsAura(UIControlsAura* instance); |
| 85 #endif |
| 86 |
| 87 #if defined(USE_ASH) |
| 88 ui_controls::UIControlsAura* CreateAshUIControls(); |
86 #endif | 89 #endif |
87 | 90 |
88 } // namespace ui_controls | 91 } // namespace ui_controls |
89 | 92 |
90 #endif // UI_UI_CONTROLS_UI_CONTROLS_H_ | 93 #endif // UI_UI_CONTROLS_UI_CONTROLS_H_ |
OLD | NEW |