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, WX_GRID *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 onGridLabelLeftClick (wxGridEvent &event)
 
void onGridLabelRightClick (wxGridEvent &event)
 
void onPopupSelection (wxCommandEvent &event)
 
void onKeyDown (wxKeyEvent &ev)
 
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
 
WX_GRIDm_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
 

Detailed Description

Definition at line 225 of file panel_fp_lib_table.cpp.

Constructor & Destructor Documentation

◆ FP_GRID_TRICKS()

FP_GRID_TRICKS::FP_GRID_TRICKS ( DIALOG_EDIT_LIBRARY_TABLES aParent,
WX_GRID aGrid 
)
inline

Definition at line 228 of file panel_fp_lib_table.cpp.

228  :
229  GRID_TRICKS( aGrid ),
230  m_dialog( aParent )
231  { }
GRID_TRICKS(WX_GRID *aGrid)
Definition: grid_tricks.cpp:39
DIALOG_EDIT_LIBRARY_TABLES * m_dialog

Member Function Documentation

◆ cutcopy()

void GRID_TRICKS::cutcopy ( bool  doCut)
protectedvirtualinherited

Definition at line 505 of file grid_tricks.cpp.

506 {
507  if( wxTheClipboard->Open() )
508  {
509  wxGridTableBase* tbl = m_grid->GetTable();
510  wxString txt;
511 
512  // fill txt with a format that is compatible with most spreadsheets
513  for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row )
514  {
515  for( int col = m_sel_col_start; col < m_sel_col_start + m_sel_col_count; ++col )
516  {
517  txt += tbl->GetValue( row, col );
518 
519  if( col < m_sel_col_start + m_sel_col_count - 1 ) // that was not last column
520  txt += COL_SEP;
521 
522  if( doCut )
523  tbl->SetValue( row, col, wxEmptyString );
524  }
525  txt += ROW_SEP;
526  }
527 
528  wxTheClipboard->SetData( new wxTextDataObject( txt ) );
529  wxTheClipboard->Close();
530 
531  if( doCut )
532  m_grid->ForceRefresh();
533  }
534 }
int m_sel_row_count
Definition: grid_tricks.h:64
int m_sel_col_start
Definition: grid_tricks.h:63
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
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

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(), and GRID_TRICKS::onKeyDown().

◆ doPopupSelection()

void FP_GRID_TRICKS::doPopupSelection ( wxCommandEvent &  event)
inlineoverrideprotectedvirtual

Reimplemented from GRID_TRICKS.

Definition at line 279 of file panel_fp_lib_table.cpp.

280  {
281  if( event.GetId() == MYID_OPTIONS_EDITOR )
282  optionsEditor( m_grid->GetGridCursorRow() );
283  else
285  }
#define MYID_OPTIONS_EDITOR
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
void optionsEditor(int aRow)
virtual void doPopupSelection(wxCommandEvent &event)

References GRID_TRICKS::doPopupSelection(), GRID_TRICKS::m_grid, MYID_OPTIONS_EDITOR, and optionsEditor().

◆ getSelectedArea()

void GRID_TRICKS::getSelectedArea ( )
protectedinherited

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

Definition at line 167 of file grid_tricks.cpp.

