Use enum for wxMouseEvent::m_wheelAxis instead of int.

This variable can take only 2 values, use symbolic names for them instead of
difficult to understand 0 and 1.

See ##14105.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2012-03-22 00:26:59 +00:00
parent 32632baf6d
commit 41469c9e5e
5 changed files with 32 additions and 12 deletions

View File

@ -1448,6 +1448,12 @@ private:
wxEVT_RIGHT_DCLICK
*/
enum wxMouseWheelAxis
{
wxMOUSE_WHEEL_VERTICAL,
wxMOUSE_WHEEL_HORIZONTAL
};
class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent,
public wxMouseState
{
@ -1535,10 +1541,10 @@ public:
// should occur for each delta.
int GetWheelDelta() const { return m_wheelDelta; }
// Gets the axis the wheel operation concerns, 0 being the y axis as on
// most mouse wheels, 1 is the x axis for things like MightyMouse scrolls
// or horizontal trackpad scrolling
int GetWheelAxis() const { return m_wheelAxis; }
// Gets the axis the wheel operation concerns; wxMOUSE_WHEEL_VERTICAL
// (most common case) or wxMOUSE_WHEEL_HORIZONTAL (for horizontal scrolling
// using e.g. a trackpad).
wxMouseWheelAxis GetWheelAxis() const { return m_wheelAxis; }
// Returns the configured number of lines (or whatever) to be scrolled per
// wheel action. Defaults to one.
@ -1560,7 +1566,7 @@ public:
public:
int m_clickCount;
int m_wheelAxis;
wxMouseWheelAxis m_wheelAxis;
int m_wheelRotation;
int m_wheelDelta;
int m_linesPerAction;

View File

@ -2187,6 +2187,16 @@ public:
wxClipboardTextEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
};
/**
Possible axis values for mouse wheel scroll events.
@since 2.9.4
*/
enum wxMouseWheelAxis
{
wxMOUSE_WHEEL_VERTICAL, ///< Vertical scroll event.
wxMOUSE_WHEEL_HORIZONTAL ///< Horizontal scroll event.
};
/**
@ -2440,12 +2450,16 @@ public:
int GetWheelRotation() const;
/**
Gets the axis the wheel operation concerns; @c 0 is the Y axis as on
most mouse wheels, @c 1 is the X axis.
Gets the axis the wheel operation concerns.
Note that only some models of mouse have horizontal wheel axis.
Usually the mouse wheel is used to scroll vertically so @c
wxMOUSE_WHEEL_VERTICAL is returned but some mice (and most trackpads)
also allow to use the wheel to scroll horizontally in which case
@c wxMOUSE_WHEEL_HORIZONTAL is returned.
Notice that before wxWidgets 2.9.4 this method returned @c int.
*/
int GetWheelAxis() const;
wxMouseWheelAxis GetWheelAxis() const;
/**
Returns @true if the event was a mouse button event (not necessarily a button

View File

@ -554,10 +554,10 @@ wxMouseEvent::wxMouseEvent(wxEventType commandType)
m_clickCount = -1;
m_wheelAxis = wxMOUSE_WHEEL_VERTICAL;
m_wheelRotation = 0;
m_wheelDelta = 0;
m_linesPerAction = 0;
m_wheelAxis = 0;
}
void wxMouseEvent::Assign(const wxMouseEvent& event)

View File

@ -547,7 +547,7 @@ WXDLLEXPORT void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEve
wxevent.m_wheelDelta = 1;
wxevent.m_linesPerAction = 1;
if ( axis == kEventMouseWheelAxisX )
wxevent.m_wheelAxis = 1;
wxevent.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL;
}
break ;

View File

@ -633,7 +633,7 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
if ( fabs(deltaX) > fabs(deltaY) )
{
wxevent.m_wheelAxis = 1;
wxevent.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL;
wxevent.m_wheelRotation = (int)deltaX;
}
else