- return width;
-}
-
-size_t wxHVScrolledWindow::FindFirstFromBottom(size_t rowLast, bool full)
-{
- const wxCoord hWindow = GetClientSize().y;
-
- // go upwards until we arrive at a line such that lineLast is not visible
- // any more when it is shown
- size_t lineFirst = rowLast;
- wxCoord h = 0;
- for ( ;; )
- {
- h += OnGetRowHeight(lineFirst);
-
- if ( h > hWindow )
- {
- // 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;
- }
-
- if ( !lineFirst )
- break;
-
- lineFirst--;
- }
-
- return lineFirst;
-}
-
-size_t wxHVScrolledWindow::FindFirstFromRight(size_t columnLast, bool full)
-{
- const wxCoord wWindow = GetClientSize().x;
-
- // go upwards until we arrive at a line such that lineLast is not visible
- // any more when it is shown
- size_t lineFirst = columnLast;
- wxCoord w = 0;
- for ( ;; )
- {
- w += OnGetColumnWidth(lineFirst);
-
- if ( w > wWindow )
- {
- // 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;
- }
-
- if ( !lineFirst )
- break;
-
- lineFirst--;
- }
-
- return lineFirst;
-}
-
-void wxHVScrolledWindow::UpdateScrollbars()
-{
- // see how many lines can we fit on screen (on both axes)
- const wxCoord wWindow = GetClientSize().x;
- const wxCoord hWindow = GetClientSize().y;
-
- // first do the horizontal calculations
- wxCoord w = 0;
- size_t column;
- for ( column = m_columnsFirst; column < m_columnsMax; column++ )
- {
- if ( w > wWindow )
- break;
-
- w += OnGetColumnWidth(column);
- }
-
- m_nColumnsVisible = column - m_columnsFirst;
-
- int columnsPageSize = m_nColumnsVisible;
- if ( w > wWindow )
- {
- // last line is only partially visible, we still need the scrollbar and
- // so we have to "fix" pageSize because if it is equal to
- // m_horizLineMax the scrollbar is not shown at all under MSW
- columnsPageSize--;
- }
-
- // set the scrollbar parameters to reflect this
- SetScrollbar(wxHORIZONTAL, m_columnsFirst, columnsPageSize, m_columnsMax);
-
-
- // now do the vertical calculations
- wxCoord h = 0;
- size_t row;
- for ( row = m_rowsFirst; row < m_rowsMax; row++ )
- {
- if ( h > hWindow )
- break;
-
- h += OnGetRowHeight(row);
- }
-
- m_nRowsVisible = row - m_rowsFirst;
-
- int rowsPageSize = m_nRowsVisible;
- if ( h > hWindow )
- {
- // last line is only partially visible, we still need the scrollbar and
- // so we have to "fix" pageSize because if it is equal to m_vertLineMax
- // the scrollbar is not shown at all under MSW
- rowsPageSize--;
- }
-
- // set the scrollbar parameters to reflect this
- SetScrollbar(wxVERTICAL, m_rowsFirst, rowsPageSize, m_rowsMax);
-}
-
-void wxHVScrolledWindow::PrepareDC(wxDC& dc)
-{
- if(m_physicalScrolling)
- {
- dc.SetDeviceOrigin(-GetColumnsWidth(0, GetVisibleColumnsBegin()),
- -GetRowsHeight(0, GetVisibleRowsBegin()));
- }
-}
-
-// ----------------------------------------------------------------------------
-// operations
-// ----------------------------------------------------------------------------
-
-void wxHVScrolledWindow::SetRowColumnCounts(size_t rowCount, size_t columnCount)
-{
- // save the number of lines
- m_rowsMax = rowCount;
- m_columnsMax = columnCount;
-
- // and our estimate for their total height and width
- m_heightTotal = EstimateTotalHeight();
- m_widthTotal = EstimateTotalWidth();
-
- // recalculate the scrollbars parameters
- if(m_rowsFirst >= rowCount)
- m_rowsFirst = (rowCount > 0) ? rowCount - 1 : 0;
-
- if(m_columnsFirst >= columnCount)
- m_columnsFirst = (columnCount > 0) ? columnCount - 1 : 0;
-
-#if 0
- // checks disabled due to size_t type of members
- // but leave them here if anyone would want to do some debugging
- if(m_rowsFirst < 0)
- m_rowsFirst = 0;
-
- if(m_columnsFirst < 0)
- m_columnsFirst = 0;
-#endif
-
- ScrollToRowColumn(m_rowsFirst, m_columnsFirst);
-}
-
-void wxHVScrolledWindow::RefreshColumn(size_t column)
-{
- // is this line visible?
- if ( !IsColumnVisible(column) )
- {
- // no, it is useless to do anything
- return;
- }
-
- // calculate the rect occupied by this line on screen
- wxRect rect;
- rect.width = OnGetColumnWidth(column);
- rect.height = GetClientSize().y;
- for ( size_t n = GetVisibleColumnsBegin(); n < column; n++ )
- {
- rect.y += OnGetColumnWidth(n);
- }
-
- // do refresh it
- RefreshRect(rect);
-}
-
-void wxHVScrolledWindow::RefreshRow(size_t row)
-{
- // is this line visible?
- if ( !IsRowVisible(row) )
- {
- // 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 = OnGetRowHeight(row);
- for ( size_t n = GetVisibleRowsBegin(); n < row; n++ )
- {
- rect.y += OnGetRowHeight(n);
- }
-
- // do refresh it
- RefreshRect(rect);
-}
-
-void wxHVScrolledWindow::RefreshRowColumn(size_t row, size_t column)
-{
- // is this line visible?
- if ( !IsRowVisible(row) || !IsColumnVisible(column) )
- {
- // no, it is useless to do anything
- return;
- }
-
- // calculate the rect occupied by this cell on screen
- wxRect rect;
- rect.height = OnGetRowHeight(row);
- rect.width = OnGetColumnWidth(column);
-
- size_t n;
-
- for ( n = GetVisibleRowsBegin(); n < row; n++ )
- {
- rect.y += OnGetRowHeight(n);
- }
-
- for ( n = GetVisibleColumnsBegin(); n < column; n++ )
- {
- rect.x += OnGetColumnWidth(n);
- }
-
- // do refresh it
- RefreshRect(rect);
-}
-
-void wxHVScrolledWindow::RefreshRows(size_t from, size_t to)
-{
- wxASSERT_MSG( from <= to, _T("RefreshRows(): empty range") );
-
- // clump the range to just the visible lines -- it is useless to refresh
- // the other ones
- if ( from < GetVisibleRowsBegin() )
- from = GetVisibleRowsBegin();
-
- if ( to > GetVisibleRowsEnd() )
- to = GetVisibleRowsEnd();
-
- // calculate the rect occupied by these lines on screen
- wxRect rect;
- rect.width = GetClientSize().x;
- for ( size_t nBefore = GetVisibleRowsBegin();
- nBefore < from;
- nBefore++ )
- {
- rect.y += OnGetRowHeight(nBefore);
- }
-
- for ( size_t nBetween = from; nBetween <= to; nBetween++ )
- {
- rect.height += OnGetRowHeight(nBetween);
- }
-
- // do refresh it
- RefreshRect(rect);
-}
-
-void wxHVScrolledWindow::RefreshColumns(size_t from, size_t to)
-{
- wxASSERT_MSG( from <= to, _T("RefreshColumns(): empty range") );
-
- // clump the range to just the visible lines -- it is useless to refresh
- // the other ones
- if ( from < GetVisibleColumnsBegin() )
- from = GetVisibleColumnsBegin();
-
- if ( to > GetVisibleColumnsEnd() )
- to = GetVisibleColumnsEnd();
-
- // calculate the rect occupied by these lines on screen
- wxRect rect;
- rect.height = GetClientSize().y;
- for ( size_t nBefore = GetVisibleColumnsBegin();
- nBefore < from;
- nBefore++ )
- {
- rect.x += OnGetColumnWidth(nBefore);
- }
-
- for ( size_t nBetween = from; nBetween <= to; nBetween++ )
- {
- rect.width += OnGetColumnWidth(nBetween);
- }
-
- // do refresh it
- RefreshRect(rect);
-}
-
-void wxHVScrolledWindow::RefreshRowsColumns(size_t fromRow, size_t toRow,
- size_t fromColumn, size_t toColumn)
-{
- wxASSERT_MSG( fromRow <= toRow || fromColumn <= toColumn,
- _T("RefreshRowsColumns(): empty range") );
-
- // clump the range to just the visible lines -- it is useless to refresh
- // the other ones
- if ( fromRow < GetVisibleRowsBegin() )
- fromRow = GetVisibleRowsBegin();
-
- if ( toRow > GetVisibleRowsEnd() )
- toRow = GetVisibleRowsEnd();
-
- if ( fromColumn < GetVisibleColumnsBegin() )
- fromColumn = GetVisibleColumnsBegin();