168 {
169  wxGridCellCoordsArray topLeft = m_grid->GetSelectionBlockTopLeft();
170  wxGridCellCoordsArray botRight = m_grid->GetSelectionBlockBottomRight();
171 
172  wxArrayInt cols = m_grid->GetSelectedCols();
173  wxArrayInt rows = m_grid->GetSelectedRows();
174 
175  if( topLeft.Count() && botRight.Count() )
176  {
177  m_sel_row_start = topLeft[0].GetRow();
178  m_sel_col_start = topLeft[0].GetCol();
179 
180  m_sel_row_count = botRight[0].GetRow() - m_sel_row_start + 1;
181  m_sel_col_count = botRight[0].GetCol() - m_sel_col_start + 1;
182  }
183  else if( cols.Count() )
184  {
185  m_sel_col_start = cols[0];
186  m_sel_col_count = cols.Count();
187  m_sel_row_start = 0;
188  m_sel_row_count = m_grid->GetNumberRows();
189  }
190  else if( rows.Count() )
191  {
192  m_sel_col_start = 0;
193  m_sel_col_count = m_grid->GetNumberCols();
194  m_sel_row_start = rows[0];
195  m_sel_row_count = rows.Count();
196  }
197  else
198  {
199  m_sel_row_start = m_grid->GetGridCursorRow();
200  m_sel_col_start = m_grid->GetGridCursorCol();
201  m_sel_row_count = m_sel_row_start >= 0 ? 1 : 0;
202  m_sel_col_count = m_sel_col_start >= 0 ? 1 : 0;
203  }
204 }
int m_sel_row_count
Definition: grid_tricks.h:64
int m_sel_col_start
Definition: grid_tricks.h:63
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
int m_sel_col_count
Definition: grid_tricks.h:65
int m_sel_row_start
Definition: grid_tricks.h:62

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().

◆ handleDoubleClick()

bool FP_GRID_TRICKS::handleDoubleClick ( wxGridEvent &  aEvent)
inlineoverrideprotectedvirtual

Reimplemented from GRID_TRICKS.

Definition at line 257 of file panel_fp_lib_table.cpp.

258  {
259  if( aEvent.GetCol() == COL_OPTIONS )
260  {
261  optionsEditor( aEvent.GetRow() );
262  return true;
263  }
264 
265  return false;
266  }
void optionsEditor(int aRow)

References COL_OPTIONS, and optionsEditor().

◆ isCtl()

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

Definition at line 70 of file grid_tricks.h.

71  {
72  return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() && !e.ShiftDown() && !e.MetaDown();
73  }

Referenced by GRID_TRICKS::onKeyDown().

◆ onGridCellLeftClick()

void GRID_TRICKS::onGridCellLeftClick ( wxGridEvent &  event)
protectedinherited

Definition at line 134 of file grid_tricks.cpp.

135 {
136  int row = aEvent.GetRow();
137  int col = aEvent.GetCol();
138 
139  // Don't make users click twice to toggle a checkbox or edit a text cell
140  if( !aEvent.GetModifiers() )
141  {
142  if( toggleCell( row, col ) )
143  return;
144 
145  if( showEditor( row, col ) )
146  return;
147  }
148 
149  aEvent.Skip();
150 }
bool toggleCell(int aRow, int aCol)
Definition: grid_tricks.cpp:58
bool showEditor(int aRow, int aCol)
Definition: grid_tricks.cpp:99

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

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

◆ onGridCellLeftDClick()

void GRID_TRICKS::onGridCellLeftDClick ( wxGridEvent &  event)
protectedinherited

Definition at line 153 of file grid_tricks.cpp.

154 {
155  if( !handleDoubleClick( aEvent ) )
156  onGridCellLeftClick( aEvent );
157 }
void onGridCellLeftClick(wxGridEvent &event)
virtual bool handleDoubleClick(wxGridEvent &aEvent)

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

Referenced by GRID_TRICKS::GRID_TRICKS().

◆ onGridCellRightClick()

void GRID_TRICKS::onGridCellRightClick ( wxGridEvent &  event)
protectedinherited

Definition at line 207 of file grid_tricks.cpp.

208 {
209  wxMenu menu;
210 
211  showPopupMenu( menu );
212 }
virtual void showPopupMenu(wxMenu &menu)

References GRID_TRICKS::showPopupMenu().

Referenced by GRID_TRICKS::GRID_TRICKS().

◆ onGridLabelLeftClick()

void GRID_TRICKS::onGridLabelLeftClick ( wxGridEvent &  event)
protectedinherited

Definition at line 215 of file grid_tricks.cpp.

