Added wxGetMouseState which returns the current state of the mouse.

Returns an instance of a wxMouseState object that contains the current
position of the mouse pointer in screen coordinants, as well as
boolean values indicating the up/down status of the mouse buttons and
the modifier keys.  Implemented for wxMSW, wxGTK and wxMac.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-01-05 04:31:27 +00:00
parent 18a1de69aa
commit 7dd40b6f4b
7 changed files with 210 additions and 0 deletions

View File

@@ -114,6 +114,70 @@ WXDLLEXPORT bool wxGetKeyState(wxKeyCode key);
// in wxMSW.
WXDLLEXPORT bool wxSetDetectableAutoRepeat( bool flag );
// wxMouseState is used to hold information about button and modifier state
// and is what is returned from wxGetMouseState.
class WXDLLEXPORT wxMouseState
{
public:
wxMouseState()
: m_x(0), m_y(0),
m_leftDown(false), m_middleDown(false), m_rightDown(false),
m_controlDown(false), m_shiftDown(false), m_altDown(false),
m_metaDown(false)
{}
wxCoord GetX() { return m_x; }
wxCoord GetY() { return m_y; }
bool LeftDown() { return m_leftDown; }
bool MiddleDown() { return m_middleDown; }
bool RightDown() { return m_rightDown; }
bool ControlDown() { return m_controlDown; }
bool ShiftDown() { return m_shiftDown; }
bool AltDown() { return m_altDown; }
bool MetaDown() { return m_metaDown; }
bool CmdDown()
{
#if defined(__WXMAC__) || defined(__WXCOCOA__)
return MetaDown();
#else
return ControlDown();
#endif
}
void SetX(wxCoord x) { m_x = x; }
void SetY(wxCoord y) { m_y = y; }
void SetLeftDown(bool down) { m_leftDown = down; }
void SetMiddleDown(bool down) { m_middleDown = down; }
void SetRightDown(bool down) { m_rightDown = down; }
void SetControlDown(bool down) { m_controlDown = down; }
void SetShiftDown(bool down) { m_shiftDown = down; }
void SetAltDown(bool down) { m_altDown = down; }
void SetMetaDown(bool down) { m_metaDown = down; }
private:
wxCoord m_x;
wxCoord m_y;
bool m_leftDown;
bool m_middleDown;
bool m_rightDown;
bool m_controlDown;
bool m_shiftDown;
bool m_altDown;
bool m_metaDown;
};
// Returns the current state of the mouse position, buttons and modifers
WXDLLEXPORT wxMouseState wxGetMouseState();
// ----------------------------------------------------------------------------
// Window ID management
// ----------------------------------------------------------------------------