summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@gmx.com>2012-02-28 00:06:24 +0100
committerMatteo Casalin <matteo.casalin@gmx.com>2012-03-03 09:49:35 +0100
commite336f41e50ea96880dd71a2b42aa37cf53256383 (patch)
tree0f3dddf82cd730394007d3ed8fb234dd4100c76c /svtools
parent0809906906d7941ceb9ae170a41c482fdd1e6bfa (diff)
ValueSet: simplified autoscroll logic
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/valueset.cxx53
1 files changed, 21 insertions, 32 deletions
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 9db8f934f03c..8cd032be9716 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -994,46 +994,35 @@ void ValueSet::ImplDraw()
bool ValueSet::ImplScroll( const Point& rPos )
{
- Size aOutSize = GetOutputSizePixel();
- long nScrBarWidth;
-
- if ( mpScrBar )
- nScrBarWidth = mpScrBar->GetSizePixel().Width();
- else
- nScrBarWidth = 0;
-
- if ( !mbScroll || (rPos.X() < 0) || (rPos.X() > aOutSize.Width()-nScrBarWidth) )
+ if ( !mbScroll || !maItemListRect.IsInside(rPos) )
return false;
- long nScrollOffset;
- sal_uInt16 nOldLine = mnFirstLine;
- const Rectangle aTopRect = ImplGetItemRect( mnFirstLine*mnCols );
- if ( aTopRect.GetHeight() <= 16 )
- nScrollOffset = SCROLL_OFFSET/2;
- else
- nScrollOffset = SCROLL_OFFSET;
- if ( (mnFirstLine > 0) && (rPos.Y() >= 0) )
+ const long nScrollOffset = (mnItemHeight <= 16) ? SCROLL_OFFSET/2 : SCROLL_OFFSET;
+ bool bScroll = false;
+
+ if ( rPos.Y() <= maItemListRect.Top()+nScrollOffset )
{
- long nTopPos = aTopRect.Top();
- if ( (rPos.Y() >= nTopPos) && (rPos.Y() <= nTopPos+nScrollOffset) )
- mnFirstLine--;
+ if ( mnFirstLine > 0 )
+ {
+ --mnFirstLine;
+ bScroll = true;
+ }
}
- if ( (mnFirstLine == nOldLine) &&
- (mnFirstLine < (sal_uInt16)(mnLines-mnVisLines)) && (rPos.Y() < aOutSize.Height()) )
+ else if ( rPos.Y() >= maItemListRect.Bottom()-nScrollOffset )
{
- const long nBottomPos = ImplGetItemRect((mnFirstLine+mnVisLines-1)*mnCols).Bottom();
- if ( (rPos.Y() >= nBottomPos-nScrollOffset) && (rPos.Y() <= nBottomPos) )
- mnFirstLine++;
+ if ( mnFirstLine < static_cast<sal_uInt16>(mnLines-mnVisLines) )
+ {
+ ++mnFirstLine;
+ bScroll = true;
+ }
}
- if ( mnFirstLine != nOldLine )
- {
- mbFormat = true;
- ImplDraw();
- return true;
- }
- else
+ if ( !bScroll )
return false;
+
+ mbFormat = true;
+ ImplDraw();
+ return true;
}
// -----------------------------------------------------------------------