remove the vertical scrollbar completely if the control is empty

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-04-26 00:17:52 +00:00
parent b1b408af9e
commit c1aa5517ac
2 changed files with 21 additions and 4 deletions

View File

@@ -188,6 +188,9 @@ protected:
// update the thumb size shown by the scrollbar // update the thumb size shown by the scrollbar
void UpdateScrollbar(); void UpdateScrollbar();
// remove the scrollbar completely because we don't need it
void RemoveScrollbar();
private: private:
// common part of all ctors // common part of all ctors
void Init(); void Init();

View File

@@ -160,6 +160,13 @@ size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast, bool full)
return lineFirst; return lineFirst;
} }
void wxVScrolledWindow::RemoveScrollbar()
{
m_lineFirst = 0;
m_nVisible = m_lineMax;
SetScrollbar(wxVERTICAL, 0, 0, 0);
}
void wxVScrolledWindow::UpdateScrollbar() void wxVScrolledWindow::UpdateScrollbar()
{ {
// see how many lines can we fit on screen // see how many lines can we fit on screen
@@ -189,8 +196,8 @@ void wxVScrolledWindow::UpdateScrollbar()
if ( hAll < hWindow ) if ( hAll < hWindow )
{ {
// we don't need scrollbar at all // we don't need scrollbar at all
m_lineFirst = 0; RemoveScrollbar();
SetScrollbar(wxVERTICAL, 0, 0, 0); return;
} }
} }
@@ -222,8 +229,15 @@ void wxVScrolledWindow::SetLineCount(size_t count)
m_heightTotal = EstimateTotalHeight(); m_heightTotal = EstimateTotalHeight();
// recalculate the scrollbars parameters // recalculate the scrollbars parameters
m_lineFirst = 1; // make sure it is != 0 if ( count )
ScrollToLine(0); {
m_lineFirst = 1; // make sure it is != 0
ScrollToLine(0);
}
else // no items
{
RemoveScrollbar();
}
} }
void wxVScrolledWindow::RefreshLine(size_t line) void wxVScrolledWindow::RefreshLine(size_t line)