Bugfixes; added selection modes demo to griddemo
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6439 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -997,7 +997,9 @@ public:
|
||||
void DoEndDragResizeCol();
|
||||
|
||||
wxGridTableBase * GetTable() const { return m_table; }
|
||||
bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE );
|
||||
bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE,
|
||||
wxGrid::wxGridSelectionModes selmode =
|
||||
wxGrid::wxGridSelectCells );
|
||||
|
||||
void ClearGrid();
|
||||
bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
|
||||
|
@@ -83,6 +83,9 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
|
||||
EVT_MENU( ID_DELETEROW, GridFrame::DeleteSelectedRows )
|
||||
EVT_MENU( ID_DELETECOL, GridFrame::DeleteSelectedCols )
|
||||
EVT_MENU( ID_CLEARGRID, GridFrame::ClearGrid )
|
||||
EVT_MENU( ID_SELCELLS, GridFrame::SelectCells )
|
||||
EVT_MENU( ID_SELROWS, GridFrame::SelectRows )
|
||||
EVT_MENU( ID_SELCOLS, GridFrame::SelectCols )
|
||||
|
||||
EVT_MENU( ID_SET_CELL_FG_COLOUR, GridFrame::SetCellFgColour )
|
||||
EVT_MENU( ID_SET_CELL_BG_COLOUR, GridFrame::SetCellBgColour )
|
||||
@@ -159,6 +162,16 @@ GridFrame::GridFrame()
|
||||
editMenu->Append( ID_DELETECOL, "Delete selected co&ls" );
|
||||
editMenu->Append( ID_CLEARGRID, "Cl&ear grid cell contents" );
|
||||
|
||||
wxMenu *selectionMenu = new wxMenu;
|
||||
|
||||
editMenu->Append( ID_CHANGESEL, "Change &selection mode",
|
||||
selectionMenu,
|
||||
"Change selection mode" );
|
||||
|
||||
selectionMenu->Append( ID_SELCELLS, "Select &Cells" );
|
||||
selectionMenu->Append( ID_SELROWS, "Select &Rows" );
|
||||
selectionMenu->Append( ID_SELCOLS, "Select C&ols" );
|
||||
|
||||
wxMenu *helpMenu = new wxMenu;
|
||||
helpMenu->Append( ID_ABOUT, "&About wxGrid demo" );
|
||||
|
||||
@@ -482,27 +495,23 @@ void GridFrame::InsertCol( wxCommandEvent& WXUNUSED(ev) )
|
||||
|
||||
void GridFrame::DeleteSelectedRows( wxCommandEvent& WXUNUSED(ev) )
|
||||
{
|
||||
#if 0
|
||||
if ( grid->IsSelection() )
|
||||
{
|
||||
int topRow, bottomRow, leftCol, rightCol;
|
||||
grid->GetSelection( &topRow, &leftCol, &bottomRow, &rightCol );
|
||||
grid->DeleteRows( topRow, bottomRow - topRow + 1 );
|
||||
for ( int n = 0; n < grid->GetNumberRows(); n++ )
|
||||
if ( grid->IsInSelection( n , 0 ) )
|
||||
grid->DeleteRows( n, 1 );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void GridFrame::DeleteSelectedCols( wxCommandEvent& WXUNUSED(ev) )
|
||||
{
|
||||
#if 0
|
||||
if ( grid->IsSelection() )
|
||||
{
|
||||
int topRow, bottomRow, leftCol, rightCol;
|
||||
grid->GetSelection( &topRow, &leftCol, &bottomRow, &rightCol );
|
||||
grid->DeleteCols( leftCol, rightCol - leftCol + 1 );
|
||||
for ( int n = 0; n < grid->GetNumberCols(); n++ )
|
||||
if ( grid->IsInSelection( 0 , n ) )
|
||||
grid->DeleteCols( n, 1 );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -511,6 +520,21 @@ void GridFrame::ClearGrid( wxCommandEvent& WXUNUSED(ev) )
|
||||
grid->ClearGrid();
|
||||
}
|
||||
|
||||
void GridFrame::SelectCells( wxCommandEvent& WXUNUSED(ev) )
|
||||
{
|
||||
grid->SetSelectionMode( wxGrid::wxGridSelectCells );
|
||||
}
|
||||
|
||||
void GridFrame::SelectRows( wxCommandEvent& WXUNUSED(ev) )
|
||||
{
|
||||
grid->SetSelectionMode( wxGrid::wxGridSelectRows );
|
||||
}
|
||||
|
||||
void GridFrame::SelectCols( wxCommandEvent& WXUNUSED(ev) )
|
||||
{
|
||||
grid->SetSelectionMode( wxGrid::wxGridSelectColumns );
|
||||
}
|
||||
|
||||
void GridFrame::SetCellFgColour( wxCommandEvent& WXUNUSED(ev) )
|
||||
{
|
||||
wxColour col = wxGetColourFromUser(this);
|
||||
|
@@ -56,6 +56,9 @@ class GridFrame : public wxFrame
|
||||
void DeleteSelectedRows( wxCommandEvent& );
|
||||
void DeleteSelectedCols( wxCommandEvent& );
|
||||
void ClearGrid( wxCommandEvent& );
|
||||
void SelectCells( wxCommandEvent& );
|
||||
void SelectRows( wxCommandEvent& );
|
||||
void SelectCols( wxCommandEvent& );
|
||||
|
||||
void OnLabelLeftClick( wxGridEvent& );
|
||||
void OnCellLeftClick( wxGridEvent& );
|
||||
@@ -99,6 +102,10 @@ public:
|
||||
ID_DELETEROW,
|
||||
ID_DELETECOL,
|
||||
ID_CLEARGRID,
|
||||
ID_CHANGESEL,
|
||||
ID_SELCELLS,
|
||||
ID_SELROWS,
|
||||
ID_SELCOLS,
|
||||
ID_SET_CELL_FG_COLOUR,
|
||||
ID_SET_CELL_BG_COLOUR,
|
||||
ID_ABOUT,
|
||||
|
@@ -3165,9 +3165,9 @@ bool wxGrid::CreateGrid( int numRows, int numCols,
|
||||
m_table->SetView( this );
|
||||
m_ownTable = TRUE;
|
||||
Init();
|
||||
m_selection = new wxGridSelection( this, selmode );
|
||||
m_created = TRUE;
|
||||
}
|
||||
m_selection = new wxGridSelection( this, selmode );
|
||||
return m_created;
|
||||
}
|
||||
|
||||
@@ -3181,7 +3181,8 @@ void wxGrid::SetSelectionMode(wxGrid::wxGridSelectionModes selmode)
|
||||
m_selection->SetSelectionMode( selmode );
|
||||
}
|
||||
|
||||
bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership )
|
||||
bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
|
||||
wxGrid::wxGridSelectionModes selmode )
|
||||
{
|
||||
if ( m_created )
|
||||
{
|
||||
@@ -3190,6 +3191,7 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership )
|
||||
// View at runtime. Is there anything in the implmentation that would
|
||||
// prevent this?
|
||||
|
||||
// At least, you now have to copy with m_selection
|
||||
wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") );
|
||||
return FALSE;
|
||||
}
|
||||
@@ -3203,6 +3205,7 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership )
|
||||
if (takeOwnership)
|
||||
m_ownTable = TRUE;
|
||||
Init();
|
||||
m_selection = new wxGridSelection( this, selmode );
|
||||
m_created = TRUE;
|
||||
}
|
||||
|
||||
@@ -4391,10 +4394,10 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
||||
if ( m_selectingTopLeft != wxGridNoCellCoords &&
|
||||
m_selectingBottomRight != wxGridNoCellCoords )
|
||||
{
|
||||
m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
|
||||
m_selectingTopLeft.GetCol(),
|
||||
m_selectingBottomRight.GetRow(),
|
||||
m_selectingBottomRight.GetCol() );
|
||||
m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
|
||||
m_selectingTopLeft.GetCol(),
|
||||
m_selectingBottomRight.GetRow(),
|
||||
m_selectingBottomRight.GetCol() );
|
||||
if (m_winCapture)
|
||||
{
|
||||
m_winCapture->ReleaseMouse();
|
||||
|
@@ -147,9 +147,10 @@ void wxGridSelection::SetSelectionMode(wxGrid::wxGridSelectionModes selmode)
|
||||
else // selmode == wxGridSelectColumns)
|
||||
SelectCol( col );
|
||||
}
|
||||
while( ( n = m_blockSelectionTopLeft.GetCount() ) > 0)
|
||||
|
||||
for (n = 0; n < m_blockSelectionTopLeft.GetCount(); n++)
|
||||
// Note that m_blockSelectionTopLeft's size may be changing!
|
||||
{
|
||||
n--;
|
||||
wxGridCellCoords& coords = m_blockSelectionTopLeft[n];
|
||||
int topRow = coords.GetRow();
|
||||
int leftCol = coords.GetCol();
|
||||
@@ -177,6 +178,7 @@ void wxGridSelection::SetSelectionMode(wxGrid::wxGridSelectionModes selmode)
|
||||
}
|
||||
}
|
||||
}
|
||||
m_selectionMode = selmode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,9 +459,15 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol, int bottomRow, int r
|
||||
void wxGridSelection::SelectCell( int row, int col)
|
||||
{
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectRows )
|
||||
{
|
||||
SelectBlock(row, 0, row, m_grid->GetNumberCols() - 1 );
|
||||
return;
|
||||
}
|
||||
else if ( m_selectionMode == wxGrid::wxGridSelectColumns )
|
||||
{
|
||||
SelectBlock(0, col, m_grid->GetNumberRows() - 1, col );
|
||||
return;
|
||||
}
|
||||
else if ( IsInSelection ( row, col ) )
|
||||
return;
|
||||
m_cellSelection.Add( wxGridCellCoords( row, col ) );
|
||||
|
Reference in New Issue
Block a user