void PGM_KICAD::MacOpenFile( const wxString& aFileName ) { #if defined(__WXMAC__) KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) App().GetTopWindow(); frame->SetProjectFileName( aFileName ); wxCommandEvent loadEvent( 0, wxID_ANY ); frame->OnLoadProject( loadEvent ); #endif }
void KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate( int pid, int status ) { wxString msg = wxString::Format( _( "%s closed [pid=%d]\n" ), GetChars( m_appName ), pid ); wxWindow* window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME ); if( window ) // Should always happen. { // Be sure the kicad frame manager is found // This dynamic cast is not really mandatory, but ... KICAD_MANAGER_FRAME* frame = dynamic_cast<KICAD_MANAGER_FRAME*> (window); if( frame ) frame->PrintMsg( msg ); } delete this; }
bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) { m_wx_app = aWxApp; // first thing. wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath(); if( !wxIsAbsolutePath( absoluteArgv0 ) ) { wxLogError( wxT( "No meaningful argv[0]" ) ); return false; } // Set LIB_ENV_VAR *before* loading the KIFACE DSOs, in case they have hard // dependencies on subsidiary DSOs below it. set_lib_env_var( absoluteArgv0 ); if( !initPgm() ) return false; m_bm.Init(); // Add search paths to feed the PGM_KICAD::SysSearch() function, // currenly limited in support to only look for project templates { SEARCH_STACK bases; SystemDirsAppend( &bases ); // DBG( bases.Show( (std::string(__func__) + " bases").c_str() );) for( unsigned i = 0; i < bases.GetCount(); ++i ) { wxFileName fn( bases[i], wxEmptyString ); // Add KiCad template file path to search path list. fn.AppendDir( wxT( "template" ) ); m_bm.m_search.AddPaths( fn.GetPath() ); } //DBG( m_bm.m_search.Show( (std::string( __func__ ) + " SysSearch()").c_str() );) } // Must be called before creating the main frame in order to // display the real hotkeys in menus or tool tips extern struct EDA_HOTKEY_CONFIG kicad_Manager_Hokeys_Descr[]; ReadHotkeyConfig( KICAD_MANAGER_FRAME_NAME, kicad_Manager_Hokeys_Descr ); KICAD_MANAGER_FRAME* frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ), wxDefaultPosition, wxDefaultSize ); App().SetTopWindow( frame ); Kiway.SetTop( frame ); bool prjloaded = false; // true when the project is loaded if( App().argc > 1 ) frame->SetProjectFileName( App().argv[1] ); else if( GetFileHistory().GetCount() ) { wxString last_pro = GetFileHistory().GetHistoryFile( 0 ); if( !wxFileExists( last_pro ) ) { GetFileHistory().RemoveFileFromHistory( 0 ); wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, ProjectFileExtension ); frame->SetProjectFileName( namelessProject.GetFullPath() ); } else { // Try to open the last opened project, // if a project name is not given when starting Kicad frame->SetProjectFileName( last_pro ); wxCommandEvent cmd( 0, wxID_FILE1 ); frame->OnFileHistory( cmd ); prjloaded = true; // OnFileHistory() loads the project } } else // there is no history { wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, ProjectFileExtension ); frame->SetProjectFileName( namelessProject.GetFullPath() ); } if( !prjloaded ) { wxCommandEvent cmd( 0, wxID_ANY ); frame->OnLoadProject( cmd ); } frame->Show( true ); frame->Raise(); return true; }
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame ) { wxString sep = wxFileName().GetPathSeparator(); wxString fullFileName = GetFileName(); wxTreeItemId id = GetId(); KICAD_MANAGER_FRAME* frame = aTreePrjFrame->m_Parent; KIWAY& kiway = frame->Kiway(); switch( GetType() ) { case TREE_PROJECT: // Select a new project if this is not the current project: if( id != aTreePrjFrame->m_TreeProject->GetRootItem() ) frame->LoadProject( fullFileName ); break; case TREE_DIRECTORY: m_parent->Toggle( id ); break; case TREE_SCHEMA: if( fullFileName == frame->SchFileName() ) { // the project's schematic is opened using the *.kiface as part of this process. // We do not call frame->RunEeschema( fullFileName ), // because after the double click, for some reason, // the tree project frame is brought to the foreground after Eeschema is called from here. // Instead, we post an event, equivalent to click on the eeschema tool in command frame wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_SCH ); wxPostEvent( frame, evt ); } else { // schematics not part of the project are opened in a separate process. frame->Execute( m_parent, EESCHEMA_EXE, fullFileName ); } break; case TREE_LEGACY_PCB: case TREE_SEXP_PCB: if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() ) { // the project's BOARD is opened using the *.kiface as part of this process. // We do not call frame->RunPcbNew( fullFileName ), // because after the double click, for some reason, // the tree project frame is brought to the foreground after PcbNew is called from here. // Instead, we post an event, equivalent to simple click on the pcb editor tool in command frame wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_PCB ); wxPostEvent( frame, evt ); } else { // boards not part of the project are opened in a separate process. frame->Execute( m_parent, PCBNEW_EXE, fullFileName ); } break; case TREE_GERBER: frame->Execute( m_parent, GERBVIEW_EXE, fullFileName ); break; case TREE_HTML: wxLaunchDefaultBrowser( fullFileName ); break; case TREE_PDF: OpenPDF( fullFileName ); break; case TREE_NET: case TREE_DRILL: case TREE_TXT: case TREE_REPORT: { wxString editorname = Pgm().GetEditorName(); if( !editorname.IsEmpty() ) frame->Execute( m_parent, editorname, fullFileName ); } break; case TREE_PAGE_LAYOUT_DESCR: frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName ); break; case TREE_FOOTPRINT_FILE: { wxCommandEvent dummy; frame->OnRunPcbFpEditor( dummy ); kiway.ExpressMail( FRAME_PCB_MODULE_EDITOR, MAIL_FP_EDIT, fullFileName.ToStdString() ); } break; case TREE_SCHEMATIC_LIBFILE: { wxCommandEvent dummy; frame->OnRunSchLibEditor( dummy ); kiway.ExpressMail( FRAME_SCH_LIB_EDITOR, MAIL_LIB_EDIT, fullFileName.ToStdString() ); } break; default: AddDelimiterString( fullFileName ); OpenFile( fullFileName ); break; } }
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) { wxString sep = wxFileName().GetPathSeparator(); wxString fullFileName = GetFileName(); wxTreeItemId id = GetId(); KICAD_MANAGER_FRAME* frame = prjframe->m_Parent; wxASSERT( frame ); switch( GetType() ) { case TREE_PROJECT: break; case TREE_DIRECTORY: m_parent->Toggle( id ); break; case TREE_SCHEMA: if( fullFileName == frame->SchFileName() ) { // the project's schematic is opened using the *.kiface as part of this process. // We do not call frame->RunEeschema( fullFileName ), // because after the double click, for some reason, // the tree project frame is brought to the foreground after Eeschema is called from here. // Instead, we post an event, equivalent to click on the eeschema tool in command frame wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_SCH ); wxPostEvent( frame, evt ); } else { // schematics not part of the project are opened in a separate process. frame->Execute( m_parent, EESCHEMA_EXE, fullFileName ); } break; case TREE_LEGACY_PCB: case TREE_SEXP_PCB: if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() ) { // the project's BOARD is opened using the *.kiface as part of this process. // We do not call frame->RunPcbNew( fullFileName ), // because after the double click, for some reason, // the tree project frame is brought to the foreground after PcbNew is called from here. // Instead, we post an event, equivalent to simple click on the pcb editor tool in command frame wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_PCB ); wxPostEvent( frame, evt ); } else { // boards not part of the project are opened in a separate process. frame->Execute( m_parent, PCBNEW_EXE, fullFileName ); } break; case TREE_GERBER: frame->Execute( m_parent, GERBVIEW_EXE, fullFileName ); break; case TREE_HTML: wxLaunchDefaultBrowser( fullFileName ); break; case TREE_PDF: OpenPDF( fullFileName ); break; case TREE_NET: // Nothing to do ( can be read only by Pcbnew, or by a text editor) break; case TREE_TXT: { wxString editorname = Pgm().GetEditorName(); if( !editorname.IsEmpty() ) frame->Execute( m_parent, editorname, fullFileName ); } break; case TREE_PAGE_LAYOUT_DESCR: frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName ); break; default: AddDelimiterString( fullFileName ); OpenFile( fullFileName ); break; } }
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) { wxString sep = wxFileName().GetPathSeparator(); wxString fullFileName = GetFileName(); wxTreeItemId id = GetId(); KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) Pgm().App().GetTopWindow(); switch( GetType() ) { case TREE_PROJECT: break; case TREE_DIRECTORY: m_parent->Toggle( id ); break; case TREE_SCHEMA: if( fullFileName == frame->SchFileName() ) { // the project's schematic is opened using the *.kiface as part of this process. frame->RunEeschema( fullFileName ); } else { // schematics not part of the project are opened in a separate process. frame->Execute( m_parent, EESCHEMA_EXE, fullFileName ); } break; case TREE_LEGACY_PCB: case TREE_SEXP_PCB: if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() ) { // the project's BOARD is opened using the *.kiface as part of this process. frame->RunPcbNew( fullFileName ); } else { // boards not part of the project are opened in a separate process. frame->Execute( m_parent, PCBNEW_EXE, fullFileName ); } break; case TREE_GERBER: frame->Execute( m_parent, GERBVIEW_EXE, fullFileName ); break; case TREE_HTML: wxLaunchDefaultBrowser( fullFileName ); break; case TREE_PDF: OpenPDF( fullFileName ); break; /* No, use a text editor. Netlists can only be handled sanely now from within eeschema's launcher for the *.kiface, NOT THE EXE which is now gone. case TREE_NET: frame->Execute( m_parent, CVPCB_EXE, fullFileName ); break; */ case TREE_TXT: { wxString editorname = Pgm().GetEditorName(); if( !editorname.IsEmpty() ) frame->Execute( m_parent, editorname, fullFileName ); } break; case TREE_PAGE_LAYOUT_DESCR: frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName ); break; default: AddDelimiterString( fullFileName ); OpenFile( fullFileName ); break; } }