KiCad PCB EDA Suite
DIALOG_FP_LIB_TABLE Class Reference

Class DIALOG_FP_LIB_TABLE shows and edits the PCB library tables. More...

Inheritance diagram for DIALOG_FP_LIB_TABLE:
DIALOG_FP_LIB_TABLE_BASE DIALOG_SHIM KIWAY_HOLDER

Public Member Functions

 DIALOG_FP_LIB_TABLE (wxTopLevelWindow *aParent, FP_LIB_TABLE *aGlobal, FP_LIB_TABLE *aProject)
 
 ~DIALOG_FP_LIB_TABLE ()
 
int ShowQuasiModal ()
 
void EndQuasiModal (int retCode)
 
bool IsQuasiModal ()
 
bool Show (bool show) override
 
bool Enable (bool enable) override
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Protected Member Functions

void FinishDialogSettings ()
 In all dialogs, we must call the same functions to fix minimal dlg size, the default position and perhaps some others to fix a few issues depending on Windows Managers this helper function does these calls. More...
 
void FixOSXCancelButtonIssue ()
 A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms. More...
 

Protected Attributes

wxAuiNotebook * m_auinotebook
 
wxPanel * m_global_panel
 
wxStaticText * m_staticText3
 
wxStaticText * m_GblTableFilename
 
wxGrid * m_global_grid
 
wxPanel * m_project_panel
 
wxStaticText * m_staticText4
 
wxStaticText * m_PrjTableFilename
 
wxGrid * m_project_grid
 
wxButton * m_buttonWizard
 
wxButton * m_append_button
 
wxButton * m_delete_button
 
wxButton * m_move_up_button
 
wxButton * m_move_down_button
 
wxButton * m_edit_options
 
wxGrid * m_path_subs_grid
 
wxStdDialogButtonSizer * m_sdbSizer
 
wxButton * m_sdbSizerOK
 
wxButton * m_sdbSizerCancel
 
std::string m_hash_key
 
EVENT_LOOPm_qmodal_loop
 
bool m_qmodal_showing
 
WDO_ENABLE_DISABLEm_qmodal_parent_disabler
 

Private Member Functions

int getCursorCol () const
 If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based column index. More...
 
int getCursorRow () const
 If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based row index. More...
 
bool verifyTables ()
 Function verifyTables trims important fields, removes blank row entries, and checks for duplicates. More...
 
void onKeyDown (wxKeyEvent &ev) override
 
void pageChangedHandler (wxAuiNotebookEvent &event) override
 
void appendRowHandler (wxCommandEvent &event) override
 
void deleteRowHandler (wxCommandEvent &event) override
 
void moveUpHandler (wxCommandEvent &event) override
 
void moveDownHandler (wxCommandEvent &event) override
 
void optionsEditor (wxCommandEvent &event) override
 
void OnClickLibraryWizard (wxCommandEvent &event) override
 
void onCancelButtonClick (wxCommandEvent &event) override
 
void onCancelCaptionButtonClick (wxCloseEvent &event) override
 
void onOKButtonClick (wxCommandEvent &event) override
 
void populateEnvironReadOnlyTable ()
 Populate the readonly environment variable table with names and values by examining all the full_uri columns. More...
 
FP_LIB_TABLE_GRIDglobal_model () const
 
FP_LIB_TABLE_GRIDproject_model () const
 
FP_LIB_TABLE_GRIDcur_model () const
 

Private Attributes

FP_LIB_TABLEm_global
 
FP_LIB_TABLEm_project
 
wxGrid * m_cur_grid
 changed based on tab choice More...
 

Static Private Attributes

static int m_pageNdx = 0
 Remember the last notebook page selected during a session. More...
 

Detailed Description

Class DIALOG_FP_LIB_TABLE shows and edits the PCB library tables.

Two tables are expected, one global and one project specific.

Definition at line 161 of file dialog_fp_lib_table.cpp.

Constructor & Destructor Documentation

DIALOG_FP_LIB_TABLE::DIALOG_FP_LIB_TABLE ( wxTopLevelWindow *  aParent,
FP_LIB_TABLE aGlobal,
FP_LIB_TABLE aProject 
)
inline

Definition at line 165 of file dialog_fp_lib_table.cpp.

References COL_DESCR, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, IO_MGR::EAGLE, IO_MGR::GEDA_PCB, FP_LIB_TABLE::GetGlobalTableFileName(), IO_MGR::GITHUB, IO_MGR::KICAD, IO_MGR::LEGACY, DIALOG_FP_LIB_TABLE_BASE::m_auinotebook, m_cur_grid, DIALOG_FP_LIB_TABLE_BASE::m_GblTableFilename, DIALOG_FP_LIB_TABLE_BASE::m_global_grid, m_pageNdx, DIALOG_FP_LIB_TABLE_BASE::m_PrjTableFilename, DIALOG_FP_LIB_TABLE_BASE::m_project_grid, pageChangedHandler(), populateEnvironReadOnlyTable(), KIWAY_HOLDER::Prj(), and IO_MGR::ShowType().

