#include "wx/grid.h"
#include "wx/generic/gridsel.h"
+// Required for wxIs... functions
+#include <ctype.h>
+
// ----------------------------------------------------------------------------
// array classes
// ----------------------------------------------------------------------------
{
}
-long wxGridStringTable::GetNumberRows()
+int wxGridStringTable::GetNumberRows()
{
return m_data.GetCount();
}
-long wxGridStringTable::GetNumberCols()
+int wxGridStringTable::GetNumberCols()
{
if ( m_data.GetCount() > 0 )
return m_data[0].GetCount();
break;
case WXGRID_CURSOR_SELECT_ROW:
- if ( (row = YToRow( y )) >= 0 &&
- !IsInSelection( row, 0 ) )
- {
- SelectRow( row, TRUE );
+ if ( (row = YToRow( y )) >= 0 )
+ {
+ m_selection->SelectRow( row,
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
}
// default label to suppress warnings about "enumeration value
if ( row >= 0 &&
!SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, row, -1, event ) )
{
- SelectRow( row, event.ShiftDown() );
+ if ( !event.ShiftDown() && !event.ControlDown() )
+ ClearSelection();
+ if ( event.ShiftDown() )
+ m_selection->SelectBlock( m_currentCellCoords.GetRow(),
+ 0,
+ row,
+ GetNumberCols() - 1,
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
+ else
+ m_selection->SelectRow( row,
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, m_rowLabelWin);
}
}
break;
case WXGRID_CURSOR_SELECT_COL:
- if ( (col = XToCol( x )) >= 0 &&
- !IsInSelection( 0, col ) )
- {
- SelectCol( col, TRUE );
+ if ( (col = XToCol( x )) >= 0 )
+ {
+ m_selection->SelectCol( col,
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
}
// default label to suppress warnings about "enumeration value
if ( col >= 0 &&
!SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, col, event ) )
{
- SelectCol( col, event.ShiftDown() );
+ if ( !event.ShiftDown() && !event.ControlDown() )
+ ClearSelection();
+ if ( event.ShiftDown() )
+ m_selection->SelectBlock( 0,
+ m_currentCellCoords.GetCol(),
+ GetNumberRows() - 1, col,
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
+ else
+ m_selection->SelectCol( col,
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, m_colLabelWin);
}
}
if ( coords != wxGridNoCellCoords )
{
- if ( !IsSelection() )
- {
- SelectBlock( coords, coords );
- }
- else
- {
- SelectBlock( m_currentCellCoords, coords );
+ if ( event.ControlDown() )
+ {
+ if ( m_selectingKeyboard == wxGridNoCellCoords)
+ m_selectingKeyboard = coords;
+ SelectBlock ( m_selectingKeyboard, coords );
+ }
+ else
+ {
+ if ( !IsSelection() )
+ {
+ SelectBlock( coords, coords );
+ }
+ else
+ {
+ SelectBlock( m_currentCellCoords, coords );
+ }
}
if (! IsVisible(coords))
{
MakeCellVisible(coords);
// TODO: need to introduce a delay or something here. The
- // scrolling is way to fast, at least on MSW.
+ // scrolling is way to fast, at least on MSW - also on GTK.
}
}
}
}
else
{
- m_selection->ToggleCellSelection( coords.GetRow(),
- coords.GetCol(),
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
- m_selectingTopLeft = wxGridNoCellCoords;
- m_selectingBottomRight = wxGridNoCellCoords;
- SetCurrentCell( coords );
+ if ( event.ControlDown() )
+ {
+ m_selection->ToggleCellSelection( coords.GetRow(),
+ coords.GetCol(),
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
+ m_selectingTopLeft = wxGridNoCellCoords;
+ m_selectingBottomRight = wxGridNoCellCoords;
+ m_selectingKeyboard = coords;
+ }
+ else
+ SetCurrentCell( coords );
m_waitForSlowClick = TRUE;
}
}
type,
this,
row, col,
- FALSE,
mouseEv.GetX(), mouseEv.GetY(),
+ FALSE,
mouseEv.ControlDown(),
mouseEv.ShiftDown(),
mouseEv.AltDown(),
if ( !event.ShiftDown() &&
m_selectingKeyboard != wxGridNoCellCoords )
{
- m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
- m_selectingTopLeft.GetCol(),
- m_selectingBottomRight.GetRow(),
- m_selectingBottomRight.GetCol(),
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ if ( m_selectingTopLeft != wxGridNoCellCoords &&
+ m_selectingBottomRight != wxGridNoCellCoords )
+ m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
+ m_selectingTopLeft.GetCol(),
+ m_selectingBottomRight.GetRow(),
+ m_selectingBottomRight.GetCol(),
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
m_selectingTopLeft = wxGridNoCellCoords;
m_selectingBottomRight = wxGridNoCellCoords;
m_selectingKeyboard = wxGridNoCellCoords;
break;
case WXK_ESCAPE:
- m_selection->ClearSelection();
+ ClearSelection();
break;
case WXK_TAB:
MovePageDown();
break;
-#if 1
case WXK_SPACE:
+ if ( event.ControlDown() )
+ {
+ m_selection->ToggleCellSelection( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol(),
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
+ break;
+ }
if ( !IsEditable() )
{
MoveCursorRight( FALSE );
break;
}
// Otherwise fall through to default
-#else
- case WXK_SPACE:
- m_selection->ToggleCellSelection( m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol(),
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
- break;
-#endif
default:
// alphanumeric keys or F2 (special key just for this) enable
if ( m_currentCellCoords != wxGridNoCellCoords &&
m_currentCellCoords.GetRow() > 0 )
{
- MakeCellVisible( m_currentCellCoords.GetRow() - 1,
- m_currentCellCoords.GetCol() );
if ( expandSelection )
{
if ( m_selectingKeyboard == wxGridNoCellCoords )
m_selectingKeyboard = m_currentCellCoords;
m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() - 1 );
+ MakeCellVisible( m_selectingKeyboard.GetRow(),
+ m_selectingKeyboard.GetCol() );
SelectBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
+ {
+ ClearSelection();
+ MakeCellVisible( m_currentCellCoords.GetRow() - 1,
+ m_currentCellCoords.GetCol() );
SetCurrentCell( m_currentCellCoords.GetRow() - 1,
m_currentCellCoords.GetCol() );
+ }
return TRUE;
}
if ( m_currentCellCoords != wxGridNoCellCoords &&
m_currentCellCoords.GetRow() < m_numRows-1 )
{
- MakeCellVisible( m_currentCellCoords.GetRow() + 1,
- m_currentCellCoords.GetCol() );
if ( expandSelection )
{
if ( m_selectingKeyboard == wxGridNoCellCoords )
m_selectingKeyboard = m_currentCellCoords;
m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() + 1 );
+ MakeCellVisible( m_selectingKeyboard.GetRow(),
+ m_selectingKeyboard.GetCol() );
SelectBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
+ {
+ ClearSelection();
+ MakeCellVisible( m_currentCellCoords.GetRow() + 1,
+ m_currentCellCoords.GetCol() );
SetCurrentCell( m_currentCellCoords.GetRow() + 1,
m_currentCellCoords.GetCol() );
+ }
return TRUE;
}
if ( m_currentCellCoords != wxGridNoCellCoords &&
m_currentCellCoords.GetCol() > 0 )
{
- MakeCellVisible( m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol() - 1 );
if ( expandSelection )
{
if ( m_selectingKeyboard == wxGridNoCellCoords )
m_selectingKeyboard = m_currentCellCoords;
m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() - 1 );
+ MakeCellVisible( m_selectingKeyboard.GetRow(),
+ m_selectingKeyboard.GetCol() );
SelectBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
+ {
+ ClearSelection();
+ MakeCellVisible( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol() - 1 );
SetCurrentCell( m_currentCellCoords.GetRow(),
m_currentCellCoords.GetCol() - 1 );
+ }
return TRUE;
}
if ( m_currentCellCoords != wxGridNoCellCoords &&
m_currentCellCoords.GetCol() < m_numCols - 1 )
{
- MakeCellVisible( m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol() + 1 );
-
if ( expandSelection )
{
if ( m_selectingKeyboard == wxGridNoCellCoords )
m_selectingKeyboard = m_currentCellCoords;
m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() + 1 );
+ MakeCellVisible( m_selectingKeyboard.GetRow(),
+ m_selectingKeyboard.GetCol() );
SelectBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
- SetCurrentCell( m_currentCellCoords.GetRow(),
+ {
+ ClearSelection();
+ MakeCellVisible( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol() + 1 );
+ SetCurrentCell( m_currentCellCoords.GetRow(),
m_currentCellCoords.GetCol() + 1 );
+ }
return TRUE;
}
SelectBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
- SetCurrentCell( row, col );
-
+ {
+ ClearSelection();
+ SetCurrentCell( row, col );
+ }
return TRUE;
}
SelectBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
- SetCurrentCell( row, col );
+ {
+ ClearSelection();
+ SetCurrentCell( row, col );
+ }
return TRUE;
}
SelectBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
- SetCurrentCell( row, col );
+ {
+ ClearSelection();
+ SetCurrentCell( row, col );
+ }
return TRUE;
}
SelectBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
- SetCurrentCell( row, col );
+ {
+ ClearSelection();
+ SetCurrentCell( row, col );
+ }
return TRUE;
}
void wxGrid::SelectRow( int row, bool addToSelected )
{
if ( IsSelection() && !addToSelected )
- m_selection->ClearSelection();
+ ClearSelection();
m_selection->SelectRow( row );
}
void wxGrid::SelectCol( int col, bool addToSelected )
{
if ( IsSelection() && !addToSelected )
- m_selection->ClearSelection();
+ ClearSelection();
m_selection->SelectCol( col );
}