1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxUIActionSimulator interface
4 // Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin
7 // Copyright: (c) Kevin Ollivier
8 // (c) 2010 Steven Lamerton
9 // (c) 2010 Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_UIACTIONSIMULATOR_H_
14 #define _WX_UIACTIONSIMULATOR_H_
18 #if wxUSE_UIACTIONSIMULATOR
20 #include "wx/mousestate.h" // for wxMOUSE_BTN_XXX constants
22 class WXDLLIMPEXP_CORE wxUIActionSimulator
25 wxUIActionSimulator() { }
28 // Default dtor, copy ctor and assignment operator are ok (even though the
29 // last two don't make much sense for this class).
36 bool MouseMove(long x
, long y
);
37 bool MouseMove(const wxPoint
& point
) { return MouseMove(point
.x
, point
.y
); }
39 bool MouseDown(int button
= wxMOUSE_BTN_LEFT
);
40 bool MouseUp(int button
= wxMOUSE_BTN_LEFT
);
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
); }
51 // Keyboard simulation
52 // -------------------
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); }
58 bool KeyUp(int keycode
, int modifiers
= wxMOD_NONE
)
59 { return Key(keycode
, modifiers
, false); }
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
);
66 bool Text(const char *text
);
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
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
);
78 // Call DoKey() for all modifier keys whose bits are set in the parameter.
79 void SimulateModifiers(int modifier
, bool isDown
);
82 // The low-level port-specific function which really generates the key
83 // presses. It should generate exactly one key event with the given
85 bool DoKey(int keycode
, int modifiers
, bool isDown
);
88 #endif // wxUSE_UIACTIONSIMULATOR
90 #endif // _WX_UIACTIONSIMULATOR_H_