165  :
166  DIALOG_FP_LIB_TABLE_BASE( aParent ),
167  m_global( aGlobal ),
168  m_project( aProject )
169  {
170  // For user info, shows the table filenames:
171  m_PrjTableFilename->SetLabel( Prj().FootprintLibTblName() );
173 
174  // wxGrid only supports user owned tables if they exist past end of ~wxGrid(),
175  // so make it a grid owned table.
176  m_global_grid->SetTable( new FP_LIB_TABLE_GRID( *aGlobal ), true );
177  m_project_grid->SetTable( new FP_LIB_TABLE_GRID( *aProject ), true );
178 
179  // add Cut, Copy, and Paste to wxGrids
180  m_global_grid->PushEventHandler( new FP_GRID_TRICKS( m_global_grid ) );
181  m_project_grid->PushEventHandler( new FP_GRID_TRICKS( m_project_grid ) );
182 
183  m_global_grid->AutoSizeColumns( false );
184  m_project_grid->AutoSizeColumns( false );
185 
186  wxArrayString choices;
187 
188  choices.Add( IO_MGR::ShowType( IO_MGR::KICAD ) );
189  choices.Add( IO_MGR::ShowType( IO_MGR::GITHUB ) );
190  choices.Add( IO_MGR::ShowType( IO_MGR::LEGACY ) );
191  choices.Add( IO_MGR::ShowType( IO_MGR::EAGLE ) );
192  choices.Add( IO_MGR::ShowType( IO_MGR::GEDA_PCB ) );
193 
194  /* PCAD_PLUGIN does not support Footprint*() functions
195  choices.Add( IO_MGR::ShowType( IO_MGR::GITHUB ) );
196  */
197 
198  wxGridCellAttr* attr;
199 
200  attr = new wxGridCellAttr;
201  attr->SetEditor( new wxGridCellChoiceEditor( choices ) );
202  m_project_grid->SetColAttr( COL_TYPE, attr );
203 
204  attr = new wxGridCellAttr;
205  attr->SetEditor( new wxGridCellChoiceEditor( choices ) );
206  m_global_grid->SetColAttr( COL_TYPE, attr );
207 
209 
210  for( int i=0; i<2; ++i )
211  {
212  wxGrid* g = i==0 ? m_global_grid : m_project_grid;
213 
214  // all but COL_OPTIONS, which is edited with Option Editor anyways.
215  g->AutoSizeColumn( COL_NICKNAME, false );
216  g->AutoSizeColumn( COL_TYPE, false );
217  g->AutoSizeColumn( COL_URI, false );
218  g->AutoSizeColumn( COL_DESCR, false );
219 
220  // would set this to width of title, if it was easily known.
221  g->SetColSize( COL_OPTIONS, 80 );
222  }
223 
224  // This scrunches the dialog hideously, probably due to wxAUI container.
225  // Fit();
226  // We derive from DIALOG_SHIM so prior size will be used anyways.
227 
228  // select the last selected page
229  m_auinotebook->SetSelection( m_pageNdx );
230 
231  // fire pageChangedHandler() so m_cur_grid gets set
232  // m_auinotebook->SetSelection will generate a pageChangedHandler()
233  // event call later, but too late.
234  wxAuiNotebookEvent uneventful;
235  pageChangedHandler( uneventful );
236 
237  // Gives a selection for each grid, mainly for delete lib button.
238  // Without that, we do not see what lib will be deleted
239  m_global_grid->SelectRow( 0 );
240  m_project_grid->SelectRow( 0 );
241 
242  // for ALT+A handling, we want the initial focus to be on the first selected grid.
243  m_cur_grid->SetFocus();
244 
245  // On some windows manager (Unity, XFCE), this dialog is
246  // not always raised, depending on this dialog is run.
247  // Force it to be raised
248  Raise();
249  }
static const wxString ShowType(PCB_FILE_T aFileType)
Function ShowType returns a brief name for a plugin, given aFileType enum.
Definition: io_mgr.cpp:105
DIALOG_FP_LIB_TABLE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("PCB Library Tables"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(717, 600), long style=wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU)
Geda PCB file formats.
Definition: io_mgr.h:57
void populateEnvironReadOnlyTable()
Populate the readonly environment variable table with names and values by examining all the full_uri ...
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
S-expression Pcbnew file format.
Definition: io_mgr.h:54
void pageChangedHandler(wxAuiNotebookEvent &event) override
Legacy Pcbnew file formats prior to s-expression.
Definition: io_mgr.h:53
static int m_pageNdx
Remember the last notebook page selected during a session.
wxGrid * m_cur_grid
changed based on tab choice
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
Read only http://github.com repo holding pretty footprints.
Definition: io_mgr.h:58
static wxString GetGlobalTableFileName()
Function GetGlobalTableFileName.
DIALOG_FP_LIB_TABLE::~DIALOG_FP_LIB_TABLE ( )
inline

Definition at line 251 of file dialog_fp_lib_table.cpp.

References DIALOG_FP_LIB_TABLE_BASE::m_global_grid, and DIALOG_FP_LIB_TABLE_BASE::m_project_grid.

252  {
253  // Delete the GRID_TRICKS.
254  // Any additional event handlers should be popped before the window is deleted.
255  m_global_grid->PopEventHandler( true );
256  m_project_grid->PopEventHandler( true );
257  }

Member Function Documentation

void DIALOG_FP_LIB_TABLE::appendRowHandler ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 392 of file dialog_fp_lib_table.cpp.

References m_cur_grid.

393  {
394  if( m_cur_grid->AppendRows( 1 ) )
395  {
396  int last_row = m_cur_grid->GetNumberRows() - 1;
397 
398  // wx documentation is wrong, SetGridCursor does not make visible.
399  m_cur_grid->MakeCellVisible( last_row, 0 );
400  m_cur_grid->SetGridCursor( last_row, 0 );
401  m_cur_grid->SelectRow( m_cur_grid->GetGridCursorRow() );
402  }
403  }
wxGrid * m_cur_grid
changed based on tab choice
FP_LIB_TABLE_GRID* DIALOG_FP_LIB_TABLE::cur_model ( ) const
inlineprivate

Definition at line 695 of file dialog_fp_lib_table.cpp.

References m_cur_grid.

Referenced by moveDownHandler(), moveUpHandler(), optionsEditor(), and verifyTables().

696  {
697  return (FP_LIB_TABLE_GRID*) m_cur_grid->GetTable();
698  }
wxGrid * m_cur_grid
changed based on tab choice
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
void DIALOG_FP_LIB_TABLE::deleteRowHandler ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 405 of file dialog_fp_lib_table.cpp.

References getCursorCol(), getCursorRow(), and m_cur_grid.

406  {
407  int currRow = getCursorRow();
408 
409  // In a wxGrid, collect rows that have a selected cell, or are selected
410  // is not so easy: it depend on the way the selection was made.
411  // Here, we collect row selected by clicking on a row label, and
412  // row that contain a cell previously selected.
413  // If no candidate, just delete the row with the grid cursor.
414  wxArrayInt selectedRows = m_cur_grid->GetSelectedRows();
415  wxGridCellCoordsArray cells = m_cur_grid->GetSelectedCells();
416 
417  // Add all row having cell selected to list:
418  for( unsigned ii = 0; ii < cells.GetCount(); ii++ )
419  selectedRows.Add( cells[ii].GetRow() );
420 
421  // Use the row having the grid cursor only if we have no candidate:
422  if( selectedRows.size() == 0 && getCursorRow() >= 0 )
423  selectedRows.Add( getCursorRow() );
424 
425  std::sort( selectedRows.begin(), selectedRows.end() );
426 
427  // Remove selected rows (note: a row can be stored more than once in list)
428  int last_row = -1;
429  for( int ii = selectedRows.GetCount()-1; ii >= 0; ii-- )
430  {
431  int row = selectedRows[ii];
432 
433  if( row != last_row )
434  {
435  last_row = row;
436  m_cur_grid->DeleteRows( row, 1 );
437  }
438  }
439 
440  if( currRow >= m_cur_grid->GetNumberRows() )
441  m_cur_grid->SetGridCursor(m_cur_grid->GetNumberRows()-1, getCursorCol() );
442 
443  m_cur_grid->SelectRow( m_cur_grid->GetGridCursorRow() );
444  }
int getCursorCol() const
If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based column index.
int getCursorRow() const
If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based row index.
wxGrid * m_cur_grid
changed based on tab choice
bool DIALOG_SHIM::Enable ( bool  enable)
overrideinherited

Definition at line 181 of file dialog_shim.cpp.

Referenced by DIALOG_PRINT_USING_PRINTER::InitValues().

182 {
183  // so we can do logging of this state change:
184 
185 #if defined(DEBUG)
186  const char* type_id = typeid( *this ).name();
187  printf( "wxDialog %s: %s\n", type_id, enable ? "enabled" : "disabled" );
188 #endif
189 
190  return wxDialog::Enable( enable );
191 }
void DIALOG_SHIM::EndQuasiModal ( int  retCode)
inherited

Definition at line 539 of file dialog_shim.cpp.

References DIALOG_SHIM::IsQuasiModal(), DIALOG_SHIM::m_qmodal_loop, DIALOG_SHIM::m_qmodal_parent_disabler, DIALOG_SHIM::m_qmodal_showing, and DIALOG_SHIM::Show().

