changing GRID_SCROLL_LINE to 1.
Fixed Bug #413014 (Missing refresh after calling DeleteCols) by fixing
Redimension.
Fixed Bug #232657 (Mouse not captured during wxGrid column resize) by
fixing ChangeCursorMode.
Fixed some minor problems with screen updates (CalcDimensions should only be
called while not BatchMode, Autosizing Rows/Cols should happen within
BatchMode, Sizing a row/column should update also labels)
- touched various functions.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9772
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxRect wxGridNoCellRect( -1, -1, -1, -1 );
// scroll line size
wxRect wxGridNoCellRect( -1, -1, -1, -1 );
// scroll line size
-// TODO: fixed so far - make configurable later (and also different for x/y)
-static const size_t GRID_SCROLL_LINE = 10;
+// TODO: this doesn't work at all, grid cells have different sizes and approx
+// calculations don't work as because of the size mismatch scrollbars
+// sometimes fail to be shown when they should be or vice versa
+static const size_t GRID_SCROLL_LINE = 1;
// the size of hash tables used a bit everywhere (the max number of elements
// in these hash tables is the number of rows/columns)
// the size of hash tables used a bit everywhere (the max number of elements
// in these hash tables is the number of rows/columns)
event.Skip( m_grid->GetEventHandler()->ProcessEvent( event ) );
break;
event.Skip( m_grid->GetEventHandler()->ProcessEvent( event ) );
break;
- if ( !m_grid->GetEventHandler()->ProcessEvent(event) )
+ case WXK_NUMPAD_ENTER:
+ if (!m_grid->GetEventHandler()->ProcessEvent(event))
m_editor->HandleReturn(event);
break;
m_editor->HandleReturn(event);
break;
wxGridCellRenderer* wxGridTypeRegistry::GetRenderer(int index)
{
wxGridCellRenderer* renderer = m_typeinfo[index]->m_renderer;
wxGridCellRenderer* wxGridTypeRegistry::GetRenderer(int index)
{
wxGridCellRenderer* renderer = m_typeinfo[index]->m_renderer;
- if (renderer)
- renderer->IncRef();
+ if (renderer)
+ renderer->IncRef();
return renderer;
}
wxGridCellEditor* wxGridTypeRegistry::GetEditor(int index)
{
wxGridCellEditor* editor = m_typeinfo[index]->m_editor;
return renderer;
}
wxGridCellEditor* wxGridTypeRegistry::GetEditor(int index)
{
wxGridCellEditor* editor = m_typeinfo[index]->m_editor;
- if (editor)
- editor->IncRef();
+ if (editor)
+ editor->IncRef();
int cw, ch;
GetClientSize( &cw, &ch );
int cw, ch;
GetClientSize( &cw, &ch );
- if ( m_numRows > 0 || m_numCols > 0 )
- {
- int right = m_numCols > 0 ? GetColRight( m_numCols-1 ) + m_extraWidth : 0;
- int bottom = m_numRows > 0 ? GetRowBottom( m_numRows-1 ) + m_extraHeight : 0;
+ if ( m_colLabelWin->IsShown() )
+ cw -= m_rowLabelWidth;
+ if ( m_rowLabelWin->IsShown() )
+ ch -= m_colLabelHeight;
- // TODO: restore the scroll position that we had before sizing
- //
- int x, y;
- GetViewStart( &x, &y );
- SetScrollbars( GRID_SCROLL_LINE, GRID_SCROLL_LINE,
- right/GRID_SCROLL_LINE, bottom/GRID_SCROLL_LINE,
- x, y );
+ // grid total size
+ int w = m_numCols > 0 ? GetColRight(m_numCols - 1) + m_extraWidth + 1 : 0;
+ int h = m_numRows > 0 ? GetRowBottom(m_numRows - 1) + m_extraHeight + 1 : 0;
+
+ // preserve (more or less) the previous position
+ int x, y;
+ GetViewStart( &x, &y );
+ // maybe we don't need scrollbars at all? and if we do, transform w and h
+ // from pixels into logical units
+ if ( w <= cw )
+ {
+ w = 0; x= 0;
+ }
+ else
+ {
+ w = (w + GRID_SCROLL_LINE - 1)/GRID_SCROLL_LINE;
+ if ( x >= w )
+ x = w - 1;
+ if ( h <= ch )
+ {
+ h = 0; y = 0;
+ }
+ else
+ {
+ h = (h + GRID_SCROLL_LINE - 1)/GRID_SCROLL_LINE;
+ if ( y >= h )
+ y = h - 1;
+ }
+
+ // do set scrollbar parameters
+ SetScrollbars( GRID_SCROLL_LINE, GRID_SCROLL_LINE,
+ w, h, x, y, GetBatchCount() );
CalcDimensions();
m_colLabelWin->Refresh();
}
CalcDimensions();
m_colLabelWin->Refresh();
}
-#if 0
-// There is no path to this code !!!!!!
- result = TRUE;
}
if (result && !GetBatchCount() )
}
if (result && !GetBatchCount() )
cursorModes[m_cursorMode], cursorModes[mode]);
#endif // __WXDEBUG__
cursorModes[m_cursorMode], cursorModes[mode]);
#endif // __WXDEBUG__
- if ( mode == m_cursorMode )
+ if ( mode == m_cursorMode &&
+ win == m_winCapture &&
+ captureMouse == (m_winCapture != NULL))
- mouseEv.GetX() + GetColLabelSize(),
- mouseEv.GetY() + GetRowLabelSize(),
+ mouseEv.GetX() + GetRowLabelSize(),
+ mouseEv.GetY() + GetColLabelSize(),
mouseEv.ControlDown(),
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
mouseEv.ControlDown(),
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
return GetEventHandler()->ProcessEvent(gridEvt);
}
else if ( type == wxEVT_GRID_RANGE_SELECT )
return GetEventHandler()->ProcessEvent(gridEvt);
}
else if ( type == wxEVT_GRID_RANGE_SELECT )
- mouseEv.GetX() + GetColLabelSize(),
- mouseEv.GetY() + GetRowLabelSize(),
+ mouseEv.GetX() + GetRowLabelSize(),
+ mouseEv.GetY() + GetColLabelSize(),
FALSE,
mouseEv.ControlDown(),
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
FALSE,
mouseEv.ControlDown(),
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
return GetEventHandler()->ProcessEvent(gridEvt);
}
}
return GetEventHandler()->ProcessEvent(gridEvt);
}
}
// (old comment from when this was the body of SelectBlock)
}
// (old comment from when this was the body of SelectBlock)
}
//
// ------ functions to get/send data (see also public functions)
//
//
// ------ functions to get/send data (see also public functions)
//
if ( resizeExistingRows )
{
InitRowHeights();
if ( resizeExistingRows )
{
InitRowHeights();
+ if ( !GetBatchCount() )
+ CalcDimensions();
{
m_rowBottoms[i] += diff;
}
{
m_rowBottoms[i] += diff;
}
+ if ( !GetBatchCount() )
+ CalcDimensions();
}
void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
}
void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
if ( resizeExistingCols )
{
InitColWidths();
if ( resizeExistingCols )
{
InitColWidths();
+ if ( !GetBatchCount() )
+ CalcDimensions();
{
m_colRights[i] += diff;
}
{
m_colRights[i] += diff;
}
+ if ( !GetBatchCount() )
+ CalcDimensions();
SetColSize(col, extentMax);
SetColSize(col, extentMax);
+ if ( !GetBatchCount() )
+ {
+ int cw, ch, dummy;
+ m_gridWin->GetClientSize( &cw, &ch );
+ wxRect rect ( CellToRect( 0, col ) );
+ rect.y = 0;
+ CalcScrolledPosition(rect.x, 0, &rect.x, &dummy);
+ rect.width = cw - rect.x;
+ rect.height = m_colLabelHeight;
+ m_colLabelWin->Refresh( TRUE, &rect );
+ }
+ }
+ else{
SetRowSize(row, extentMax);
SetRowSize(row, extentMax);
+ if ( !GetBatchCount() )
+ {
+ int cw, ch, dummy;
+ m_gridWin->GetClientSize( &cw, &ch );
+ wxRect rect ( CellToRect( row, 0 ) );
+ rect.x = 0;
+ CalcScrolledPosition(0, rect.y, &dummy, &rect.y);
+ rect.width = m_rowLabelWidth;
+ rect.height = ch - rect.y;
+ m_rowLabelWin->Refresh( TRUE, &rect );
+ }
+ }
if ( setAsMin )
{
if ( column )
if ( setAsMin )
{
if ( column )
{
int width = m_rowLabelWidth;
{
int width = m_rowLabelWidth;
+ if ( !calcOnly )
+ BeginBatch();
for ( int col = 0; col < m_numCols; col++ )
{
if ( !calcOnly )
for ( int col = 0; col < m_numCols; col++ )
{
if ( !calcOnly )
width += GetColWidth(col);
}
width += GetColWidth(col);
}
+ if ( !calcOnly )
+ EndBatch();
{
int height = m_colLabelHeight;
{
int height = m_colLabelHeight;
+ if ( !calcOnly )
+ BeginBatch();
for ( int row = 0; row < m_numRows; row++ )
{
if ( !calcOnly )
for ( int row = 0; row < m_numRows; row++ )
{
if ( !calcOnly )
height += GetRowHeight(row);
}
height += GetRowHeight(row);
}
+ if ( !calcOnly )
+ EndBatch();
return height;
}
void wxGrid::AutoSize()
{
// set the size too
return height;
}
void wxGrid::AutoSize()
{
// set the size too
- SetSize(SetOrCalcColumnSizes(FALSE), SetOrCalcRowSizes(FALSE));
+ SetClientSize(SetOrCalcColumnSizes(FALSE), SetOrCalcRowSizes(FALSE));
}
wxSize wxGrid::DoGetBestSize() const
}
wxSize wxGrid::DoGetBestSize() const