25#include <wx/tokenzr.h>
26#include <wx/clipbrd.h>
29#include <wx/stc/stc.h>
30#include <wx/textctrl.h>
31#include <wx/toplevel.h>
32#include <wx/weakref.h>
41#define COL_SEP wxT( '\t' )
42#define ROW_SEP wxT( '\n' )
43#define ROW_SEP_R wxT( '\r' )
49 return dynamic_cast<wxComboBox*
>( aControl ) ||
dynamic_cast<wxComboCtrl*
>( aControl );
55 if( wxComboBox* combo =
dynamic_cast<wxComboBox*
>( aControl ) )
57 else if( wxComboCtrl* comboCtrl =
dynamic_cast<wxComboCtrl*
>( aControl ) )
112 wxGridCellEditor*
editor =
m_grid->GetCellEditor( aRow, aCol );
113 bool retval = (
dynamic_cast<wxGridCellTextEditor*
>(
editor )
124 wxGridCellEditor*
editor =
m_grid->GetCellEditor( aRow, aCol );
125 bool retval = (
dynamic_cast<wxGridCellChoiceEditor*
>(
editor )
136 wxGridCellRenderer* renderer =
m_grid->GetCellRenderer( aRow, aCol );
137 bool retval = (
dynamic_cast<wxGridCellBoolRenderer*
>( renderer ) );
146 return !
m_grid->IsEditable() ||
m_grid->IsReadOnly( aRow, aCol );
159 const wxString oldValue =
m_grid->GetCellValue( aRow, aCol );
160 const wxString newValue = oldValue == wxT(
"1" ) ? wxT(
"0" ) : wxT(
"1" );
161 wxGridEvent changing(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGING,
m_grid, aRow, aCol );
162 changing.SetString( newValue );
163 m_grid->GetEventHandler()->ProcessEvent( changing );
165 if( !changing.IsAllowed() )
168 m_grid->SetCellValue( aRow, aCol, newValue );
170 wxGridEvent changed(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, aRow, aCol );
171 changed.SetString( oldValue );
172 m_grid->GetEventHandler()->ProcessEvent( changed );
174 if( !changed.IsAllowed() )
175 m_grid->SetCellValue( aRow, aCol, oldValue );
181 if( !aPreserveSelection )
184 m_grid->SetGridCursor( aRow, aCol );
189 if(
model->CanGetValueAs( aRow, aCol, wxGRID_VALUE_BOOL )
190 &&
model->CanSetValueAs( aRow, aCol, wxGRID_VALUE_BOOL ) )
192 model->SetValueAsBool( aRow, aCol, !
model->GetValueAsBool( aRow, aCol ) );
196 if(
model->GetValue( aRow, aCol ) == wxT(
"1" ) )
197 model->SetValue( aRow, aCol, wxT(
"0" ) );
199 model->SetValue( aRow, aCol, wxT(
"1" ) );
206 wxGridEvent event(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, aRow, aCol );
207 event.SetString(
model->GetValue( aRow, aCol ) );
208 m_grid->GetEventHandler()->ProcessEvent( event );
221 if(
m_grid->GetGridCursorRow() != aRow ||
m_grid->GetGridCursorCol() != aCol )
222 m_grid->SetGridCursor( aRow, aCol );
230 if( !
m_grid->IsInSelection( aRow, aCol ) )
231 m_grid->SelectBlock( aRow, aCol, aRow, aCol );
233 for(
const wxGridBlockCoords& block :
m_grid->GetSelectedBlocks() )
246 if(
rows.size() != 1 ||
rows.Item( 0 ) != aRow )
247 m_grid->SelectRow( aRow );
259 m_grid->ShowEditorOnMouseUp();
270 int row = aEvent.GetRow();
271 int col = aEvent.GetCol();
274 if( !aEvent.GetModifiers() )
279 m_grid->SetGridCursor( row, col );
280 m_grid->SelectBlock( row, col, row, col );
283 bool toggled =
false;
311 wxString newVal =
m_grid->GetCellValue( row, col );
315 if( otherRow == row )
318 m_grid->SetCellValue( otherRow, col, newVal );
339 const int row = aEvent.GetRow();
340 const int col = aEvent.GetCol();
341 std::vector<int> selectedRows;
348 else if(
m_grid->IsInSelection( row, col ) )
350 for(
int otherRow = 0; otherRow <
m_grid->GetNumberRows(); ++otherRow )
352 if(
m_grid->IsInSelection( otherRow, col ) )
353 selectedRows.push_back( otherRow );
358 GetNextHandler()->ProcessEvent( aEvent );
359 aEvent.Skip(
false );
361 if( !aEvent.IsAllowed() )
364 for(
int otherRow : selectedRows )
366 if( otherRow == row || otherRow >=
m_grid->GetNumberRows() ||
isReadOnly( otherRow, col ) )
371 wxGridEvent changing(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGING,
m_grid, otherRow, col );
372 changing.SetString( aEvent.GetString() );
373 GetNextHandler()->ProcessEvent( changing );
375 if( !changing.IsAllowed() )
394 wxWindow* control = aEvent.GetWindow();
413 std::vector<wxGridBlockCoords> selection = std::move(
m_bulkEditor.Selection );
414 m_bulkEditor.Begin( wxGridCellCoords( aEvent.GetRow(), aEvent.GetCol() ) );
416 for(
const wxGridBlockCoords& block : selection )
417 m_grid->SelectBlock( block.GetTopRow(), block.GetLeftCol(), block.GetBottomRow(), block.GetRightCol(),
true );
419 const int row = aEvent.GetRow();
420 const int col = aEvent.GetCol();
424 for(
int otherRow = 0; otherRow <
m_grid->GetNumberRows(); ++otherRow )
426 if(
m_grid->IsInSelection( otherRow, col ) )
439 if( aEvent.GetEventType() == wxEVT_TEXT )
446 const int row =
m_grid->GetGridCursorRow();
447 const int col =
m_grid->GetGridCursorCol();
451 if( aEvent.GetEventType() == wxEVT_TEXT &&
dynamic_cast<wxTextCtrl*
>( aEvent.GetEventObject() ) )
453 if(
m_bulkEditor.TextInitialized || aEvent.GetString() !=
m_grid->GetCellValue( row, col ) )
458 else if( aEvent.GetEventType() == wxEVT_COMBOBOX || aEvent.GetString() !=
m_grid->GetCellValue( row, col ) )
463 if( aEvent.GetEventType() == wxEVT_COMBOBOX
476 if(
m_columnBulkEditEnabled && ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER ) )
485 comboCtrl->GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent( aEvent );
491 switch( aEvent.GetKeyCode() )
498 case WXK_PAGEDOWN:
m_bulkEditor.KeyboardNavigation =
true;
break;
501 case WXK_NUMPAD_ENTER:
finishEditor(
false,
true );
return;
522 wxWindow* control =
dynamic_cast<wxWindow*
>( aEvent.GetEventObject() );
523 wxCHECK_RET( control, wxT(
"Missing grid dropdown control" ) );
528 [control = wxWeakRef<wxWindow>( control )]()
557 const unsigned int generation =
m_bulkEditor.Generation;
560 [
this,
grid, generation]()
571 const bool enter = key.GetKeyCode() == WXK_RETURN || key.GetKeyCode() == WXK_NUMPAD_ENTER;
572 const bool committed =
finishEditor( key.GetKeyCode() == WXK_ESCAPE, enter && !key.GetModifiers() );
574 if( committed && enter && key.GetModifiers() == wxMOD_SHIFT )
576 if( wxTopLevelWindow* window =
dynamic_cast<wxTopLevelWindow*
>( wxGetTopLevelParent(
m_grid ) ) )
578 wxWindow* button = window->GetDefaultItem();
580 if( button && button->IsEnabled() )
582 wxCommandEvent accept( wxEVT_BUTTON, button->GetId() );
583 accept.SetEventObject( button );
584 wxPostEvent( button, accept );
594 || ( aEnterKey.GetKeyCode() != WXK_RETURN && aEnterKey.GetKeyCode() != WXK_NUMPAD_ENTER ) )
600 wxComboCtrl* comboCtrl =
dynamic_cast<wxComboCtrl*
>(
editor->GetWindow() );
604 return comboCtrl && comboCtrl->IsPopupShown() ? comboCtrl :
nullptr;
615 const int row =
m_grid->GetGridCursorRow();
616 const int col =
m_grid->GetGridCursorCol();
617 int nextRow = row + 1;
621 while( nextRow < m_grid->GetNumberRows()
622 && (
m_grid->IsInSelection( nextRow, col ) || !
m_grid->IsRowShown( nextRow ) ) )
628 wxGridCellEditor*
editor =
m_grid->GetCellEditor( row, col );
632 bool committed =
false;
638 m_grid->CancelPendingChanges();
642 committed =
m_grid->CommitPendingChanges();
647 if( committed && aMoveDown && nextRow < m_grid->GetNumberRows() )
649 m_grid->GoToCell( nextRow, col );
651 if(
m_grid->GetGridCursorRow() == nextRow &&
m_grid->GetGridCursorCol() == col )
652 m_grid->SelectBlock( nextRow, col, nextRow, col );
668 const int row = aEvent.GetRow();
669 const int col = aEvent.GetCol();
670 wxGridCellEditor*
editor =
m_grid->GetCellEditor( row, col );
672 if( !
editor->IsCreated() )
680 const wxString value =
editor->GetValue();
691 GetNextHandler()->ProcessEvent( aEvent );
692 aEvent.Skip(
false );
694 if( !aEvent.IsAllowed() )
700 if( value !=
m_grid->GetCellValue( row, col ) )
706 wxGridEvent changing(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGING,
m_grid, row, col );
707 changing.SetString( value );
708 m_grid->GetEventHandler()->ProcessEvent( changing );
710 if( !changing.IsAllowed() )
720 wxGridEvent changed(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, row, col );
721 changed.SetString( value );
722 m_grid->GetEventHandler()->ProcessEvent( changed );
724 if( !changed.IsAllowed() )
735 const int col = aEvent.GetCol();
736 const wxString sourceOldValue = aEvent.GetString();
737 std::vector<std::pair<int, wxString>>
rows;
740 wxGridUpdateLocker lock(
m_grid );
742 for(
const auto& [row, oldValue] :
rows )
747 for(
const auto& [row, oldValue] :
rows )
749 wxGridEvent changed(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, row, col );
750 changed.SetString( oldValue );
751 GetNextHandler()->ProcessEvent( changed );
753 if( !changed.IsAllowed() )
762 GetNextHandler()->ProcessEvent( aEvent );
763 allowed = aEvent.IsAllowed();
766 aEvent.Skip(
false );
770 for(
const auto& [row, oldValue] :
rows )
771 m_grid->SetCellValue( row, col, oldValue );
773 m_grid->SetCellValue( aEvent.GetRow(), col, sourceOldValue );
778 m_grid->EvaluateCell( aEvent.GetRow(), col );
780 for(
const auto& [row, oldValue] :
rows )
781 m_grid->EvaluateCell( row, col );
804 wxPoint pt = aEvent.GetPosition();
805 wxPoint pos =
m_grid->CalcUnscrolledPosition( wxPoint( pt.x, pt.y ) );
807 int col =
m_grid->XToCol( pos.x );
808 int row =
m_grid->YToRow( pos.y );
813 m_grid->GetGridWindow()->SetToolTip( wxS(
"" ) );
818 m_grid->GetGridWindow()->SetToolTip(
m_grid->GetCellValue( row, col ) );
833 int firstRow =
m_grid->GetNumberRows();
834 int firstCol =
m_grid->GetNumberCols();
838 for(
const wxGridBlockCoords& block :
m_grid->GetSelectedBlocks() )
840 firstRow = std::min( firstRow, block.GetTopRow() );
841 firstCol = std::min( firstCol, block.GetLeftCol() );
842 lastRow = std::max( lastRow, block.GetBottomRow() );
843 lastCol = std::max( lastCol, block.GetRightCol() );
853 wxGridCellCoordsArray topLeft =
m_grid->GetSelectionBlockTopLeft();
854 wxGridCellCoordsArray botRight =
m_grid->GetSelectionBlockBottomRight();
856 wxArrayInt cols =
m_grid->GetSelectedCols();
859 if( topLeft.Count() && botRight.Count() )
867 else if( cols.Count() )
874 else if(
rows.Count() )
897 int row = aEvent.GetRow();
899 if(
m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows )
901 wxArrayInt selectedRows =
m_grid->GetSelectedRows();
903 if( selectedRows.Index( row ) == wxNOT_FOUND )
908 if( !
m_grid->IsInSelection( row, aEvent.GetCol() ) )
910 m_grid->SetGridCursor( row, aEvent.GetCol() );
913 m_grid->SelectBlock( row, aEvent.GetCol(), row, aEvent.GetCol() );
925 m_grid->CommitPendingChanges();
935 for(
int i = 0; i <
m_grid->GetNumberCols(); ++i )
938 menu.AppendCheckItem(
id,
m_grid->GetColLabelValue( i ) );
939 menu.Check(
id,
m_grid->IsColShown( i ) );
942 m_grid->PopupMenu( &menu );
949 _(
"Clear selected cells placing original contents on clipboard" ) );
951 _(
"Copy selected cells to clipboard" ) );
956 _(
"Paste clipboard cells to matrix at current cell" ) );
958 _(
"Clear contents of selected cells" ) );
962 _(
"Select all cells" ) );
970 auto anyCellsWritable =
988 if( anyCellsWritable() )
998 if( wxTheClipboard->Open() )
1000 if( wxTheClipboard->IsSupported( wxDF_TEXT )
1001 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
1003 if(
m_grid->IsEditable() )
1007 wxTheClipboard->Close();
1011 m_grid->PopupMenu( &menu );
1023 int menu_id =
event.GetId();
1055 if(
m_grid->IsColShown( col ) )
1066 bool handled =
false;
1081 && ( ev.GetKeyCode() == WXK_RETURN || ev.GetKeyCode() == WXK_NUMPAD_ENTER ) )
1083 const int row =
m_grid->GetGridCursorRow();
1084 const int col =
m_grid->GetGridCursorCol();
1086 if(
m_grid->IsCellEditControlEnabled() )
1092 wxCommandEvent
dummy;
1095 else if( row >= 0 && col >= 0 && !
isReadOnly( row, col ) )
1097 if( !
m_grid->IsInSelection( row, col ) )
1098 m_grid->SelectBlock( row, col, row, col );
1101 m_grid->EnableCellEditControl();
1104 if(
m_grid->IsCellEditControlEnabled() )
1106 wxGridCellEditor*
editor =
m_grid->GetCellEditor( row, col );
1110 if( wxComboBox* combo =
dynamic_cast<wxComboBox*
>(
editor->GetWindow() ) )
1112 auto handler =
static_cast<wxGridCellEditorEvtHandler*
>( combo->GetEventHandler() );
1114 handler->SetInSetFocus(
true );
1116 handler->SetInSetFocus(
false );
1127 else if( ( ev.GetKeyCode() == WXK_RETURN || ev.GetKeyCode() == WXK_NUMPAD_ENTER ) && ev.GetModifiers() == wxMOD_NONE
1128 &&
m_grid->GetGridCursorRow() ==
m_grid->GetNumberRows() - 1 )
1130 if(
m_grid->IsCellEditControlShown() )
1132 if(
m_grid->CommitPendingChanges() )
1139 wxCommandEvent
dummy;
1146 else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() ==
'C' )
1148 if(
m_grid->IsCellEditControlShown() )
1150 wxTextEntry* te =
dynamic_cast<wxTextEntry*
>( ev.GetEventObject() );
1154 wxString selectedText = te->GetStringSelection();
1156 if( !selectedText.IsEmpty() )
1160 if( wxTheClipboard->Open() )
1162 wxTheClipboard->SetData(
new wxTextDataObject( selectedText ) );
1163 wxTheClipboard->Flush();
1164 wxTheClipboard->Close();
1172 m_grid->CancelPendingChanges();
1179 else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() ==
'V' )
1181 if(
m_grid->IsCellEditControlShown() )
1185 if( wxTheClipboard->Open() )
1187 if( wxTheClipboard->IsSupported( wxDF_TEXT )
1188 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
1190 wxTextDataObject data;
1191 wxTheClipboard->GetData( data );
1192 wxString
text = data.GetText();
1196 if( hasMultipleCells )
1203 wxTextEntry* te =
dynamic_cast<wxTextEntry*
>( ev.GetEventObject() );
1205 if( te && te->IsEditable() )
1207 te->WriteText(
text );
1212 m_grid->CancelPendingChanges();
1219 wxTheClipboard->Close();
1224 else if( ev.GetKeyCode() == WXK_ESCAPE )
1226 if(
m_grid->IsCellEditControlShown() )
1231 m_grid->CancelPendingChanges();
1245 && ( ev.GetKeyCode() == WXK_RETURN || ev.GetKeyCode() == WXK_NUMPAD_ENTER ) )
1250 else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() ==
'A' )
1255 else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() ==
'C' )
1261 else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() ==
'V' )
1267 else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() ==
'X' )
1273 else if( !ev.GetModifiers() && ev.GetKeyCode() == WXK_DELETE )
1281 if(
m_grid->IsEditable() && ev.GetKeyCode() ==
' ' )
1285 const int row =
m_grid->GetGridCursorRow();
1286 const int col =
m_grid->GetGridCursorCol();
1288 if( row >= 0 && col >= 0 &&
toggleCell( row, col,
true ) )
1295 bool retVal =
false;
1298 if(
m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows )
1300 wxArrayInt rowSel =
m_grid->GetSelectedRows();
1302 for(
unsigned int rowInd = 0; rowInd < rowSel.GetCount(); rowInd++ )
1303 retVal |=
toggleCell( rowSel[rowInd], 0,
true );
1307 else if(
m_grid->GetSelectionMode() == wxGrid::wxGridSelectColumns )
1309 wxArrayInt colSel =
m_grid->GetSelectedCols();
1311 for(
unsigned int colInd = 0; colInd < colSel.GetCount(); colInd++ )
1312 retVal |=
toggleCell( 0, colSel[colInd],
true );
1316 else if(
m_grid->GetSelectionMode() == wxGrid::wxGridSelectCells )
1318 wxArrayInt rowSel =
m_grid->GetSelectedRows();
1319 wxArrayInt colSel =
m_grid->GetSelectedCols();
1320 wxGridCellCoordsArray cellSel =
m_grid->GetSelectedCells();
1321 wxGridCellCoordsArray topLeft =
m_grid->GetSelectionBlockTopLeft();
1322 wxGridCellCoordsArray botRight =
m_grid->GetSelectionBlockBottomRight();
1325 for(
unsigned int cellInd = 0; cellInd < cellSel.GetCount(); cellInd++ )
1327 retVal |=
toggleCell( cellSel[cellInd].GetRow(), cellSel[cellInd].GetCol(),
true );
1331 for(
unsigned int colInd = 0; colInd < colSel.GetCount(); colInd++ )
1333 for(
int row = 0; row <
m_grid->GetNumberRows(); row++ )
1334 retVal |=
toggleCell( row, colSel[colInd],
true );
1338 for(
unsigned int rowInd = 0; rowInd < rowSel.GetCount(); rowInd++ )
1340 for(
int col = 0; col <
m_grid->GetNumberCols(); col++ )
1341 retVal |=
toggleCell( rowSel[rowInd], col,
true );
1345 for(
unsigned int blockInd = 0; blockInd < topLeft.GetCount(); blockInd++ )
1347 wxGridCellCoords start = topLeft[blockInd];
1348 wxGridCellCoords
end = botRight[blockInd];
1350 for(
int row = start.GetRow(); row <=
end.GetRow(); row++ )
1352 for(
int col = start.GetCol(); col <=
end.GetCol(); col++ )
1365 bool ctrl = ev.RawControlDown();
1367 bool ctrl = ev.ControlDown();
1370 if( ctrl && ev.GetKeyCode() == WXK_TAB )
1375 test =
m_grid->GetParent()->GetNextSibling();
1377 while(
test && !
test->IsTopLevel() )
1381 if(
test->HasFocus() )
1384 if( !
test->GetChildren().empty() )
1386 test =
test->GetChildren().front();
1388 else if(
test->GetNextSibling() )
1402 else if(
test &&
test->GetNextSibling() )
1422 if(
m_grid->IsEditable() && ( wxTheClipboard->IsOpened() || wxTheClipboard->Open() ) )
1424 if( wxTheClipboard->IsSupported( wxDF_TEXT )
1425 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
1427 wxTextDataObject data;
1429 wxTheClipboard->GetData( data );
1431 wxString
text = data.GetText();
1435 text.Replace(
"\n\n",
"\n" );
1441 wxTheClipboard->Close();
1452 wxGridTableBase* tbl =
m_grid->GetTable();
1454 const int cur_row =
m_grid->GetGridCursorRow();
1455 const int cur_col =
m_grid->GetGridCursorCol();
1460 bool is_selection =
false;
1462 if( cur_row < 0 || cur_col < 0 )
1468 if(
m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows )
1471 is_selection =
true;
1475 is_selection =
true;
1478 wxStringTokenizer
rows( cb_text,
ROW_SEP, wxTOKEN_RET_EMPTY );
1493 start_row = cur_row;
1494 end_row = cur_row +
rows.CountTokens();
1496 if( end_row > tbl->GetNumberRows() )
1500 for(
int ii = end_row - tbl->GetNumberRows(); ii > 0; --ii )
1502 wxCommandEvent
dummy;
1507 end_row = tbl->GetNumberRows();
1510 start_col = cur_col;
1511 end_col = start_col;
1514 for(
int row = start_row; row < end_row; ++row )
1518 if( !
rows.HasMoreTokens() )
1519 rows.SetString( cb_text,
ROW_SEP, wxTOKEN_RET_EMPTY );
1521 wxString rowTxt =
rows.GetNextToken();
1523 wxStringTokenizer cols( rowTxt,
COL_SEP, wxTOKEN_RET_EMPTY );
1526 end_col = cur_col + cols.CountTokens();
1528 for(
int col = start_col; col < end_col && col < tbl->GetNumberCols(); ++col )
1531 if( !
m_grid->IsColShown( col ) )
1539 if( !cols.HasMoreTokens() )
1540 cols.SetString( rowTxt,
COL_SEP, wxTOKEN_RET_EMPTY );
1542 wxString cellTxt = cols.GetNextToken();
1549 if( tbl->CanSetValueAs( row, col, wxGRID_VALUE_STRING ) && !
isReadOnly( row, col ) )
1551 tbl->SetValue( row, col, cellTxt );
1553 wxGridEvent evt(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, row, col );
1554 m_grid->GetEventHandler()->ProcessEvent( evt );
1557 else if( tbl->CanSetValueAs( row, col, wxGRID_VALUE_BOOL ) )
1559 tbl->SetValueAsBool( row, col, cellTxt == wxT(
"1" ) );
1561 wxGridEvent evt(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, row, col );
1562 m_grid->GetEventHandler()->ProcessEvent( evt );
1573 if( doCopy && !wxTheClipboard->Open() )
1576 wxGridTableBase* tbl =
m_grid->GetTable();
1587 if( !
m_grid->IsColShown( col ) )
1590 const bool selected =
1594 txt += tbl->GetValue( row, col );
1599 if( doDelete && selected )
1605 bool hadContent = !tbl->GetValue( row, col ).IsEmpty();
1607 tbl->SetValue( row, col, wxEmptyString );
1611 wxGridEvent evt(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, row, col );
1612 m_grid->GetEventHandler()->ProcessEvent( evt );
1621 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
1622 wxTheClipboard->Flush();
1623 wxTheClipboard->Close();
1635 if(
m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows )
1637 int cursorRow =
m_grid->GetGridCursorRow();
1638 bool cursorInSelectedRow =
false;
1640 for(
int row :
m_grid->GetSelectedRows() )
1642 if( row == cursorRow )
1644 cursorInSelectedRow =
true;
1649 if( !cursorInSelectedRow && cursorRow >= 0 )
1650 m_grid->SelectRow( cursorRow );
bool isReadOnly(int aRow, int aCol)
wxGridCellCoords m_bulkEditSource
void onGridMotion(wxMouseEvent &event)
void onGridLabelLeftClick(wxGridEvent &event)
virtual void paste_text(const wxString &cb_text)
void init()
Shared initialization for various ctors.
void onGridEditorShown(wxGridEvent &aEvent)
std::vector< std::pair< int, wxString > > m_bulkEditRows
void getSelectedArea()
Puts the selected area into a sensible rectangle of m_sel_{row,col}_{start,count} above.
bool m_multiCellEditEnabled
GRID_TRICKS(WX_GRID *aGrid)
void onGridEditorHidden(wxGridEvent &aEvent)
bool isChoiceEditor(int aRow, int aCol)
void onKeyDown(wxKeyEvent &event)
BULK_EDIT_SESSION m_bulkEditor
void onPopupSelection(wxCommandEvent &event)
virtual void cutcopy(bool doCopy, bool doDelete)
void onEditorInput(wxCommandEvent &aEvent)
void onEditorKeyDown(wxKeyEvent &aEvent)
void onGridCellChanged(wxGridEvent &aEvent)
bool m_enableSingleClickEdit
void onGridCellChanging(wxGridEvent &aEvent)
virtual void doPopupSelection(wxCommandEvent &event)
bool isCheckbox(int aRow, int aCol)
std::function< void(wxCommandEvent &)> m_addHandler
bool m_bulkEditorEnterHandled
void onEditorDropdownOpened(wxCommandEvent &aEvent)
virtual void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent)
std::bitset< GRIDTRICKS_MAX_COL > m_tooltipEnabled
wxComboCtrl * shownGenericPopup(const wxKeyEvent &aEnterKey)
void onEditorTextEnter(wxCommandEvent &aEvent)
void onUpdateUI(wxUpdateUIEvent &event)
void onGridCellRightClick(wxGridEvent &event)
virtual void appendPopupMenuItems(wxMenu &aMenu)
WX_GRID * m_grid
I don't own the grid, but he owns me.
bool isTextEntry(int aRow, int aCol)
void onGridEditorCreated(wxGridEditorCreatedEvent &aEvent)
void onGridCellLeftDClick(wxGridEvent &event)
bool m_columnBulkEditEnabled
virtual void onGridCellLeftClick(wxGridEvent &event)
virtual bool handleDoubleClick(wxGridEvent &aEvent)
virtual void onCharHook(wxKeyEvent &event)
virtual void paste_clipboard()
bool showEditor(int aRow, int aCol)
void onEditorDropdownClosed(wxCommandEvent &aEvent)
bool finishEditor(bool aCancel, bool aMoveDown=false)
void onGridLabelRightClick(wxGridEvent &event)
virtual bool toggleCell(int aRow, int aCol, bool aPreserveSelection=false)
static void dismissDropdown(wxWindow *aControl)
static bool isDropdown(wxWindow *aControl)
@ GRIDTRICKS_FIRST_SHOWHIDE
std::vector< FAB_LAYER_COLOR > dummy
std::vector< DATABASE_CONNECTION::ROW > rows