From 4eeceb15733c862a09041bb6ffb0e8599d890b6e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Apr 2012 22:27:34 +0000 Subject: [PATCH] Add support for horizontal mouse wheel events to wxGTK too. Handle GDK_SCROLL_{RIGHT,LEFT} directions in scroll-event handler in wxGTK. Closes #14221. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 +- src/gtk/window.cpp | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3319dd013b..ebbe812abc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -480,6 +480,7 @@ All: All (GUI): - Added strike-through support to wxFont (Igor Korot). +- Add support for horizontal mouse wheel events to MSW and GTK (Lauri Nurmi). - Fix infinite loop in wxHtmlEasyPrinting when trying to page break images taller than the page height in wxHtmlEasyPrinting (Laurent Poujoulat). - Added wxFilePickerCtrl::SetInitialDirectory(). @@ -521,7 +522,6 @@ MSW: - Add wxActiveXContainer::QueryClientSiteInterface and implement it in wxWebViewIE to improve the default behaviour (Allonii). - Update stretchable spaces in wxToolBar after tool removal (Catalin Raceanu). -- Add support for horizontal mouse wheel events (Lauri Nurmi). - Implement wxGraphicsContext::SetInterpolationQuality() (Eric Jensen). - Fix coordinate handling in wxDC::Blit() when source DC is a DIB. - Fix handling of composite windows in wxToolTip (Armel Asselin). diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index b8734c412d..ac10b6fc7d 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1641,22 +1641,43 @@ window_scroll_event_hscrollbar(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* static gboolean window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win) { - if (gdk_event->direction != GDK_SCROLL_UP && - gdk_event->direction != GDK_SCROLL_DOWN) - { - return false; - } - wxMouseEvent event(wxEVT_MOUSEWHEEL); InitMouseEvent(win, event, gdk_event); // FIXME: Get these values from GTK or GDK event.m_linesPerAction = 3; event.m_wheelDelta = 120; - if (gdk_event->direction == GDK_SCROLL_UP) - event.m_wheelRotation = 120; - else - event.m_wheelRotation = -120; + + // Determine the scroll direction. + switch (gdk_event->direction) + { + case GDK_SCROLL_UP: + case GDK_SCROLL_RIGHT: + event.m_wheelRotation = 120; + break; + + case GDK_SCROLL_DOWN: + case GDK_SCROLL_LEFT: + event.m_wheelRotation = -120; + break; + + default: + return false; // Unknown/unhandled direction + } + + // And the scroll axis. + switch (gdk_event->direction) + { + case GDK_SCROLL_UP: + case GDK_SCROLL_DOWN: + event.m_wheelAxis = wxMOUSE_WHEEL_VERTICAL; + break; + + case GDK_SCROLL_LEFT: + case GDK_SCROLL_RIGHT: + event.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL; + break; + } if (win->GTKProcessEvent(event)) return TRUE; -- 2.45.2