From 4f0eda0e6ee3c289a932ef5fd224ea1d67bb086a Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 12 Sep 2006 09:48:27 +0000 Subject: [PATCH] More RTL fixes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41172 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/scrlwing.cpp | 56 ++++++++++++++++++++++++++++++++++++++-- src/gtk/window.cpp | 3 --- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 42c47c8904..ad1b381399 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -936,7 +936,33 @@ void wxScrollHelper::GetViewStart (int *x, int *y) const void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) - *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine; + { + if ((m_xScrollLines == 0) || (m_xScrollPixelsPerLine == 0)) + { + // nothing to do + *xx = x; + } + else + { +#ifdef __WXGTK__ + if (m_win->GetLayoutDirection() == wxLayout_RightToLeft) + { + int w = 0, h = 0; + GetTargetSize(&w, &h); + + // Calculate page size i.e. number of scroll units you get on the + // current client window + int noPagePositions = w/m_xScrollPixelsPerLine; + if (noPagePositions < 1) noPagePositions = 1; + *xx = x - ((m_xScrollLines - noPagePositions - m_xScrollPosition) * m_xScrollPixelsPerLine); + } + else +#endif + { + *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine; + } + } + } if ( yy ) *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine; } @@ -944,7 +970,33 @@ void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) cons void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) - *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine; + { + if ((m_xScrollLines == 0) || (m_xScrollPixelsPerLine == 0)) + { + // nothing to do + *xx = x; + } + else + { +#ifdef __WXGTK__ + if (m_win->GetLayoutDirection() == wxLayout_RightToLeft) + { + int w = 0, h = 0; + GetTargetSize(&w, &h); + + // Calculate page size i.e. number of scroll units you get on the + // current client window + int noPagePositions = w/m_xScrollPixelsPerLine; + if (noPagePositions < 1) noPagePositions = 1; + *xx = x + ((m_xScrollLines - noPagePositions - m_xScrollPosition) * m_xScrollPixelsPerLine); + } + else +#endif + { + *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine; + } + } + } if ( yy ) *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine; } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a18ed12377..9f639a3586 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1286,10 +1286,7 @@ template void InitMouseEvent(wxWindowGTK *win, if ((win->m_wxwindow) && (win->GetLayoutDirection() == wxLayout_RightToLeft)) { // origin in the upper right corner - int virtual_width = win->GetVirtualSize().x; int window_width = gtk_pizza_get_rtl_offset( GTK_PIZZA(win->m_wxwindow) ); - //wxPrintf( wxT("event.m_x %d virtual_width %d window_width %d m_xoffset %d\n"), - // event.m_x, virtual_width, window_width, GTK_PIZZA(win->m_wxwindow)->m_xoffset ); event.m_x = window_width - event.m_x; } -- 2.45.2