216 {
218 
219  aEvent.Skip();
220 }
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:172

References WX_GRID::CommitPendingChanges(), and GRID_TRICKS::m_grid.

Referenced by GRID_TRICKS::GRID_TRICKS().

◆ onGridLabelRightClick()

void GRID_TRICKS::onGridLabelRightClick ( wxGridEvent &  event)
protectedinherited

Definition at line 223 of file grid_tricks.cpp.

224 {
225  wxMenu menu;
226 
227  for( int i = 0; i < m_grid->GetNumberCols(); ++i )
228  {
229  int id = GRIDTRICKS_FIRST_SHOWHIDE + i;
230  menu.AppendCheckItem( id, m_grid->GetColLabelValue( i ) );
231  menu.Check( id, m_grid->IsColShown( i ) );
232  }
233 
234  m_grid->PopupMenu( &menu );
235 }
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58

References GRIDTRICKS_FIRST_SHOWHIDE, and GRID_TRICKS::m_grid.

Referenced by GRID_TRICKS::GRID_TRICKS().

◆ onKeyDown()

void GRID_TRICKS::onKeyDown ( wxKeyEvent &  ev)
protectedinherited

Definition at line 310 of file grid_tricks.cpp.

311 {
312  if( isCtl( 'A', ev ) )
313  {
314  m_grid->SelectAll();
315  return;
316  }
317  else if( isCtl( 'C', ev ) )
318  {
319  getSelectedArea();
320  cutcopy( false );
321  return;
322  }
323  else if( isCtl( 'V', ev ) )
324  {
325  getSelectedArea();
326  paste_clipboard();
327  return;
328  }
329  else if( isCtl( 'X', ev ) )
330  {
331  getSelectedArea();
332  cutcopy( true );
333  return;
334  }
335 
336  // space-bar toggling of checkboxes
337  if( ev.GetKeyCode() == ' ' )
338  {
339  int row = m_grid->GetGridCursorRow();
340  int col = m_grid->GetGridCursorCol();
341 
342  if( m_grid->IsVisible( row, col ) && toggleCell( row, col ) )
343  return;
344  }
345 
346  // ctrl-tab for exit grid
347 #ifdef __APPLE__
348  bool ctrl = ev.RawControlDown();
349 #else
350  bool ctrl = ev.ControlDown();
351 #endif
352 
353  if( ctrl && ev.GetKeyCode() == WXK_TAB )
354  {
355  wxWindow* test = m_grid->GetNextSibling();
356 
357  if( !test )
358  test = m_grid->GetParent()->GetNextSibling();
359 
360  while( test && !test->IsTopLevel() )
361  {
362  test->SetFocus();
363 
364  if( test->HasFocus() )
365  break;
366 
367  if( !test->GetChildren().empty() )
368  test = test->GetChildren().front();
369  else if( test->GetNextSibling() )
370  test = test->GetNextSibling();
371  else
372  {
373  while( test )
374  {
375  test = test->GetParent();
376 
377  if( test && test->IsTopLevel() )
378  {
379  break;
380  }
381  else if( test && test->GetNextSibling() )
382  {
383  test = test->GetNextSibling();
384  break;
385  }
386  }
387  }
388  }
389 
390  return;
391  }
392 
393  ev.Skip( true );
394 }
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:70
bool toggleCell(int aRow, int aCol)
Definition: grid_tricks.cpp:58
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
virtual void paste_clipboard()
virtual void cutcopy(bool doCut)

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().

◆ onPopupSelection()

void GRID_TRICKS::onPopupSelection ( wxCommandEvent &  event)
protectedinherited

Definition at line 268 of file grid_tricks.cpp.

269 {
270  doPopupSelection( event );
271 }
virtual void doPopupSelection(wxCommandEvent &event)

References GRID_TRICKS::doPopupSelection().

Referenced by GRID_TRICKS::GRID_TRICKS().

◆ onUpdateUI()

