[Libreoffice-commits] .: 3 commits - svtools/inc svtools/source
Tor Lillqvist
tml at kemper.freedesktop.org
Wed Jun 22 04:02:12 PDT 2011
svtools/inc/svtools/svtreebx.hxx | 2 ++
svtools/inc/svtools/treelist.hxx | 6 ++++++
svtools/source/contnr/svimpbox.cxx | 37 +++++++++++++++++++++++++++++++++++++
svtools/source/contnr/svtreebx.cxx | 27 +++++++++++++++++++++++++++
svtools/source/inc/svimpbox.hxx | 1 +
5 files changed, 73 insertions(+)
New commits:
commit ecce0e532296bc332912daf847493e8f06bb471f
Author: Luke Symes <allsymes at gmail.com>
Date: Wed Jun 22 16:03:10 2011 +1200
Implement GetLastEntryInView for SvTreeListBox.
This function matches up with GetFirstEntryInView, and will be useful
in saving the scroll state of a SvTreeListBox, in particular
the CustomAnimationList.
Signed-off-by: Tor Lillqvist <tlillqvist at novell.com>
diff --git a/svtools/inc/svtools/svtreebx.hxx b/svtools/inc/svtools/svtreebx.hxx
index 2b0a100..29c3822 100644
--- a/svtools/inc/svtools/svtreebx.hxx
+++ b/svtools/inc/svtools/svtreebx.hxx
@@ -369,6 +369,7 @@ public:
SvLBoxEntry* GetFirstEntryInView() const;
SvLBoxEntry* GetNextEntryInView(SvLBoxEntry*) const;
+ SvLBoxEntry* GetLastEntryInView() const;
void ScrollToAbsPos( long nPos );
void ShowFocusRect( const SvLBoxEntry* pEntry );
diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/svtreebx.cxx
index 76c82b6..175d9cd 100644
--- a/svtools/source/contnr/svtreebx.cxx
+++ b/svtools/source/contnr/svtreebx.cxx
@@ -2452,6 +2452,28 @@ SvLBoxEntry* SvTreeListBox::GetNextEntryInView(SvLBoxEntry* pEntry ) const
return pNext;
}
+SvLBoxEntry* SvTreeListBox::GetLastEntryInView() const
+{
+ SvLBoxEntry* pEntry = GetFirstEntryInView();
+ SvLBoxEntry* pNext = 0;
+ while( pEntry )
+ {
+ pNext = (SvLBoxEntry*)NextVisible( pEntry );
+ if( pNext )
+ {
+ Point aPos( GetEntryPosition(pNext) );
+ const Size& rSize = pImp->GetOutputSize();
+ if( aPos.Y() < 0 || aPos.Y() >= rSize.Height() )
+ break;
+ else
+ pEntry = pNext;
+ }
+ else
+ break;
+ }
+ return pEntry;
+}
+
void SvTreeListBox::ShowFocusRect( const SvLBoxEntry* pEntry )
{
pImp->ShowFocusRect( pEntry );
commit 21d0a9a47c8c31e40ccd5987a40aefcdcdf34d89
Author: Luke Symes <allsymes at gmail.com>
Date: Wed Jun 22 15:56:50 2011 +1200
Implement ScrollToAbsPos for listboxes.
Scrolls the listbox so the given entry is the first visible entry.
The existing MakeVisible is not good enough since it won't scroll
down if the given entry is already visible.
Signed-off-by: Tor Lillqvist <tlillqvist at novell.com>
diff --git a/svtools/inc/svtools/svtreebx.hxx b/svtools/inc/svtools/svtreebx.hxx
index 4453d0f..2b0a100 100644
--- a/svtools/inc/svtools/svtreebx.hxx
+++ b/svtools/inc/svtools/svtreebx.hxx
@@ -369,6 +369,7 @@ public:
SvLBoxEntry* GetFirstEntryInView() const;
SvLBoxEntry* GetNextEntryInView(SvLBoxEntry*) const;
+ void ScrollToAbsPos( long nPos );
void ShowFocusRect( const SvLBoxEntry* pEntry );
void SetTabBar( TabBar* pTabBar );
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index 6c296d2..63545ed 100644
--- a/svtools/inc/svtools/treelist.hxx
+++ b/svtools/inc/svtools/treelist.hxx
@@ -494,9 +494,15 @@ public:
SvListEntry* LastSelected() const
{ return pModel->LastSelected(this); }
+ SvListEntry* GetEntryAtAbsPos( sal_uLong nAbsPos ) const
+ { return pModel->GetEntryAtAbsPos(nAbsPos); }
+
SvListEntry* GetEntryAtVisPos( sal_uLong nVisPos ) const
{ return pModel->GetEntryAtVisPos((SvListView*)this,nVisPos); }
+ sal_uLong GetAbsPos( SvListEntry* pEntry ) const
+ { return pModel->GetAbsPos(pEntry); }
+
sal_uLong GetVisiblePos( SvListEntry* pEntry ) const
{ return pModel->GetVisiblePos((SvListView*)this,pEntry); }
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index ab6d4e1..fd5a649 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -1012,6 +1012,32 @@ void SvImpLBox::MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop )
pView->Invalidate();
}
+void SvImpLBox::ScrollToAbsPos( long nPos )
+{
+ long nLastEntryPos = pView->GetAbsPos( pView->Last() );
+
+ if( nPos < 0 )
+ nPos = 0;
+ else if( nPos > nLastEntryPos )
+ nPos = nLastEntryPos;
+
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pView->GetEntryAtAbsPos( nPos );
+ if( !pEntry || pEntry == pStartEntry )
+ return;
+
+ if( pStartEntry || (m_nStyle & WB_FORCE_MAKEVISIBLE) )
+ nFlags &= (~F_FILLING);
+
+ if( pView->IsEntryVisible(pEntry) )
+ {
+ pStartEntry = pEntry;
+ ShowCursor( sal_False );
+ aVerSBar.SetThumbPos( nPos );
+ ShowCursor( sal_True );
+ if (GetUpdateMode())
+ pView->Invalidate();
+ }
+}
void SvImpLBox::RepaintSelectionItems()
{
diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/svtreebx.cxx
index e9648d2..76c82b6 100644
--- a/svtools/source/contnr/svtreebx.cxx
+++ b/svtools/source/contnr/svtreebx.cxx
@@ -853,6 +853,11 @@ void SvTreeListBox::ScrollOutputArea( short nDeltaEntries )
NotifyEndScroll();
}
+void SvTreeListBox::ScrollToAbsPos( long nPos )
+{
+ pImp->ScrollToAbsPos( nPos );
+}
+
void SvTreeListBox::SetSelectionMode( SelectionMode eSelectMode )
{
DBG_CHKTHIS(SvTreeListBox,0);
diff --git a/svtools/source/inc/svimpbox.hxx b/svtools/source/inc/svimpbox.hxx
index 01648d8..7f666fc 100644
--- a/svtools/source/inc/svimpbox.hxx
+++ b/svtools/source/inc/svimpbox.hxx
@@ -313,6 +313,7 @@ public:
void SetCurEntry( SvLBoxEntry* );
Point GetEntryPosition( SvLBoxEntry* ) const;
void MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop=sal_False );
+ void ScrollToAbsPos( long nPos );
void PaintDDCursor( SvLBoxEntry* );
commit 8370f1cb9cd1ffc1dad53c6d20b9215b7f251801
Author: Luke Symes <allsymes at gmail.com>
Date: Wed Jun 22 15:40:26 2011 +1200
Set the listbox height to an integer multiple of the listbox entry height.
This ensures that we don't get a half visible entry at the bottom of the view.
Signed-off-by: Tor Lillqvist <tlillqvist at novell.com>
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index da5aff8..ab6d4e1 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -1358,8 +1358,19 @@ void SvImpLBox::InitScrollBarBox()
void SvImpLBox::Resize()
{
Size aSize( pView->Control::GetOutputSizePixel());
+ long nEntryHeight = pView->GetEntryHeight();
+ int nEntryCount = 0;
+
if( aSize.Width() <= 0 || aSize.Height() <= 0 )
return;
+ if( nEntryHeight )
+ {
+ // Set the view height to an integer multiple of the entry height.
+ nEntryCount = (int) aSize.Height() / nEntryHeight;
+ aSize.Height() = pView->GetEntryHeight() * nEntryCount;
+ pView->Control::SetOutputSizePixel( aSize );
+ }
+
nFlags |= F_IN_RESIZE;
InitScrollBarBox();
More information about the Libreoffice-commits
mailing list