Changed wxGridCellCoords from long to int (get rid of most HP warnings?)
Added Shift/Control+Click handling for labels. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6589 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
2c4ad28347
commit
e32352cf66
@ -699,8 +699,8 @@ public:
|
|||||||
|
|
||||||
// You must override these functions in a derived table class
|
// You must override these functions in a derived table class
|
||||||
//
|
//
|
||||||
virtual long GetNumberRows() = 0;
|
virtual int GetNumberRows() = 0;
|
||||||
virtual long GetNumberCols() = 0;
|
virtual int GetNumberCols() = 0;
|
||||||
virtual bool IsEmptyCell( int row, int col ) = 0;
|
virtual bool IsEmptyCell( int row, int col ) = 0;
|
||||||
virtual wxString GetValue( int row, int col ) = 0;
|
virtual wxString GetValue( int row, int col ) = 0;
|
||||||
virtual void SetValue( int row, int col, const wxString& value ) = 0;
|
virtual void SetValue( int row, int col, const wxString& value ) = 0;
|
||||||
@ -843,8 +843,8 @@ public:
|
|||||||
|
|
||||||
// these are pure virtual in wxGridTableBase
|
// these are pure virtual in wxGridTableBase
|
||||||
//
|
//
|
||||||
long GetNumberRows();
|
int GetNumberRows();
|
||||||
long GetNumberCols();
|
int GetNumberCols();
|
||||||
wxString GetValue( int row, int col );
|
wxString GetValue( int row, int col );
|
||||||
void SetValue( int row, int col, const wxString& s );
|
void SetValue( int row, int col, const wxString& s );
|
||||||
bool IsEmptyCell( int row, int col );
|
bool IsEmptyCell( int row, int col );
|
||||||
@ -894,11 +894,11 @@ public:
|
|||||||
|
|
||||||
// default copy ctor is ok
|
// default copy ctor is ok
|
||||||
|
|
||||||
long GetRow() const { return m_row; }
|
int GetRow() const { return m_row; }
|
||||||
void SetRow( long n ) { m_row = n; }
|
void SetRow( int n ) { m_row = n; }
|
||||||
long GetCol() const { return m_col; }
|
int GetCol() const { return m_col; }
|
||||||
void SetCol( long n ) { m_col = n; }
|
void SetCol( int n ) { m_col = n; }
|
||||||
void Set( long row, long col ) { m_row = row; m_col = col; }
|
void Set( int row, int col ) { m_row = row; m_col = col; }
|
||||||
|
|
||||||
wxGridCellCoords& operator=( const wxGridCellCoords& other )
|
wxGridCellCoords& operator=( const wxGridCellCoords& other )
|
||||||
{
|
{
|
||||||
@ -926,8 +926,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long m_row;
|
int m_row;
|
||||||
long m_col;
|
int m_col;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -572,6 +572,7 @@ void GridFrame::OnLabelLeftClick( wxGridEvent& ev )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ev.ShiftDown() ) logBuf << " (shift down)";
|
if ( ev.ShiftDown() ) logBuf << " (shift down)";
|
||||||
|
if ( ev.ControlDown() ) logBuf << " (control down)";
|
||||||
wxLogMessage( "%s", logBuf.c_str() );
|
wxLogMessage( "%s", logBuf.c_str() );
|
||||||
|
|
||||||
// you must call event skip if you want default grid processing
|
// you must call event skip if you want default grid processing
|
||||||
@ -911,12 +912,12 @@ wxString BugsGridTable::GetTypeName(int WXUNUSED(row), int col)
|
|||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
long BugsGridTable::GetNumberRows()
|
int BugsGridTable::GetNumberRows()
|
||||||
{
|
{
|
||||||
return WXSIZEOF(gs_dataBugsGrid);
|
return WXSIZEOF(gs_dataBugsGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
long BugsGridTable::GetNumberCols()
|
int BugsGridTable::GetNumberCols()
|
||||||
{
|
{
|
||||||
return Col_Max;
|
return Col_Max;
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,8 @@ class BigGridTable : public wxGridTableBase
|
|||||||
public:
|
public:
|
||||||
BigGridTable(long sizeGrid) { m_sizeGrid = sizeGrid; }
|
BigGridTable(long sizeGrid) { m_sizeGrid = sizeGrid; }
|
||||||
|
|
||||||
long GetNumberRows() { return m_sizeGrid; }
|
int GetNumberRows() { return m_sizeGrid; }
|
||||||
long GetNumberCols() { return m_sizeGrid; }
|
int GetNumberCols() { return m_sizeGrid; }
|
||||||
wxString GetValue( int row, int col )
|
wxString GetValue( int row, int col )
|
||||||
{
|
{
|
||||||
return wxString::Format("(%d, %d)", row, col);
|
return wxString::Format("(%d, %d)", row, col);
|
||||||
@ -190,8 +190,8 @@ class BugsGridTable : public wxGridTableBase
|
|||||||
public:
|
public:
|
||||||
BugsGridTable();
|
BugsGridTable();
|
||||||
|
|
||||||
virtual long GetNumberRows();
|
virtual int GetNumberRows();
|
||||||
virtual long GetNumberCols();
|
virtual int GetNumberCols();
|
||||||
virtual bool IsEmptyCell( int row, int col );
|
virtual bool IsEmptyCell( int row, int col );
|
||||||
virtual wxString GetValue( int row, int col );
|
virtual wxString GetValue( int row, int col );
|
||||||
virtual void SetValue( int row, int col, const wxString& value );
|
virtual void SetValue( int row, int col, const wxString& value );
|
||||||
|
@ -2456,12 +2456,12 @@ wxGridStringTable::~wxGridStringTable()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxGridStringTable::GetNumberRows()
|
int wxGridStringTable::GetNumberRows()
|
||||||
{
|
{
|
||||||
return m_data.GetCount();
|
return m_data.GetCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxGridStringTable::GetNumberCols()
|
int wxGridStringTable::GetNumberCols()
|
||||||
{
|
{
|
||||||
if ( m_data.GetCount() > 0 )
|
if ( m_data.GetCount() > 0 )
|
||||||
return m_data[0].GetCount();
|
return m_data[0].GetCount();
|
||||||
@ -3803,10 +3803,13 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXGRID_CURSOR_SELECT_ROW:
|
case WXGRID_CURSOR_SELECT_ROW:
|
||||||
if ( (row = YToRow( y )) >= 0 &&
|
if ( (row = YToRow( y )) >= 0 )
|
||||||
!IsInSelection( row, 0 ) )
|
{
|
||||||
{
|
m_selection->SelectRow( row,
|
||||||
SelectRow( row, TRUE );
|
event.ControlDown(),
|
||||||
|
event.ShiftDown(),
|
||||||
|
event.AltDown(),
|
||||||
|
event.MetaDown() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// default label to suppress warnings about "enumeration value
|
// default label to suppress warnings about "enumeration value
|
||||||
@ -3843,7 +3846,23 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
if ( row >= 0 &&
|
if ( row >= 0 &&
|
||||||
!SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, row, -1, event ) )
|
!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);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, m_rowLabelWin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3970,10 +3989,13 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXGRID_CURSOR_SELECT_COL:
|
case WXGRID_CURSOR_SELECT_COL:
|
||||||
if ( (col = XToCol( x )) >= 0 &&
|
if ( (col = XToCol( x )) >= 0 )
|
||||||
!IsInSelection( 0, col ) )
|
{
|
||||||
{
|
m_selection->SelectCol( col,
|
||||||
SelectCol( col, TRUE );
|
event.ControlDown(),
|
||||||
|
event.ShiftDown(),
|
||||||
|
event.AltDown(),
|
||||||
|
event.MetaDown() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// default label to suppress warnings about "enumeration value
|
// default label to suppress warnings about "enumeration value
|
||||||
@ -4010,7 +4032,22 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
if ( col >= 0 &&
|
if ( col >= 0 &&
|
||||||
!SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, col, event ) )
|
!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);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, m_colLabelWin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4268,7 +4305,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
{
|
{
|
||||||
MakeCellVisible(coords);
|
MakeCellVisible(coords);
|
||||||
// TODO: need to introduce a delay or something here. The
|
// 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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5105,7 +5142,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_ESCAPE:
|
case WXK_ESCAPE:
|
||||||
m_selection->ClearSelection();
|
ClearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
@ -7585,7 +7622,7 @@ void wxGrid::SetCellValue( int row, int col, const wxString& s )
|
|||||||
void wxGrid::SelectRow( int row, bool addToSelected )
|
void wxGrid::SelectRow( int row, bool addToSelected )
|
||||||
{
|
{
|
||||||
if ( IsSelection() && !addToSelected )
|
if ( IsSelection() && !addToSelected )
|
||||||
m_selection->ClearSelection();
|
ClearSelection();
|
||||||
|
|
||||||
m_selection->SelectRow( row );
|
m_selection->SelectRow( row );
|
||||||
}
|
}
|
||||||
@ -7594,7 +7631,7 @@ void wxGrid::SelectRow( int row, bool addToSelected )
|
|||||||
void wxGrid::SelectCol( int col, bool addToSelected )
|
void wxGrid::SelectCol( int col, bool addToSelected )
|
||||||
{
|
{
|
||||||
if ( IsSelection() && !addToSelected )
|
if ( IsSelection() && !addToSelected )
|
||||||
m_selection->ClearSelection();
|
ClearSelection();
|
||||||
|
|
||||||
m_selection->SelectCol( col );
|
m_selection->SelectCol( col );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user