]>
Commit | Line | Data |
---|---|---|
a02a5cfc | 1 | ///////////////////////////////////////////////////////////////////////////// |
233f5738 | 2 | // Name: wx/uiaction.h |
a02a5cfc | 3 | // Purpose: wxUIActionSimulator interface |
571d991b | 4 | // Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin |
a02a5cfc KO |
5 | // Modified by: |
6 | // Created: 2010-03-06 | |
a02a5cfc | 7 | // Copyright: (c) Kevin Ollivier |
571d991b VZ |
8 | // (c) 2010 Steven Lamerton |
9 | // (c) 2010 Vadim Zeitlin | |
a02a5cfc KO |
10 | // Licence: wxWindows licence |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
9b7e0226 VZ |
13 | #ifndef _WX_UIACTIONSIMULATOR_H_ |
14 | #define _WX_UIACTIONSIMULATOR_H_ | |
a02a5cfc | 15 | |
9b7e0226 VZ |
16 | #include "wx/defs.h" |
17 | ||
18 | #if wxUSE_UIACTIONSIMULATOR | |
19 | ||
571d991b | 20 | #include "wx/mousestate.h" // for wxMOUSE_BTN_XXX constants |
a02a5cfc KO |
21 | |
22 | class WXDLLIMPEXP_CORE wxUIActionSimulator | |
23 | { | |
24 | public: | |
571d991b | 25 | wxUIActionSimulator() { } |
9b7e0226 | 26 | |
9b7e0226 | 27 | |
571d991b VZ |
28 | // Default dtor, copy ctor and assignment operator are ok (even though the |
29 | // last two don't make much sense for this class). | |
a02a5cfc | 30 | |
9b7e0226 | 31 | |
571d991b VZ |
32 | // Mouse simulation |
33 | // ---------------- | |
9b7e0226 | 34 | |
571d991b VZ |
35 | // Low level methods |
36 | bool MouseMove(long x, long y); | |
37 | bool MouseMove(const wxPoint& point) { return MouseMove(point.x, point.y); } | |
a02a5cfc | 38 | |
571d991b VZ |
39 | bool MouseDown(int button = wxMOUSE_BTN_LEFT); |
40 | bool MouseUp(int button = wxMOUSE_BTN_LEFT); | |
41 | ||
42 | // Higher level interface, use it if possible instead | |
43 | bool MouseClick(int button = wxMOUSE_BTN_LEFT); | |
44 | bool MouseDblClick(int button = wxMOUSE_BTN_LEFT); | |
45 | bool MouseDragDrop(long x1, long y1, long x2, long y2, | |
46 | int button = wxMOUSE_BTN_LEFT); | |
12bb29f5 SC |
47 | bool MouseDragDrop(const wxPoint& p1, const wxPoint& p2, |
48 | int button = wxMOUSE_BTN_LEFT) | |
49 | { return MouseDragDrop(p1.x, p1.y, p2.x, p2.y, button); } | |
571d991b | 50 | |
571d991b VZ |
51 | // Keyboard simulation |
52 | // ------------------- | |
53 | ||
54 | // Low level methods for generating key presses and releases | |
55 | bool KeyDown(int keycode, int modifiers = wxMOD_NONE) | |
56 | { return Key(keycode, modifiers, true); } | |
57 | ||
58 | bool KeyUp(int keycode, int modifiers = wxMOD_NONE) | |
59 | { return Key(keycode, modifiers, false); } | |
60 | ||
61 | // Higher level methods for generating both the key press and release for a | |
c0c9009c VZ |
62 | // single key or for all characters in the ASCII string "text" which can currently |
63 | // contain letters, digits and characters for the definition of numbers [+-., ]. | |
571d991b VZ |
64 | bool Char(int keycode, int modifiers = wxMOD_NONE); |
65 | ||
66 | bool Text(const char *text); | |
67 | ||
68 | private: | |
69 | // This is the common part of Key{Down,Up}() methods: while we keep them | |
70 | // separate at public API level for consistency with Mouse{Down,Up}(), at | |
71 | // implementation level it makes more sense to have them in a single | |
72 | // function. | |
73 | // | |
37141214 VZ |
74 | // It calls DoModifiers() to simulate pressing the modifier keys if |
75 | // necessary and then DoKey() for the key itself. | |
571d991b VZ |
76 | bool Key(int keycode, int modifiers, bool isDown); |
77 | ||
37141214 VZ |
78 | // Call DoKey() for all modifier keys whose bits are set in the parameter. |
79 | void SimulateModifiers(int modifier, bool isDown); | |
80 | ||
81 | ||
82 | // The low-level port-specific function which really generates the key | |
83 | // presses. It should generate exactly one key event with the given | |
84 | // parameters. | |
571d991b | 85 | bool DoKey(int keycode, int modifiers, bool isDown); |
a02a5cfc KO |
86 | }; |
87 | ||
9b7e0226 VZ |
88 | #endif // wxUSE_UIACTIONSIMULATOR |
89 | ||
90 | #endif // _WX_UIACTIONSIMULATOR_H_ |