X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f07941fc73d4f263a33e767263c4da507ba9bc54..ddc80eb4eb7e96ff23ebe329283bb2b940dd1df2:/samples/grid/griddemo.cpp?ds=sidebyside diff --git a/samples/grid/griddemo.cpp b/samples/grid/griddemo.cpp index 2857b714fc..9464900565 100644 --- a/samples/grid/griddemo.cpp +++ b/samples/grid/griddemo.cpp @@ -74,6 +74,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame ) EVT_MENU( ID_TOGGLEROWSIZING, GridFrame::ToggleRowSizing ) EVT_MENU( ID_TOGGLECOLSIZING, GridFrame::ToggleColSizing ) EVT_MENU( ID_TOGGLEGRIDSIZING, GridFrame::ToggleGridSizing ) + EVT_MENU( ID_TOGGLEGRIDDRAGCELL, GridFrame::ToggleGridDragCell ) EVT_MENU( ID_TOGGLEGRIDLINES, GridFrame::ToggleGridLines ) EVT_MENU( ID_AUTOSIZECOLS, GridFrame::AutoSizeCols ) EVT_MENU( ID_CELLOVERFLOW, GridFrame::CellOverflow ) @@ -124,6 +125,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame ) EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell ) EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected ) EVT_GRID_CELL_CHANGE( GridFrame::OnCellValueChanged ) + EVT_GRID_CELL_BEGIN_DRAG( GridFrame::OnCellBeginDrag ) EVT_GRID_EDITOR_SHOWN( GridFrame::OnEditorShown ) EVT_GRID_EDITOR_HIDDEN( GridFrame::OnEditorHidden ) @@ -149,6 +151,7 @@ GridFrame::GridFrame() viewMenu->Append( ID_TOGGLEROWSIZING, _T("Ro&w drag-resize"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLECOLSIZING, _T("C&ol drag-resize"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLEGRIDSIZING, _T("&Grid drag-resize"), wxEmptyString, wxITEM_CHECK ); + viewMenu->Append( ID_TOGGLEGRIDDRAGCELL, _T("&Grid drag-cell"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLEGRIDLINES, _T("&Grid Lines"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_SET_HIGHLIGHT_WIDTH, _T("&Set Cell Highlight Width...") ); viewMenu->Append( ID_SET_RO_HIGHLIGHT_WIDTH, _T("&Set Cell RO Highlight Width...") ); @@ -348,6 +351,7 @@ GridFrame::GridFrame() wxEXPAND ); #endif // wxUSE_LOG + SetAutoLayout(true); SetSizer( topSizer ); topSizer->Fit( this ); @@ -373,6 +377,7 @@ void GridFrame::SetDefaults() GetMenuBar()->Check( ID_TOGGLEROWSIZING, true ); GetMenuBar()->Check( ID_TOGGLECOLSIZING, true ); GetMenuBar()->Check( ID_TOGGLEGRIDSIZING, true ); + GetMenuBar()->Check( ID_TOGGLEGRIDDRAGCELL, false ); GetMenuBar()->Check( ID_TOGGLEGRIDLINES, true ); GetMenuBar()->Check( ID_CELLOVERFLOW, true ); } @@ -430,6 +435,11 @@ void GridFrame::ToggleGridSizing( wxCommandEvent& WXUNUSED(ev) ) GetMenuBar()->IsChecked( ID_TOGGLEGRIDSIZING ) ); } +void GridFrame::ToggleGridDragCell( wxCommandEvent& WXUNUSED(ev) ) +{ + grid->EnableDragCell( + GetMenuBar()->IsChecked( ID_TOGGLEGRIDDRAGCELL ) ); +} void GridFrame::ToggleGridLines( wxCommandEvent& WXUNUSED(ev) ) { @@ -712,7 +722,8 @@ void GridFrame::SetCellBgColour( wxCommandEvent& WXUNUSED(ev) ) { // Check the new Refresh function by passing it a rectangle // which exactly fits the grid. - wxRect r(wxPoint(0, 0), grid->GetSize()); + wxPoint pt(0, 0); + wxRect r(pt, grid->GetSize()); grid->SetDefaultCellBackgroundColour(col); grid->Refresh(true, &r); } @@ -875,6 +886,18 @@ void GridFrame::OnCellValueChanged( wxGridEvent& ev ) ev.Skip(); } +void GridFrame::OnCellBeginDrag( wxGridEvent& ev ) +{ + logBuf = _T(""); + logBuf << _T("Got request to drag cell at") + << _T(" row ") << ev.GetRow() + << _T(" col ") << ev.GetCol(); + + wxLogMessage( wxT("%s"), logBuf.c_str() ); + + ev.Skip(); +} + void GridFrame::OnEditorShown( wxGridEvent& ev ) { @@ -1327,10 +1350,6 @@ wxString BugsGridTable::GetColLabelValue( int col ) return headers[col]; } -BugsGridTable::BugsGridTable() -{ -} - // ---------------------------------------------------------------------------- // BugsGridFrame // ----------------------------------------------------------------------------