2010-03-06 15:09:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2010-07-13 09:29:58 -04:00
|
|
|
// Name: wx/uiaction.h
|
2010-03-06 15:09:23 -05:00
|
|
|
// Purpose: wxUIActionSimulator interface
|
2010-08-22 18:15:42 -04:00
|
|
|
// Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin
|
2010-03-06 15:09:23 -05:00
|
|
|
// Created: 2010-03-06
|
2016-05-21 12:34:45 -04:00
|
|
|
// Copyright: (c) 2010 Kevin Ollivier
|
2010-08-22 18:15:42 -04:00
|
|
|
// (c) 2010 Steven Lamerton
|
2016-05-21 12:34:45 -04:00
|
|
|
// (c) 2010-2016 Vadim Zeitlin
|
2010-03-06 15:09:23 -05:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-03-22 07:40:35 -04:00
|
|
|
#ifndef _WX_UIACTIONSIMULATOR_H_
|
|
|
|
#define _WX_UIACTIONSIMULATOR_H_
|
2010-03-06 15:09:23 -05:00
|
|
|
|
2010-03-22 07:40:35 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_UIACTIONSIMULATOR
|
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
#include "wx/mousestate.h" // for wxMOUSE_BTN_XXX constants
|
2010-03-06 15:09:23 -05:00
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxUIActionSimulator
|
|
|
|
{
|
|
|
|
public:
|
2016-05-21 12:34:45 -04:00
|
|
|
wxUIActionSimulator();
|
|
|
|
~wxUIActionSimulator();
|
2010-03-06 15:09:23 -05:00
|
|
|
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
// Mouse simulation
|
|
|
|
// ----------------
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
// Low level methods
|
|
|
|
bool MouseMove(long x, long y);
|
|
|
|
bool MouseMove(const wxPoint& point) { return MouseMove(point.x, point.y); }
|
2010-03-06 15:09:23 -05:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
bool MouseDown(int button = wxMOUSE_BTN_LEFT);
|
|
|
|
bool MouseUp(int button = wxMOUSE_BTN_LEFT);
|
|
|
|
|
|
|
|
// Higher level interface, use it if possible instead
|
|
|
|
bool MouseClick(int button = wxMOUSE_BTN_LEFT);
|
|
|
|
bool MouseDblClick(int button = wxMOUSE_BTN_LEFT);
|
|
|
|
bool MouseDragDrop(long x1, long y1, long x2, long y2,
|
|
|
|
int button = wxMOUSE_BTN_LEFT);
|
2013-06-11 19:14:20 -04:00
|
|
|
bool MouseDragDrop(const wxPoint& p1, const wxPoint& p2,
|
|
|
|
int button = wxMOUSE_BTN_LEFT)
|
|
|
|
{ return MouseDragDrop(p1.x, p1.y, p2.x, p2.y, button); }
|
2010-08-22 18:15:42 -04:00
|
|
|
|
|
|
|
// Keyboard simulation
|
|
|
|
// -------------------
|
|
|
|
|
|
|
|
// Low level methods for generating key presses and releases
|
|
|
|
bool KeyDown(int keycode, int modifiers = wxMOD_NONE)
|
|
|
|
{ return Key(keycode, modifiers, true); }
|
|
|
|
|
|
|
|
bool KeyUp(int keycode, int modifiers = wxMOD_NONE)
|
|
|
|
{ return Key(keycode, modifiers, false); }
|
|
|
|
|
|
|
|
// Higher level methods for generating both the key press and release for a
|
2011-11-15 10:56:55 -05:00
|
|
|
// single key or for all characters in the ASCII string "text" which can currently
|
|
|
|
// contain letters, digits and characters for the definition of numbers [+-., ].
|
2010-08-22 18:15:42 -04:00
|
|
|
bool Char(int keycode, int modifiers = wxMOD_NONE);
|
|
|
|
|
|
|
|
bool Text(const char *text);
|
|
|
|
|
2014-09-10 12:52:01 -04:00
|
|
|
// Select the item with the given text in the currently focused control.
|
|
|
|
bool Select(const wxString& text);
|
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
private:
|
|
|
|
// This is the common part of Key{Down,Up}() methods: while we keep them
|
|
|
|
// separate at public API level for consistency with Mouse{Down,Up}(), at
|
|
|
|
// implementation level it makes more sense to have them in a single
|
|
|
|
// function.
|
|
|
|
//
|
2010-09-11 06:18:15 -04:00
|
|
|
// It calls DoModifiers() to simulate pressing the modifier keys if
|
|
|
|
// necessary and then DoKey() for the key itself.
|
2010-08-22 18:15:42 -04:00
|
|
|
bool Key(int keycode, int modifiers, bool isDown);
|
|
|
|
|
2010-09-11 06:18:15 -04:00
|
|
|
// Call DoKey() for all modifier keys whose bits are set in the parameter.
|
|
|
|
void SimulateModifiers(int modifier, bool isDown);
|
|
|
|
|
|
|
|
|
2016-05-21 12:34:45 -04:00
|
|
|
|
|
|
|
// This pointer is allocated in the ctor and points to the
|
|
|
|
// platform-specific implementation.
|
|
|
|
class wxUIActionSimulatorImpl* const m_impl;
|
|
|
|
|
|
|
|
wxDECLARE_NO_COPY_CLASS(wxUIActionSimulator);
|
2010-03-06 15:09:23 -05:00
|
|
|
};
|
|
|
|
|
2010-03-22 07:40:35 -04:00
|
|
|
#endif // wxUSE_UIACTIONSIMULATOR
|
|
|
|
|
|
|
|
#endif // _WX_UIACTIONSIMULATOR_H_
|