Add wxEVT_MAGNIFY mouse event.

Currently this is implemented for wxOSX only.

Closes #14322.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78274 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-12-16 13:59:26 +00:00
parent 2de13dd12e
commit ea47af08cb
5 changed files with 52 additions and 1 deletions

View File

@@ -62,6 +62,7 @@ All (GUI):
- Allow requesting modern (3.x+) OpenGL version in wxGLCanvas (Fabio Arnold). - Allow requesting modern (3.x+) OpenGL version in wxGLCanvas (Fabio Arnold).
- Allow customizing window shown by wxBusyInfo. - Allow customizing window shown by wxBusyInfo.
- Add wxEVT_MAGNIFY mouse event (Joost Nieuwenhuijse).
- Make results of wxDC::DrawEllipticArc() consistent across all platforms. - Make results of wxDC::DrawEllipticArc() consistent across all platforms.
- XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart). - XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart).
- Add wxCursor::GetHotSpot(). - Add wxCursor::GetHotSpot().

View File

@@ -681,6 +681,7 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DCLICK, wxMouseEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent); wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent); wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent); wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAGNIFY, wxMouseEvent);
// Character input event type // Character input event type
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent); wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent);
@@ -1733,6 +1734,8 @@ public:
bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_DCLICK); } bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_DCLICK); }
bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); } bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); }
bool Magnify() const { return (m_eventType == wxEVT_MAGNIFY); }
// True if a button is down and the mouse is moving // True if a button is down and the mouse is moving
bool Dragging() const bool Dragging() const
{ {
@@ -1787,6 +1790,7 @@ public:
// Is the system set to do page scrolling? // Is the system set to do page scrolling?
bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); } bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
float GetMagnification() const { return m_magnification; }
virtual wxEvent *Clone() const wxOVERRIDE { return new wxMouseEvent(*this); } virtual wxEvent *Clone() const wxOVERRIDE { return new wxMouseEvent(*this); }
virtual wxEventCategory GetEventCategory() const wxOVERRIDE { return wxEVT_CATEGORY_USER_INPUT; } virtual wxEventCategory GetEventCategory() const wxOVERRIDE { return wxEVT_CATEGORY_USER_INPUT; }
@@ -1805,6 +1809,7 @@ public:
int m_wheelDelta; int m_wheelDelta;
int m_linesPerAction; int m_linesPerAction;
int m_columnsPerAction; int m_columnsPerAction;
float m_magnification;
protected: protected:
void Assign(const wxMouseEvent& evt); void Assign(const wxMouseEvent& evt);
@@ -4198,6 +4203,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&
#define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func)) #define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func))
#define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func)) #define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func))
#define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func)) #define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func))
#define EVT_MAGNIFY(func) wx__DECLARE_EVT0(wxEVT_MAGNIFY, wxMouseEventHandler(func))
// All mouse events // All mouse events
#define EVT_MOUSE_EVENTS(func) \ #define EVT_MOUSE_EVENTS(func) \
@@ -4219,7 +4225,8 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&
EVT_MOTION(func) \ EVT_MOTION(func) \
EVT_LEAVE_WINDOW(func) \ EVT_LEAVE_WINDOW(func) \
EVT_ENTER_WINDOW(func) \ EVT_ENTER_WINDOW(func) \
EVT_MOUSEWHEEL(func) EVT_MOUSEWHEEL(func) \
EVT_MAGNIFY(func)
// Scrolling from wxWindow (sent to wxScrolledWindow) // Scrolling from wxWindow (sent to wxScrolledWindow)
#define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func)) #define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func))

View File

@@ -2634,6 +2634,8 @@ enum wxMouseWheelAxis
Process a @c wxEVT_MOUSEWHEEL event. Process a @c wxEVT_MOUSEWHEEL event.
@event{EVT_MOUSE_EVENTS(func)} @event{EVT_MOUSE_EVENTS(func)}
Process all mouse events. Process all mouse events.
@event{EVT_MAGNIFY(func)}
Process a @c wxEVT_MAGNIFY event (new since wxWidgets 3.1.0).
@endEventTable @endEventTable
@library{wxcore} @library{wxcore}
@@ -2667,6 +2669,7 @@ public:
@li @c wxEVT_AUX2_DCLICK @li @c wxEVT_AUX2_DCLICK
@li @c wxEVT_MOTION @li @c wxEVT_MOTION
@li @c wxEVT_MOUSEWHEEL @li @c wxEVT_MOUSEWHEEL
@li @c wxEVT_MAGNIFY
*/ */
wxMouseEvent(wxEventType mouseEventType = wxEVT_NULL); wxMouseEvent(wxEventType mouseEventType = wxEVT_NULL);
@@ -2792,6 +2795,21 @@ public:
*/ */
wxPoint GetLogicalPosition(const wxDC& dc) const; wxPoint GetLogicalPosition(const wxDC& dc) const;
/**
For magnify (pinch to zoom) events: returns the change in magnification.
A value of 0 means no change, a positive value means we should enlarge
(or zoom in), a negative value means we should shrink (or zoom out).
This method is only valid to call for @c wxEVT_MAGNIFY events which are
currently only generated under OS X.
@see Magnify()
@since 3.1.0
*/
float GetMagnification() const;
/** /**
Get wheel delta, normally 120. Get wheel delta, normally 120.
@@ -2858,6 +2876,17 @@ public:
*/ */
bool LeftUp() const; bool LeftUp() const;
/**
Returns @true if the event is a magnify (i.e.\ pinch to zoom) event.
Such events are currently generated only under OS X.
@see GetMagnification()
@since 3.1.0
*/
bool Magnify() const;
/** /**
Returns @true if the Meta key was down at the time of the event. Returns @true if the Meta key was down at the time of the event.
*/ */