void GRID_TRICKS::onUpdateUI ( wxUpdateUIEvent &  event)
protectedinherited

Definition at line 537 of file grid_tricks.cpp.

538 {
539  // Respect ROW selectionMode when moving cursor
540 
541  if( m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows )
542  {
543  int cursorRow = m_grid->GetGridCursorRow();
544  bool cursorInSelectedRow = false;
545 
546  for( int row : m_grid->GetSelectedRows() )
547  {
548  if( row == cursorRow )
549  {
550  cursorInSelectedRow = true;
551  break;
552  }
553  }
554 
555  if( !cursorInSelectedRow && cursorRow >= 0 )
556  m_grid->SelectRow( cursorRow );
557  }
558 }
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58

References GRID_TRICKS::m_grid.

Referenced by GRID_TRICKS::GRID_TRICKS().

◆ optionsEditor()

void FP_GRID_TRICKS::optionsEditor ( int  aRow)
inlineprotected

Definition at line 236 of file panel_fp_lib_table.cpp.

237  {
238  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
239 
240  if( tbl->GetNumberRows() > aRow )
241  {
242  LIB_TABLE_ROW* row = tbl->at( (size_t) aRow );
243  const wxString& options = row->GetOptions();
244  wxString result = options;
245 
246  InvokePluginOptionsEditor( m_dialog, row->GetNickName(), row->GetType(), options,
247  &result );
248 
249  if( options != result )
250  {
251  row->SetOptions( result );
252  m_grid->Refresh();
253  }
254  }
255  }
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
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.
virtual const wxString GetType() const =0
Return the type of library represented by this row.
int GetNumberRows() override
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
const wxString & GetNickName() const
DIALOG_EDIT_LIBRARY_TABLES * m_dialog
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

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

Referenced by doPopupSelection(), and handleDoubleClick().

◆ paste_clipboard()

void GRID_TRICKS::paste_clipboard ( )
protectedvirtualinherited

Definition at line 397 of file grid_tricks.cpp.

398 {
399  if( wxTheClipboard->Open() )
400  {
401  if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
402  {
403  wxTextDataObject data;
404 
405  wxTheClipboard->GetData( data );
406 
407  paste_text( data.GetText() );
408  }
409 
410  wxTheClipboard->Close();
411  m_grid->ForceRefresh();
412  }
413 }
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
virtual void paste_text(const wxString &cb_text)

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

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

◆ paste_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 289 of file panel_fp_lib_table.cpp.

290  {
291  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
292  size_t ndx = cb_text.find( "(fp_lib_table" );
293 
294  if( ndx != std::string::npos )
295  {
296  // paste the FP_LIB_TABLE_ROWs of s-expression (fp_lib_table), starting
297  // at column 0 regardless of current cursor column.
298 
299  STRING_LINE_READER slr( TO_UTF8( cb_text ), "Clipboard" );
300  LIB_TABLE_LEXER lexer( &slr );
301  FP_LIB_TABLE tmp_tbl;
302  bool parsed = true;
303 
304  try
305  {
306  tmp_tbl.Parse( &lexer );
307  }
308  catch( PARSE_ERROR& pe )
309  {
310  DisplayError( m_dialog, pe.What() );
311  parsed = false;
312  }
313 
314  if( parsed )
315  {
316  // make sure the table is big enough...
317  if( tmp_tbl.GetCount() > (unsigned) tbl->GetNumberRows() )
318  tbl->AppendRows( tmp_tbl.GetCount() - tbl->GetNumberRows() );
319 
320  for( unsigned i = 0; i < tmp_tbl.GetCount(); ++i )
321  tbl->rows.replace( i, tmp_tbl.At( i ).clone() );
322  }
323 
324  m_grid->AutoSizeColumns( false );
325  }
326  else
327  {
328  // paste spreadsheet formatted text.
329  GRID_TRICKS::paste_text( cb_text );
330 
331  m_grid->AutoSizeColumns( false );
332  }
333  }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
unsigned GetCount() const
Get the number of rows contained in the table.
LIB_TABLE_ROWS rows
int GetNumberRows() override
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
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:48
LIB_TABLE_ROW * clone() const
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...
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
DIALOG_EDIT_LIBRARY_TABLES * m_dialog
bool AppendRows(size_t aNumRows=1) override
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254

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

