You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1048 lines
32 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
7 years ago
18 years ago
18 years ago
18 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
7 years ago
18 years ago
18 years ago
18 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
7 years ago
7 years ago
7 years ago
7 years ago
18 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #include <bitmaps.h>
  26. #include <confirm.h>
  27. #include <eda_dde.h>
  28. #include <fp_lib_table.h>
  29. #include <kiface_i.h>
  30. #include <kiway_express.h>
  31. #include <macros.h>
  32. #include <netlist_reader/netlist_reader.h>
  33. #include <numeric>
  34. #include <tool/action_toolbar.h>
  35. #include <tool/common_control.h>
  36. #include <tool/tool_dispatcher.h>
  37. #include <tool/tool_manager.h>
  38. #include <widgets/progress_reporter.h>
  39. #include <wx/statline.h>
  40. #include <cvpcb_association.h>
  41. #include <cvpcb_id.h>
  42. #include <cvpcb_mainframe.h>
  43. #include <cvpcb_settings.h>
  44. #include <display_footprints_frame.h>
  45. #include <kiplatform/ui.h>
  46. #include <listboxes.h>
  47. #include <tools/cvpcb_actions.h>
  48. #include <tools/cvpcb_association_tool.h>
  49. #include <tools/cvpcb_control.h>
  50. #define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
  51. CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
  52. KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
  53. wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME )
  54. {
  55. m_compListBox = NULL;
  56. m_footprintListBox = NULL;
  57. m_libListBox = NULL;
  58. m_mainToolBar = NULL;
  59. m_modified = false;
  60. m_skipComponentSelect = false;
  61. m_filteringOptions = FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST;
  62. m_tcFilterString = NULL;
  63. m_FootprintsList = FOOTPRINT_LIST::GetInstance( Kiway() );
  64. m_initialized = false;
  65. // Give an icon
  66. wxIcon icon;
  67. icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
  68. SetIcon( icon );
  69. SetAutoLayout( true );
  70. LoadSettings( config() );
  71. setupTools();
  72. ReCreateMenuBar();
  73. ReCreateHToolbar();
  74. // Create list of available modules and components of the schematic
  75. BuildCmpListBox();
  76. BuildFOOTPRINTS_LISTBOX();
  77. BuildLIBRARY_LISTBOX();
  78. m_auimgr.SetManagedWindow( this );
  79. m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
  80. m_auimgr.AddPane( m_libListBox, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(1)
  81. .Caption( _( "Footprint Libraries" ) )
  82. .BestSize( (int) ( m_FrameSize.x * 0.20 ), m_FrameSize.y ) );
  83. m_auimgr.AddPane( m_compListBox, EDA_PANE().Palette().Name( "Components" ).Center().Layer(0)
  84. .Caption( _( "Symbol : Footprint Assignments" ) ) );
  85. m_auimgr.AddPane( m_footprintListBox, EDA_PANE().Palette().Name( "Footprints" ).Right().Layer(1)
  86. .Caption( _( "Filtered Footprints" ) )
  87. .BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) );
  88. // Build the bottom panel, to display 2 status texts and the buttons:
  89. auto bottomPanel = new wxPanel( this );
  90. auto panelSizer = new wxBoxSizer( wxVERTICAL );
  91. wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 3, 1, 0, 0 );
  92. fgSizerStatus->SetFlexibleDirection( wxBOTH );
  93. fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
  94. m_statusLine1 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
  95. fgSizerStatus->Add( m_statusLine1, 0, 0, 5 );
  96. m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
  97. fgSizerStatus->Add( m_statusLine2, 0, 0, 5 );
  98. m_statusLine3 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
  99. fgSizerStatus->Add( m_statusLine3, 0, wxBOTTOM, 3 );
  100. panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
  101. wxStaticLine* staticline1 = new wxStaticLine( bottomPanel );
  102. panelSizer->Add( staticline1, 0, wxEXPAND, 5 );
  103. wxFont statusFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
  104. statusFont.SetSymbolicSize( wxFONTSIZE_SMALL );
  105. m_statusLine1->SetFont( statusFont );
  106. m_statusLine2->SetFont( statusFont );
  107. m_statusLine3->SetFont( statusFont );
  108. // Add buttons:
  109. auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
  110. auto sdbSizer = new wxStdDialogButtonSizer();
  111. m_saveAndContinue = new wxButton( bottomPanel, ID_SAVE_PROJECT,
  112. _( "Apply, Save Schematic && Continue" ) );
  113. buttonsSizer->Add( m_saveAndContinue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 20 );
  114. auto sdbSizerOK = new wxButton( bottomPanel, wxID_OK );
  115. sdbSizer->AddButton( sdbSizerOK );
  116. auto sdbSizerCancel = new wxButton( bottomPanel, wxID_CANCEL );
  117. sdbSizer->AddButton( sdbSizerCancel );
  118. sdbSizer->Realize();
  119. buttonsSizer->Add( sdbSizer, 0, 0, 5 );
  120. panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
  121. bottomPanel->SetSizer( panelSizer );
  122. bottomPanel->Fit();
  123. sdbSizerOK->SetDefault();
  124. KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( this );
  125. m_auimgr.AddPane( bottomPanel, EDA_PANE().HToolbar().Name( "Buttons" ).Bottom().Layer(6) );
  126. m_auimgr.Update();
  127. m_initialized = true;
  128. // Connect Events
  129. setupEventHandlers();
  130. // Start the main processing loop
  131. m_toolManager->InvokeTool( "cvpcb.Control" );
  132. // Ensure the toolbars are sync'd properly so the filtering options display correct
  133. SyncToolbars();
  134. SetShutdownBlockReason( _( "Symbol to footprint changes are unsaved" ) );
  135. }
  136. CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
  137. {
  138. // Shutdown all running tools
  139. if( m_toolManager )
  140. m_toolManager->ShutdownAllTools();
  141. // Clean up the tool infrastructure
  142. delete m_actions;
  143. delete m_toolManager;
  144. delete m_toolDispatcher;
  145. m_auimgr.UnInit();
  146. }
  147. void CVPCB_MAINFRAME::setupTools()
  148. {
  149. // Create the manager
  150. m_actions = new CVPCB_ACTIONS();
  151. m_toolManager = new TOOL_MANAGER;
  152. m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
  153. m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
  154. // Register tools
  155. m_toolManager->RegisterTool( new COMMON_CONTROL );
  156. m_toolManager->RegisterTool( new CVPCB_CONTROL );
  157. m_toolManager->RegisterTool( new CVPCB_ASSOCIATION_TOOL );
  158. m_toolManager->InitTools();
  159. CVPCB_CONTROL* tool = m_toolManager->GetTool<CVPCB_CONTROL>();
  160. // Even though these menus will open with the right-click, we treat them as a normal
  161. // menu instead of a context menu because we don't care about their position and want
  162. // to be able to tell the difference between a menu click and a hotkey activation.
  163. // Create the context menu for the component list box
  164. m_componentContextMenu = new ACTION_MENU( false );
  165. m_componentContextMenu->SetTool( tool );
  166. m_componentContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
  167. m_componentContextMenu->AppendSeparator();
  168. m_componentContextMenu->Add( ACTIONS::cut );
  169. m_componentContextMenu->Add( ACTIONS::copy );
  170. m_componentContextMenu->Add( ACTIONS::paste );
  171. m_componentContextMenu->AppendSeparator();
  172. m_componentContextMenu->Add( CVPCB_ACTIONS::deleteAssoc );
  173. // Create the context menu for the footprint list box
  174. m_footprintContextMenu = new ACTION_MENU( false );
  175. m_footprintContextMenu->SetTool( tool );
  176. m_footprintContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
  177. }
  178. void CVPCB_MAINFRAME::setupEventHandlers()
  179. {
  180. // Connect the handlers to launch the context menus in the listboxes
  181. m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
  182. [this]( wxMouseEvent& )
  183. {
  184. PopupMenu( m_footprintContextMenu );
  185. } );
  186. m_compListBox->Bind( wxEVT_RIGHT_DOWN,
  187. [this]( wxMouseEvent& )
  188. {
  189. PopupMenu( m_componentContextMenu );
  190. } );
  191. // Connect the handler for the save button
  192. m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
  193. [this]( wxCommandEvent& )
  194. {
  195. // saveAssociations must be run immediately
  196. this->GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations, true );
  197. } );
  198. // Connect the handlers for the ok/cancel buttons
  199. Bind( wxEVT_BUTTON,
  200. [this]( wxCommandEvent& )
  201. {
  202. // saveAssociations must be run immediately, before running Close( true )
  203. this->GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations, true );
  204. Close( true );
  205. }, wxID_OK );
  206. Bind( wxEVT_BUTTON,
  207. [this]( wxCommandEvent& )
  208. {
  209. Close( false );
  210. }, wxID_CANCEL );
  211. // Connect the handlers for the close events
  212. Bind( wxEVT_CLOSE_WINDOW, &CVPCB_MAINFRAME::OnCloseWindow, this );
  213. Bind( wxEVT_MENU,
  214. [this]( wxCommandEvent& )
  215. {
  216. Close( false );
  217. }, wxID_CLOSE );
  218. Bind( wxEVT_MENU,
  219. [this]( wxCommandEvent& )
  220. {
  221. Close( false );
  222. }, wxID_EXIT );
  223. // Toolbar events
  224. Bind( wxEVT_TEXT, &CVPCB_MAINFRAME::OnEnterFilteringText, this, ID_CVPCB_FILTER_TEXT_EDIT );
  225. // Just skip the resize events
  226. Bind( wxEVT_SIZE,
  227. []( wxSizeEvent& aEvent )
  228. {
  229. aEvent.Skip();
  230. } );
  231. // Attach the events to the tool dispatcher
  232. Bind( wxEVT_TOOL, &TOOL_DISPATCHER::DispatchWxCommand, m_toolDispatcher );
  233. Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
  234. Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
  235. }
  236. void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& aEvent )
  237. {
  238. if( m_modified )
  239. {
  240. // Shutdown blocks must be determined and vetoed as early as possible
  241. if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
  242. {
  243. aEvent.Veto();
  244. return;
  245. }
  246. if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. "
  247. "Save changes?" ),
  248. [&]()->bool { return SaveFootprintAssociation( false ); } ) )
  249. {
  250. aEvent.Veto();
  251. return;
  252. }
  253. }
  254. // Close module display frame
  255. if( GetFootprintViewerFrame() )
  256. GetFootprintViewerFrame()->Close( true );
  257. m_modified = false;
  258. // clear highlight symbol in schematic:
  259. SendMessageToEESCHEMA( true );
  260. // Skip the close event. Looks like needed to have the close event sent to the
  261. // root class EDA_BASE_FRAME, and save config
  262. aEvent.Skip();
  263. }
  264. void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
  265. {
  266. // Called when changing the filter string in main toolbar.
  267. // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
  268. // of available footprints which match the filter
  269. wxListEvent l_event;
  270. OnSelectComponent( l_event );
  271. }
  272. void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
  273. {
  274. if( m_skipComponentSelect )
  275. return;
  276. wxString libraryName;
  277. COMPONENT* component = GetSelectedComponent();
  278. libraryName = m_libListBox->GetSelectedLibrary();
  279. m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, component,
  280. m_tcFilterString->GetValue(), m_filteringOptions );
  281. if( component && component->GetFPID().IsValid() )
  282. m_footprintListBox->SetSelectedFootprint( component->GetFPID() );
  283. else
  284. m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
  285. refreshAfterComponentSearch( component );
  286. }
  287. void CVPCB_MAINFRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
  288. {
  289. EDA_BASE_FRAME::LoadSettings( aCfg );
  290. auto cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
  291. m_filteringOptions = cfg->m_FilterFootprint;
  292. }
  293. void CVPCB_MAINFRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
  294. {
  295. EDA_BASE_FRAME::SaveSettings( aCfg );
  296. auto cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
  297. cfg->m_FilterFootprint = m_filteringOptions;
  298. }
  299. void CVPCB_MAINFRAME::UndoAssociation()
  300. {
  301. if( m_undoList.size() == 0 )
  302. return;
  303. CVPCB_UNDO_REDO_ENTRIES redoEntries;
  304. CVPCB_UNDO_REDO_ENTRIES curEntry = m_undoList.back();
  305. m_undoList.pop_back();
  306. // Iterate over the entries to undo
  307. for( const auto& assoc : curEntry )
  308. {
  309. AssociateFootprint( assoc, true, false );
  310. redoEntries.emplace_back( assoc.Reverse() );
  311. }
  312. // Add the redo entries to the redo stack
  313. m_redoList.emplace_back( redoEntries );
  314. }
  315. void CVPCB_MAINFRAME::RedoAssociation()
  316. {
  317. if( m_redoList.size() == 0 )
  318. return;
  319. CVPCB_UNDO_REDO_ENTRIES curEntry = m_redoList.back();
  320. m_redoList.pop_back();
  321. // Iterate over the entries to undo
  322. bool firstAssoc = true;
  323. for( const auto& assoc : curEntry )
  324. {
  325. AssociateFootprint( assoc, firstAssoc );
  326. firstAssoc = false;
  327. }
  328. }
  329. void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
  330. bool aNewEntry, bool aAddUndoItem )
  331. {
  332. if( m_netlist.IsEmpty() )
  333. return;
  334. COMPONENT* component = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
  335. if( component == NULL )
  336. return;
  337. LIB_ID fpid = aAssociation.GetNewFootprint();
  338. LIB_ID oldFpid = component->GetFPID();
  339. // Test for validity of the requested footprint
  340. if( !fpid.empty() && !fpid.IsValid() )
  341. {
  342. wxString msg =
  343. wxString::Format( _( "\"%s\" is not a valid footprint." ), fpid.Format().wx_str() );
  344. DisplayErrorMessage( this, msg );
  345. return;
  346. }
  347. // Set the new footprint
  348. component->SetFPID( fpid );
  349. // create the new component description and set it
  350. wxString description = wxString::Format( CMP_FORMAT,
  351. aAssociation.GetComponentIndex() + 1,
  352. component->GetReference(),
  353. component->GetValue(),
  354. component->GetFPID().Format().wx_str() );
  355. m_compListBox->SetString( aAssociation.GetComponentIndex(), description );
  356. // Mark the data as being modified
  357. m_modified = true;
  358. // Update the statusbar and refresh the list
  359. DisplayStatus();
  360. m_compListBox->Refresh();
  361. if( !aAddUndoItem )
  362. return;
  363. // Update the undo list
  364. if ( aNewEntry )
  365. {
  366. // Create a new entry for this association
  367. CVPCB_UNDO_REDO_ENTRIES newEntry;
  368. newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
  369. aAssociation.GetNewFootprint() ) );
  370. m_undoList.emplace_back( newEntry );
  371. // Clear the redo list
  372. m_redoList.clear();
  373. }
  374. else
  375. m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
  376. oldFpid, aAssociation.GetNewFootprint() ) );
  377. }
  378. bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
  379. {
  380. return true;
  381. }
  382. void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
  383. {
  384. // Tell AuiMgr that objects are changed !
  385. if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
  386. // (could be not the case when starting CvPcb
  387. m_auimgr.Update();
  388. if( component == NULL )
  389. {
  390. DisplayStatus();
  391. return;
  392. }
  393. // Preview of the already assigned footprint.
  394. // Find the footprint that was already chosen for this component and select it,
  395. // but only if the selection is made from the component list or the library list.
  396. // If the selection is made from the footprint list, do not change the current
  397. // selected footprint.
  398. if( FindFocus() == m_compListBox || FindFocus() == m_libListBox )
  399. {
  400. wxString module = FROM_UTF8( component->GetFPID().Format().c_str() );
  401. m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
  402. for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
  403. {
  404. wxString footprintName;
  405. wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
  406. msg.Trim( true );
  407. msg.Trim( false );
  408. footprintName = msg.AfterFirst( wxChar( ' ' ) );
  409. if( module.Cmp( footprintName ) == 0 )
  410. {
  411. m_footprintListBox->SetSelection( ii, true );
  412. break;
  413. }
  414. }
  415. if( GetFootprintViewerFrame() )
  416. m_toolManager->RunAction( CVPCB_ACTIONS::showFootprintViewer, true );
  417. }
  418. SendMessageToEESCHEMA();
  419. DisplayStatus();
  420. }
  421. void CVPCB_MAINFRAME::SetFootprintFilter( FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter,
  422. CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction )
  423. {
  424. int option = aFilter;
  425. // Apply the filter accordingly
  426. switch( aAction )
  427. {
  428. case CVPCB_MAINFRAME::FILTER_DISABLE:
  429. m_filteringOptions &= ~option;
  430. break;
  431. case CVPCB_MAINFRAME::FILTER_ENABLE:
  432. m_filteringOptions |= option;
  433. break;
  434. case CVPCB_MAINFRAME::FILTER_TOGGLE:
  435. m_filteringOptions ^= option;
  436. break;
  437. }
  438. wxListEvent l_event;
  439. OnSelectComponent( l_event );
  440. }
  441. void CVPCB_MAINFRAME::DisplayStatus()
  442. {
  443. if( !m_initialized )
  444. return;
  445. wxString filters, msg;
  446. COMPONENT* component = GetSelectedComponent();
  447. if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS ) )
  448. {
  449. msg.Empty();
  450. if( component )
  451. {
  452. for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ )
  453. {
  454. if( msg.IsEmpty() )
  455. msg += component->GetFootprintFilters()[ii];
  456. else
  457. msg += wxT( ", " ) + component->GetFootprintFilters()[ii];
  458. }
  459. }
  460. filters += _( "key words" );
  461. if( !msg.IsEmpty() )
  462. filters += wxString::Format( wxT( " (%s)" ), msg );
  463. }
  464. if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) )
  465. {
  466. msg.Empty();
  467. if( component )
  468. msg = wxString::Format( wxT( "%i" ), component->GetPinCount() );
  469. if( !filters.IsEmpty() )
  470. filters += wxT( ", " );
  471. filters += _( "pin count" );
  472. if( !msg.IsEmpty() )
  473. filters += wxString::Format( wxT( " (%s)" ), msg );
  474. }
  475. if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) )
  476. {
  477. msg = m_libListBox->GetSelectedLibrary();
  478. if( !filters.IsEmpty() )
  479. filters += wxT( ", " );
  480. filters += _( "library" );
  481. if( !msg.IsEmpty() )
  482. filters += wxString::Format( wxT( " (%s)" ), msg );
  483. }
  484. wxString textFilter = m_tcFilterString->GetValue();
  485. if( !textFilter.IsEmpty() )
  486. {
  487. if( !filters.IsEmpty() )
  488. filters += wxT( ", " );
  489. filters += _( "search text" ) + wxString::Format( wxT( " (%s)" ), textFilter );
  490. }
  491. if( filters.IsEmpty() )
  492. msg = _( "No filtering" );
  493. else
  494. msg.Printf( _( "Filtered by %s" ), GetChars( filters ) );
  495. msg << wxT( ": " ) << m_footprintListBox->GetCount();
  496. SetStatusText( msg );
  497. msg.Empty();
  498. wxString footprintName = GetSelectedFootprint();
  499. FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( footprintName );
  500. if( module ) // can be NULL if no netlist loaded
  501. {
  502. msg = wxString::Format( _( "Description: %s; Key words: %s" ),
  503. module->GetDescription(),
  504. module->GetKeywords() );
  505. }
  506. SetStatusText( msg, 1 );
  507. msg.Empty();
  508. wxString lib;
  509. // Choose the footprint to get the information on
  510. if( module )
  511. {
  512. // Use the footprint in the footprint viewer
  513. lib = module->GetLibNickname();
  514. }
  515. else if( GetFocusedControl() == CVPCB_MAINFRAME::CONTROL_COMPONENT )
  516. {
  517. // Use the footprint of the selected component
  518. if( component )
  519. lib = component->GetFPID().GetLibNickname();
  520. }
  521. else if( GetFocusedControl() == CVPCB_MAINFRAME::CONTROL_LIBRARY )
  522. {
  523. // Use the library that is selected
  524. lib = m_libListBox->GetSelectedLibrary();
  525. }
  526. // Extract the library information
  527. FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs( Kiway() );
  528. if( fptbl->HasLibrary( lib ) )
  529. msg = wxString::Format( _( "Library location: %s" ), fptbl->GetFullURI( lib ) );
  530. else
  531. msg = wxString::Format( _( "Library location: unknown" ) );
  532. SetStatusText( msg, 2 );
  533. }
  534. bool CVPCB_MAINFRAME::LoadFootprintFiles()
  535. {
  536. FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs( Kiway() );
  537. // Check if there are footprint libraries in the footprint library table.
  538. if( !fptbl || !fptbl->GetLogicalLibs().size() )
  539. {
  540. wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
  541. "library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
  542. return false;
  543. }
  544. WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
  545. m_FootprintsList->ReadFootprintFiles( fptbl, nullptr, &progressReporter );
  546. if( m_FootprintsList->GetErrorCount() )
  547. {
  548. m_FootprintsList->DisplayErrors( this );
  549. }
  550. return true;
  551. }
  552. void CVPCB_MAINFRAME::SendMessageToEESCHEMA( bool aClearHighligntOnly )
  553. {
  554. if( m_netlist.IsEmpty() )
  555. return;
  556. // clear highlight of previously selected components (if any):
  557. // Selecting a non existing symbol clears any previously highlighted symbols
  558. std::string packet = "$CLEAR: \"HIGHLIGHTED\"";
  559. if( Kiface().IsSingle() )
  560. SendCommand( MSG_TO_SCH, packet.c_str() );
  561. else
  562. Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
  563. if( aClearHighligntOnly )
  564. return;
  565. int selection = m_compListBox->GetSelection();
  566. if ( selection < 0 ) // Nothing selected
  567. return;
  568. if( m_netlist.GetComponent( selection ) == NULL )
  569. return;
  570. // Now highlight the selected component:
  571. COMPONENT* component = m_netlist.GetComponent( selection );
  572. packet = StrPrintf( "$PART: \"%s\"", TO_UTF8( component->GetReference() ) );
  573. if( Kiface().IsSingle() )
  574. SendCommand( MSG_TO_SCH, packet.c_str() );
  575. else
  576. Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
  577. }
  578. int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
  579. {
  580. STRING_LINE_READER* strrdr = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
  581. KICAD_NETLIST_READER netrdr( strrdr, &m_netlist );
  582. m_netlist.Clear();
  583. try
  584. {
  585. netrdr.LoadNetlist();
  586. }
  587. catch( const IO_ERROR& ioe )
  588. {
  589. wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ),
  590. ioe.What().GetData() );
  591. wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
  592. return 1;
  593. }
  594. // We also remove footprint name if it is "$noname" because this is a dummy name,
  595. // not the actual name of the footprint.
  596. for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
  597. {
  598. if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
  599. m_netlist.GetComponent( ii )->SetFPID( LIB_ID() );
  600. }
  601. // Sort components by reference:
  602. m_netlist.SortByReference();
  603. return 0;
  604. }
  605. void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX()
  606. {
  607. wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
  608. if( m_footprintListBox == NULL )
  609. {
  610. m_footprintListBox = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST );
  611. m_footprintListBox->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN,
  612. wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
  613. }
  614. m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, NULL,
  615. wxEmptyString, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST );
  616. DisplayStatus();
  617. }
  618. void CVPCB_MAINFRAME::BuildCmpListBox()
  619. {
  620. wxString msg;
  621. COMPONENT* component;
  622. wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
  623. if( m_compListBox == NULL )
  624. {
  625. m_compListBox = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST );
  626. m_compListBox->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN,
  627. wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
  628. }
  629. m_compListBox->m_ComponentList.Clear();
  630. for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
  631. {
  632. component = m_netlist.GetComponent( i );
  633. msg.Printf( CMP_FORMAT,
  634. m_compListBox->GetCount() + 1,
  635. component->GetReference(),
  636. component->GetValue(),
  637. component->GetFPID().Format().wx_str() );
  638. m_compListBox->m_ComponentList.Add( msg );
  639. }
  640. if( m_compListBox->m_ComponentList.Count() )
  641. {
  642. m_compListBox->SetItemCount( m_compListBox->m_ComponentList.Count() );
  643. m_compListBox->SetSelection( 0, true );
  644. m_compListBox->RefreshItems( 0L, m_compListBox->m_ComponentList.Count()-1 );
  645. m_compListBox->UpdateWidth();
  646. }
  647. }
  648. void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX()
  649. {
  650. wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
  651. if( m_libListBox == NULL )
  652. {
  653. m_libListBox = new LIBRARY_LISTBOX( this, ID_CVPCB_LIBRARY_LIST );
  654. m_libListBox->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN,
  655. wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
  656. }
  657. FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs( Kiway() );
  658. if( tbl )
  659. {
  660. wxArrayString libNames;
  661. std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
  662. for( const wxString& libNickName : libNickNames )
  663. libNames.Add( libNickName );
  664. m_libListBox->SetLibraryList( libNames );
  665. }
  666. }
  667. COMPONENT* CVPCB_MAINFRAME::GetSelectedComponent()
  668. {
  669. int selection = m_compListBox->GetSelection();
  670. if( selection >= 0 && selection < (int) m_netlist.GetCount() )
  671. return m_netlist.GetComponent( selection );
  672. return NULL;
  673. }
  674. void CVPCB_MAINFRAME::SetSelectedComponent( int aIndex, bool aSkipUpdate )
  675. {
  676. m_skipComponentSelect = aSkipUpdate;
  677. if( aIndex < 0 )
  678. {
  679. m_compListBox->DeselectAll();
  680. }
  681. else if( aIndex < m_compListBox->GetCount() )
  682. {
  683. m_compListBox->DeselectAll();
  684. m_compListBox->SetSelection( aIndex );
  685. SendMessageToEESCHEMA();
  686. }
  687. m_skipComponentSelect = false;
  688. }
  689. std::vector<unsigned int> CVPCB_MAINFRAME::GetComponentIndices(
  690. CVPCB_MAINFRAME::CRITERIA aCriteria )
  691. {
  692. std::vector<unsigned int> idx;
  693. // Make sure a netlist has been loaded and the box has contents
  694. if( m_netlist.IsEmpty() || m_compListBox->GetCount() == 0 )
  695. return idx;
  696. switch( aCriteria )
  697. {
  698. case CVPCB_MAINFRAME::ALL_COMPONENTS:
  699. idx.resize( m_netlist.GetCount() );
  700. std::iota( idx.begin(), idx.end(), 0 );
  701. break;
  702. case CVPCB_MAINFRAME::SEL_COMPONENTS:
  703. {
  704. // Check to see if anything is selected
  705. if( m_compListBox->GetSelectedItemCount() < 1 )
  706. break;
  707. // Get the components
  708. int lastIdx = m_compListBox->GetFirstSelected();
  709. idx.emplace_back( lastIdx );
  710. lastIdx = m_compListBox->GetNextSelected( lastIdx );
  711. while( lastIdx > 0 )
  712. {
  713. idx.emplace_back( lastIdx );
  714. lastIdx = m_compListBox->GetNextSelected( lastIdx );
  715. }
  716. break;
  717. }
  718. case CVPCB_MAINFRAME::NA_COMPONENTS:
  719. for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
  720. {
  721. if( m_netlist.GetComponent( i )->GetFPID().empty() )
  722. idx.emplace_back( i );
  723. }
  724. break;
  725. case CVPCB_MAINFRAME::ASSOC_COMPONENTS:
  726. for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
  727. {
  728. if( !m_netlist.GetComponent( i )->GetFPID().empty() )
  729. idx.emplace_back( i );
  730. }
  731. break;
  732. default:
  733. wxASSERT_MSG( false, "Invalid component selection criteria" );
  734. }
  735. return idx;
  736. }
  737. DISPLAY_FOOTPRINTS_FRAME* CVPCB_MAINFRAME::GetFootprintViewerFrame() const
  738. {
  739. // returns the Footprint Viewer frame, if exists, or NULL
  740. return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>
  741. ( wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ) );
  742. }
  743. wxWindow* CVPCB_MAINFRAME::GetToolCanvas() const
  744. {
  745. return GetFootprintViewerFrame();
  746. }
  747. CVPCB_MAINFRAME::CONTROL_TYPE CVPCB_MAINFRAME::GetFocusedControl()
  748. {
  749. if( m_libListBox->HasFocus() )
  750. return CVPCB_MAINFRAME::CONTROL_LIBRARY;
  751. else if( m_compListBox->HasFocus() )
  752. return CVPCB_MAINFRAME::CONTROL_COMPONENT;
  753. else if( m_footprintListBox->HasFocus() )
  754. return CVPCB_MAINFRAME::CONTROL_FOOTPRINT;
  755. return CVPCB_MAINFRAME::CONTROL_NONE;
  756. }
  757. wxControl* CVPCB_MAINFRAME::GetFocusedControlObject()
  758. {
  759. if( m_libListBox->HasFocus() )
  760. return m_libListBox;
  761. else if( m_compListBox->HasFocus() )
  762. return m_compListBox;
  763. else if( m_footprintListBox->HasFocus() )
  764. return m_footprintListBox;
  765. return nullptr;
  766. }
  767. void CVPCB_MAINFRAME::SetFocusedControl( CVPCB_MAINFRAME::CONTROL_TYPE aLB )
  768. {
  769. switch( aLB )
  770. {
  771. case CVPCB_MAINFRAME::CONTROL_LIBRARY: m_libListBox->SetFocus(); break;
  772. case CVPCB_MAINFRAME::CONTROL_COMPONENT: m_compListBox->SetFocus(); break;
  773. case CVPCB_MAINFRAME::CONTROL_FOOTPRINT: m_footprintListBox->SetFocus(); break;
  774. default: break;
  775. }
  776. }
  777. wxString CVPCB_MAINFRAME::GetSelectedFootprint()
  778. {
  779. // returns the LIB_ID of the selected footprint in footprint listview
  780. // or a empty string
  781. return m_footprintListBox->GetSelectedFootprint();
  782. }
  783. void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
  784. {
  785. switch( aNumber )
  786. {
  787. case 0: m_statusLine1->SetLabel( aText ); break;
  788. case 1: m_statusLine2->SetLabel( aText ); break;
  789. case 2: m_statusLine3->SetLabel( aText ); break;
  790. default: wxFAIL_MSG( "Invalid status row number" ); break;
  791. }
  792. }
  793. void CVPCB_MAINFRAME::ShowChangedLanguage()
  794. {
  795. EDA_BASE_FRAME::ShowChangedLanguage();
  796. ReCreateHToolbar();
  797. DisplayStatus();
  798. }
  799. void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
  800. {
  801. const std::string& payload = mail.GetPayload();
  802. //DBG(printf( "%s: %s\n", __func__, payload.c_str() );)
  803. switch( mail.Command() )
  804. {
  805. case MAIL_EESCHEMA_NETLIST:
  806. ReadNetListAndFpFiles( payload );
  807. /* @todo
  808. Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
  809. */
  810. break;
  811. default:
  812. ; // ignore most
  813. }
  814. }