View File

@@ -208,6 +208,7 @@ wxDEFINE_EVENT( wxEVT_AUX1_DCLICK, wxMouseEvent );
wxDEFINE_EVENT( wxEVT_AUX2_DOWN, wxMouseEvent ); wxDEFINE_EVENT( wxEVT_AUX2_DOWN, wxMouseEvent );
wxDEFINE_EVENT( wxEVT_AUX2_UP, wxMouseEvent ); wxDEFINE_EVENT( wxEVT_AUX2_UP, wxMouseEvent );
wxDEFINE_EVENT( wxEVT_AUX2_DCLICK, wxMouseEvent ); wxDEFINE_EVENT( wxEVT_AUX2_DCLICK, wxMouseEvent );
wxDEFINE_EVENT( wxEVT_MAGNIFY, wxMouseEvent );
// Character input event type // Character input event type
wxDEFINE_EVENT( wxEVT_CHAR, wxKeyEvent ); wxDEFINE_EVENT( wxEVT_CHAR, wxKeyEvent );
@@ -565,6 +566,7 @@ wxMouseEvent::wxMouseEvent(wxEventType commandType)
m_wheelDelta = 0; m_wheelDelta = 0;
m_linesPerAction = 0; m_linesPerAction = 0;
m_columnsPerAction = 0; m_columnsPerAction = 0;
m_magnification = 0.0f;
} }
void wxMouseEvent::Assign(const wxMouseEvent& event) void wxMouseEvent::Assign(const wxMouseEvent& event)
@@ -589,6 +591,8 @@ void wxMouseEvent::Assign(const wxMouseEvent& event)
m_linesPerAction = event.m_linesPerAction; m_linesPerAction = event.m_linesPerAction;
m_columnsPerAction = event.m_columnsPerAction; m_columnsPerAction = event.m_columnsPerAction;
m_wheelAxis = event.m_wheelAxis; m_wheelAxis = event.m_wheelAxis;
m_magnification = event.m_magnification;
} }
// return true if was a button dclick event // return true if was a button dclick event

View File

@@ -749,6 +749,12 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
case NSMouseMoved : case NSMouseMoved :
wxevent.SetEventType( wxEVT_MOTION ) ; wxevent.SetEventType( wxEVT_MOTION ) ;
break; break;
case NSEventTypeMagnify:
wxevent.SetEventType( wxEVT_MAGNIFY );
wxevent.m_magnification = [nsEvent magnification];
break;
default : default :
break ; break ;
} }
@@ -1739,6 +1745,10 @@ void wxOSXCocoaClassAddWXMethods(Class c)
wxOSX_CLASS_ADD_METHOD(c, @selector(scrollWheel:), (IMP) wxOSX_mouseEvent, "v@:@" ) wxOSX_CLASS_ADD_METHOD(c, @selector(scrollWheel:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseEntered:), (IMP) wxOSX_mouseEvent, "v@:@" ) wxOSX_CLASS_ADD_METHOD(c, @selector(mouseEntered:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseExited:), (IMP) wxOSX_mouseEvent, "v@:@" ) wxOSX_CLASS_ADD_METHOD(c, @selector(mouseExited:), (IMP) wxOSX_mouseEvent, "v@:@" )
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
wxOSX_CLASS_ADD_METHOD(c, @selector(magnifyWithEvent:), (IMP)wxOSX_mouseEvent, "v@:@")
#endif
wxOSX_CLASS_ADD_METHOD(c, @selector(cursorUpdate:), (IMP) wxOSX_cursorUpdate, "v@:@" ) wxOSX_CLASS_ADD_METHOD(c, @selector(cursorUpdate:), (IMP) wxOSX_cursorUpdate, "v@:@" )