From 5833988cb7a092f9976c1fb2320d4013f825400a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 10 Jun 2013 15:53:29 +0000 Subject: [PATCH] Add wxMouseEvent::GetColumnsPerAction(). This is similar to the existing GetLinesPerAction() but is for, surprise, columns. Also change the documentation to say that the value returned by both of these methods is 3 under "most platforms" as some wxOSX currently uses 1 and not 3. Closes #15239. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74156 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/event.h | 7 ++++++- include/wx/msw/missing.h | 3 +++ interface/wx/event.h | 18 +++++++++++++++++- src/common/event.cpp | 2 ++ src/gtk/window.cpp | 1 + src/gtk1/window.cpp | 1 + src/msw/window.cpp | 13 +++++++++++++ src/osx/carbon/nonownedwnd.cpp | 1 + src/osx/cocoa/window.mm | 1 + src/x11/window.cpp | 1 + 11 files changed, 47 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3093cd06b1..4cd8f39acb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -670,6 +670,7 @@ All (GUI): - Add wxWindow::BeginRepositioningChildren() and EndRepositioningChildren(). - Fix wxStyledTextCtrl::SetInsertionPointEnd() (troelsk). - Add wxFileDialog::GetCurrentlySelectedFilename() (Carl Godkin). +- Add wxMouseEvent::GetColumnsPerAction() (toiffel). wxGTK: diff --git a/include/wx/event.h b/include/wx/event.h index 87a1a6a304..38303aaae6 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1747,9 +1747,13 @@ public: wxMouseWheelAxis GetWheelAxis() const { return m_wheelAxis; } // Returns the configured number of lines (or whatever) to be scrolled per - // wheel action. Defaults to one. + // wheel action. Defaults to three. int GetLinesPerAction() const { return m_linesPerAction; } + // Returns the configured number of columns (or whatever) to be scrolled per + // wheel action. Defaults to three. + int GetColumnsPerAction() const { return m_columnsPerAction; } + // Is the system set to do page scrolling? bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); } @@ -1770,6 +1774,7 @@ public: int m_wheelRotation; int m_wheelDelta; int m_linesPerAction; + int m_columnsPerAction; protected: void Assign(const wxMouseEvent& evt); diff --git a/include/wx/msw/missing.h b/include/wx/msw/missing.h index 9efb9f6ab5..0582e12a41 100644 --- a/include/wx/msw/missing.h +++ b/include/wx/msw/missing.h @@ -86,6 +86,9 @@ #ifndef SPI_GETWHEELSCROLLLINES #define SPI_GETWHEELSCROLLLINES 104 #endif + #ifndef SPI_GETWHEELSCROLLCHARS + #define SPI_GETWHEELSCROLLCHARS 108 + #endif #endif // wxUSE_MOUSEWHEEL // Needed by window.cpp diff --git a/interface/wx/event.h b/interface/wx/event.h index f56d4b2435..b9cc77bfe6 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -2725,10 +2725,26 @@ public: /** Returns the configured number of lines (or whatever) to be scrolled per - wheel action. Defaults to three. + wheel action. + + Default value under most platforms is three. + + @see GetColumnsPerAction() */ int GetLinesPerAction() const; + /** + Returns the configured number of columns (or whatever) to be scrolled per + wheel action. + + Default value under most platforms is three. + + @see GetLinesPerAction() + + @since 2.9.5 + */ + int GetColumnsPerAction() const; + /** Returns the logical mouse position in pixels (i.e.\ translated according to the translation set for the DC, which usually indicates that the window has been diff --git a/src/common/event.cpp b/src/common/event.cpp index c7d1d33bde..2733450352 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -565,6 +565,7 @@ wxMouseEvent::wxMouseEvent(wxEventType commandType) m_wheelRotation = 0; m_wheelDelta = 0; m_linesPerAction = 0; + m_columnsPerAction = 0; } void wxMouseEvent::Assign(const wxMouseEvent& event) @@ -587,6 +588,7 @@ void wxMouseEvent::Assign(const wxMouseEvent& event) m_wheelRotation = event.m_wheelRotation; m_wheelDelta = event.m_wheelDelta; m_linesPerAction = event.m_linesPerAction; + m_columnsPerAction = event.m_columnsPerAction; m_wheelAxis = event.m_wheelAxis; } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 52e2c23541..e6d8aeba8a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1649,6 +1649,7 @@ window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win) // FIXME: Get these values from GTK or GDK event.m_linesPerAction = 3; + event.m_columnsPerAction = 3; event.m_wheelDelta = 120; // Determine the scroll direction. diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index da39d7a90e..9dc790f7ff 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1332,6 +1332,7 @@ template void InitMouseEvent(wxWindowGTK *win, if (event.GetEventType() == wxEVT_MOUSEWHEEL) { event.m_linesPerAction = 3; + event.m_columnsPerAction = 3; event.m_wheelDelta = 120; if (((GdkEventButton*)gdk_event)->button == 4) event.m_wheelRotation = 120; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 6cef9564b7..08710f5f7b 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -5607,7 +5607,20 @@ wxWindowMSW::HandleMouseWheel(wxMouseWheelAxis axis, } } + static int s_columnsPerRotation = -1; + if ( s_columnsPerRotation == -1 ) + { + if ( !::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, + &s_columnsPerRotation, 0)) + { + // this setting is not supported on Windows 2000/XP, so use the value of 1 + // http://msdn.microsoft.com/en-us/library/ms997498.aspx + s_columnsPerRotation = 1; + } + } + event.m_linesPerAction = s_linesPerRotation; + event.m_columnsPerAction = s_columnsPerRotation; return HandleWindowEvent(event); #else // !wxUSE_MOUSEWHEEL diff --git a/src/osx/carbon/nonownedwnd.cpp b/src/osx/carbon/nonownedwnd.cpp index 45344b01a6..d3216858bf 100644 --- a/src/osx/carbon/nonownedwnd.cpp +++ b/src/osx/carbon/nonownedwnd.cpp @@ -542,6 +542,7 @@ WXDLLEXPORT void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEve wxevent.m_wheelRotation = delta; wxevent.m_wheelDelta = 1; wxevent.m_linesPerAction = 1; + wxevent.m_columnsPerAction = 1; if ( axis == kEventMouseWheelAxisX ) wxevent.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL; } diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index e7d038a84c..0f48ef7888 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -682,6 +682,7 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve wxevent.m_wheelDelta = 10; wxevent.m_linesPerAction = 1; + wxevent.m_columnsPerAction = 1; if ( fabs(deltaX) > fabs(deltaY) ) { diff --git a/src/x11/window.cpp b/src/x11/window.cpp index fcd2ee3dea..fccabf677d 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -1486,6 +1486,7 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, button = xevent->xbutton.button; wxevent.m_linesPerAction = 3; + wxevent.m_columnsPerAction = 3; wxevent.m_wheelDelta = WHEEL_DELTA; // Button 4 means mousewheel up, 5 means down -- 2.45.2