KiCad PCB EDA Suite
FIELDS_EDITOR_GRID_TRICKS Class Reference
Inheritance diagram for FIELDS_EDITOR_GRID_TRICKS:
GRID_TRICKS

Public Member Functions

 FIELDS_EDITOR_GRID_TRICKS (DIALOG_SHIM *aParent, wxGrid *aGrid, wxDataViewListCtrl *aFieldsCtrl)
 

Protected Member Functions

void showPopupMenu (wxMenu &menu) override
 
void doPopupSelection (wxCommandEvent &event) override
 
void getSelectedArea ()
 Puts the selected area into a sensible rectangle of m_sel_{row,col}_{start,count} above. More...
 
void onGridCellLeftClick (wxGridEvent &event)
 
void onGridCellLeftDClick (wxGridEvent &event)
 
void onGridCellRightClick (wxGridEvent &event)
 
void onGridLabelRightClick (wxGridEvent &event)
 
void onPopupSelection (wxCommandEvent &event)
 
void onKeyDown (wxKeyEvent &ev)
 
void onMouseUp (wxMouseEvent &aEvent)
 
void onUpdateUI (wxUpdateUIEvent &event)
 
virtual bool handleDoubleClick (wxGridEvent &aEvent)
 
bool toggleCell (int aRow, int aCol)
 
bool showEditor (int aRow, int aCol)
 
virtual void paste_clipboard ()
 
virtual void paste_text (const wxString &cb_text)
 
virtual void cutcopy (bool doCut)
 

Static Protected Member Functions

static bool isCtl (int aChar, const wxKeyEvent &e)
 

Protected Attributes

DIALOG_SHIMm_dlg
 
wxDataViewListCtrl * m_fieldsCtrl
 
wxGrid * m_grid
 I don't own the grid, but he owns me. More...
 
int m_sel_row_start
 
int m_sel_col_start
 
int m_sel_row_count
 
int m_sel_col_count
 
bool m_showEditorOnMouseUp
 

Detailed Description

Definition at line 53 of file dialog_fields_editor_global.cpp.

Constructor & Destructor Documentation

FIELDS_EDITOR_GRID_TRICKS::FIELDS_EDITOR_GRID_TRICKS ( DIALOG_SHIM aParent,
wxGrid *  aGrid,
wxDataViewListCtrl *  aFieldsCtrl 
)
inline

Definition at line 56 of file dialog_fields_editor_global.cpp.

57  :
58  GRID_TRICKS( aGrid ),
59  m_dlg( aParent ),
60  m_fieldsCtrl( aFieldsCtrl )
61  {}
GRID_TRICKS(wxGrid *aGrid)
Definition: grid_tricks.cpp:39

Member Function Documentation

void GRID_TRICKS::cutcopy ( bool  doCut)
protectedvirtualinherited

Definition at line 413 of file grid_tricks.cpp.

References COL_SEP, GRID_TRICKS::m_grid, GRID_TRICKS::m_sel_col_count, GRID_TRICKS::m_sel_col_start, GRID_TRICKS::m_sel_row_count, GRID_TRICKS::m_sel_row_start, and ROW_SEP.

Referenced by GRID_TRICKS::doPopupSelection(), GRID_TRICKS::isCtl(), and GRID_TRICKS::onKeyDown().

414 {
415  if( wxTheClipboard->Open() )
416  {
417  wxGridTableBase* tbl = m_grid->GetTable();
418  wxString txt;
419 
420  // fill txt with a format that is compatible with most spreadsheets
421  for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row )
422  {
423  for( int col = m_sel_col_start; col < m_sel_col_start + m_sel_col_count; ++col )
424  {
425  txt += tbl->GetValue( row, col );
426 
427  if( col < m_sel_col_start + m_sel_col_count - 1 ) // that was not last column
428  txt += COL_SEP;
429 
430  if( doCut )
431  tbl->SetValue( row, col, wxEmptyString );
432  }
433  txt += ROW_SEP;
434  }
435 
436  wxTheClipboard->SetData( new wxTextDataObject( txt ) );
437  wxTheClipboard->Close();
438 
439  if( doCut )
440  m_grid->ForceRefresh();
441  }
442 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
int m_sel_row_count
Definition: grid_tricks.h:64
int m_sel_col_start
Definition: grid_tricks.h:63
int m_sel_col_count
Definition: grid_tricks.h:65
int m_sel_row_start
Definition: grid_tricks.h:62
#define ROW_SEP
Definition: grid_tricks.cpp:36
#define COL_SEP
Definition: grid_tricks.cpp:35
void FIELDS_EDITOR_GRID_TRICKS::doPopupSelection ( wxCommandEvent &  event)
inlineoverrideprotectedvirtual