◆ showEditor()

bool GRID_TRICKS::showEditor ( int  aRow,
int  aCol 
)
protectedinherited

Definition at line 99 of file grid_tricks.cpp.

100 {
101  if( m_grid->GetGridCursorRow() != aRow || m_grid->GetGridCursorCol() != aCol )
102  m_grid->SetGridCursor( aRow, aCol );
103 
104  if( m_grid->IsEditable() && !m_grid->IsReadOnly( aRow, aCol ) )
105  {
106  m_grid->ClearSelection();
107 
108  if( m_grid->GetSelectionMode() == wxGrid::wxGridSelectRows )
109  {
110  wxArrayInt rows = m_grid->GetSelectedRows();
111 
112  if( rows.size() != 1 || rows.Item( 0 ) != aRow )
113  m_grid->SelectRow( aRow );
114  }
115 
116  // For several reasons we can't enable the control here. There's the whole
117  // SetInSetFocus() issue/hack in wxWidgets, and there's also wxGrid's MouseUp
118  // handler which doesn't notice it's processing a MouseUp until after it has
119  // disabled the editor yet again. So we re-use wxWidgets' slow-click hack,
120  // which is processed later in the MouseUp handler.
121  //
122  // It should be pointed out that the fact that it's wxWidgets' hack doesn't
123  // make it any less of a hack. Be extra careful with any modifications here.
124  // See, in particular, https://bugs.launchpad.net/kicad/+bug/1817965.
126 
127  return true;
128  }
129 
130  return false;
131 }
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
void ShowEditorOnMouseUp()
WxWidgets has a bunch of bugs in its handling of wxGrid mouse events which close cell editors right a...
Definition: wx_grid.h:99

References GRID_TRICKS::m_grid, and WX_GRID::ShowEditorOnMouseUp().

Referenced by GRID_TRICKS::onGridCellLeftClick().

◆ showPopupMenu()

void FP_GRID_TRICKS::showPopupMenu ( wxMenu &  menu)
inlineoverrideprotectedvirtual

Reimplemented from GRID_TRICKS.

Definition at line 268 of file panel_fp_lib_table.cpp.

269  {
270  if( m_grid->GetGridCursorCol() == COL_OPTIONS )
271  {
272  menu.Append( MYID_OPTIONS_EDITOR, _( "Options Editor..." ), _( "Edit options" ) );
273  menu.AppendSeparator();
274  }
275 
277  }
#define MYID_OPTIONS_EDITOR
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
virtual void showPopupMenu(wxMenu &menu)
#define _(s)
Definition: 3d_actions.cpp:31

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

◆ toggleCell()

bool GRID_TRICKS::toggleCell ( int  aRow,
int  aCol 
)
protectedinherited

Definition at line 58 of file grid_tricks.cpp.

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

References GRID_TRICKS::m_grid.

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

Member Data Documentation

◆ m_dialog

DIALOG_EDIT_LIBRARY_TABLES* FP_GRID_TRICKS::m_dialog
protected

Definition at line 234 of file panel_fp_lib_table.cpp.

Referenced by optionsEditor(), and paste_text().

◆ m_grid

◆ m_sel_col_count

int GRID_TRICKS::m_sel_col_count
protectedinherited

◆ m_sel_col_start

int GRID_TRICKS::m_sel_col_start
protectedinherited

◆ m_sel_row_count

int GRID_TRICKS::m_sel_row_count
protectedinherited

◆ m_sel_row_start

int GRID_TRICKS::m_sel_row_start
protectedinherited

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