]> git.saurik.com Git - wxWidgets.git/blob - include/wx/uiaction.h
Better name for wxXmlResource::GetDirection() argument.
[wxWidgets.git] / include / wx / uiaction.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/uiaction.h
3 // Purpose: wxUIActionSimulator interface
4 // Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin
5 // Modified by:
6 // Created: 2010-03-06
7 // Copyright: (c) Kevin Ollivier
8 // (c) 2010 Steven Lamerton
9 // (c) 2010 Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_UIACTIONSIMULATOR_H_
14 #define _WX_UIACTIONSIMULATOR_H_
15
16 #include "wx/defs.h"
17
18 #if wxUSE_UIACTIONSIMULATOR
19
20 #include "wx/mousestate.h" // for wxMOUSE_BTN_XXX constants
21
22 class WXDLLIMPEXP_CORE wxUIActionSimulator
23 {
24 public:
25 wxUIActionSimulator() { }
26
27
28 // Default dtor, copy ctor and assignment operator are ok (even though the
29 // last two don't make much sense for this class).
30
31
32 // Mouse simulation
33 // ----------------
34
35 // Low level methods
36 bool MouseMove(long x, long y);
37 bool MouseMove(const wxPoint& point) { return MouseMove(point.x, point.y); }
38
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);
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); }
50
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
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 [+-., ].
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 //
74 // It calls DoModifiers() to simulate pressing the modifier keys if
75 // necessary and then DoKey() for the key itself.
76 bool Key(int keycode, int modifiers, bool isDown);
77
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.
85 bool DoKey(int keycode, int modifiers, bool isDown);
86 };
87
88 #endif // wxUSE_UIACTIONSIMULATOR
89
90 #endif // _WX_UIACTIONSIMULATOR_H_