Reimplemented from GRID_TRICKS.

Definition at line 80 of file dialog_fields_editor_global.cpp.

References DATASHEET, KIWAY_PLAYER::Destroy(), GRID_TRICKS::doPopupSelection(), FOOTPRINT, FRAME_PCB_MODULE_VIEWER_MODAL, GetAssociatedDocument(), GRIDTRICKS_FIRST_SHOWHIDE, GRIDTRICKS_LAST_ID, i, KIWAY_HOLDER::Kiway(), m_dlg, m_fieldsCtrl, GRID_TRICKS::m_grid, MYID_SELECT_FOOTPRINT, MYID_SHOW_DATASHEET, KIWAY::Player(), ResolveUriByEnvVars(), and KIWAY_PLAYER::ShowModal().

81  {
82  if( event.GetId() == MYID_SELECT_FOOTPRINT )
83  {
84  // pick a footprint using the footprint picker.
85  wxString fpid = m_grid->GetCellValue( m_grid->GetGridCursorRow(), FOOTPRINT );
87 
88  if( frame->ShowModal( &fpid, m_dlg ) )
89  m_grid->SetCellValue( m_grid->GetGridCursorRow(), FOOTPRINT, fpid );
90 
91  frame->Destroy();
92  }
93  else if (event.GetId() == MYID_SHOW_DATASHEET )
94  {
95  wxString datasheet_uri = m_grid->GetCellValue( m_grid->GetGridCursorRow(), DATASHEET );
96  datasheet_uri = ResolveUriByEnvVars( datasheet_uri );
97  GetAssociatedDocument( m_dlg, datasheet_uri );
98  }
99  else
100  {
102  }
103 
104  if( event.GetId() >= GRIDTRICKS_FIRST_SHOWHIDE && event.GetId() < GRIDTRICKS_LAST_ID )
105  {
106  // Refresh Show checkboxes from grid columns
107  for( int i = 0; i < m_fieldsCtrl->GetItemCount(); ++i )
108  m_fieldsCtrl->SetToggleValue( m_grid->IsColShown( i ), i, 1 );
109  }
110  }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
name of datasheet
const wxString ResolveUriByEnvVars(const wxString &aUri)
Replace any environment variables in file-path uris (leaving network-path URIs alone).
Definition: common.cpp:456
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:87
Field Name Module PCB, i.e. "16DIP300".
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
virtual void doPopupSelection(wxCommandEvent &event)
size_t i
Definition: json11.cpp:597
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
VTBL_ENTRY bool ShowModal(wxString *aResult=NULL, wxWindow *aResultantFocusWindow=NULL)
Function ShowModal puts up this wxFrame as if it were a modal dialog, with all other instantiated wxF...
void GRID_TRICKS::getSelectedArea ( )
protectedinherited

Puts the selected area into a sensible rectangle of m_sel_{row,col}_{start,count} above.

Definition at line 174 of file grid_tricks.cpp.

References GRID_TRICKS::m_grid, GRID_TRICKS::m_sel_col_count, GRID_TRICKS::m_sel_col_start, GRID_TRICKS::m_sel_row_count, and GRID_TRICKS::m_sel_row_start.

Referenced by GRID_TRICKS::onKeyDown(), and GRID_TRICKS::showPopupMenu().

