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

Public Member Functions

 FP_GRID_TRICKS (DIALOG_EDIT_LIBRARY_TABLES *aParent, wxGrid *aGrid)
 

Protected Member Functions

void optionsEditor (int aRow)
 
bool handleDoubleClick (wxGridEvent &aEvent) override
 
void showPopupMenu (wxMenu &menu) override
 
void doPopupSelection (wxCommandEvent &event) override
 
void paste_text (const wxString &cb_text) override
 handle specialized clipboard text, with leading "(fp_lib_table", OR spreadsheet formatted text. More...
 
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)
 
bool toggleCell (int aRow, int aCol)
 
bool showEditor (int aRow, int aCol)
 
virtual void paste_clipboard ()
 
virtual void cutcopy (bool doCut)
 

Static Protected Member Functions

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

Protected Attributes

DIALOG_EDIT_LIBRARY_TABLESm_dialog
 
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 155 of file panel_fp_lib_table.cpp.

Constructor & Destructor Documentation

FP_GRID_TRICKS::FP_GRID_TRICKS ( DIALOG_EDIT_LIBRARY_TABLES aParent,
wxGrid *  aGrid 
)
inline

Definition at line 158 of file panel_fp_lib_table.cpp.

158  :
159  GRID_TRICKS( aGrid ),
160  m_dialog( aParent )
161  { }
GRID_TRICKS(wxGrid *aGrid)
Definition: grid_tricks.cpp:39
DIALOG_EDIT_LIBRARY_TABLES * m_dialog

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 FP_GRID_TRICKS::doPopupSelection ( wxCommandEvent &  event)
inlineoverrideprotectedvirtual

Reimplemented from GRID_TRICKS.

Definition at line 209 of file panel_fp_lib_table.cpp.

References GRID_TRICKS::doPopupSelection(), and MYID_OPTIONS_EDITOR.

210  {
211  if( event.GetId() == MYID_OPTIONS_EDITOR )
212  optionsEditor( m_grid->GetGridCursorRow() );
213  else
215  }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
#define MYID_OPTIONS_EDITOR
void optionsEditor(int aRow)
virtual void doPopupSelection(wxCommandEvent &event)
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 FP_GRID_TRICKS::handleDoubleClick ( wxGridEvent &  aEvent)
inlineoverrideprotectedvirtual

Reimplemented from GRID_TRICKS.

Definition at line 187 of file panel_fp_lib_table.cpp.

References COL_OPTIONS.

188  {
189  if( aEvent.GetCol() == COL_OPTIONS )
190  {
191  optionsEditor( aEvent.GetRow() );
192  return true;
193  }
194 
195  return false;
196  }
void optionsEditor(int aRow)
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 FP_GRID_TRICKS::optionsEditor ( int  aRow)
inlineprotected

Definition at line 166 of file panel_fp_lib_table.cpp.

References FP_LIB_TABLE_GRID::at(), LIB_TABLE_ROW::GetNickName(), LIB_TABLE_GRID::GetNumberRows(), LIB_TABLE_ROW::GetOptions(), LIB_TABLE_ROW::GetType(), InvokePluginOptionsEditor(), and LIB_TABLE_ROW::SetOptions().

167  {
168  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
169 
170  if( tbl->GetNumberRows() > aRow )
171  {
172  LIB_TABLE_ROW* row = tbl->at( (size_t) aRow );
173  const wxString& options = row->GetOptions();
174  wxString result = options;
175 
176  InvokePluginOptionsEditor( m_dialog, row->GetNickName(), row->GetType(), options,
177  &result );
178 
179  if( options != result )
180  {
181  row->SetOptions( result );
182  m_grid->Refresh();
183  }
184  }
185  }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
void InvokePluginOptionsEditor(wxWindow *aCaller, const wxString &aNickname, const wxString &aPluginType, const wxString &aOptions, wxString *aResult)
Function InvokePluginOptionsEditor calls DIALOG_FP_PLUGIN_OPTIONS dialog so that plugin options set c...
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE...
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
virtual const wxString GetType() const =0
Return the type of library represented by this row.
int GetNumberRows() override
DIALOG_EDIT_LIBRARY_TABLES * m_dialog
const wxString & GetNickName() const
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
void SetOptions(const wxString &aOptions)
Change the library options strings.
LIB_TABLE_ROW * at(size_t aIndex) override
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 FP_GRID_TRICKS::paste_text ( const wxString &  cb_text)
inlineoverrideprotectedvirtual

