summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-04-21 18:16:12 +0300
committerTor Lillqvist <tml@iki.fi>2013-04-22 11:21:41 +0300
commitc16de2eb12cc8d2885d55f7d240a17fa0444a3ca (patch)
tree9754a3066f176f8df55052813b8c44df4146fe99 /vcl/source/window
parent671b73789b2b09384e278efa0b989560b6606e4f (diff)
Factor out identical code for vertical and horizontal scrollbar
Change-Id: Ifc4925feccea9c35654356120b157f27d7cbfd3b
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/window2.cxx56
1 files changed, 20 insertions, 36 deletions
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 838809530cd6..98d7559fde43 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()