175 {
176  wxGridCellCoordsArray topLeft = m_grid->GetSelectionBlockTopLeft();
177  wxGridCellCoordsArray botRight = m_grid->GetSelectionBlockBottomRight();
178 
179  wxArrayInt cols = m_grid->GetSelectedCols();
180  wxArrayInt rows = m_grid->GetSelectedRows();
181 
182  if( topLeft.Count() && botRight.Count() )
183  {
184  m_sel_row_start = topLeft[0].GetRow();
185  m_sel_col_start = topLeft[0].GetCol();
186 
187  m_sel_row_count = botRight[0].GetRow() - m_sel_row_start + 1;
188  m_sel_col_count = botRight[0].GetCol() - m_sel_col_start + 1;
189  }
190  else if( cols.Count() )
191  {
192  m_sel_col_start = cols[0];
193  m_sel_col_count = cols.Count();
194  m_sel_row_start = 0;
195  m_sel_row_count = m_grid->GetNumberRows();
196  }
197  else if( rows.Count() )
198  {
199  m_sel_col_start = 0;
200  m_sel_col_count = m_grid->GetNumberCols();
201  m_sel_row_start = rows[0];
202  m_sel_row_count = rows.Count();
203  }
204  else
205  {
206  m_sel_row_start = m_grid->GetGridCursorRow();
207  m_sel_col_start = m_grid->GetGridCursorCol();
208  m_sel_row_count = m_sel_row_start >= 0 ? 1 : 0;
209  m_sel_col_count = m_sel_col_start >= 0 ? 1 : 0;
210  }
211 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
int m_sel_row_count
Definition: grid_tricks.h:64
int m_sel_col_start
Definition: grid_tricks.h:63
int m_sel_col_count
Definition: grid_tricks.h:65
int m_sel_row_start
Definition: grid_tricks.h:62
bool GRID_TRICKS::handleDoubleClick ( wxGridEvent &  aEvent)
protectedvirtualinherited

Reimplemented in FP_GRID_TRICKS.

Definition at line 167 of file grid_tricks.cpp.

Referenced by GRID_TRICKS::isCtl(), and GRID_TRICKS::onGridCellLeftDClick().

168 {
169  // Double-click processing must be handled by specific sub-classes
170  return false;
171 }
void GRID_TRICKS::onGridCellLeftClick ( wxGridEvent &  event)
protectedinherited

Definition at line 120 of file grid_tricks.cpp.

References GRID_TRICKS::showEditor(), and GRID_TRICKS::toggleCell().

Referenced by GRID_TRICKS::GRID_TRICKS(), GRID_TRICKS::isCtl(), and GRID_TRICKS::onGridCellLeftDClick().

121 {
122  int row = aEvent.GetRow();
123  int col = aEvent.GetCol();
124 
125  // Don't make users click twice to toggle a checkbox or edit a text cell
126 
127  if( !aEvent.GetModifiers() )
128  {
129  if( toggleCell( row, col ) )
130  return;
131 
132  if( showEditor( row, col ) )
133  return;
134  }
135 
136  aEvent.Skip();
137 }
bool toggleCell(int aRow, int aCol)
Definition: grid_tricks.cpp:60
bool showEditor(int aRow, int aCol)
Definition: grid_tricks.cpp:98
void GRID_TRICKS::onGridCellLeftDClick ( wxGridEvent &  event)
protectedinherited

Definition at line 140 of file grid_tricks.cpp.

References GRID_TRICKS::handleDoubleClick(), and GRID_TRICKS::onGridCellLeftClick().

Referenced by GRID_TRICKS::GRID_TRICKS(), and GRID_TRICKS::isCtl().

141 {
142  if( !handleDoubleClick( aEvent ) )
143  onGridCellLeftClick( aEvent );
144 }
void onGridCellLeftClick(wxGridEvent &event)
virtual bool handleDoubleClick(wxGridEvent &aEvent)
void GRID_TRICKS::onGridCellRightClick ( wxGridEvent &  event)
protectedinherited

Definition at line 214 of file grid_tricks.cpp.

References GRID_TRICKS::showPopupMenu().

Referenced by GRID_TRICKS::GRID_TRICKS(), and GRID_TRICKS::isCtl().

215 {
216  wxMenu menu;
217 
218  showPopupMenu( menu );
219 }
virtual void showPopupMenu(wxMenu &menu)
void GRID_TRICKS::onGridLabelRightClick ( wxGridEvent &  event)
protectedinherited

Definition at line 222 of file grid_tricks.cpp.

References GRIDTRICKS_FIRST_SHOWHIDE, i, and GRID_TRICKS::m_grid.

Referenced by GRID_TRICKS::GRID_TRICKS(), and GRID_TRICKS::isCtl().

223 {
224  wxMenu menu;
225 
226  for( int i = 0; i < m_grid->GetNumberCols(); ++i )
227  {
228  int id = GRIDTRICKS_FIRST_SHOWHIDE + i;
229  menu.AppendCheckItem( id, m_grid->GetColLabelValue( i ) );
230  menu.Check( id, m_grid->IsColShown( i ) );
231  }
232 
233  m_grid->PopupMenu( &menu );
234 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
size_t i
Definition: json11.cpp:597
void GRID_TRICKS::onKeyDown ( wxKeyEvent &  ev)
protectedinherited

Definition at line 309 of file grid_tricks.cpp.

References GRID_TRICKS::cutcopy(), GRID_TRICKS::getSelectedArea(), GRID_TRICKS::isCtl(), GRID_TRICKS::m_grid, GRID_TRICKS::paste_clipboard(), and GRID_TRICKS::toggleCell().

Referenced by GRID_TRICKS::GRID_TRICKS(), and GRID_TRICKS::isCtl().

310 {
311  if( isCtl( 'A', ev ) )
312  {
313  m_grid->SelectAll();
314  return;
315  }
316  else if( isCtl( 'C', ev ) )
317  {
318  getSelectedArea();
319  cutcopy( false );
320  return;
321  }
322  else if( isCtl( 'V', ev ) )
323  {
324  getSelectedArea();
325  paste_clipboard();
326  return;
327  }
328  else if( isCtl( 'X', ev ) )
329  {
330  getSelectedArea();
331  cutcopy( true );
332  return;
333  }
334 
335  // space-bar toggling of checkboxes
336  if( ev.GetKeyCode() == ' ' )
337  {
338  int row = m_grid->GetGridCursorRow();
339  int col = m_grid->GetGridCursorCol();
340 
341  if( m_grid->IsVisible( row, col ) && toggleCell( row, col ) )
342  return;
343  }
344 
345  // shift-return for OK
346  if( ev.GetKeyCode() == WXK_RETURN && ev.ShiftDown() )
347  {
348  wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
349  return;
350  }
351 
352  ev.Skip( true );
353 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
void getSelectedArea()
Puts the selected area into a sensible rectangle of m_sel_{row,col}_{start,count} above...
static bool isCtl(int aChar, const wxKeyEvent &e)
Definition: grid_tricks.h:72
bool toggleCell(int aRow, int aCol)
Definition: grid_tricks.cpp:60
virtual void paste_clipboard()
virtual void cutcopy(bool doCut)
void GRID_TRICKS::onMouseUp ( wxMouseEvent &  aEvent)
protectedinherited

Definition at line 147 of file grid_tricks.cpp.

References GRID_TRICKS::m_grid, and GRID_TRICKS::m_showEditorOnMouseUp.

Referenced by GRID_TRICKS::GRID_TRICKS(), and GRID_TRICKS::isCtl().

148 {
150  {
151  // Some wxGridCellEditors don't have the SetInSetFocus() hack. Even when they do,
152  // it sometimes fails. Activating the control here seems to avoid those issues.
153  if( m_grid->CanEnableCellControl() )
154  {
155  // Yes, the first of these also shows the control. Well, at least sometimes.
156  // The second call corrects those (as yet undefined) "other times".
157  m_grid->EnableCellEditControl();
158  m_grid->ShowCellEditControl();
159  }
160  m_showEditorOnMouseUp = false;
161  }
162  else
163  aEvent.Skip();
164 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
bool m_showEditorOnMouseUp
Definition: grid_tricks.h:67
void GRID_TRICKS::onPopupSelection ( wxCommandEvent &  event)
protectedinherited

Definition at line 267 of file grid_tricks.cpp.

References GRID_TRICKS::doPopupSelection().

Referenced by GRID_TRICKS::GRID_TRICKS(), and GRID_TRICKS::isCtl().

268 {
269  doPopupSelection( event );
270 }
virtual void doPopupSelection(wxCommandEvent &event)
void GRID_TRICKS::onUpdateUI ( wxUpdateUIEvent &  event)
protectedinherited

Definition at line 445 of file grid_tricks.cpp.

References GRID_TRICKS::m_grid.

Referenced by GRID_TRICKS::GRID_TRICKS(), and GRID_TRICKS::isCtl().

446 {
447  // Respect ROW selectionMode when moving cursor
448 
449  if( m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows )
450  {
451  int cursorRow = m_grid->GetGridCursorRow();
452  bool cursorInSelectedRow = false;
453 
454  for( int row : m_grid->GetSelectedRows() )
455  {
456  if( row == cursorRow )
457  {
458  cursorInSelectedRow = true;
459  break;
460  }
461  }
462 
463  if( !cursorInSelectedRow )
464  m_grid->SelectRow( cursorRow );
465  }
466 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
void GRID_TRICKS::paste_clipboard ( )
protectedvirtualinherited

Definition at line 356 of file grid_tricks.cpp.

References GRID_TRICKS::m_grid, and GRID_TRICKS::paste_text().

Referenced by GRID_TRICKS::doPopupSelection(), GRID_TRICKS::isCtl(), and GRID_TRICKS::onKeyDown().

357 {
358  if( wxTheClipboard->Open() )
359  {
360  if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
361  {
362  wxTextDataObject data;
363 
364  wxTheClipboard->GetData( data );
365 
366  paste_text( data.GetText() );
367  }
368 
369  wxTheClipboard->Close();
370  m_grid->ForceRefresh();
371  }
372 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
virtual void paste_text(const wxString &cb_text)
void GRID_TRICKS::paste_text ( const wxString &  cb_text)
protectedvirtualinherited

Reimplemented in FP_GRID_TRICKS, and SYMBOL_GRID_TRICKS.

Definition at line 375 of file grid_tricks.cpp.

References COL_SEP, GRID_TRICKS::m_grid, and ROW_SEP.

Referenced by GRID_TRICKS::isCtl(), GRID_TRICKS::paste_clipboard(), SYMBOL_GRID_TRICKS::paste_text(), and FP_GRID_TRICKS::paste_text().

376 {
377  wxGridTableBase* tbl = m_grid->GetTable();
378 
379  const int cur_row = m_grid->GetGridCursorRow();
380  const int cur_col = m_grid->GetGridCursorCol();
381 
382  if( cur_row < 0 || cur_col < 0 )
383  {
384  wxBell();
385  return;
386  }
387 
388  wxStringTokenizer rows( cb_text, ROW_SEP, wxTOKEN_RET_EMPTY );
389 
390  // if clipboard rows would extend past end of current table size...
391  if( int( rows.CountTokens() ) > tbl->GetNumberRows() - cur_row )
392  {
393  int newRowsNeeded = rows.CountTokens() - ( tbl->GetNumberRows() - cur_row );
394 
395  tbl->AppendRows( newRowsNeeded );
396  }
397 
398  for( int row = cur_row; rows.HasMoreTokens(); ++row )
399  {
400  wxString rowTxt = rows.GetNextToken();
401 
402  wxStringTokenizer cols( rowTxt, COL_SEP, wxTOKEN_RET_EMPTY );
403 
404  for( int col = cur_col; cols.HasMoreTokens(); ++col )
405  {
406  wxString cellTxt = cols.GetNextToken();
407  tbl->SetValue( row, col, cellTxt );
408  }
409  }
410 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
#define ROW_SEP
Definition: grid_tricks.cpp:36
#define COL_SEP
Definition: grid_tricks.cpp:35
bool GRID_TRICKS::showEditor ( int  aRow,
int  aCol 
)
protectedinherited

Definition at line 98 of file grid_tricks.cpp.

References GRID_TRICKS::m_grid, and GRID_TRICKS::m_showEditorOnMouseUp.

Referenced by GRID_TRICKS::isCtl(), and GRID_TRICKS::onGridCellLeftClick().

99 {
100  if( m_grid->IsEditable() && !m_grid->IsReadOnly( aRow, aCol ) )
101  {
102  if( m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows )
103  m_grid->SelectRow( aRow );
104 
105  m_grid->SetGridCursor( aRow, aCol );
106 
107  // For several reasons we can't enable the control here. There's the whole
108  // SetInSetFocus() issue/hack in wxWidgets, and there's also wxGrid's MouseUp
109  // handler which doesn't notice it's processing a MouseUp until after it has
110  // disabled the editor yet again. So we wait for the MouseUp.
111  m_showEditorOnMouseUp = true;
112 
113  return true;
114  }
115 
116  return false;
117 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
bool m_showEditorOnMouseUp
Definition: grid_tricks.h:67
void FIELDS_EDITOR_GRID_TRICKS::showPopupMenu ( wxMenu &  menu)
inlineoverrideprotectedvirtual

Reimplemented from GRID_TRICKS.

Definition at line 64 of file dialog_fields_editor_global.cpp.

References DATASHEET, FOOTPRINT, GRID_TRICKS::m_grid, MYID_SELECT_FOOTPRINT, MYID_SHOW_DATASHEET, and GRID_TRICKS::showPopupMenu().

65  {
66  if( m_grid->GetGridCursorCol() == FOOTPRINT )
67  {
68  menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ), _( "Browse for footprint" ) );
69  menu.AppendSeparator();
70  }
71  else if( m_grid->GetGridCursorCol() == DATASHEET )
72  {
73  menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ), _( "Show datasheet in browser" ) );
74  menu.AppendSeparator();
75  }
76 
78  }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
name of datasheet
Field Name Module PCB, i.e. "16DIP300".
virtual void showPopupMenu(wxMenu &menu)
bool GRID_TRICKS::toggleCell ( int  aRow,
int  aCol 
)
protectedinherited

Definition at line 60 of file grid_tricks.cpp.

References GRID_TRICKS::m_grid.

Referenced by GRID_TRICKS::isCtl(), GRID_TRICKS::onGridCellLeftClick(), and GRID_TRICKS::onKeyDown().

61 {
62  auto renderer = m_grid->GetCellRenderer( aRow, aCol );
63  bool isCheckbox = ( dynamic_cast<wxGridCellBoolRenderer*>( renderer ) != nullptr );
64  renderer->DecRef();
65 
66  if( isCheckbox )
67  {
68  wxGridTableBase* model = m_grid->GetTable();
69 
70  if( model->CanGetValueAs( aRow, aCol, wxGRID_VALUE_BOOL )
71  && model->CanSetValueAs( aRow, aCol, wxGRID_VALUE_BOOL ))
72  {
73  model->SetValueAsBool( aRow, aCol, !model->GetValueAsBool( aRow, aCol ));
74  }
75  else // fall back to string processing
76  {
77  if( model->GetValue( aRow, aCol ) == wxT( "1" ) )
78  model->SetValue( aRow, aCol, wxT( "0" ) );
79  else
80  model->SetValue( aRow, aCol, wxT( "1" ) );
81  }
82 
83  // Mac needs this for the keyboard events; Linux appears to always need it.
84  m_grid->ForceRefresh();
85 
86  // Let any clients know
87  wxGridEvent event( m_grid->GetId(), wxEVT_GRID_CELL_CHANGED, m_grid, aRow, aCol );
88  event.SetString( model->GetValue( aRow, aCol ) );
89  m_grid->GetEventHandler()->ProcessEvent( event );
90 
91  return true;
92  }
93 
94  return false;
95 }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58

Member Data Documentation

DIALOG_SHIM* FIELDS_EDITOR_GRID_TRICKS::m_dlg
protected

Definition at line 112 of file dialog_fields_editor_global.cpp.

Referenced by doPopupSelection().

wxDataViewListCtrl* FIELDS_EDITOR_GRID_TRICKS::m_fieldsCtrl
protected

Definition at line 113 of file dialog_fields_editor_global.cpp.

Referenced by doPopupSelection().

int GRID_TRICKS::m_sel_col_count
protectedinherited
int GRID_TRICKS::m_sel_col_start
protectedinherited
int GRID_TRICKS::m_sel_row_count
protectedinherited
int GRID_TRICKS::m_sel_row_start
protectedinherited
bool GRID_TRICKS::m_showEditorOnMouseUp
protectedinherited

The documentation for this class was generated from the following file: