wxGrid::~wxGrid()
{
+ // Ensure that the editor control is destroyed before the grid is,
+ // otherwise we crash later when the editor tries to do something with the
+ // half destroyed grid
+ HideCellEditControl();
+
// Must do this or ~wxScrollHelper will pop the wrong event handler
SetTargetWindow(this);
ClearAttrCache();
if ( (row = YToRow( y )) >= 0 )
{
if ( m_selection )
- {
- m_selection->SelectRow( row,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
- }
+ m_selection->SelectRow(row, event);
}
}
break;
{
if ( event.ShiftDown() )
{
- m_selection->SelectBlock( m_currentCellCoords.GetRow(),
- 0,
- row,
- GetNumberCols() - 1,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ m_selection->SelectBlock
+ (
+ m_currentCellCoords.GetRow(), 0,
+ row, GetNumberCols() - 1,
+ event
+ );
}
else
{
- m_selection->SelectRow( row,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ m_selection->SelectRow(row, event);
}
}
if ( (col = XToCol( x )) >= 0 )
{
if ( m_selection )
- {
- m_selection->SelectCol( col,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
- }
+ m_selection->SelectCol(col, event);
}
}
break;
{
if ( event.ShiftDown() )
{
- m_selection->SelectBlock( 0,
- m_currentCellCoords.GetCol(),
- GetNumberRows() - 1, col,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ m_selection->SelectBlock
+ (
+ 0, m_currentCellCoords.GetCol(),
+ GetNumberRows() - 1, col,
+ event
+ );
}
else
{
- m_selection->SelectCol( col,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ m_selection->SelectCol(col, event);
}
}
{
if ( m_selection )
{
- m_selection->SelectBlock( m_currentCellCoords,
- coords,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ m_selection->SelectBlock(m_currentCellCoords, coords, event);
m_selectedBlockCorner = coords;
}
}
{
if ( m_selection )
{
- m_selection->ToggleCellSelection( coords,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ m_selection->ToggleCellSelection(coords, event);
}
+
m_selectedBlockTopLeft = wxGridNoCellCoords;
m_selectedBlockBottomRight = wxGridNoCellCoords;
m_selectedBlockCorner = coords;
{
m_selection->SelectBlock( m_selectedBlockTopLeft,
m_selectedBlockBottomRight,
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ event );
}
m_selectedBlockTopLeft = wxGridNoCellCoords;
rowOrCol,
mouseEv.GetX() + GetRowLabelSize(),
mouseEv.GetY() + GetColLabelSize(),
- mouseEv.ControlDown(),
- mouseEv.ShiftDown(),
- mouseEv.AltDown(),
- mouseEv.MetaDown() );
+ mouseEv);
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
m_selectedBlockTopLeft,
m_selectedBlockBottomRight,
true,
- mouseEv.ControlDown(),
- mouseEv.ShiftDown(),
- mouseEv.AltDown(),
- mouseEv.MetaDown() );
+ mouseEv);
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
pos.x,
pos.y,
false,
- mouseEv.ControlDown(),
- mouseEv.ShiftDown(),
- mouseEv.AltDown(),
- mouseEv.MetaDown() );
+ mouseEv);
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
}
mouseEv.GetX() + GetRowLabelSize(),
mouseEv.GetY() + GetColLabelSize(),
false,
- mouseEv.ControlDown(),
- mouseEv.ShiftDown(),
- mouseEv.AltDown(),
- mouseEv.MetaDown() );
+ mouseEv);
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
}
m_selection->SelectBlock(
m_selectedBlockTopLeft,
m_selectedBlockBottomRight,
- event.ControlDown(),
- true,
- event.AltDown(),
- event.MetaDown() );
+ event);
}
}
void wxGrid::SelectRow( int row, bool addToSelected )
{
- if ( IsSelection() && !addToSelected )
+ if ( !m_selection )
+ return;
+
+ if ( !addToSelected )
ClearSelection();
- if ( m_selection )
- m_selection->SelectRow( row, false, addToSelected );
+ m_selection->SelectRow(row);
}
void wxGrid::SelectCol( int col, bool addToSelected )
{
- if ( IsSelection() && !addToSelected )
+ if ( !m_selection )
+ return;
+
+ if ( !addToSelected )
ClearSelection();
- if ( m_selection )
- m_selection->SelectCol( col, false, addToSelected );
+ m_selection->SelectCol(col);
}
-void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
- bool addToSelected )
+void wxGrid::SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol,
+ bool addToSelected)
{
- if ( IsSelection() && !addToSelected )
+ if ( !m_selection )
+ return;
+
+ if ( !addToSelected )
ClearSelection();
- if ( m_selection )
- m_selection->SelectBlock( topRow, leftCol, bottomRow, rightCol,
- false, addToSelected );
+ m_selection->SelectBlock(topRow, leftCol, bottomRow, rightCol);
}
void wxGrid::SelectAll()
wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj,
int row, int col, int x, int y, bool sel,
bool control, bool shift, bool alt, bool meta )
- : wxNotifyEvent( type, id )
+ : wxNotifyEvent( type, id ),
+ wxKeyboardState(control, shift, alt, meta)
{
- m_row = row;
- m_col = col;
- m_x = x;
- m_y = y;
- m_selecting = sel;
- m_control = control;
- m_shift = shift;
- m_alt = alt;
- m_meta = meta;
+ Init(row, col, x, y, sel);
SetEventObject(obj);
}
-
IMPLEMENT_DYNAMIC_CLASS( wxGridSizeEvent, wxNotifyEvent )
wxGridSizeEvent::wxGridSizeEvent( int id, wxEventType type, wxObject* obj,
int rowOrCol, int x, int y,
bool control, bool shift, bool alt, bool meta )
- : wxNotifyEvent( type, id )
+ : wxNotifyEvent( type, id ),
+ wxKeyboardState(control, shift, alt, meta)
{
- m_rowOrCol = rowOrCol;
- m_x = x;
- m_y = y;
- m_control = control;
- m_shift = shift;
- m_alt = alt;
- m_meta = meta;
+ Init(rowOrCol, x, y);
SetEventObject(obj);
}
const wxGridCellCoords& bottomRight,
bool sel, bool control,
bool shift, bool alt, bool meta )
- : wxNotifyEvent( type, id )
-{
- m_topLeft = topLeft;
- m_bottomRight = bottomRight;
- m_selecting = sel;
- m_control = control;
- m_shift = shift;
- m_alt = alt;
- m_meta = meta;
+ : wxNotifyEvent( type, id ),
+ wxKeyboardState(control, shift, alt, meta)
+{
+ Init(topLeft, bottomRight, sel);
SetEventObject(obj);
}