handle specialized clipboard text, with leading "(fp_lib_table", OR spreadsheet formatted text.

Reimplemented from GRID_TRICKS.

Definition at line 219 of file panel_fp_lib_table.cpp.

References LIB_TABLE_GRID::AppendRows(), LIB_TABLE::At(), DisplayError(), LIB_TABLE::GetCount(), LIB_TABLE_GRID::GetNumberRows(), i, FP_LIB_TABLE::Parse(), GRID_TRICKS::paste_text(), LIB_TABLE::rows, TO_UTF8, and IO_ERROR::What().

220  {
221  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
222  size_t ndx = cb_text.find( "(fp_lib_table" );
223 
224  if( ndx != std::string::npos )
225  {
226  // paste the FP_LIB_TABLE_ROWs of s-expression (fp_lib_table), starting
227  // at column 0 regardless of current cursor column.
228 
229  STRING_LINE_READER slr( TO_UTF8( cb_text ), "Clipboard" );
230  LIB_TABLE_LEXER lexer( &slr );
231  FP_LIB_TABLE tmp_tbl;
232  bool parsed = true;
233 
234  try
235  {
236  tmp_tbl.Parse( &lexer );
237  }
238  catch( PARSE_ERROR& pe )
239  {
240  DisplayError( m_dialog, pe.What() );
241  parsed = false;
242  }
243 
244  if( parsed )
245  {
246  // make sure the table is big enough...
247  if( tmp_tbl.GetCount() > tbl->GetNumberRows() )
248  tbl->AppendRows( tmp_tbl.GetCount() - tbl->GetNumberRows() );
249 
250  for( int i = 0; i < tmp_tbl.GetCount(); ++i )
251  tbl->rows.replace( i, tmp_tbl.At( i ) );
252  }
253 
254  m_grid->AutoSizeColumns( false );
255  }
256  else
257  {
258  // paste spreadsheet formatted text.
259  GRID_TRICKS::paste_text( cb_text );
260 
261  m_grid->AutoSizeColumns( false );
262  }
263  }
int GetCount()
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
LIB_TABLE_ROW * At(int aIndex)
LIB_TABLE_ROWS rows
int GetNumberRows() override
virtual void paste_text(const wxString &cb_text)
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
virtual void Parse(LIB_TABLE_LEXER *aLexer) override
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objec...
DIALOG_EDIT_LIBRARY_TABLES * m_dialog
bool AppendRows(size_t aNumRows=1) override
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct PARSE_ERROR contains a filename or source description, a problem input line, a line number, a byte offset, and an error message which contains the the caller&#39;s report and his call site information: CPP source file, function, and line number.
Definition: ki_exception.h:123
size_t i
Definition: json11.cpp:597
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
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 FP_GRID_TRICKS::showPopupMenu ( wxMenu &  menu)
inlineoverrideprotectedvirtual

Reimplemented from GRID_TRICKS.

Definition at line 198 of file panel_fp_lib_table.cpp.

References COL_OPTIONS, MYID_OPTIONS_EDITOR, and GRID_TRICKS::showPopupMenu().

199  {
200  if( m_grid->GetGridCursorCol() == COL_OPTIONS )
201  {
202  menu.Append( MYID_OPTIONS_EDITOR, _( "Options Editor..." ), _( "Edit options" ) );
203  menu.AppendSeparator();
204  }
205 
207  }
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
#define MYID_OPTIONS_EDITOR
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_EDIT_LIBRARY_TABLES* FP_GRID_TRICKS::m_dialog
protected

Definition at line 164 of file panel_fp_lib_table.cpp.

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: