make wxKeyEvent and wxMouseEvent derive from the same wxKeyboardState object (indirectly via wxMouseState in the case of the latter) to make Get/HasModifiers() available in wxMouseEvent as well while avoiding code duplication
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55745 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
70
include/wx/mousestate.h
Normal file
70
include/wx/mousestate.h
Normal file
@@ -0,0 +1,70 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/mousestate.h
|
||||
// Purpose: Declaration of wxMouseState class
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-09-19 (extracted from wx/utils.h)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MOUSESTATE_H_
|
||||
#define _WX_MOUSESTATE_H_
|
||||
|
||||
#include "wx/kbdstate.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMouseState contains the information about mouse position, buttons and also
|
||||
// key modifiers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// wxMouseState is used to hold information about button and modifier state
|
||||
// and is what is returned from wxGetMouseState.
|
||||
class WXDLLIMPEXP_CORE wxMouseState : public wxKeyboardState
|
||||
{
|
||||
public:
|
||||
wxMouseState()
|
||||
: m_x(0), m_y(0),
|
||||
m_leftDown(false), m_middleDown(false), m_rightDown(false),
|
||||
m_aux1Down(false), m_aux2Down(false)
|
||||
{
|
||||
}
|
||||
|
||||
// default copy ctor, assignment operator and dtor are ok
|
||||
|
||||
|
||||
// accessors for the mouse position
|
||||
wxCoord GetX() const { return m_x; }
|
||||
wxCoord GetY() const { return m_y; }
|
||||
wxPoint GetPosition() const { return wxPoint(m_x, m_y); }
|
||||
|
||||
// accessors for the pressed buttons
|
||||
bool LeftDown() const { return m_leftDown; }
|
||||
bool MiddleDown() const { return m_middleDown; }
|
||||
bool RightDown() const { return m_rightDown; }
|
||||
bool Aux1Down() const { return m_aux1Down; }
|
||||
bool Aux2Down() const { return m_aux2Down; }
|
||||
|
||||
// these functions are mostly used by wxWidgets itself
|
||||
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 SetAux1Down(bool down) { m_aux1Down = down; }
|
||||
void SetAux2Down(bool down) { m_aux2Down = down; }
|
||||
|
||||
private:
|
||||
bool m_leftDown : 1;
|
||||
bool m_middleDown : 1;
|
||||
bool m_rightDown : 1;
|
||||
bool m_aux1Down : 1;
|
||||
bool m_aux2Down : 1;
|
||||
|
||||
wxCoord m_x,
|
||||
m_y;
|
||||
};
|
||||
|
||||
#endif // _WX_MOUSESTATE_H_
|
||||
|
Reference in New Issue
Block a user