uiaction.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifndef _WX_UIACTIONSIMULATOR_H_
  13. #define _WX_UIACTIONSIMULATOR_H_
  14. #include "wx/defs.h"
  15. #if wxUSE_UIACTIONSIMULATOR
  16. #include "wx/mousestate.h" // for wxMOUSE_BTN_XXX constants
  17. class WXDLLIMPEXP_CORE wxUIActionSimulator
  18. {
  19. public:
  20. wxUIActionSimulator() { }
  21. // Default dtor, copy ctor and assignment operator are ok (even though the
  22. // last two don't make much sense for this class).
  23. // Mouse simulation
  24. // ----------------
  25. // Low level methods
  26. bool MouseMove(long x, long y);
  27. bool MouseMove(const wxPoint& point) { return MouseMove(point.x, point.y); }
  28. bool MouseDown(int button = wxMOUSE_BTN_LEFT);
  29. bool MouseUp(int button = wxMOUSE_BTN_LEFT);
  30. // Higher level interface, use it if possible instead
  31. bool MouseClick(int button = wxMOUSE_BTN_LEFT);
  32. bool MouseDblClick(int button = wxMOUSE_BTN_LEFT);
  33. bool MouseDragDrop(long x1, long y1, long x2, long y2,
  34. int button = wxMOUSE_BTN_LEFT);
  35. bool MouseDragDrop(const wxPoint& p1, const wxPoint& p2,
  36. int button = wxMOUSE_BTN_LEFT)
  37. { return MouseDragDrop(p1.x, p1.y, p2.x, p2.y, button); }
  38. // Keyboard simulation
  39. // -------------------
  40. // Low level methods for generating key presses and releases
  41. bool KeyDown(int keycode, int modifiers = wxMOD_NONE)
  42. { return Key(keycode, modifiers, true); }
  43. bool KeyUp(int keycode, int modifiers = wxMOD_NONE)
  44. { return Key(keycode, modifiers, false); }
  45. // Higher level methods for generating both the key press and release for a
  46. // single key or for all characters in the ASCII string "text" which can currently
  47. // contain letters, digits and characters for the definition of numbers [+-., ].
  48. bool Char(int keycode, int modifiers = wxMOD_NONE);
  49. bool Text(const char *text);
  50. private:
  51. // This is the common part of Key{Down,Up}() methods: while we keep them
  52. // separate at public API level for consistency with Mouse{Down,Up}(), at
  53. // implementation level it makes more sense to have them in a single
  54. // function.
  55. //
  56. // It calls DoModifiers() to simulate pressing the modifier keys if
  57. // necessary and then DoKey() for the key itself.
  58. bool Key(int keycode, int modifiers, bool isDown);
  59. // Call DoKey() for all modifier keys whose bits are set in the parameter.
  60. void SimulateModifiers(int modifier, bool isDown);
  61. // The low-level port-specific function which really generates the key
  62. // presses. It should generate exactly one key event with the given
  63. // parameters.
  64. bool DoKey(int keycode, int modifiers, bool isDown);
  65. };
  66. #endif // wxUSE_UIACTIONSIMULATOR
  67. #endif // _WX_UIACTIONSIMULATOR_H_