return height;
}
-size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast)
+size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast, bool full)
{
const wxCoord hWindow = GetClientSize().y;
if ( h > hWindow )
{
- lineFirst++;
+ // for this line to be fully visible we need to go one line
+ // down, but if it is enough for it to be only partly visible then
+ // this line will do as well
+ if ( full )
+ {
+ lineFirst++;
+ }
break;
}
count/2 + NUM_LINES_TO_SAMPLE/2);
// use the height of the lines we looked as the average
- m_heightTotal = ((float)m_heightTotal / (3*NUM_LINES_TO_SAMPLE)) *
- m_lineMax;
+ m_heightTotal = (wxCoord)
+ (((float)m_heightTotal / (3*NUM_LINES_TO_SAMPLE)) * m_lineMax);
}
// recalculate the scrollbars parameters
+ m_lineFirst = 1; // make sure it is != 0
ScrollToLine(0);
}
+void wxVScrolledWindow::RefreshLine(size_t line)
+{
+ // is this line visible?
+ if ( !IsVisible(line) )
+ {
+ // no, it is useless to do anything
+ return;
+ }
+
+ // calculate the rect occupied by this line on screen
+ wxRect rect;
+ rect.width = GetClientSize().x;
+ rect.height = OnGetLineHeight(line);
+ for ( size_t n = GetFirstVisibleLine(); n < line; n++ )
+ {
+ rect.y += OnGetLineHeight(n);
+ }
+
+ // do refresh it
+ RefreshRect(rect);
+}
+
+void wxVScrolledWindow::RefreshAll()
+{
+ UpdateScrollbar();
+
+ Refresh();
+}
+
+int wxVScrolledWindow::HitTest(wxCoord WXUNUSED(x), wxCoord y) const
+{
+ const size_t lineMax = GetLastVisibleLine();
+ for ( size_t line = GetFirstVisibleLine(); line <= lineMax; line++ )
+ {
+ y -= OnGetLineHeight(line);
+ if ( y < 0 )
+ return line;
+ }
+
+ return wxNOT_FOUND;
+}
+
// ----------------------------------------------------------------------------
// scrolling
// ----------------------------------------------------------------------------
// determine the real first line to scroll to: we shouldn't scroll beyond
// the end
- size_t lineFirstLast = FindFirstFromBottom(m_lineMax - 1);
+ size_t lineFirstLast = FindFirstFromBottom(m_lineMax - 1, true);
if ( line > lineFirstLast )
line = lineFirstLast;
}
ScrollToLine(lineFirstNew);
+
+#ifdef __WXMAC__
+ Update();
+#endif // __WXMAC__
}