Referenced by HK_PROMPT_DIALOG::EndFlexible(), DIALOG_SHIM::OnButton(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCancelButtonClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick(), DIALOG_EDIT_ONE_FIELD::OnCancelClick(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCloseDialog(), DIALOG_EDIT_ONE_FIELD::OnCloseDialog(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCloseDialog(), DIALOG_CHOOSE_COMPONENT::OnCloseTimer(), DIALOG_SHIM::OnCloseWindow(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), DIALOG_EDIT_ONE_FIELD::OnOkClick(), DIALOG_EXCHANGE_MODULE::OnQuit(), DIALOG_CHOOSE_COMPONENT::OnSchViewDClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp(), and DIALOG_SHIM::~DIALOG_SHIM().

540 {
541  // Hook up validator and transfer data from controls handling so quasi-modal dialogs
542  // handle validation in the same way as other dialogs.
543  if( ( retCode == wxID_OK ) && ( !Validate() || !TransferDataFromWindow() ) )
544  return;
545 
546  SetReturnCode( retCode );
547 
548  if( !IsQuasiModal() )
549  {
550  wxFAIL_MSG( wxT( "either DIALOG_SHIM::EndQuasiModal called twice or ShowQuasiModal wasn't called" ) );
551  return;
552  }
553 
554  m_qmodal_showing = false;
555 
556  if( m_qmodal_loop )
557  {
558  if( m_qmodal_loop->IsRunning() )
559  m_qmodal_loop->Exit( 0 );
560  else
561  m_qmodal_loop->ScheduleExit( 0 );
562 
563  m_qmodal_loop = NULL;
564  }
565 
568 
569  Show( false );
570 }
bool m_qmodal_showing
Definition: dialog_shim.h:132
EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:131
bool IsQuasiModal()
Definition: dialog_shim.h:93
bool Show(bool show) override
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:133
void DIALOG_SHIM::FinishDialogSettings ( )
protectedinherited

In all dialogs, we must call the same functions to fix minimal dlg size, the default position and perhaps some others to fix a few issues depending on Windows Managers this helper function does these calls.

FinishDialogSettings must be called from derived classes, when all widgets are initialized, and therefore their size fixed. If TransferDataToWindow() is used to initialize widgets, at end of TransferDataToWindow, or better at end of a wxInitDialogEvent handler

In any case, the best way is to call it in a wxInitDialogEvent handler after calling TransfertDataToWindow(), which is the default wxInitDialogEvent handler wxDialog

Definition at line 103 of file dialog_shim.cpp.

References PCAD2KICAD::Center.

Referenced by DIALOG_BOM::DIALOG_BOM(), DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE(), DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES(), DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR(), DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS(), DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY(), DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS(), DIALOG_ENUM_PADS::DIALOG_ENUM_PADS(), DIALOG_EXPORT_3DFILE::DIALOG_EXPORT_3DFILE(), DIALOG_EXPORT_IDF3::DIALOG_EXPORT_IDF3(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST(), DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES(), DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR(), DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM(), DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT(), DIALOG_LIB_NEW_COMPONENT::DIALOG_LIB_NEW_COMPONENT(), DIALOG_LIBEDIT_OPTIONS::DIALOG_LIBEDIT_OPTIONS(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC(), DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN(), DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS(), DIALOG_SELECT_PRETTY_LIB::DIALOG_SELECT_PRETTY_LIB(), DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE(), DIALOG_EDIT_ONE_FIELD::init(), NETLIST_DIALOG::NETLIST_DIALOG(), DIALOG_LIB_EDIT_PIN::OnInitDialog(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog(), DIALOG_TRACK_VIA_PROPERTIES::OnInitDlg(), DIALOG_GRAPHIC_ITEMS_OPTIONS::OnInitDlg(), DialogEditModuleText::OnInitDlg(), DIALOG_SET_GRID::OnInitDlg(), DIALOG_PCB_TEXT_PROPERTIES::OnInitDlg(), DIALOG_PRINT_FOR_MODEDIT::OnInitDlg(), DIALOG_GRAPHIC_ITEM_PROPERTIES::OnInitDlg(), DIALOG_MODULE_MODULE_EDITOR::OnInitDlg(), DIALOG_SIM_SETTINGS::onInitDlg(), DIALOG_SPICE_MODEL::onInitDlg(), DIALOG_MODULE_BOARD_EDITOR::OnInitDlg(), DIALOG_PRINT_USING_PRINTER::OnInitDlg(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnInitDlg(), TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR(), and DIALOG_SIGNAL_LIST::TransferDataToWindow().

104 {
105  // must be called from the constructor of derived classes,
106  // when all widgets are initialized, and therefore their size fixed
107 
108  // SetSizeHints fixes the minimal size of sizers in the dialog
109  // (SetSizeHints calls Fit(), so no need to call it)
110  GetSizer()->SetSizeHints( this );
111 
112  // the default position, when calling the first time the dlg
113  Center();
114 }
void DIALOG_SHIM::FixOSXCancelButtonIssue ( )
protectedinherited

A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms.

Definition at line 116 of file dialog_shim.cpp.

Referenced by DIALOG_SHIM::Show().

117 {
118 #ifdef __WXMAC__
119  // A ugly hack to fix an issue on OSX: ctrl+c closes the dialog instead of
120  // copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer
121  // created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority
122  // to copy text standard accelerator, and the dlg is closed when trying to copy text
123  wxButton* button = dynamic_cast< wxButton* > ( wxWindow::FindWindowById( wxID_CANCEL, this ) );
124 
125  if( button )
126  button->SetLabel( _( "Cancel" ) );
127 #endif
128 }
int DIALOG_FP_LIB_TABLE::getCursorCol ( ) const
inlineprivate

If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based column index.

Definition at line 263 of file dialog_fp_lib_table.cpp.

References m_cur_grid.

Referenced by deleteRowHandler(), moveDownHandler(), and moveUpHandler().

264  {
265  return m_cur_grid->GetGridCursorCol();
266  }
wxGrid * m_cur_grid
changed based on tab choice
int DIALOG_FP_LIB_TABLE::getCursorRow ( ) const
inlineprivate

If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based row index.

Definition at line 270 of file dialog_fp_lib_table.cpp.

References m_cur_grid.

Referenced by deleteRowHandler(), moveDownHandler(), moveUpHandler(), and optionsEditor().

271  {
272  return m_cur_grid->GetGridCursorRow();
273  }
wxGrid * m_cur_grid
changed based on tab choice
FP_LIB_TABLE_GRID* DIALOG_FP_LIB_TABLE::global_model ( ) const
inlineprivate

Definition at line 685 of file dialog_fp_lib_table.cpp.

References DIALOG_FP_LIB_TABLE_BASE::m_global_grid.

Referenced by onOKButtonClick(), populateEnvironReadOnlyTable(), and verifyTables().

686  {
687  return (FP_LIB_TABLE_GRID*) m_global_grid->GetTable();
688  }
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
KIWAY& KIWAY_HOLDER::Kiway ( ) const
inlineinherited

Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in.

A KIWAY_HOLDER is not necessarily a KIWAY_PLAYER.

Definition at line 60 of file kiway_player.h.

References KIWAY_HOLDER::m_kiway.

Referenced by SCH_EDIT_FRAME::AppendOneEEProject(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_CHOOSE_COMPONENT::ConstructRightPanel(), CVPCB_MAINFRAME::CreateScreenCmp(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_SHIM::DIALOG_SHIM(), EDIT_TOOL::editFootprintInFpEditor(), SCH_EDIT_FRAME::EditSheet(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_EDIT_FRAME::GetPlotSettings(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers(), LIB_EDIT_FRAME::InstallConfigFrame(), PCB_EDIT_FRAME::InstallModuleOptionsFrame(), KIWAY_PLAYER::language_change(), SCH_SHEET::Load(), CVPCB_MAINFRAME::LoadFootprintFiles(), KIWAY_PLAYER::OnChangeIconsOptions(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), SCH_EDIT_FRAME::OnLeftClick(), SCH_BASE_FRAME::OnOpenLibraryViewer(), SCH_EDIT_FRAME::OnSimulate(), DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard(), SCH_EDIT_FRAME::OpenProjectFiles(), KIWAY_HOLDER::Prj(), PCB_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_EDIT_FRAME::refreshSchematic(), SCH_EDIT_FRAME::SaveEEFile(), CVPCB_MAINFRAME::SaveFootprintAssociation(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_EDIT_FRAME::SetPlotSettings(), DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame(), FOOTPRINT_VIEWER_FRAME::Show3D_Frame(), FOOTPRINT_EDIT_FRAME::Show3D_Frame(), FOOTPRINT_WIZARD_FRAME::Show3D_Frame(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint().

61  {
62  wxASSERT( m_kiway ); // smoke out bugs in Debug build, then Release runs fine.
63  return *m_kiway;
64  }
KIWAY * m_kiway
Definition: kiway_player.h:85
void DIALOG_FP_LIB_TABLE::moveDownHandler ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 485 of file dialog_fp_lib_table.cpp.

References cur_model(), getCursorCol(), getCursorRow(), m_cur_grid, and LIB_TABLE::rows.

486  {
487  wxArrayInt rowsSelected = m_cur_grid->GetSelectedRows();
488 
489  if( rowsSelected.GetCount() == 0 )
490  return;
491 
492  FP_LIB_TABLE_GRID* tbl = cur_model();
493 
494  // @todo: add multiple selection moves.
495  int curRow = rowsSelected[0];
496 
497  if( unsigned( curRow + 1 ) < tbl->rows.size() )
498  {
499  int curCol = getCursorCol();
500 
501  boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
502  tbl->rows.release( tbl->rows.begin() + curRow );
503 
504  ++curRow;
505  tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
506 
507  if( tbl->GetView() )
508  {
509  // fire a msg to cause redrawing
510  wxGridTableMessage msg( tbl,
511  wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
512  curRow - 1,
513  0 );
514 
515  tbl->GetView()->ProcessTableMessage( msg );
516  }
517 
518  m_cur_grid->MakeCellVisible( curRow, curCol );
519  m_cur_grid->SetGridCursor( curRow, curCol );
520  m_cur_grid->SelectRow( getCursorRow() );
521  }
522  }
int getCursorCol() const
If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based column index.
int getCursorRow() const
If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based row index.
LIB_TABLE_ROWS rows
FP_LIB_TABLE_GRID * cur_model() const
wxGrid * m_cur_grid
changed based on tab choice
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
void DIALOG_FP_LIB_TABLE::moveUpHandler ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 446 of file dialog_fp_lib_table.cpp.

References cur_model(), getCursorCol(), getCursorRow(), m_cur_grid, and LIB_TABLE::rows.

447  {
448  wxArrayInt rowsSelected = m_cur_grid->GetSelectedRows();
449 
450  if( rowsSelected.GetCount() == 0 )
451  return;
452 
453  // @todo: add multiple selection moves.
454  int curRow = rowsSelected[0];
455 
456  if( curRow >= 1 )
457  {
458  int curCol = getCursorCol();
459 
460  FP_LIB_TABLE_GRID* tbl = cur_model();
461 
462  boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
463  tbl->rows.release( tbl->rows.begin() + curRow );
464 
465  --curRow;
466  tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
467 
468  if( tbl->GetView() )
469  {
470  // fire a msg to cause redrawing
471  wxGridTableMessage msg( tbl,
472  wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
473  curRow,
474  0 );
475 
476  tbl->GetView()->ProcessTableMessage( msg );
477  }
478 
479  m_cur_grid->MakeCellVisible( curRow, curCol );
480  m_cur_grid->SetGridCursor( curRow, curCol );
481  m_cur_grid->SelectRow( getCursorRow() );
482  }
483  }
int getCursorCol() const
If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based column index.
int getCursorRow() const
If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based row index.
LIB_TABLE_ROWS rows
FP_LIB_TABLE_GRID * cur_model() const
wxGrid * m_cur_grid
changed based on tab choice
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
void DIALOG_FP_LIB_TABLE::onCancelButtonClick ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 558 of file dialog_fp_lib_table.cpp.

559  {
560  EndModal( 0 );
561  }
void DIALOG_FP_LIB_TABLE::onCancelCaptionButtonClick ( wxCloseEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 563 of file dialog_fp_lib_table.cpp.

564  {
565  EndModal( 0 );
566  }
void DIALOG_FP_LIB_TABLE::OnClickLibraryWizard ( wxCommandEvent &  event)
overrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 708 of file dialog_fp_lib_table.cpp.

References COL_NICKNAME, COL_TYPE, COL_URI, WIZARD_FPLIB_TABLE::GetFirstPage(), WIZARD_FPLIB_TABLE::GetLibraries(), WIZARD_FPLIB_TABLE::GetLibScope(), LIB_TABLE_GRID::GetNumberRows(), WIZARD_FPLIB_TABLE::GLOBAL, WIZARD_FPLIB_TABLE::LIBRARY::INVALID, DIALOG_FP_LIB_TABLE_BASE::m_auinotebook, DIALOG_FP_LIB_TABLE_BASE::m_global_grid, DIALOG_FP_LIB_TABLE_BASE::m_project_grid, and LIB_TABLE_GRID::SetValue().

709 {
710  WIZARD_FPLIB_TABLE dlg( this );
711 
712  if( !dlg.RunWizard( dlg.GetFirstPage() ) )
713  return; // Aborted by user
714 
715  const std::vector<WIZARD_FPLIB_TABLE::LIBRARY>& libs = dlg.GetLibraries();
716  bool global_scope = dlg.GetLibScope() == WIZARD_FPLIB_TABLE::GLOBAL;
717  wxGrid* libgrid = global_scope ? m_global_grid : m_project_grid;
718  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) libgrid->GetTable();
719 
720  for( std::vector<WIZARD_FPLIB_TABLE::LIBRARY>::const_iterator it = libs.begin();
721  it != libs.end(); ++it )
722  {
723  if( it->GetStatus() == WIZARD_FPLIB_TABLE::LIBRARY::INVALID )
724  continue;
725 
726  if( libgrid->AppendRows( 1 ) )
727  {
728  int last_row = libgrid->GetNumberRows() - 1;
729 
730  // Add the nickname: currently make it from filename
731  tbl->SetValue( last_row, COL_NICKNAME, it->GetDescription() );
732 
733  // Add the path:
734  tbl->SetValue( last_row, COL_URI, it->GetAutoPath( dlg.GetLibScope() ) );
735 
736  // Add the plugin name:
737  tbl->SetValue( last_row, COL_TYPE, it->GetPluginName() );
738 
739  libgrid->MakeCellVisible( last_row, 0 );
740  libgrid->SetGridCursor( last_row, 0 );
741  }
742  }
743 
744  // Switch to the current scope tab
745  if( global_scope )
746  m_auinotebook->SetSelection( 0 );
747  else
748  m_auinotebook->SetSelection( 1 );
749 
750  libgrid->SelectRow( libgrid->GetGridCursorRow() );
751 }
int GetNumberRows() override
void SetValue(int aRow, int aCol, const wxString &aValue) override
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
void DIALOG_FP_LIB_TABLE::onKeyDown ( wxKeyEvent &  ev)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 374 of file dialog_fp_lib_table.cpp.

References m_cur_grid.

375  {
376 #if 0
377  // send the key to the current grid
378  ((wxEvtHandler*)m_cur_grid)->ProcessEvent( ev );
379 #else
380  // or no:
381  // m_cur_grid has the focus most of the time anyways, so above not needed.
382  ev.Skip();
383 #endif
384  }
wxGrid * m_cur_grid
changed based on tab choice
void DIALOG_FP_LIB_TABLE::onOKButtonClick ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 568 of file dialog_fp_lib_table.cpp.

References LIB_TABLE::Clear(), global_model(), m_cur_grid, m_global, m_project, project_model(), LIB_TABLE::reindex(), LIB_TABLE::rows, and verifyTables().

569  {
570  int dialogRet = 0;
571 
572  // stuff any pending cell editor text into the table.
573  m_cur_grid->SaveEditControlValue();
574 
575  if( verifyTables() )
576  {
577  if( *global_model() != *m_global )
578  {
579  dialogRet |= 1;
580 
581  m_global->Clear();
582  m_global->rows.transfer( m_global->rows.end(), global_model()->rows.begin(),
583  global_model()->rows.end(), global_model()->rows );
584  m_global->reindex();
585  }
586 
587  if( *project_model() != *m_project )
588  {
589  dialogRet |= 2;
590 
591  m_project->Clear();
592  m_project->rows.transfer( m_project->rows.end(), project_model()->rows.begin(),
593  project_model()->rows.end(), project_model()->rows );
594  m_project->reindex();
595  }
596 
597  EndModal( dialogRet );
598  }
599  }
FP_LIB_TABLE_GRID * project_model() const
void Clear()
Delete all rows.
void reindex()
LIB_TABLE_ROWS rows
FP_LIB_TABLE_GRID * global_model() const
wxGrid * m_cur_grid
changed based on tab choice
bool verifyTables()
Function verifyTables trims important fields, removes blank row entries, and checks for duplicates...
void DIALOG_FP_LIB_TABLE::optionsEditor ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 524 of file dialog_fp_lib_table.cpp.

References COL_NICKNAME, COL_TYPE, COL_URI, cur_model(), getCursorRow(), LIB_TABLE_ROW::GetNickName(), LIB_TABLE_GRID::GetNumberRows(), LIB_TABLE_ROW::GetOptions(), LIB_TABLE_ROW::GetType(), InvokePluginOptionsEditor(), m_cur_grid, Refresh(), LIB_TABLE::rows, and LIB_TABLE_ROW::SetOptions().

525  {
526  FP_LIB_TABLE_GRID* tbl = cur_model();
527 
528  if( tbl->GetNumberRows() )
529  {
530  int curRow = getCursorRow();
531  LIB_TABLE_ROW* row = &tbl->rows[curRow];
532 
533  wxString result;
534  const wxString& options = row->GetOptions();
535 
536  InvokePluginOptionsEditor( this, row->GetNickName(), row->GetType(), options, &result );
537 
538  if( options != result )
539  {
540  row->SetOptions( result );
541 
542  // all but options:
543  m_cur_grid->AutoSizeColumn( COL_NICKNAME, false );
544  m_cur_grid->AutoSizeColumn( COL_URI, false );
545  m_cur_grid->AutoSizeColumn( COL_TYPE, false );
546 
547  // On Windows, the grid is not refresh,
548  // so force resfresh after a change
549 #ifdef __WINDOWS__
550  Refresh();
551 #endif
552  }
553  }
554  }
int getCursorRow() const
If the cursor is not on a valid cell, because there are no rows at all, return -1, else return a 0 based row index.
Class LIB_TABLE_ROW.
void InvokePluginOptionsEditor(wxTopLevelWindow *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...
const wxString & GetOptions() const
Function GetOptions.
LIB_TABLE_ROWS rows
virtual const wxString GetType() const =0
Function GetType.
int GetNumberRows() override
void Refresh()
FP_LIB_TABLE_GRID * cur_model() const
const wxString & GetNickName() const
Function GetNickName.
wxGrid * m_cur_grid
changed based on tab choice
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
void SetOptions(const wxString &aOptions)
Function SetOptions.
void DIALOG_FP_LIB_TABLE::pageChangedHandler ( wxAuiNotebookEvent &  event)
inlineoverrideprivatevirtual

Implements DIALOG_FP_LIB_TABLE_BASE.

Definition at line 386 of file dialog_fp_lib_table.cpp.

References DIALOG_FP_LIB_TABLE_BASE::m_auinotebook, m_cur_grid, DIALOG_FP_LIB_TABLE_BASE::m_global_grid, m_pageNdx, and DIALOG_FP_LIB_TABLE_BASE::m_project_grid.

Referenced by DIALOG_FP_LIB_TABLE().

387  {
388  m_pageNdx = m_auinotebook->GetSelection();
390  }
static int m_pageNdx
Remember the last notebook page selected during a session.
wxGrid * m_cur_grid
changed based on tab choice
void DIALOG_FP_LIB_TABLE::populateEnvironReadOnlyTable ( )
inlineprivate

Populate the readonly environment variable table with names and values by examining all the full_uri columns.

Definition at line 603 of file dialog_fp_lib_table.cpp.

References COL_URI, LIB_TABLE_GRID::GetNumberRows(), LIB_TABLE_GRID::GetValue(), global_model(), FP_LIB_TABLE::GlobalPathEnvVariableName(), KISYS3DMOD, DIALOG_FP_LIB_TABLE_BASE::m_path_subs_grid, project_model(), and PROJECT_VAR_NAME.

Referenced by DIALOG_FP_LIB_TABLE().

604  {
605  wxRegEx re( ".*?\\$\\{(.+?)\\}.*?", wxRE_ADVANCED );
606  wxASSERT( re.IsValid() ); // wxRE_ADVANCED is required.
607 
608  std::set< wxString > unique;
609  typedef std::set<wxString>::const_iterator SET_CITER;
610 
611  // clear the table
612  m_path_subs_grid->DeleteRows( 0, m_path_subs_grid->GetNumberRows() );
613 
616 
617  int gblRowCount = gbl->GetNumberRows();
618  int prjRowCount = prj->GetNumberRows();
619  int row;
620 
621  for( row = 0; row < gblRowCount; ++row )
622  {
623  wxString uri = gbl->GetValue( row, COL_URI );
624 
625  while( re.Matches( uri ) )
626  {
627  wxString envvar = re.GetMatch( uri, 1 );
628 
629  // ignore duplicates
630  unique.insert( envvar );
631 
632  // delete the last match and search again
633  uri.Replace( re.GetMatch( uri, 0 ), wxEmptyString );
634  }
635  }
636 
637  for( row = 0; row < prjRowCount; ++row )
638  {
639  wxString uri = prj->GetValue( row, COL_URI );
640 
641  while( re.Matches( uri ) )
642  {
643  wxString envvar = re.GetMatch( uri, 1 );
644 
645  // ignore duplicates
646  unique.insert( envvar );
647 
648  // delete the last match and search again
649  uri.Replace( re.GetMatch( uri, 0 ), wxEmptyString );
650  }
651  }
652 
653  // Make sure this special environment variable shows up even if it was
654  // not used yet. It is automatically set by KiCad to the directory holding
655  // the current project.
656  unique.insert( PROJECT_VAR_NAME );
657  unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() );
658  // This special environment variable is used to locate 3d shapes
659  unique.insert( KISYS3DMOD );
660 
661  m_path_subs_grid->AppendRows( unique.size() );
662 
663  row = 0;
664 
665  for( SET_CITER it = unique.begin(); it != unique.end(); ++it, ++row )
666  {
667  wxString evName = *it;
668  wxString evValue;
669 
670  m_path_subs_grid->SetCellValue( row, 0, evName );
671 
672  if( wxGetEnv( evName, &evValue ) )
673  m_path_subs_grid->SetCellValue( row, 1, evValue );
674  }
675 
676  m_path_subs_grid->AutoSizeColumns();
677  }
FP_LIB_TABLE_GRID * project_model() const
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition: project.h:32
int GetNumberRows() override
FP_LIB_TABLE_GRID * global_model() const
static const wxString GlobalPathEnvVariableName()
Function GlobalPathEnvVarVariableName.
#define KISYS3DMOD
A variable name whose value holds the path of 3D shape files.
Definition: 3d_viewer.h:38
wxString GetValue(int aRow, int aCol) override
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
PROJECT & KIWAY_HOLDER::Prj ( ) const
inherited

Function Prj returns a reference to the PROJECT "associated with" this KIWAY.

Definition at line 34 of file kiway_holder.cpp.

References KIWAY_HOLDER::Kiway(), and KIWAY::Prj().

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::AppendOneEEProject(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), LIB_VIEW_FRAME::BestZoom(), DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile(), DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_MODULE_MODULE_EDITOR::Cfg3DPath(), DIALOG_MODULE_BOARD_EDITOR::Cfg3DPath(), SCH_EDIT_FRAME::CheckAnnotate(), SCH_SCREEN::CheckComponentsToPartsLinks(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), SCH_EDIT_FRAME::CreateArchiveLibrary(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary(), LIB_EDIT_FRAME::DeleteOnePart(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG(), DIALOG_FP_LIB_TABLE(), DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR(), DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), LIB_VIEW_FRAME::DisplayLibInfos(), SCH_BASE_FRAME::DisplayListComponentsInLib(), PCB_EDIT_FRAME::doAutoSave(), DIALOG_MODULE_MODULE_EDITOR::Edit3DShapeFileName(), DIALOG_MODULE_BOARD_EDITOR::Edit3DShapeFileName(), SCH_EDIT_FRAME::EditComponentFieldText(), SCH_EDIT_FRAME::EditSheet(), PCB_EDIT_FRAME::Export_IDF3(), PCB_EDIT_FRAME::ExportToGenCAD(), PCB_EDIT_FRAME::ExportVRML_File(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::GenD356File(), DIALOG_GENDRILL::GenDrillAndMapFiles(), NETLIST_DIALOG::GenNetlist(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), LIB_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), LIB_EDIT_FRAME::GetCurPart(), FOOTPRINT_EDIT_FRAME::GetCurrentLib(), FOOTPRINT_EDIT_FRAME::getLibPath(), DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable(), DIALOG_BOM::getPluginFileName(), LIB_VIEW_FRAME::getSelectedAlias(), FP_THREAD_IFACE::GetTable(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers(), DIALOG_MODULE_MODULE_EDITOR::initModeditProperties(), DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties(), LIB_EDIT_FRAME::InstallConfigFrame(), SCH_EDIT_FRAME::InstallConfigFrame(), PCB_EDIT_FRAME::InstallNetlistFrame(), SCH_EDIT_FRAME::IsSearchCacheObsolete(), SCH_EDIT_FRAME::Load_Component(), SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile(), CVPCB_MAINFRAME::LoadFootprintFiles(), SCH_EDIT_FRAME::LoadOneEEFile(), LIB_EDIT_FRAME::LoadOneLibraryPart(), LIB_EDIT_FRAME::LoadOneSymbol(), CVPCB_MAINFRAME::LoadProjectFile(), SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), DIALOG_DRC_CONTROL::makeValidFileNameReport(), FOOTPRINT_VIEWER_FRAME::OnActivate(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath(), DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick(), LIB_EDIT_FRAME::OnCloseWindow(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), DIALOG_GENDRILL::OnGenReportFile(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), PCB_EDIT_FRAME::OnLeftClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), DIALOG_NETLIST::OnOpenNetlistClick(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked(), LIB_EDIT_FRAME::OnPlotCurrentComponent(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), SCH_EDIT_FRAME::OnRightClick(), DIALOG_BOM::OnRunPlugin(), DIALOG_NETLIST::OnSaveMessagesToFile(), SCH_EDIT_FRAME::OnSaveProject(), DIALOG_SPICE_MODEL::onSelectIcLib(), LIB_VIEW_FRAME::OnSelectSymbol(), SCH_EDIT_FRAME::OnSelectUnit(), DIALOG_SPICE_MODEL::onSemiSelectLib(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnTestChipName(), FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib(), LIB_EDIT_FRAME::OnViewEntryDoc(), LIB_VIEW_FRAME::onViewSymbolDocument(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::PasteListOfItems(), PCB_EDITOR_CONTROL::PlaceModule(), SCH_EDIT_FRAME::prepareForNetlist(), SCH_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Special_Functions(), SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_VIEW_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_VIEW_FRAME::ReCreateListCmp(), LIB_VIEW_FRAME::ReCreateListLib(), LIB_VIEW_FRAME::RedrawActiveWindow(), EDA_3D_VIEWER::ReloadRequest(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), SCH_EDIT_FRAME::RescueProject(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SCH_SCREEN::Save(), LIB_EDIT_FRAME::SaveActiveLibrary(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), CVPCB_MAINFRAME::SaveProjectFile(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), SCH_BASE_FRAME::SelectComponentFromLibrary(), FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint(), PCB_BASE_FRAME::SelectLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), LIB_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), LIB_EDIT_FRAME::SetCurPart(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), EDA_3D_VIEWER::takeScreenshot(), DIALOG_ERC::TestErc(), DIALOG_SPICE_MODEL::updateFromFile(), SIM_PLOT_FRAME::updateNetlistExporter(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), CVPCB_MAINFRAME::UpdateTitle(), FOOTPRINT_EDIT_FRAME::updateTitle(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR(), and DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR().

35 {
36  return Kiway().Prj();
37 }
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
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:144
FP_LIB_TABLE_GRID* DIALOG_FP_LIB_TABLE::project_model ( ) const
inlineprivate

Definition at line 690 of file dialog_fp_lib_table.cpp.

References DIALOG_FP_LIB_TABLE_BASE::m_project_grid.

Referenced by onOKButtonClick(), populateEnvironReadOnlyTable(), and verifyTables().

691  {
692  return (FP_LIB_TABLE_GRID*) m_project_grid->GetTable();
693  }
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
void KIWAY_HOLDER::SetKiway ( wxWindow *  aDest,
KIWAY aKiway 
)
inherited

Function SetKiway.

Parameters
aDestis the recipient of aKiway pointer. It is only used for debugging, since "this" is not a wxWindow*. "this" is a KIWAY_HOLDER mix-in.
aKiwayis often from a parent window, or from KIFACE::CreateWindow().

Definition at line 41 of file kiway_holder.cpp.

References KIWAY_HOLDER::m_kiway, and name.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

42 {
43 #if defined(DEBUG)
44  // offer a trap point for debugging most any window
45  wxASSERT( aDest );
46  if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
47  {
48  int breakhere=1;
49  (void) breakhere;
50  }
51 #endif
52 
53  (void) aDest;
54 
55  m_kiway = aKiway;
56 }
KIWAY * m_kiway
Definition: kiway_player.h:85
const char * name
bool DIALOG_SHIM::Show ( bool  show)
overrideinherited

Definition at line 138 of file dialog_shim.cpp.

References class_map, DIALOG_SHIM::FixOSXCancelButtonIssue(), EDA_RECT::GetPosition(), EDA_RECT::GetSize(), DIALOG_SHIM::m_hash_key, wxPoint::x, and wxPoint::y.

Referenced by DisplayHotkeyList(), DIALOG_SHIM::EndQuasiModal(), InvokeDialogERC(), DIALOG_SCH_FIND::OnCancel(), DIALOG_DRC_CONTROL::OnLeftDClickClearance(), DIALOG_DRC_CONTROL::OnLeftDClickUnconnected(), DIALOG_DRC_CONTROL::OnPopupMenu(), DIALOG_EXCHANGE_MODULE::OnQuit(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), DRC::ShowDRCDialog(), and DIALOG_SHIM::ShowQuasiModal().

139 {
140  bool ret;
141  const char* hash_key;
142 
143  if( m_hash_key.size() )
144  {
145  // a special case like EDA_LIST_DIALOG, which has multiple uses.
146  hash_key = m_hash_key.c_str();
147  }
148  else
149  {
150  hash_key = typeid(*this).name();
151  }
152 
153  // Show or hide the window. If hiding, save current position and size.
154  // If showing, use previous position and size.
155  if( show )
156  {
157  wxDialog::Raise(); // Needed on OS X and some other window managers (i.e. Unity)
158  ret = wxDialog::Show( show );
159 
160  // classname is key, returns a zeroed out default EDA_RECT if none existed before.
161  EDA_RECT r = class_map[ hash_key ];
162 
163  if( r.GetSize().x != 0 && r.GetSize().y != 0 )
164  SetSize( r.GetPosition().x, r.GetPosition().y, r.GetSize().x, r.GetSize().y, 0 );
165  }
166  else
167  {
168  // Save the dialog's position & size before hiding, using classname as key
169  EDA_RECT r( wxDialog::GetPosition(), wxDialog::GetSize() );
170  class_map[ hash_key ] = r;
171 
172  ret = wxDialog::Show( show );
173  }
174 
176 
177  return ret;
178 }
std::string m_hash_key
Definition: dialog_shim.h:128
void FixOSXCancelButtonIssue()
A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms.
static RECT_MAP class_map
const wxPoint & GetPosition() const
Class EDA_RECT handles the component boundary box.
const wxSize & GetSize() const
int DIALOG_SHIM::ShowQuasiModal ( )
inherited

Definition at line 494 of file dialog_shim.cpp.

References DBG, DIALOG_SHIM::m_qmodal_loop, DIALOG_SHIM::m_qmodal_parent_disabler, DIALOG_SHIM::m_qmodal_showing, and DIALOG_SHIM::Show().

Referenced by LIB_EDIT_FRAME::DeleteOnePart(), SCH_EDIT_FRAME::EditComponent(), SCH_EDIT_FRAME::EditComponentFieldText(), LIB_EDIT_FRAME::EditField(), EDIT_TOOL::ExchangeFootprints(), PCB_EDIT_FRAME::InstallExchangeModuleFrame(), LIB_EDIT_FRAME::InstallFieldsEditorDialog(), LIB_VIEW_FRAME::OnSelectSymbol(), and SCH_BASE_FRAME::SelectComponentFromLibrary().

495 {
496  // This is an exception safe way to zero a pointer before returning.
497  // Yes, even though DismissModal() clears this first normally, this is
498  // here in case there's an exception before the dialog is dismissed.
499  struct NULLER
500  {
501  void*& m_what;
502  NULLER( void*& aPtr ) : m_what( aPtr ) {}
503  ~NULLER() { m_what = 0; } // indeed, set it to NULL on destruction
504  } clear_this( (void*&) m_qmodal_loop );
505 
506  // release the mouse if it's currently captured as the window having it
507  // will be disabled when this dialog is shown -- but will still keep the
508  // capture making it impossible to do anything in the modal dialog itself
509  wxWindow* win = wxWindow::GetCapture();
510  if( win )
511  win->ReleaseMouse();
512 
513  // Get the optimal parent
514  wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() );
515 
516  // Show the optimal parent
517  DBG( if( parent ) printf( "%s: optimal parent: %s\n", __func__, typeid(*parent).name() );)
518 
519  wxASSERT_MSG( !m_qmodal_parent_disabler,
520  wxT( "Caller using ShowQuasiModal() twice on same window?" ) );
521 
522  // quasi-modal: disable only my "optimal" parent
524 
525  Show( true );
526 
527  m_qmodal_showing = true;
528 
529  EVENT_LOOP event_loop;
530 
531  m_qmodal_loop = &event_loop;
532 
533  event_loop.Run();
534 
535  return GetReturnCode();
536 }
bool m_qmodal_showing
Definition: dialog_shim.h:132
EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:131
bool Show(bool show) override
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:133
Toggle a window's "enable" status to disabled, then enabled on destruction.
Definition: dialog_shim.cpp:33
#define DBG(x)
Definition: fctsys.h:33
bool DIALOG_FP_LIB_TABLE::verifyTables ( )
inlineprivate

Function verifyTables trims important fields, removes blank row entries, and checks for duplicates.

Returns
bool - true if tables are OK, else false.

Definition at line 280 of file dialog_fp_lib_table.cpp.

References COL_NICKNAME, COL_URI, cur_model(), LIB_TABLE_GRID::DeleteRows(), Format(), GetChars(), LIB_TABLE_GRID::GetNumberRows(), LIB_TABLE_GRID::GetValue(), global_model(), DIALOG_FP_LIB_TABLE_BASE::m_auinotebook, m_cur_grid, project_model(), and LIB_TABLE_GRID::SetValue().

Referenced by onOKButtonClick().

281  {
282  for( int t=0; t<2; ++t )
283  {
284  FP_LIB_TABLE_GRID& model = t==0 ? *global_model() : *project_model();
285 
286  for( int r = 0; r < model.GetNumberRows(); )
287  {
288  wxString nick = model.GetValue( r, COL_NICKNAME ).Trim( false ).Trim();
289  wxString uri = model.GetValue( r, COL_URI ).Trim( false ).Trim();
290 
291  if( !nick || !uri )
292  {
293  // Delete the "empty" row, where empty means missing nick or uri.
294  // This also updates the UI which could be slow, but there should only be a few
295  // rows to delete, unless the user fell asleep on the Add Row
296  // button.
297  model.DeleteRows( r, 1 );
298  }
299  else if( nick.find( ':' ) != size_t( -1 ) )
300  {
301  wxString msg = wxString::Format(
302  _( "Illegal character '%s' found in Nickname: '%s' in row %d" ),
303  ":", GetChars( nick ), r );
304 
305  // show the tabbed panel holding the grid we have flunked:
306  if( &model != cur_model() )
307  {
308  m_auinotebook->SetSelection( &model == global_model() ? 0 : 1 );
309  }
310 
311  // go to the problematic row
312  m_cur_grid->SetGridCursor( r, 0 );
313  m_cur_grid->SelectBlock( r, 0, r, 0 );
314  m_cur_grid->MakeCellVisible( r, 0 );
315 
316  wxMessageDialog errdlg( this, msg, _( "No Colon in Nicknames" ) );
317  errdlg.ShowModal();
318  return false;
319  }
320  else
321  {
322  // set the trimmed values back into the table so they get saved to disk.
323  model.SetValue( r, COL_NICKNAME, nick );
324  model.SetValue( r, COL_URI, uri );
325  ++r; // this row was OK.
326  }
327  }
328  }
329 
330  // check for duplicate nickNames, separately in each table.
331  for( int t=0; t<2; ++t )
332  {
333  FP_LIB_TABLE_GRID& model = t==0 ? *global_model() : *project_model();
334 
335  for( int r1 = 0; r1 < model.GetNumberRows() - 1; ++r1 )
336  {
337  wxString nick1 = model.GetValue( r1, COL_NICKNAME );
338 
339  for( int r2=r1+1; r2 < model.GetNumberRows(); ++r2 )
340  {
341  wxString nick2 = model.GetValue( r2, COL_NICKNAME );
342 
343  if( nick1 == nick2 )
344  {
345  wxString msg = wxString::Format(
346  _( "Duplicate Nickname: '%s' in rows %d and %d" ),
347  GetChars( nick1 ), r1+1, r2+1
348  );
349 
350  // show the tabbed panel holding the grid we have flunked:
351  if( &model != cur_model() )
352  {
353  m_auinotebook->SetSelection( &model == global_model() ? 0 : 1 );
354  }
355 
356  // go to the lower of the two rows, it is technically the duplicate:
357  m_cur_grid->SetGridCursor( r2, 0 );
358  m_cur_grid->SelectBlock( r2, 0, r2, 0 );
359  m_cur_grid->MakeCellVisible( r2, 0 );
360 
361  wxMessageDialog errdlg( this, msg, _( "Please Delete or Modify One" ) );
362  errdlg.ShowModal();
363  return false;
364  }
365  }
366  }
367  }
368 
369  return true;
370  }
FP_LIB_TABLE_GRID * project_model() const
bool DeleteRows(size_t aPos, size_t aNumRows) override
int GetNumberRows() override
FP_LIB_TABLE_GRID * global_model() const
FP_LIB_TABLE_GRID * cur_model() const
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxString GetValue(int aRow, int aCol) override
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxGrid * m_cur_grid
changed based on tab choice
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.

Member Data Documentation

wxButton* DIALOG_FP_LIB_TABLE_BASE::m_append_button
protectedinherited
wxButton* DIALOG_FP_LIB_TABLE_BASE::m_buttonWizard
protectedinherited
wxButton* DIALOG_FP_LIB_TABLE_BASE::m_delete_button
protectedinherited
wxButton* DIALOG_FP_LIB_TABLE_BASE::m_edit_options
protectedinherited
wxStaticText* DIALOG_FP_LIB_TABLE_BASE::m_GblTableFilename
protectedinherited
FP_LIB_TABLE* DIALOG_FP_LIB_TABLE::m_global
private

Definition at line 682 of file dialog_fp_lib_table.cpp.

Referenced by onOKButtonClick().

wxGrid* DIALOG_FP_LIB_TABLE_BASE::m_global_grid
protectedinherited
wxPanel* DIALOG_FP_LIB_TABLE_BASE::m_global_panel
protectedinherited
std::string DIALOG_SHIM::m_hash_key
protectedinherited
wxButton* DIALOG_FP_LIB_TABLE_BASE::m_move_down_button
protectedinherited
wxButton* DIALOG_FP_LIB_TABLE_BASE::m_move_up_button
protectedinherited
int DIALOG_FP_LIB_TABLE::m_pageNdx = 0
staticprivate

Remember the last notebook page selected during a session.

Definition at line 701 of file dialog_fp_lib_table.cpp.

Referenced by DIALOG_FP_LIB_TABLE(), and pageChangedHandler().

wxGrid* DIALOG_FP_LIB_TABLE_BASE::m_path_subs_grid
protectedinherited
wxStaticText* DIALOG_FP_LIB_TABLE_BASE::m_PrjTableFilename
protectedinherited
FP_LIB_TABLE* DIALOG_FP_LIB_TABLE::m_project
private

Definition at line 683 of file dialog_fp_lib_table.cpp.

Referenced by onOKButtonClick().

wxGrid* DIALOG_FP_LIB_TABLE_BASE::m_project_grid
protectedinherited
wxPanel* DIALOG_FP_LIB_TABLE_BASE::m_project_panel
protectedinherited
EVENT_LOOP* DIALOG_SHIM::m_qmodal_loop
protectedinherited

Definition at line 131 of file dialog_shim.h.

Referenced by DIALOG_SHIM::EndQuasiModal(), and DIALOG_SHIM::ShowQuasiModal().

WDO_ENABLE_DISABLE* DIALOG_SHIM::m_qmodal_parent_disabler
protectedinherited
bool DIALOG_SHIM::m_qmodal_showing
protectedinherited
wxStdDialogButtonSizer* DIALOG_FP_LIB_TABLE_BASE::m_sdbSizer
protectedinherited
wxButton* DIALOG_FP_LIB_TABLE_BASE::m_sdbSizerCancel
protectedinherited
wxButton* DIALOG_FP_LIB_TABLE_BASE::m_sdbSizerOK
protectedinherited
wxStaticText* DIALOG_FP_LIB_TABLE_BASE::m_staticText3
protectedinherited
wxStaticText* DIALOG_FP_LIB_TABLE_BASE::m_staticText4
protectedinherited

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