DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxDialog( aParent, id, title, pos, size, style, name ), KIWAY_HOLDER( 0 ), m_qmodal_loop( 0 ), m_qmodal_showing( false ), m_qmodal_parent_disabler( 0 ) { // pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation. KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent ); // wxASSERT_MSG( h, wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) ); if( h ) SetKiway( this, &h->Kiway() ); #ifdef __WINDOWS__ // On Windows, the app top windows can be brought to the foreground // (at least temporary) in certain circumstances, // for instance when calling an external tool in Eeschema boom generation. // So set the parent KIWAY_PLAYER kicad frame (if exists) to top window // to avoid this annoying behavior KIWAY_PLAYER* parent_kiwayplayer = dynamic_cast<KIWAY_PLAYER*>( aParent ); if( parent_kiwayplayer ) Pgm().App().SetTopWindow( parent_kiwayplayer ); #endif #if DLGSHIM_USE_SETFOCUS Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SHIM::onInit ) ); #endif }
DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxDialog( aParent, id, title, pos, size, style, name ), KIWAY_HOLDER( 0 ), m_qmodal_loop( 0 ), m_qmodal_showing( false ), m_qmodal_parent_disabler( 0 ) { // pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation. KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent ); // wxASSERT_MSG( h, wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) ); if( h ) SetKiway( this, &h->Kiway() ); #if DLGSHIM_USE_SETFOCUS Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SHIM::onInit ) ); #endif }
SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SIM_PLOT_FRAME_BASE( aParent ), m_lastSimPlot( nullptr ) { SetKiway( this, aKiway ); m_signalsIconColorList = NULL; m_schematicFrame = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); if( m_schematicFrame == NULL ) throw std::runtime_error( "There is no schematic window" ); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( simulator_xpm ) ); SetIcon( icon ); m_simulator = SPICE_SIMULATOR::CreateInstance( "ngspice" ); if( !m_simulator ) { throw std::runtime_error( "Could not create simulator instance" ); return; } m_simulator->Init(); m_reporter = new SIM_THREAD_REPORTER( this ); m_simulator->SetReporter( m_reporter ); updateNetlistExporter(); Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( SIM_PLOT_FRAME::onClose ), NULL, this ); Connect( EVT_SIM_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onSimUpdate ), NULL, this ); Connect( EVT_SIM_REPORT, wxCommandEventHandler( SIM_PLOT_FRAME::onSimReport ), NULL, this ); Connect( EVT_SIM_STARTED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimStarted ), NULL, this ); Connect( EVT_SIM_FINISHED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimFinished ), NULL, this ); Connect( EVT_SIM_CURSOR_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onCursorUpdate ), NULL, this ); // Toolbar buttons m_toolSimulate = m_toolBar->AddTool( ID_SIM_RUN, _( "Run/Stop Simulation" ), KiBitmap( sim_run_xpm ), _( "Run Simulation" ), wxITEM_NORMAL ); m_toolAddSignals = m_toolBar->AddTool( ID_SIM_ADD_SIGNALS, _( "Add Signals" ), KiBitmap( sim_add_signal_xpm ), _( "Add signals to plot" ), wxITEM_NORMAL ); m_toolProbe = m_toolBar->AddTool( ID_SIM_PROBE, _( "Probe" ), KiBitmap( sim_probe_xpm ), _( "Probe signals on the schematic" ), wxITEM_NORMAL ); m_toolTune = m_toolBar->AddTool( ID_SIM_TUNE, _( "Tune" ), KiBitmap( sim_tune_xpm ), _( "Tune component values" ), wxITEM_NORMAL ); m_toolSettings = m_toolBar->AddTool( wxID_ANY, _( "Settings" ), KiBitmap( sim_settings_xpm ), _( "Simulation settings" ), wxITEM_NORMAL ); Connect( m_toolSimulate->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimulate ), NULL, this ); Connect( m_toolAddSignals->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onAddSignal ), NULL, this ); Connect( m_toolProbe->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onProbe ), NULL, this ); Connect( m_toolTune->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onTune ), NULL, this ); Connect( m_toolSettings->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onSettings ), NULL, this ); // Bind toolbar buttons event to existing menu event handlers, so they behave the same Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onSimulate, this, m_runSimulation->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onAddSignal, this, m_addSignals->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onProbe, this, m_probeSignals->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onTune, this, m_tuneValue->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onSettings, this, m_settings->GetId() ); m_toolBar->Realize(); m_plotNotebook->SetPageText( 0, _( "Welcome!" ) ); // the settings dialog will be created later, on demand. // if created in the ctor, for some obscure reason, there is an issue // on Windows: when open it, the simulator frame is sent to the background. // instead of beeing behind the dialog frame (as it does) m_settingsDlg = NULL; }
SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SIM_PLOT_FRAME_BASE( aParent ), m_lastSimPlot( nullptr ) { SetKiway( this, aKiway ); m_signalsIconColorList = NULL; m_schematicFrame = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); if( m_schematicFrame == NULL ) throw std::runtime_error( "There is no schematic window" ); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( simulator_xpm ) ); SetIcon( icon ); // Gives a minimal size SetSizeHints( 500, 400, -1, -1, -1, -1 ); // Get the previous size and position of windows: LoadSettings( config() ); m_simulator = SPICE_SIMULATOR::CreateInstance( "ngspice" ); if( !m_simulator ) { throw std::runtime_error( "Could not create simulator instance" ); return; } m_simulator->Init(); if( m_savedWorkbooksPath.IsEmpty() ) { m_savedWorkbooksPath = Prj().GetProjectPath(); } m_reporter = new SIM_THREAD_REPORTER( this ); m_simulator->SetReporter( m_reporter ); updateNetlistExporter(); Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( SIM_PLOT_FRAME::onClose ), NULL, this ); Connect( EVT_SIM_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onSimUpdate ), NULL, this ); Connect( EVT_SIM_REPORT, wxCommandEventHandler( SIM_PLOT_FRAME::onSimReport ), NULL, this ); Connect( EVT_SIM_STARTED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimStarted ), NULL, this ); Connect( EVT_SIM_FINISHED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimFinished ), NULL, this ); Connect( EVT_SIM_CURSOR_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onCursorUpdate ), NULL, this ); // Toolbar buttons m_toolSimulate = m_toolBar->AddTool( ID_SIM_RUN, _( "Run/Stop Simulation" ), KiBitmap( sim_run_xpm ), _( "Run Simulation" ), wxITEM_NORMAL ); m_toolAddSignals = m_toolBar->AddTool( ID_SIM_ADD_SIGNALS, _( "Add Signals" ), KiBitmap( sim_add_signal_xpm ), _( "Add signals to plot" ), wxITEM_NORMAL ); m_toolProbe = m_toolBar->AddTool( ID_SIM_PROBE, _( "Probe" ), KiBitmap( sim_probe_xpm ), _( "Probe signals on the schematic" ), wxITEM_NORMAL ); m_toolTune = m_toolBar->AddTool( ID_SIM_TUNE, _( "Tune" ), KiBitmap( sim_tune_xpm ), _( "Tune component values" ), wxITEM_NORMAL ); m_toolSettings = m_toolBar->AddTool( wxID_ANY, _( "Settings" ), KiBitmap( sim_settings_xpm ), _( "Simulation settings" ), wxITEM_NORMAL ); Connect( m_toolSimulate->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimulate ), NULL, this ); Connect( m_toolAddSignals->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onAddSignal ), NULL, this ); Connect( m_toolProbe->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onProbe ), NULL, this ); Connect( m_toolTune->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onTune ), NULL, this ); Connect( m_toolSettings->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onSettings ), NULL, this ); // Bind toolbar buttons event to existing menu event handlers, so they behave the same Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onSimulate, this, m_runSimulation->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onAddSignal, this, m_addSignals->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onProbe, this, m_probeSignals->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onTune, this, m_tuneValue->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onShowNetlist, this, m_showNetlist->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onSettings, this, m_settings->GetId() ); m_toolBar->Realize(); m_plotNotebook->SetPageText( 0, _( "Welcome!" ) ); // the settings dialog will be created later, on demand. // if created in the ctor, for some obscure reason, there is an issue // on Windows: when open it, the simulator frame is sent to the background. // instead of being behind the dialog frame (as it does) m_settingsDlg = NULL; // resize the subwindows size. At least on Windows, calling wxSafeYield before // resizing the subwindows forces the wxSplitWindows size events automatically generated // by wxWidgets to be executed before our resize code. // Otherwise, the changes made by setSubWindowsSashSize are overwritten by one these // events wxSafeYield(); setSubWindowsSashSize(); }
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_CALCULATOR_FRAME_BASE( aParent ) { SetKiway( this, aKiway ); m_currTransLine = NULL; m_currTransLineType = DEFAULT_TYPE; m_currAttenuator = NULL; m_RegulatorListChanged = false; m_Config = GetNewConfig( Pgm().App().GetAppName() ); // Populate transline list ordered like in dialog menu list const static TRANSLINE_TYPE_ID tltype_list[8] = { MICROSTRIP_TYPE, CPW_TYPE, GROUNDED_CPW_TYPE, RECTWAVEGUIDE_TYPE, COAX_TYPE, C_MICROSTRIP_TYPE, STRIPLINE_TYPE, TWISTEDPAIR_TYPE }; for( int ii = 0; ii < 8; ii++ ) m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) ); // Populate attenuator list ordered like in dialog menu list m_attenuator_list.push_back( new ATTENUATOR_PI() ); m_attenuator_list.push_back( new ATTENUATOR_TEE() ); m_attenuator_list.push_back( new ATTENUATOR_BRIDGE() ); m_attenuator_list.push_back( new ATTENUATOR_SPLITTER() ); m_currAttenuator = m_attenuator_list[0]; ReadConfig(); ReadDataFile(); TranslineTypeSelection( m_currTransLineType ); m_TranslineSelection->SetSelection( m_currTransLineType ); TW_Init(); SetAttenuator( m_AttenuatorsSelection->GetSelection() ); ToleranceSelection( m_rbToleranceSelection->GetSelection() ); BoardClassesUpdateData( m_BoardClassesUnitsSelector->GetUnitScale() ); ElectricalSpacingUpdateData( m_ElectricalSpacingUnitsSelector->GetUnitScale() ); m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() ); SelectLastSelectedRegulator(); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_pcbcalculator_xpm ) ); SetIcon( icon ); GetSizer()->SetSizeHints( this ); // Set previous size and position SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); if( m_FramePos == wxDefaultPosition ) Centre(); }