[Libreoffice-commits] core.git: vcl/source
Tor Lillqvist
tml at iki.fi
Mon Apr 22 01:22:17 PDT 2013
vcl/source/window/window2.cxx | 56 +++++++++++++++---------------------------
1 file changed, 20 insertions(+), 36 deletions(-)
New commits:
commit c16de2eb12cc8d2885d55f7d240a17fa0444a3ca
Author: Tor Lillqvist <tml at iki.fi>
Date: Sun Apr 21 18:16:12 2013 +0300
Factor out identical code for vertical and horizontal scrollbar
Change-Id: Ifc4925feccea9c35654356120b157f27d7cbfd3b
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 8388095..98d7559 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1197,26 +1197,19 @@ sal_Bool Window::HandleScrollCommand( const CommandEvent& rCmd,
// -----------------------------------------------------------------------
-// Not that when called for COMMAND_WHEEL above, despite its name,
-// pVScrl isn't necessarily the vertical scroll bar. Depending on
-// whether the scroll is horizontal or vertical, it is either the
-// horizontal or vertical scroll bar. nY is correspondingly either
-// the horizontal or vertical scroll amount.
-
-void Window::ImplHandleScroll( ScrollBar* pHScrl, long nX,
- ScrollBar* pVScrl, long nY )
+static void lcl_HandleScrollHelper( ScrollBar* pScrl, long nN )
{
- if ( pHScrl && nX && pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() )
+ if ( pScrl && nN && pScrl->IsEnabled() && pScrl->IsInputEnabled() && ! pScrl->IsInModalMode() )
{
- long nNewPos = pHScrl->GetThumbPos();
+ long nNewPos = pScrl->GetThumbPos();
- if ( nX == -LONG_MAX )
- nNewPos += pHScrl->GetPageSize();
- else if ( nX == LONG_MAX )
- nNewPos -= pHScrl->GetPageSize();
+ if ( nN == -LONG_MAX )
+ nNewPos += pScrl->GetPageSize();
+ else if ( nN == LONG_MAX )
+ nNewPos -= pScrl->GetPageSize();
else
{
- const double fVal = (double)nNewPos - ((double)nX * pHScrl->GetLineSize());
+ const double fVal = (double)nNewPos - ((double)nN * pScrl->GetLineSize());
if ( fVal < LONG_MIN )
nNewPos = LONG_MIN;
@@ -1226,31 +1219,22 @@ void Window::ImplHandleScroll( ScrollBar* pHScrl, long nX,
nNewPos = (long)fVal;
}
- pHScrl->DoScroll( nNewPos );
+ pScrl->DoScroll( nNewPos );
}
- if ( pVScrl && nY && pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() )
- {
- long nNewPos = pVScrl->GetThumbPos();
-
- if ( nY == -LONG_MAX )
- nNewPos += pVScrl->GetPageSize();
- else if ( nY == LONG_MAX )
- nNewPos -= pVScrl->GetPageSize();
- else
- {
- const double fVal = (double)nNewPos - ((double)nY * pVScrl->GetLineSize());
+}
- if ( fVal < LONG_MIN )
- nNewPos = LONG_MIN;
- else if ( fVal > LONG_MAX )
- nNewPos = LONG_MAX;
- else
- nNewPos = (long)fVal;
- }
+// Note that when called for COMMAND_WHEEL above, despite its name,
+// pVScrl isn't necessarily the vertical scroll bar. Depending on
+// whether the scroll is horizontal or vertical, it is either the
+// horizontal or vertical scroll bar. nY is correspondingly either
+// the horizontal or vertical scroll amount.
- pVScrl->DoScroll( nNewPos );
- }
+void Window::ImplHandleScroll( ScrollBar* pHScrl, long nX,
+ ScrollBar* pVScrl, long nY )
+{
+ lcl_HandleScrollHelper( pHScrl, nX );
+ lcl_HandleScrollHelper( pVScrl, nY );
}
DockingManager* Window::GetDockingManager()
More information about the Libreoffice-commits
mailing list