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
This commit is contained in:
@@ -374,8 +374,10 @@ wxGridCellCoords wxGridNoCellCoords( -1, -1 );
|
|||||||
wxRect wxGridNoCellRect( -1, -1, -1, -1 );
|
wxRect wxGridNoCellRect( -1, -1, -1, -1 );
|
||||||
|
|
||||||
// scroll line size
|
// scroll line size
|
||||||
// TODO: fixed so far - make configurable later (and also different for x/y)
|
// TODO: this doesn't work at all, grid cells have different sizes and approx
|
||||||
static const size_t GRID_SCROLL_LINE = 10;
|
// 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
|
// the size of hash tables used a bit everywhere (the max number of elements
|
||||||
// in these hash tables is the number of rows/columns)
|
// in these hash tables is the number of rows/columns)
|
||||||
@@ -1413,9 +1415,9 @@ void wxGridCellEditorEvtHandler::OnKeyDown(wxKeyEvent& event)
|
|||||||
event.Skip( m_grid->GetEventHandler()->ProcessEvent( event ) );
|
event.Skip( m_grid->GetEventHandler()->ProcessEvent( event ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_NUMPAD_ENTER:
|
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
if ( !m_grid->GetEventHandler()->ProcessEvent(event) )
|
case WXK_NUMPAD_ENTER:
|
||||||
|
if (!m_grid->GetEventHandler()->ProcessEvent(event))
|
||||||
m_editor->HandleReturn(event);
|
m_editor->HandleReturn(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2440,16 +2442,16 @@ int wxGridTypeRegistry::FindOrCloneDataType(const wxString& typeName)
|
|||||||
wxGridCellRenderer* wxGridTypeRegistry::GetRenderer(int index)
|
wxGridCellRenderer* wxGridTypeRegistry::GetRenderer(int index)
|
||||||
{
|
{
|
||||||
wxGridCellRenderer* renderer = m_typeinfo[index]->m_renderer;
|
wxGridCellRenderer* renderer = m_typeinfo[index]->m_renderer;
|
||||||
if (renderer)
|
if (renderer)
|
||||||
renderer->IncRef();
|
renderer->IncRef();
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridCellEditor* wxGridTypeRegistry::GetEditor(int index)
|
wxGridCellEditor* wxGridTypeRegistry::GetEditor(int index)
|
||||||
{
|
{
|
||||||
wxGridCellEditor* editor = m_typeinfo[index]->m_editor;
|
wxGridCellEditor* editor = m_typeinfo[index]->m_editor;
|
||||||
if (editor)
|
if (editor)
|
||||||
editor->IncRef();
|
editor->IncRef();
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3679,19 +3681,44 @@ void wxGrid::CalcDimensions()
|
|||||||
int cw, ch;
|
int cw, ch;
|
||||||
GetClientSize( &cw, &ch );
|
GetClientSize( &cw, &ch );
|
||||||
|
|
||||||
if ( m_numRows > 0 || m_numCols > 0 )
|
if ( m_colLabelWin->IsShown() )
|
||||||
{
|
cw -= m_rowLabelWidth;
|
||||||
int right = m_numCols > 0 ? GetColRight( m_numCols-1 ) + m_extraWidth : 0;
|
if ( m_rowLabelWin->IsShown() )
|
||||||
int bottom = m_numRows > 0 ? GetRowBottom( m_numRows-1 ) + m_extraHeight : 0;
|
ch -= m_colLabelHeight;
|
||||||
|
|
||||||
// TODO: restore the scroll position that we had before sizing
|
// grid total size
|
||||||
//
|
int w = m_numCols > 0 ? GetColRight(m_numCols - 1) + m_extraWidth + 1 : 0;
|
||||||
int x, y;
|
int h = m_numRows > 0 ? GetRowBottom(m_numRows - 1) + m_extraHeight + 1 : 0;
|
||||||
GetViewStart( &x, &y );
|
|
||||||
SetScrollbars( GRID_SCROLL_LINE, GRID_SCROLL_LINE,
|
// preserve (more or less) the previous position
|
||||||
right/GRID_SCROLL_LINE, bottom/GRID_SCROLL_LINE,
|
int x, y;
|
||||||
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() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4008,13 +4035,9 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
|
|||||||
CalcDimensions();
|
CalcDimensions();
|
||||||
m_colLabelWin->Refresh();
|
m_colLabelWin->Refresh();
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
#if 0
|
result = TRUE;
|
||||||
// There is no path to this code !!!!!!
|
|
||||||
result = TRUE;
|
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result && !GetBatchCount() )
|
if (result && !GetBatchCount() )
|
||||||
@@ -4614,7 +4637,9 @@ void wxGrid::ChangeCursorMode(CursorMode mode,
|
|||||||
cursorModes[m_cursorMode], cursorModes[mode]);
|
cursorModes[m_cursorMode], cursorModes[mode]);
|
||||||
#endif // __WXDEBUG__
|
#endif // __WXDEBUG__
|
||||||
|
|
||||||
if ( mode == m_cursorMode )
|
if ( mode == m_cursorMode &&
|
||||||
|
win == m_winCapture &&
|
||||||
|
captureMouse == (m_winCapture != NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( !win )
|
if ( !win )
|
||||||
@@ -5285,13 +5310,12 @@ bool wxGrid::SendEvent( const wxEventType type,
|
|||||||
type,
|
type,
|
||||||
this,
|
this,
|
||||||
rowOrCol,
|
rowOrCol,
|
||||||
mouseEv.GetX() + GetColLabelSize(),
|
mouseEv.GetX() + GetRowLabelSize(),
|
||||||
mouseEv.GetY() + GetRowLabelSize(),
|
mouseEv.GetY() + GetColLabelSize(),
|
||||||
mouseEv.ControlDown(),
|
mouseEv.ControlDown(),
|
||||||
mouseEv.ShiftDown(),
|
mouseEv.ShiftDown(),
|
||||||
mouseEv.AltDown(),
|
mouseEv.AltDown(),
|
||||||
mouseEv.MetaDown() );
|
mouseEv.MetaDown() );
|
||||||
|
|
||||||
return GetEventHandler()->ProcessEvent(gridEvt);
|
return GetEventHandler()->ProcessEvent(gridEvt);
|
||||||
}
|
}
|
||||||
else if ( type == wxEVT_GRID_RANGE_SELECT )
|
else if ( type == wxEVT_GRID_RANGE_SELECT )
|
||||||
@@ -5316,14 +5340,13 @@ bool wxGrid::SendEvent( const wxEventType type,
|
|||||||
type,
|
type,
|
||||||
this,
|
this,
|
||||||
row, col,
|
row, col,
|
||||||
mouseEv.GetX() + GetColLabelSize(),
|
mouseEv.GetX() + GetRowLabelSize(),
|
||||||
mouseEv.GetY() + GetRowLabelSize(),
|
mouseEv.GetY() + GetColLabelSize(),
|
||||||
FALSE,
|
FALSE,
|
||||||
mouseEv.ControlDown(),
|
mouseEv.ControlDown(),
|
||||||
mouseEv.ShiftDown(),
|
mouseEv.ShiftDown(),
|
||||||
mouseEv.AltDown(),
|
mouseEv.AltDown(),
|
||||||
mouseEv.MetaDown() );
|
mouseEv.MetaDown() );
|
||||||
|
|
||||||
return GetEventHandler()->ProcessEvent(gridEvt);
|
return GetEventHandler()->ProcessEvent(gridEvt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5792,7 +5815,6 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
|
|||||||
// (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)
|
||||||
//
|
//
|
||||||
@@ -7991,8 +8013,8 @@ void wxGrid::SetDefaultRowSize( int height, bool resizeExistingRows )
|
|||||||
if ( resizeExistingRows )
|
if ( resizeExistingRows )
|
||||||
{
|
{
|
||||||
InitRowHeights();
|
InitRowHeights();
|
||||||
|
if ( !GetBatchCount() )
|
||||||
CalcDimensions();
|
CalcDimensions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8015,7 +8037,8 @@ void wxGrid::SetRowSize( int row, int height )
|
|||||||
{
|
{
|
||||||
m_rowBottoms[i] += diff;
|
m_rowBottoms[i] += diff;
|
||||||
}
|
}
|
||||||
CalcDimensions();
|
if ( !GetBatchCount() )
|
||||||
|
CalcDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
|
void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
|
||||||
@@ -8025,8 +8048,8 @@ void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
|
|||||||
if ( resizeExistingCols )
|
if ( resizeExistingCols )
|
||||||
{
|
{
|
||||||
InitColWidths();
|
InitColWidths();
|
||||||
|
if ( !GetBatchCount() )
|
||||||
CalcDimensions();
|
CalcDimensions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8051,7 +8074,8 @@ void wxGrid::SetColSize( int col, int width )
|
|||||||
{
|
{
|
||||||
m_colRights[i] += diff;
|
m_colRights[i] += diff;
|
||||||
}
|
}
|
||||||
CalcDimensions();
|
if ( !GetBatchCount() )
|
||||||
|
CalcDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -8153,11 +8177,34 @@ void wxGrid::AutoSizeColOrRow( int colOrRow, bool setAsMin, bool column )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( column )
|
if ( column ){
|
||||||
SetColSize(col, extentMax);
|
SetColSize(col, extentMax);
|
||||||
else
|
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 ( setAsMin )
|
||||||
{
|
{
|
||||||
if ( column )
|
if ( column )
|
||||||
@@ -8171,6 +8218,8 @@ int wxGrid::SetOrCalcColumnSizes(bool calcOnly, bool setAsMin)
|
|||||||
{
|
{
|
||||||
int width = m_rowLabelWidth;
|
int width = m_rowLabelWidth;
|
||||||
|
|
||||||
|
if ( !calcOnly )
|
||||||
|
BeginBatch();
|
||||||
for ( int col = 0; col < m_numCols; col++ )
|
for ( int col = 0; col < m_numCols; col++ )
|
||||||
{
|
{
|
||||||
if ( !calcOnly )
|
if ( !calcOnly )
|
||||||
@@ -8180,7 +8229,8 @@ int wxGrid::SetOrCalcColumnSizes(bool calcOnly, bool setAsMin)
|
|||||||
|
|
||||||
width += GetColWidth(col);
|
width += GetColWidth(col);
|
||||||
}
|
}
|
||||||
|
if ( !calcOnly )
|
||||||
|
EndBatch();
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8188,6 +8238,8 @@ int wxGrid::SetOrCalcRowSizes(bool calcOnly, bool setAsMin)
|
|||||||
{
|
{
|
||||||
int height = m_colLabelHeight;
|
int height = m_colLabelHeight;
|
||||||
|
|
||||||
|
if ( !calcOnly )
|
||||||
|
BeginBatch();
|
||||||
for ( int row = 0; row < m_numRows; row++ )
|
for ( int row = 0; row < m_numRows; row++ )
|
||||||
{
|
{
|
||||||
if ( !calcOnly )
|
if ( !calcOnly )
|
||||||
@@ -8197,14 +8249,15 @@ int wxGrid::SetOrCalcRowSizes(bool calcOnly, bool setAsMin)
|
|||||||
|
|
||||||
height += GetRowHeight(row);
|
height += GetRowHeight(row);
|
||||||
}
|
}
|
||||||
|
if ( !calcOnly )
|
||||||
|
EndBatch();
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::AutoSize()
|
void wxGrid::AutoSize()
|
||||||
{
|
{
|
||||||
// set the size too
|
// set the size too
|
||||||
SetSize(SetOrCalcColumnSizes(FALSE), SetOrCalcRowSizes(FALSE));
|
SetClientSize(SetOrCalcColumnSizes(FALSE), SetOrCalcRowSizes(FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxGrid::DoGetBestSize() const
|
wxSize wxGrid::DoGetBestSize() const
|
||||||
|
Reference in New Issue
Block a user