X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5bd24f724209014da8889d1b225294777f5f856a..47e59154157bb013ce255a4efa7a615574c974f7:/src/generic/scrlwing.cpp diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index d6ace0914c..ad1b381399 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: generic/scrolwin.cpp +// Name: src/generic/scrlwing.cpp // Purpose: wxScrolledWindow implementation // Author: Julian Smart // Modified by: Vadim Zeitlin on 31.08.00: wxScrollHelper allows to implement. @@ -29,15 +29,18 @@ #pragma hdrstop #endif -#include "wx/utils.h" -#include "wx/dcclient.h" - #include "wx/scrolwin.h" -#include "wx/panel.h" -#if wxUSE_TIMER -#include "wx/timer.h" + +#ifndef WX_PRECOMP + #include "wx/utils.h" + #include "wx/panel.h" + #include "wx/dcclient.h" + #if wxUSE_TIMER + #include "wx/timer.h" + #endif + #include "wx/sizer.h" #endif -#include "wx/sizer.h" + #include "wx/recguard.h" #ifdef __WXMSW__ @@ -933,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; } @@ -941,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; } @@ -1339,4 +1394,3 @@ WXLRESULT wxScrolledWindow::MSWWindowProc(WXUINT nMsg, } #endif // __WXMSW__ -