]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/vscroll.cpp
fixing non-precomp builds
[wxWidgets.git] / src / generic / vscroll.cpp
index a4256ef8049dd11511e4645cbaef19a9dd88d03c..809ae48576edf1e2676329b89c77e6223d2b2fd3 100644 (file)
@@ -144,7 +144,7 @@ bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
 
 wxVarScrollHelperBase::wxVarScrollHelperBase(wxWindow *win)
 {
-    wxASSERT_MSG( win, _T("associated window can't be NULL in wxVarScrollHelperBase") );
+    wxASSERT_MSG( win, wxT("associated window can't be NULL in wxVarScrollHelperBase") );
 
 #if wxUSE_MOUSEWHEEL
     m_sumWheelRotation = 0;
@@ -332,7 +332,7 @@ size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent& event) cons
     }
 
     // unknown scroll event?
-    wxFAIL_MSG( _T("unknown scroll event type?") );
+    wxFAIL_MSG( wxT("unknown scroll event type?") );
     return 0;
 }
 
@@ -476,7 +476,7 @@ void wxVarScrollHelperBase::RefreshUnit(size_t unit)
 
 void wxVarScrollHelperBase::RefreshUnits(size_t from, size_t to)
 {
-    wxASSERT_MSG( from <= to, _T("RefreshUnits(): empty range") );
+    wxASSERT_MSG( from <= to, wxT("RefreshUnits(): empty range") );
 
     // clump the range to just the visible units -- it is useless to refresh
     // the other ones
@@ -674,6 +674,39 @@ bool wxVarScrollHelperBase::DoScrollPages(int pages)
 
 void wxVarScrollHelperBase::HandleOnSize(wxSizeEvent& event)
 {
+    if ( m_unitMax )
+    {
+        // sometimes change in varscrollable window's size can result in
+        // unused empty space after the last item. Fix it by decrementing
+        // first visible item position according to the available space.
+
+        // determine free space
+        const wxCoord sWindow = GetOrientationTargetSize();
+        wxCoord s = 0;
+        size_t unit;
+        for ( unit = m_unitFirst; unit < m_unitMax; ++unit )
+        {
+            if ( s > sWindow )
+                break;
+
+            s += OnGetUnitSize(unit);
+        }
+        wxCoord freeSpace = sWindow - s;
+
+        // decrement first visible item index as long as there is free space
+        size_t idealUnitFirst;
+        for ( idealUnitFirst = m_unitFirst;
+              idealUnitFirst > 0;
+              idealUnitFirst-- )
+        {
+            wxCoord us = OnGetUnitSize(idealUnitFirst-1);
+            if ( freeSpace < us )
+                break;
+            freeSpace -= us;
+        }
+        m_unitFirst = idealUnitFirst;
+    }
+
     UpdateScrollbar();
 
     event.Skip();
@@ -817,7 +850,7 @@ void wxVarHVScrollHelper::RefreshRowsColumns(size_t fromRow, size_t toRow,
                                              size_t fromColumn, size_t toColumn)
 {
     wxASSERT_MSG( fromRow <= toRow || fromColumn <= toColumn,
-        _T("RefreshRowsColumns(): empty range") );
+        wxT("RefreshRowsColumns(): empty range") );
 
     // clump the range to just the visible units -- it is useless to refresh
     // the other ones
@@ -936,7 +969,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxHVScrolledWindow, wxPanel)
 // wxVarVScrollLegacyAdaptor
 // ===========================================================================
 
-size_t wxVarVScrollLegacyAdaptor::GetFirstVisibleLine() const 
+size_t wxVarVScrollLegacyAdaptor::GetFirstVisibleLine() const
 { return GetVisibleRowsBegin(); }
 
 size_t wxVarVScrollLegacyAdaptor::GetLastVisibleLine() const
@@ -953,19 +986,19 @@ void wxVarVScrollLegacyAdaptor::RefreshLine(size_t line)
 
 void wxVarVScrollLegacyAdaptor::RefreshLines(size_t from, size_t to)
 { RefreshRows(from, to); }
-        
+
 bool wxVarVScrollLegacyAdaptor::ScrollToLine(size_t line)
 { return ScrollToRow(line); }
 
 bool wxVarVScrollLegacyAdaptor::ScrollLines(int lines)
 { return ScrollRows(lines); }
-        
+
 bool wxVarVScrollLegacyAdaptor::ScrollPages(int pages)
 { return ScrollRowPages(pages); }
 
 wxCoord wxVarVScrollLegacyAdaptor::OnGetLineHeight(size_t WXUNUSED(n)) const
 {
-    wxFAIL_MSG( _T("OnGetLineHeight() must be overridden if OnGetRowHeight() isn't!") );
+    wxFAIL_MSG( wxT("OnGetLineHeight() must be overridden if OnGetRowHeight() isn't!") );
     return -1;
 }