KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_base_frame.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2013 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2023 CERN (www.cern.ch)
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
28#include "kicad_manager_frame.h"
29#include <eda_base_frame.h>
30
31#include <advanced_config.h>
32#include <bitmaps.h>
33#include <bitmap_store.h>
34#include <dialog_shim.h>
41#include <eda_dde.h>
42#include <file_history.h>
43#include <id.h>
44#include <kiface_base.h>
45#include <hotkeys_basic.h>
47#include <paths.h>
48#include <confirm.h>
50#include <pgm_base.h>
55#include <tool/action_manager.h>
56#include <tool/action_menu.h>
57#include <tool/action_toolbar.h>
58#include <tool/actions.h>
59#include <tool/common_control.h>
60#include <tool/tool_manager.h>
63#include <trace_helpers.h>
66#include <widgets/wx_infobar.h>
68#include <widgets/wx_grid.h>
69#include <widgets/wx_treebook.h>
70#include <wx/app.h>
71#include <wx/config.h>
72#include <wx/display.h>
73#include <wx/stdpaths.h>
74#include <wx/string.h>
75#include <wx/msgdlg.h>
76#include <wx/wupdlock.h>
77#include <kiplatform/app.h>
78#include <kiplatform/io.h>
79#include <kiplatform/ui.h>
80
81#include <functional>
82#include <kiface_ids.h>
83
84#ifdef KICAD_IPC_API
85#include <api/api_server.h>
86#endif
87
88
89// Minimum window size
90static const wxSize minSizeLookup( FRAME_T aFrameType, wxWindow* aWindow )
91{
92 switch( aFrameType )
93 {
95 return wxWindow::FromDIP( wxSize( 406, 354 ), aWindow );
96
97 default:
98 return wxWindow::FromDIP( wxSize( 500, 400 ), aWindow );
99 }
100}
101
102
103static const wxSize defaultSize( FRAME_T aFrameType, wxWindow* aWindow )
104{
105 switch( aFrameType )
106 {
108 return wxWindow::FromDIP( wxSize( 850, 540 ), aWindow );
109
110 default:
111 return wxWindow::FromDIP( wxSize( 1280, 720 ), aWindow );
112 }
113}
114
115
116BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
117 // These event table entries are needed to handle events from the mac application menu
118 EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
119 EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
120
121 EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
122 EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
123 EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent )
124 EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent )
125 EVT_MOVE( EDA_BASE_FRAME::OnMove )
126 EVT_SIZE( EDA_BASE_FRAME::OnSize )
127 EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
128
129 EVT_SYS_COLOUR_CHANGED( EDA_BASE_FRAME::onSystemColorChange )
130 EVT_ICONIZE( EDA_BASE_FRAME::onIconize )
131END_EVENT_TABLE()
132
133
135{
136 m_ident = aFrameType;
137 m_maximizeByDefault = false;
138 m_infoBar = nullptr;
139 m_settingsManager = nullptr;
140 m_fileHistory = nullptr;
141 m_supportsAutoSave = false;
142 m_autoSavePending = false;
144 m_isClosing = false;
145 m_isNonUserClose = false;
146 m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
147 m_autoSaveRequired = false;
150 m_frameSize = defaultSize( aFrameType, this );
151 m_displayIndex = -1;
152
153 m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
154
156
157 // Set a reasonable minimal size for the frame
158 wxSize minSize = minSizeLookup( aFrameType, this );
159 SetSizeHints( minSize.x, minSize.y, -1, -1, -1, -1 );
160
161 // Store dimensions of the user area of the main window.
162 GetClientSize( &m_frameSize.x, &m_frameSize.y );
163
164 Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
165 wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
166
167 // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
168 // to be called before any other hook for wxCloseEvent, which is necessary.
169 Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
170
171 initExitKey();
172}
173
174
175EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle,
176 const wxPoint& aPos, const wxSize& aSize, long aStyle,
177 const wxString& aFrameName, KIWAY* aKiway,
178 const EDA_IU_SCALE& aIuScale ) :
179 wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
180 TOOLS_HOLDER(),
181 KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
182 UNITS_PROVIDER( aIuScale, EDA_UNITS::MM )
183{
184 m_tbTopMain = nullptr;
185 m_tbTopAux = nullptr;
186 m_tbRight = nullptr;
187 m_tbLeft = nullptr;
188
189 commonInit( aFrameType );
190}
191
192
193wxWindow* findQuasiModalDialog( wxWindow* aParent )
194{
195 for( wxWindow* child : aParent->GetChildren() )
196 {
197 if( DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( child ) )
198 {
199 if( dlg->IsQuasiModal() )
200 return dlg;
201
202 if( wxWindow* nestedDlg = findQuasiModalDialog( child ) )
203 return nestedDlg;
204 }
205 }
206
207 return nullptr;
208}
209
210
212{
213 if( wxWindow* dlg = ::findQuasiModalDialog( this ) )
214 return dlg;
215
216 // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
217 // so we have to look for it separately.
218 if( m_ident == FRAME_SCH )
219 {
220 wxWindow* cvpcb = wxWindow::FindWindowByName( wxS( "CvpcbFrame" ) );
221
222 if( cvpcb )
223 return cvpcb;
224 }
225
226 return nullptr;
227}
228
229
230void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
231{
232 // Don't allow closing when a quasi-modal is open.
233 wxWindow* quasiModal = findQuasiModalDialog();
234
235 if( quasiModal )
236 {
237 // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
238 // when they have no idea what those are.
239 quasiModal->Raise();
240 wxBell();
241
242 if( event.CanVeto() )
243 event.Veto();
244
245 return;
246 }
247
248
249 if( event.GetId() == wxEVT_QUERY_END_SESSION
250 || event.GetId() == wxEVT_END_SESSION )
251 {
252 // End session means the OS is going to terminate us
253 m_isNonUserClose = true;
254 }
255
256 if( canCloseWindow( event ) )
257 {
258 m_isClosing = true;
259
260 if( m_infoBar )
261 m_infoBar->Dismiss();
262
263 APP_SETTINGS_BASE* cfg = config();
264
265 if( cfg )
266 SaveSettings( cfg ); // virtual, wxFrame specific
267
269
270 // Destroy (safe delete frame) this frame only in non modal mode.
271 // In modal mode, the caller will call Destroy().
272 if( !IsModal() )
273 Destroy();
274 }
275 else
276 {
277 if( event.CanVeto() )
278 event.Veto();
279 }
280}
281
282
284{
285 Disconnect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
286 wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
287 Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
288
289 delete m_autoSaveTimer;
290 delete m_fileHistory;
291
293
295
297}
298
299
300bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
301{
302#ifdef __WXMAC__
303 // Apple in its infinite wisdom will raise a disabled window before even passing
304 // us the event, so we have no way to stop it. Instead, we have to catch an
305 // improperly ordered disabled window and quasi-modal dialog here and reorder
306 // them.
307 if( !IsEnabled() && IsActive() )
308 {
309 wxWindow* dlg = findQuasiModalDialog();
310
311 if( dlg )
312 dlg->Raise();
313 }
314#endif
315
316 if( !wxFrame::ProcessEvent( aEvent ) )
317 return false;
318
319 if( Pgm().m_Quitting )
320 return true;
321
322 if( !m_isClosing && m_supportsAutoSave && IsShownOnScreen() && IsActive()
324 && GetAutoSaveInterval() > 0 )
325 {
326 if( !m_autoSavePending )
327 {
328 wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
329 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
330 m_autoSavePending = true;
331 }
332 else if( m_autoSaveTimer->IsRunning() )
333 {
334 wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
335 m_autoSaveTimer->Stop();
336 m_autoSavePending = false;
337 }
338 }
339
340 return true;
341}
342
343
348
349
350void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
351{
352 // Don't stomp on someone else's timer event.
353 if( aEvent.GetId() != ID_AUTO_SAVE_TIMER )
354 {
355 aEvent.Skip();
356 return;
357 }
358
359 if( !doAutoSave() )
360 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
361}
362
363
365{
366 wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
367}
368
369
370void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& aKeyEvent )
371{
372 wxLogTrace( kicadTraceKeyEvent, wxS( "EDA_BASE_FRAME::OnCharHook %s" ), dump( aKeyEvent ) );
373
374 // Key events can be filtered here.
375 // Currently no filtering is made.
376 aKeyEvent.Skip();
377}
378
379
380void EDA_BASE_FRAME::OnMenuEvent( wxMenuEvent& aEvent )
381{
382 if( !m_toolDispatcher )
383 aEvent.Skip();
384 else
385 m_toolDispatcher->DispatchWxEvent( aEvent );
386}
387
388
390{
392 std::placeholders::_1,
393 this,
394 aConditions );
395
396 m_uiUpdateMap[aID] = evtFunc;
397
398 Bind( wxEVT_UPDATE_UI, evtFunc, aID );
399}
400
401
403{
404 const auto it = m_uiUpdateMap.find( aID );
405
406 if( it == m_uiUpdateMap.end() )
407 return;
408
409 Unbind( wxEVT_UPDATE_UI, it->second, aID );
410}
411
412
413void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
414 ACTION_CONDITIONS aCond )
415{
416 bool checkRes = false;
417 bool enableRes = true;
418 bool showRes = true;
419 bool isCut = aEvent.GetId() == ACTIONS::cut.GetUIId();
420 bool isCopy = aEvent.GetId() == ACTIONS::copy.GetUIId();
421 bool isPaste = aEvent.GetId() == ACTIONS::paste.GetUIId();
422 SELECTION& selection = aFrame->GetCurrentSelection();
423
424 try
425 {
426 checkRes = aCond.checkCondition( selection );
427 enableRes = aCond.enableCondition( selection );
428 showRes = aCond.showCondition( selection );
429 }
430 catch( std::exception& )
431 {
432 // Something broke with the conditions, just skip the event.
433 aEvent.Skip();
434 return;
435 }
436
437 if( showRes && aEvent.GetId() == ACTIONS::undo.GetUIId() )
438 {
439 wxString msg = _( "Undo" );
440
441 if( enableRes )
442 msg += wxS( " " ) + aFrame->GetUndoActionDescription();
443
444 aEvent.SetText( msg );
445 }
446 else if( showRes && aEvent.GetId() == ACTIONS::redo.GetUIId() )
447 {
448 wxString msg = _( "Redo" );
449
450 if( enableRes )
451 msg += wxS( " " ) + aFrame->GetRedoActionDescription();
452
453 aEvent.SetText( msg );
454 }
455
456 if( isCut || isCopy || isPaste )
457 {
458 wxWindow* focus = wxWindow::FindFocus();
459 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
460
461 if( textEntry && isCut && textEntry->CanCut() )
462 enableRes = true;
463 else if( textEntry && isCopy && textEntry->CanCopy() )
464 enableRes = true;
465 else if( textEntry && isPaste && textEntry->CanPaste() )
466 enableRes = true;
467 else if( dynamic_cast<WX_GRID*>( focus ) )
468 enableRes = false; // Must disable menu in order to get command as CharHook event
469 }
470
471 aEvent.Enable( enableRes );
472 aEvent.Show( showRes );
473
474 if( aEvent.IsCheckable() )
475 aEvent.Check( checkRes );
476}
477
478
480{
481 // Setup the conditions to check a language menu item
482 auto isCurrentLang =
483 [] ( const SELECTION& aSel, int aLangIdentifier )
484 {
485 return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
486 };
487
488 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
489 {
491 cond.Check( std::bind( isCurrentLang, std::placeholders::_1,
492 LanguagesList[ii].m_WX_Lang_Identifier ) );
493
494 RegisterUIUpdateHandler( LanguagesList[ii].m_KI_Lang_Identifier, cond );
495 }
496}
497
498
500 const ACTION_TOOLBAR_CONTROL_FACTORY& aControlFactory )
501{
502 m_toolbarControlFactories.emplace( aControlDesc.GetName(), aControlFactory );
503}
504
505
507{
508 for( auto& control : m_toolbarControlFactories )
509 {
510 if( control.first == aName )
511 return &control.second;
512 }
513
514 return nullptr;
515}
516
517
521
522
524{
525 wxWindowUpdateLocker dummy( this );
526
527 wxASSERT( m_toolbarSettings );
528
529 std::optional<TOOLBAR_CONFIGURATION> tbConfig;
530
531 // Drawing tools (typically on right edge of window)
532 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::RIGHT, config()->m_CustomToolbars );
533
534 if( tbConfig.has_value() )
535 {
536 if( !m_tbRight )
537 {
538 m_tbRight = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
539 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
540 m_tbRight->SetAuiManager( &m_auimgr );
541 }
542
543 m_tbRight->ApplyConfiguration( tbConfig.value() );
544 }
545
546 // Options (typically on left edge of window)
547 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::LEFT, config()->m_CustomToolbars );
548
549 if( tbConfig.has_value() )
550 {
551 if( !m_tbLeft )
552 {
553 m_tbLeft = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
554 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
555 m_tbLeft->SetAuiManager( &m_auimgr );
556 }
557
558 m_tbLeft->ApplyConfiguration( tbConfig.value() );
559 }
560
561 // Top main toolbar (the top one)
562 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::TOP_MAIN, config()->m_CustomToolbars );
563
564 if( tbConfig.has_value() )
565 {
566 if( !m_tbTopMain )
567 {
568 m_tbTopMain = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
569 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
570 m_tbTopMain->SetAuiManager( &m_auimgr );
571 }
572
573 m_tbTopMain->ApplyConfiguration( tbConfig.value() );
574 }
575
576 // Top aux toolbar (the bottom one)
577 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::TOP_AUX, config()->m_CustomToolbars );
578
579 if( tbConfig.has_value() )
580 {
581 if( !m_tbTopAux )
582 {
583 m_tbTopAux = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
584 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
585 m_tbTopAux->SetAuiManager( &m_auimgr );
586 }
587
588 m_tbTopAux->ApplyConfiguration( tbConfig.value() );
589 }
590}
591
592
594{
595 if( m_tbTopMain )
596 m_tbTopMain->UpdateControlWidths();
597
598 if( m_tbRight )
599 m_tbRight->UpdateControlWidths();
600
601 if( m_tbLeft )
602 m_tbLeft->UpdateControlWidths();
603
604 if( m_tbTopAux )
605 m_tbTopAux->UpdateControlWidths();
606
607}
608
609
611{
612 if( m_tbTopMain )
613 m_auimgr.GetPane( m_tbTopMain ).MaxSize( m_tbTopMain->GetSize() );
614
615 if( m_tbRight )
616 m_auimgr.GetPane( m_tbRight ).MaxSize( m_tbRight->GetSize() );
617
618 if( m_tbLeft )
619 m_auimgr.GetPane( m_tbLeft ).MaxSize( m_tbLeft->GetSize() );
620
621 if( m_tbTopAux )
622 m_auimgr.GetPane( m_tbTopAux ).MaxSize( m_tbTopAux->GetSize() );
623
624 m_auimgr.Update();
625}
626
627
629{
636
637 CallAfter( [this]()
638 {
639 if( !m_isClosing )
641 } );
642}
643
644
645void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
646{
647 COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
648 ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
649
650 helpMenu->Add( ACTIONS::help );
651 helpMenu->Add( ACTIONS::gettingStarted );
652 helpMenu->Add( ACTIONS::listHotKeys );
653 helpMenu->Add( ACTIONS::getInvolved );
654 helpMenu->Add( ACTIONS::donate );
655 helpMenu->Add( ACTIONS::reportBug );
656
657 helpMenu->AppendSeparator();
658 helpMenu->Add( ACTIONS::about );
659
660 aMenuBar->Append( helpMenu, _( "&Help" ) );
661}
662
663
665{
667
668 if( GetMenuBar() )
669 {
671 GetMenuBar()->Refresh();
672 }
673}
674
675
677{
679
680 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
681
682#ifdef KICAD_IPC_API
683 bool running = Pgm().GetApiServer().Running();
684
685 if( running && !settings->m_Api.enable_server )
686 Pgm().GetApiServer().Stop();
687 else if( !running && settings->m_Api.enable_server )
688 Pgm().GetApiServer().Start();
689#endif
690
691 if( m_fileHistory )
692 {
693 int historySize = settings->m_System.file_history_size;
694 m_fileHistory->SetMaxFiles( (unsigned) std::max( 0, historySize ) );
695 }
696
698 ThemeChanged();
699
700 if( GetMenuBar() )
701 {
702 // For icons in menus, icon scaling & hotkeys
704 GetMenuBar()->Refresh();
705 }
706
707 // Update the toolbars
709}
710
711
713{
715
716 // Update all the toolbars to have new icons
717 wxAuiPaneInfoArray panes = m_auimgr.GetAllPanes();
718
719 for( size_t i = 0; i < panes.GetCount(); ++i )
720 {
721 if( ACTION_TOOLBAR* toolbar = dynamic_cast<ACTION_TOOLBAR*>( panes[i].window ) )
722 toolbar->RefreshBitmaps();
723 }
724}
725
726
727void EDA_BASE_FRAME::OnSize( wxSizeEvent& aEvent )
728{
729#ifdef __WXMAC__
730 int currentDisplay = wxDisplay::GetFromWindow( this );
731
732 if( m_displayIndex >= 0 && currentDisplay >= 0 && currentDisplay != m_displayIndex )
733 {
734 wxLogTrace( traceDisplayLocation, wxS( "OnSize: current display changed %d to %d" ),
735 m_displayIndex, currentDisplay );
736 m_displayIndex = currentDisplay;
738 }
739#endif
740
741 aEvent.Skip();
742}
743
744
745void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
746{
747 if( !Pgm().GetCommonSettings()->m_Session.remember_open_files )
748 return;
749
750 const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName );
751
752 if( state != nullptr )
753 {
754 LoadWindowState( state->window );
755 }
756}
757
758
760{
761 bool wasDefault = false;
762
763 m_framePos.x = aState.pos_x;
764 m_framePos.y = aState.pos_y;
765 m_frameSize.x = aState.size_x;
766 m_frameSize.y = aState.size_y;
767
768 wxLogTrace( traceDisplayLocation, wxS( "Config position (%d, %d) with size (%d, %d)" ),
770
771 // Ensure minimum size is set if the stored config was zero-initialized
772 wxSize minSize = minSizeLookup( m_ident, this );
773
774 if( m_frameSize.x < minSize.x || m_frameSize.y < minSize.y )
775 {
777 wasDefault = true;
778
779 wxLogTrace( traceDisplayLocation, wxS( "Using minimum size (%d, %d)" ),
781 }
782
783 wxLogTrace( traceDisplayLocation, wxS( "Number of displays: %d" ), wxDisplay::GetCount() );
784
785 if( aState.display >= wxDisplay::GetCount() )
786 {
787 wxLogTrace( traceDisplayLocation, wxS( "Previous display not found" ) );
788
789 // If it isn't attached, use the first display
790 // Warning wxDisplay has 2 ctor variants. the parameter needs a type:
791 const unsigned int index = 0;
792 wxDisplay display( index );
793 wxRect clientSize = display.GetGeometry();
794
795 m_framePos = wxDefaultPosition;
796
797 // Ensure the window fits on the display, since the other one could have been larger
798 if( m_frameSize.x > clientSize.width )
799 m_frameSize.x = clientSize.width;
800
801 if( m_frameSize.y > clientSize.height )
802 m_frameSize.y = clientSize.height;
803 }
804 else
805 {
806 wxPoint upperRight( m_framePos.x + m_frameSize.x, m_framePos.y );
807 wxPoint upperLeft( m_framePos.x, m_framePos.y );
808
809 wxDisplay display( aState.display );
810 wxRect clientSize = display.GetClientArea();
811
812 int yLimTop = clientSize.y;
813 int yLimBottom = clientSize.y + clientSize.height;
814 int xLimLeft = clientSize.x;
815 int xLimRight = clientSize.x + clientSize.width;
816
817 if( upperLeft.x > xLimRight || // Upper left corner too close to right edge of screen
818 upperRight.x < xLimLeft || // Upper right corner too close to left edge of screen
819 upperLeft.y < yLimTop || // Upper corner too close to the bottom of the screen
820 upperLeft.y > yLimBottom )
821 {
822 m_framePos = wxDefaultPosition;
823 wxLogTrace( traceDisplayLocation, wxS( "Resetting to default position" ) );
824 }
825 }
826
827 wxLogTrace( traceDisplayLocation, wxS( "Final window position (%d, %d) with size (%d, %d)" ),
829
830 SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
831
832 // Center the window if we reset to default
833 if( m_framePos.x == -1 )
834 {
835 wxLogTrace( traceDisplayLocation, wxS( "Centering window" ) );
836 Center();
837 m_framePos = GetPosition();
838 }
839
840 // Record the frame sizes in an un-maximized state
843
844 // Maximize if we were maximized before
845 if( aState.maximized || ( wasDefault && m_maximizeByDefault ) )
846 {
847 wxLogTrace( traceDisplayLocation, wxS( "Maximizing window" ) );
848 Maximize();
849 }
850
851 m_displayIndex = wxDisplay::GetFromWindow( this );
852}
853
854
856{
857 wxDisplay display( wxDisplay::GetFromWindow( this ) );
858 wxRect clientSize = display.GetClientArea();
859 wxPoint pos = GetPosition();
860 wxSize size = GetWindowSize();
861
862 wxLogTrace( traceDisplayLocation,
863 wxS( "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d" ),
864 clientSize.x, clientSize.y,
865 clientSize.width, clientSize.height );
866
867 if( pos.y < clientSize.y )
868 {
869 wxLogTrace( traceDisplayLocation,
870 wxS( "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d" ), pos.y,
871 clientSize.y );
872 pos.y = clientSize.y;
873 }
874
875 if( pos.x < clientSize.x )
876 {
877 wxLogTrace( traceDisplayLocation,
878 wxS( "ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d" ),
879 pos.x, clientSize.x );
880 pos.x = clientSize.x;
881 }
882
883 if( pos.x + size.x - clientSize.x > clientSize.width )
884 {
885 int newWidth = clientSize.width - ( pos.x - clientSize.x );
886 wxLogTrace( traceDisplayLocation,
887 wxS( "ensureWindowIsOnScreen: effective width %d above available %d, setting "
888 "to %d" ), pos.x + size.x, clientSize.width, newWidth );
889 size.x = newWidth;
890 }
891
892 if( pos.y + size.y - clientSize.y > clientSize.height )
893 {
894 int newHeight = clientSize.height - ( pos.y - clientSize.y );
895 wxLogTrace( traceDisplayLocation,
896 wxS( "ensureWindowIsOnScreen: effective height %d above available %d, setting "
897 "to %d" ), pos.y + size.y, clientSize.height, newHeight );
898 size.y = newHeight;
899 }
900
901 wxLogTrace( traceDisplayLocation, wxS( "Updating window position (%d, %d) with size (%d, %d)" ),
902 pos.x, pos.y, size.x, size.y );
903
904 SetSize( pos.x, pos.y, size.x, size.y );
905}
906
907
917
918
920{
921 if( IsIconized() )
922 return;
923
924 // If the window is maximized, we use the saved window size from before it was maximized
925 if( IsMaximized() )
926 {
929 }
930 else
931 {
933 m_framePos = GetPosition();
934 }
935
936 aCfg->state.pos_x = m_framePos.x;
937 aCfg->state.pos_y = m_framePos.y;
938 aCfg->state.size_x = m_frameSize.x;
939 aCfg->state.size_y = m_frameSize.y;
940 aCfg->state.maximized = IsMaximized();
941 aCfg->state.display = wxDisplay::GetFromWindow( this );
942
943 wxLogTrace( traceDisplayLocation, wxS( "Saving window maximized: %s" ),
944 IsMaximized() ? wxS( "true" ) : wxS( "false" ) );
945 wxLogTrace( traceDisplayLocation, wxS( "Saving config position (%d, %d) with size (%d, %d)" ),
947
948 // Once this is fully implemented, wxAuiManager will be used to maintain
949 // the persistence of the main frame and all it's managed windows and
950 // all of the legacy frame persistence position code can be removed.
951 aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
952
953 aCfg->mru_path = m_mruPath;
954}
955
956
958{
960
961 // Get file history size from common settings
962 int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
963
964 // Load the recently used files into the history menu
965 m_fileHistory = new FILE_HISTORY( (unsigned) std::max( 1, fileHistorySize ),
967 m_fileHistory->Load( *aCfg );
968}
969
970
972{
973 wxCHECK( config(), /* void */ );
974
976
977 bool fileOpen = m_isClosing && m_isNonUserClose;
978
979 wxString currentlyOpenedFile = GetCurrentFileName();
980
981 if( Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
982 {
983 wxFileName rfn( currentlyOpenedFile );
984 rfn.MakeRelativeTo( Prj().GetProjectPath() );
985 Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &aCfg->m_Window, fileOpen );
986 }
987
988 // Save the recently used files list
989 if( m_fileHistory )
990 {
991 // Save the currently opened file in the file history
992 if( !currentlyOpenedFile.IsEmpty() )
993 UpdateFileHistory( currentlyOpenedFile );
994
995 m_fileHistory->Save( *aCfg );
996 }
997}
998
999
1004
1005
1007{
1008 // KICAD_MANAGER_FRAME overrides this
1009 return Kiface().KifaceSettings();
1010}
1011
1012
1014{
1015 return Kiface().KifaceSearch();
1016}
1017
1018
1020{
1021 return Kiface().GetHelpFileName();
1022}
1023
1024
1025void EDA_BASE_FRAME::PrintMsg( const wxString& text )
1026{
1027 SetStatusText( text );
1028}
1029
1030
1032{
1033#if defined( __WXOSX_MAC__ )
1035#else
1036 m_infoBar = new WX_INFOBAR( this, &m_auimgr );
1037
1038 m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( wxS( "InfoBar" ) ).Top().Layer(1) );
1039#endif
1040}
1041
1042
1044{
1045#if defined( __WXOSX_MAC__ )
1046 m_auimgr.Update();
1047#else
1048 // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
1049 // hiding it.
1050 m_auimgr.Update();
1051
1052 // We don't want the infobar displayed right away
1053 m_auimgr.GetPane( wxS( "InfoBar" ) ).Hide();
1054 m_auimgr.Update();
1055#endif
1056}
1057
1058
1059void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
1061{
1062 m_infoBar->RemoveAllButtons();
1063
1064 if( aShowCloseButton )
1065 m_infoBar->AddCloseButton();
1066
1067 GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR, aType );
1068}
1069
1070
1071void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
1072 std::function<void(void)> aCallback )
1073{
1074 m_infoBar->RemoveAllButtons();
1075
1076 if( aShowCloseButton )
1077 m_infoBar->AddCloseButton();
1078
1079 if( aCallback )
1080 m_infoBar->SetCallback( aCallback );
1081
1082 GetInfoBar()->ShowMessageFor( aErrorMsg, 6000, wxICON_ERROR );
1083}
1084
1085
1086void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton )
1087{
1088 m_infoBar->RemoveAllButtons();
1089
1090 if( aShowCloseButton )
1091 m_infoBar->AddCloseButton();
1092
1093 GetInfoBar()->ShowMessageFor( aWarningMsg, 6000, wxICON_WARNING );
1094}
1095
1096
1097void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton )
1098{
1099 m_infoBar->RemoveAllButtons();
1100
1101 if( aShowCloseButton )
1102 m_infoBar->AddCloseButton();
1103
1104 GetInfoBar()->ShowMessageFor( aMsg, 8000, wxICON_INFORMATION );
1105}
1106
1107
1108void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory )
1109{
1110 if( !aFileHistory )
1111 aFileHistory = m_fileHistory;
1112
1113 wxASSERT( aFileHistory );
1114
1115 aFileHistory->AddFileToHistory( FullFileName );
1116
1117 // Update the menubar to update the file history menu
1118 if( !m_isClosing && GetMenuBar() )
1119 {
1121 GetMenuBar()->Refresh();
1122 }
1123}
1124
1125
1126wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
1127 FILE_HISTORY* aFileHistory )
1128{
1129 if( !aFileHistory )
1130 aFileHistory = m_fileHistory;
1131
1132 wxASSERT( aFileHistory );
1133
1134 int baseId = aFileHistory->GetBaseId();
1135
1136 wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
1137
1138 unsigned i = cmdId - baseId;
1139
1140 if( i < aFileHistory->GetCount() )
1141 {
1142 wxString fn = aFileHistory->GetHistoryFile( i );
1143
1144 if( wxFileName::FileExists( fn ) )
1145 {
1146 return fn;
1147 }
1148 else
1149 {
1150 DisplayErrorMessage( this, wxString::Format( _( "File '%s' was not found." ), fn ) );
1151 aFileHistory->RemoveFileFromHistory( i );
1152 }
1153 }
1154
1155 // Update the menubar to update the file history menu
1156 if( GetMenuBar() )
1157 {
1159 GetMenuBar()->Refresh();
1160 }
1161
1162 return wxEmptyString;
1163}
1164
1165
1167{
1168 wxASSERT( m_fileHistory );
1169
1170 m_fileHistory->ClearFileHistory();
1171
1172 // Update the menubar to update the file history menu
1173 if( GetMenuBar() )
1174 {
1176 GetMenuBar()->Refresh();
1177 }
1178}
1179
1180
1181void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
1182{
1183 void ShowAboutDialog( EDA_BASE_FRAME * aParent ); // See AboutDialog_main.cpp
1184 ShowAboutDialog( this );
1185}
1186
1187
1188void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
1189{
1190 ShowPreferences( wxEmptyString, wxEmptyString );
1191}
1192
1193
1194void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParentPage )
1195{
1196 PAGED_DIALOG dlg( this, _( "Preferences" ), true, true, wxEmptyString,
1197 wxWindow::FromDIP( wxSize( 980, 560 ), nullptr ) );
1198
1199 dlg.SetEvtHandlerEnabled( false );
1200
1201 {
1202 WX_BUSY_INDICATOR busy_cursor;
1203
1204 WX_TREEBOOK* book = dlg.GetTreebook();
1205 PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
1206 std::vector<int> expand;
1207
1208 wxWindow* kicadMgr_window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
1209
1210 if( KICAD_MANAGER_FRAME* kicadMgr = static_cast<KICAD_MANAGER_FRAME*>( kicadMgr_window ) )
1211 {
1212 ACTION_MANAGER* actionMgr = kicadMgr->GetToolManager()->GetActionManager();
1213
1214 for( const auto& [name, action] : actionMgr->GetActions() )
1215 hotkeysPanel->ActionsList().push_back( action );
1216 }
1217
1218 book->AddLazyPage(
1219 []( wxWindow* aParent ) -> wxWindow*
1220 {
1221 return new PANEL_COMMON_SETTINGS( aParent );
1222 },
1223 _( "Common" ) );
1224
1225 book->AddLazyPage(
1226 []( wxWindow* aParent ) -> wxWindow*
1227 {
1228 return new PANEL_MOUSE_SETTINGS( aParent );
1229 }, _( "Mouse and Touchpad" ) );
1230
1231 book->AddLazyPage(
1232 [] ( wxWindow* aParent ) -> wxWindow*
1233 {
1234 return new PANEL_SPACEMOUSE( aParent );
1235 }, _( "SpaceMouse" ) );
1236
1237 book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
1238
1239 book->AddLazyPage(
1240 []( wxWindow* aParent ) -> wxWindow*
1241 {
1242 return new PANEL_GIT_REPOS( aParent );
1243 }, _( "Version Control" ) );
1244
1245#ifdef KICAD_USE_SENTRY
1246 book->AddLazyPage(
1247 []( wxWindow* aParent ) -> wxWindow*
1248 {
1249 return new PANEL_DATA_COLLECTION( aParent );
1250 }, _( "Data Collection" ) );
1251#endif
1252
1253#define LAZY_CTOR( key ) \
1254 [this, kiface]( wxWindow* aParent ) \
1255 { \
1256 return kiface->CreateKiWindow( aParent, key, &Kiway() ); \
1257 }
1258
1259 // If a dll is not loaded, the loader will show an error message.
1260
1261 try
1262 {
1263 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_SCH ) )
1264 {
1265 kiface->GetActions( hotkeysPanel->ActionsList() );
1266
1268 expand.push_back( (int) book->GetPageCount() );
1269
1270 book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) );
1271 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_DISP_OPTIONS ), _( "Display Options" ) );
1272 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_GRIDS ), _( "Grids" ) );
1273 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_OPTIONS ), _( "Editing Options" ) );
1274 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_COLORS ), _( "Colors" ) );
1275
1276 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1277 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_TOOLBARS ), _( "Toolbars" ) );
1278
1279 if( GetFrameType() == FRAME_SCH )
1280 expand.push_back( (int) book->GetPageCount() );
1281
1282 book->AddPage( new wxPanel( book ), _( "Schematic Editor" ) );
1283 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_DISP_OPTIONS ), _( "Display Options" ) );
1284 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_GRIDS ), _( "Grids" ) );
1285 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_EDIT_OPTIONS ), _( "Editing Options" ) );
1286 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_COLORS ), _( "Colors" ) );
1287
1288 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1289 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_TOOLBARS ), _( "Toolbars" ) );
1290
1291 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_FIELD_NAME_TEMPLATES ), _( "Field Name Templates" ) );
1292 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_SIMULATOR ), _( "Simulator" ) );
1293 }
1294 }
1295 catch( ... )
1296 {
1297 }
1298
1299 try
1300 {
1301 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PCB ) )
1302 {
1303 kiface->GetActions( hotkeysPanel->ActionsList() );
1304
1306 expand.push_back( (int) book->GetPageCount() );
1307
1308 book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
1309 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DISPLAY_OPTIONS ), _( "Display Options" ) );
1310 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_GRIDS ), _( "Grids" ) );
1311 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_ORIGINS_AXES ), _( "Origins & Axes" ) );
1312 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_EDIT_OPTIONS ), _( "Editing Options" ) );
1313 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_COLORS ), _( "Colors" ) );
1314
1315 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1316 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_TOOLBARS ), _( "Toolbars" ) );
1317
1318 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_FIELDS ), _( "Footprint Defaults" ) );
1319 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_GRAPHICS_VALUES ), _( "Graphics Defaults" ) );
1320
1322 expand.push_back( (int) book->GetPageCount() );
1323
1324 book->AddPage( new wxPanel( book ), _( "PCB Editor" ) );
1325 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_DISPLAY_OPTS ), _( "Display Options" ) );
1326 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_GRIDS ), _( "Grids" ) );
1327 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_ORIGINS_AXES ), _( "Origins & Axes" ) );
1328 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_EDIT_OPTIONS ), _( "Editing Options" ) );
1329 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_COLORS ), _( "Colors" ) );
1330
1331 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1332 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_TOOLBARS ), _( "Toolbars" ) );
1333
1334 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_ACTION_PLUGINS ), _( "Plugins" ) );
1335
1337 expand.push_back( (int) book->GetPageCount() );
1338
1339 book->AddPage( new wxPanel( book ), _( "3D Viewer" ) );
1340 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_DISPLAY_OPTIONS ), _( "General" ) );
1341
1342 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1343 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_TOOLBARS ), _( "Toolbars" ) );
1344
1345 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_OPENGL ), _( "Realtime Renderer" ) );
1346 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_RAYTRACING ), _( "Raytracing Renderer" ) );
1347 }
1348 }
1349 catch( ... )
1350 {
1351 }
1352
1353 try
1354 {
1355 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_GERBVIEW ) )
1356 {
1357 kiface->GetActions( hotkeysPanel->ActionsList() );
1358
1359 if( GetFrameType() == FRAME_GERBER )
1360 expand.push_back( (int) book->GetPageCount() );
1361
1362 book->AddPage( new wxPanel( book ), _( "Gerber Viewer" ) );
1363 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_DISPLAY_OPTIONS ), _( "Display Options" ) );
1364 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_COLORS ), _( "Colors" ) );
1365
1366 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1367 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_TOOLBARS ), _( "Toolbars" ) );
1368
1369 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_GRIDS ), _( "Grids" ) );
1370 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_EXCELLON_OPTIONS ), _( "Excellon Options" ) );
1371 }
1372 }
1373 catch( ... )
1374 {
1375 }
1376
1377 try
1378 {
1379 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PL_EDITOR ) )
1380 {
1381 kiface->GetActions( hotkeysPanel->ActionsList() );
1382
1383 if( GetFrameType() == FRAME_PL_EDITOR )
1384 expand.push_back( (int) book->GetPageCount() );
1385
1386 book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) );
1387 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_DISPLAY_OPTIONS ), _( "Display Options" ) );
1388 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_GRIDS ), _( "Grids" ) );
1389 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_COLORS ), _( "Colors" ) );
1390
1391 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1392 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_TOOLBARS ), _( "Toolbars" ) );
1393
1394 book->AddLazyPage(
1395 []( wxWindow* aParent ) -> wxWindow*
1396 {
1397 return new PANEL_PACKAGES_AND_UPDATES( aParent );
1398 }, _( "Packages and Updates" ) );
1399 }
1400 }
1401 catch( ... )
1402 {
1403 }
1404
1405#ifdef KICAD_IPC_API
1406 book->AddPage( new PANEL_PLUGIN_SETTINGS( book ), _( "Plugins" ) );
1407#endif
1408
1409 book->AddPage( new PANEL_MAINTENANCE( book, this ), _( "Maintenance" ) );
1410
1411 // Update all of the action hotkeys. The process of loading the actions through
1412 // the KiFACE will only get us the default hotkeys
1413 ReadHotKeyConfigIntoActions( wxEmptyString, hotkeysPanel->ActionsList() );
1414
1415 for( size_t i = 0; i < book->GetPageCount(); ++i )
1416 book->GetPage( i )->Layout();
1417
1418 for( int page : expand )
1419 book->ExpandNode( page );
1420
1421 if( !aStartPage.IsEmpty() )
1422 dlg.SetInitialPage( aStartPage, aStartParentPage );
1423
1424 dlg.SetEvtHandlerEnabled( true );
1425#undef LAZY_CTOR
1426 }
1427
1428 if( dlg.ShowModal() == wxID_OK )
1429 {
1430 // Update our grids that are cached in the tool
1431 m_toolManager->ResetTools( TOOL_BASE::REDRAW );
1434 }
1435
1436}
1437
1438
1439void EDA_BASE_FRAME::OnDropFiles( wxDropFilesEvent& aEvent )
1440{
1441 Raise();
1442
1443 wxString* files = aEvent.GetFiles();
1444
1445 for( int nb = 0; nb < aEvent.GetNumberOfFiles(); nb++ )
1446 {
1447 const wxFileName fn = wxFileName( files[nb] );
1448 wxString ext = fn.GetExt();
1449
1450 // Alias all gerber files as GerberFileExtension
1453
1454 if( m_acceptedExts.find( ext.ToStdString() ) != m_acceptedExts.end() )
1455 m_AcceptedFiles.emplace_back( fn );
1456 }
1457
1459 m_AcceptedFiles.clear();
1460}
1461
1462
1464{
1465 for( const wxFileName& file : m_AcceptedFiles )
1466 {
1467 wxString fn = file.GetFullPath();
1468 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( file.GetExt() ), &fn );
1469 }
1470}
1471
1472
1473bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName, bool aVerbose )
1474{
1475 wxString msg;
1476 wxFileName fn = aFileName;
1477
1478 // Check for absence of a file path with a file name. Unfortunately KiCad
1479 // uses paths relative to the current project path without the ./ part which
1480 // confuses wxFileName. Making the file name path absolute may be less than
1481 // elegant but it solves the problem.
1482 if( fn.GetPath().IsEmpty() && fn.HasName() )
1483 fn.MakeAbsolute();
1484
1485 wxCHECK_MSG( fn.IsOk(), false,
1486 wxT( "File name object is invalid. Bad programmer!" ) );
1487 wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
1488 wxT( "File name object path <" ) + fn.GetFullPath() +
1489 wxT( "> is not set. Bad programmer!" ) );
1490
1491 if( fn.IsDir() && !fn.IsDirWritable() )
1492 {
1493 msg.Printf( _( "Insufficient permissions to folder '%s'." ), fn.GetPath() );
1494 }
1495 else if( !fn.FileExists() && !fn.IsDirWritable() )
1496 {
1497 msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1498 }
1499 else if( fn.FileExists() && !fn.IsFileWritable() )
1500 {
1501 msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1502 }
1503
1504 if( !msg.IsEmpty() )
1505 {
1506 if( aVerbose )
1507 DisplayErrorMessage( this, msg );
1508
1509 return false;
1510 }
1511
1512 return true;
1513}
1514
1515
1516void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
1517{
1518 if( !Pgm().IsGUI() )
1519 return;
1520
1521 wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1522
1523 wxFileName autoSaveFileName = aFileName;
1524
1525 // Check for auto save file.
1526 autoSaveFileName.SetName( FILEEXT::AutoSaveFilePrefix + aFileName.GetName() );
1527
1528 wxLogTrace( traceAutoSave,
1529 wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
1530
1531 if( !autoSaveFileName.FileExists() )
1532 return;
1533
1534 wxString msg = wxString::Format( _( "Well this is potentially embarrassing!\n"
1535 "It appears that the last time you were editing\n"
1536 "%s\n"
1537 "KiCad exited before saving.\n"
1538 "\n"
1539 "Do you wish to open the auto-saved file instead?" ),
1540 aFileName.GetFullName() );
1541
1542 int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1543 this );
1544
1545 // Make a backup of the current file, delete the file, and rename the auto save file to
1546 // the file name.
1547 if( response == wxYES )
1548 {
1549 // Preserve the permissions of the current file
1550 KIPLATFORM::IO::DuplicatePermissions( aFileName.GetFullPath(),
1551 autoSaveFileName.GetFullPath() );
1552
1553 if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
1554 {
1555 wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
1556 Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
1557 }
1558 }
1559 else
1560 {
1561 DeleteAutoSaveFile( aFileName );
1562 }
1563}
1564
1565
1566void EDA_BASE_FRAME::DeleteAutoSaveFile( const wxFileName& aFileName )
1567{
1568 if( !Pgm().IsGUI() )
1569 return;
1570
1571 wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1572
1573 wxFileName autoSaveFn = aFileName;
1574 autoSaveFn.SetName( FILEEXT::AutoSaveFilePrefix + aFileName.GetName() );
1575
1576 if( autoSaveFn.FileExists() )
1577 {
1578 wxLogTrace( traceAutoSave, wxT( "Removing auto save file " ) + autoSaveFn.GetFullPath() );
1579 wxRemoveFile( autoSaveFn.GetFullPath() );
1580 }
1581}
1582
1583
1585{
1586 // This function should be overridden in child classes
1587 return false;
1588}
1589
1590
1592{
1593 wxAcceleratorEntry entries[1];
1594 entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
1595 wxAcceleratorTable accel( 1, entries );
1596 SetAcceleratorTable( accel );
1597}
1598
1599
1605
1606
1608{
1609 m_undoList.PushCommand( aNewitem );
1610
1611 // Delete the extra items, if count max reached
1612 if( m_undoRedoCountMax > 0 )
1613 {
1614 int extraitems = GetUndoCommandCount() - m_undoRedoCountMax;
1615
1616 if( extraitems > 0 )
1617 ClearUndoORRedoList( UNDO_LIST, extraitems );
1618 }
1619}
1620
1621
1623{
1624 m_redoList.PushCommand( aNewitem );
1625
1626 // Delete the extra items, if count max reached
1627 if( m_undoRedoCountMax > 0 )
1628 {
1629 int extraitems = GetRedoCommandCount() - m_undoRedoCountMax;
1630
1631 if( extraitems > 0 )
1632 ClearUndoORRedoList( REDO_LIST, extraitems );
1633 }
1634}
1635
1636
1641
1642
1647
1648
1650{
1651 if( GetUndoCommandCount() > 0 )
1652 return m_undoList.m_CommandsList.back()->GetDescription();
1653
1654 return wxEmptyString;
1655}
1656
1657
1659{
1660 if( GetRedoCommandCount() > 0 )
1661 return m_redoList.m_CommandsList.back()->GetDescription();
1662
1663 return wxEmptyString;
1664}
1665
1666
1668{
1669 m_autoSaveRequired = true;
1670}
1671
1672
1674{
1675 SetUserUnits( aUnits );
1677
1678 wxCommandEvent e( EDA_EVT_UNITS_CHANGED );
1679 e.SetInt( static_cast<int>( aUnits ) );
1680 e.SetClientData( this );
1681 ProcessEventLocally( e );
1682}
1683
1684
1685void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
1686{
1687 // When we maximize the window, we want to save the old information
1688 // so that we can add it to the settings on next window load.
1689 // Contrary to the documentation, this event seems to be generated
1690 // when the window is also being unmaximized on OSX, so we only
1691 // capture the size information when we maximize the window when on OSX.
1692#ifdef __WXOSX__
1693 if( !IsMaximized() )
1694#endif
1695 {
1697 m_normalFramePos = GetPosition();
1698 wxLogTrace( traceDisplayLocation,
1699 "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
1702 }
1703
1704 // Skip event to actually maximize the window
1705 aEvent.Skip();
1706}
1707
1708
1710{
1711#ifdef __WXGTK__
1712 wxSize winSize = GetSize();
1713
1714 // GTK includes the window decorations in the normal GetSize call,
1715 // so we have to use a GTK-specific sizing call that returns the
1716 // non-decorated window size.
1718 {
1719 int width = 0;
1720 int height = 0;
1721 GTKDoGetSize( &width, &height );
1722
1723 winSize.Set( width, height );
1724 }
1725#else
1726 wxSize winSize = GetSize();
1727#endif
1728
1729 return winSize;
1730}
1731
1732
1734{
1735 // Update the icon theme when the system theme changes and update the toolbars
1737 ThemeChanged();
1738
1739 // This isn't handled by ThemeChanged()
1740 if( GetMenuBar() )
1741 {
1742 // For icons in menus, icon scaling & hotkeys
1744 GetMenuBar()->Refresh();
1745 }
1746}
1747
1748
1749void EDA_BASE_FRAME::onSystemColorChange( wxSysColourChangedEvent& aEvent )
1750{
1751 // Call the handler to update the colors used in the frame
1753
1754 // Skip the change event to ensure the rest of the window controls get it
1755 aEvent.Skip();
1756}
1757
1758
1759void EDA_BASE_FRAME::onIconize( wxIconizeEvent& aEvent )
1760{
1761 // Call the handler
1762 handleIconizeEvent( aEvent );
1763
1764 // Skip the event.
1765 aEvent.Skip();
1766}
1767
1768
1769#ifdef __WXMSW__
1770WXLRESULT EDA_BASE_FRAME::MSWWindowProc( WXUINT message, WXWPARAM wParam, WXLPARAM lParam )
1771{
1772 // This will help avoid the menu keeping focus when the alt key is released
1773 // You can still trigger accelerators as long as you hold down alt
1774 if( message == WM_SYSCOMMAND )
1775 {
1776 if( wParam == SC_KEYMENU && ( lParam >> 16 ) <= 0 )
1777 return 0;
1778 }
1779
1780 return wxFrame::MSWWindowProc( message, wParam, lParam );
1781}
1782#endif
1783
1784
1786{
1787 ACTION_MENU* langsMenu = new ACTION_MENU( false, aControlTool );
1788 langsMenu->SetTitle( _( "Set Language" ) );
1789 langsMenu->SetIcon( BITMAPS::language );
1790
1791 wxString tooltip;
1792
1793 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
1794 {
1795 wxString label;
1796
1797 if( LanguagesList[ii].m_DoNotTranslate )
1798 label = LanguagesList[ii].m_Lang_Label;
1799 else
1800 label = wxGetTranslation( LanguagesList[ii].m_Lang_Label );
1801
1802 wxMenuItem* item =
1803 new wxMenuItem( langsMenu,
1804 LanguagesList[ii].m_KI_Lang_Identifier, // wxMenuItem wxID
1805 label, tooltip, wxITEM_CHECK );
1806
1807 langsMenu->Append( item );
1808 }
1809
1810 // This must be done after the items are added
1811 aMasterMenu->Add( langsMenu );
1812}
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
const char * name
std::function< void(ACTION_TOOLBAR *)> ACTION_TOOLBAR_CONTROL_FACTORY
Type for the function signature that is used to add custom controls to the toolbar.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void ClearScaledBitmapCache()
Wipes out the scaled bitmap cache so that the icon theme can be changed.
Definition bitmap.cpp:172
BITMAP_STORE * GetBitmapStore()
Definition bitmap.cpp:92
static TOOL_ACTION paste
Definition actions.h:80
static TOOL_ACTION about
Definition actions.h:288
static TOOL_ACTION reportBug
Definition actions.h:292
static TOOL_ACTION copy
Definition actions.h:78
static TOOL_ACTION donate
Definition actions.h:290
static TOOL_ACTION listHotKeys
Definition actions.h:289
static TOOL_ACTION getInvolved
Definition actions.h:291
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION cut
Definition actions.h:77
static TOOL_ACTION gettingStarted
Definition actions.h:286
static TOOL_ACTION help
Definition actions.h:287
Manage TOOL_ACTION objects.
const std::map< std::string, TOOL_ACTION * > & GetActions() const
Get a list of currently-registered actions mapped by their name.
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:47
void SetTitle(const wxString &aTitle) override
Set title for the menu.
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
Class to hold basic information about controls that can be added to the toolbars.
const std::string & GetName() const
Define the structure of a toolbar with buttons that invoke ACTIONs.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
WINDOW_SETTINGS m_Window
void ThemeChanged()
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.
Handle actions that are shared between different applications.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:68
int ShowModal() override
The base frame for deriving all KiCad main window classes.
virtual wxString help_name()
virtual bool doAutoSave()
This should be overridden by the derived class to handle the auto save feature.
void LoadWindowState(const wxString &aFileName)
FRAME_T GetFrameType() const
virtual void UnregisterUIUpdateHandler(int aID) override
Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler.
virtual bool isAutoSaveRequired() const
Return the auto save status of the application.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void handleIconizeEvent(wxIconizeEvent &aEvent)
Handle a window iconize event.
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
void windowClosing(wxCloseEvent &event)
(with its unexpected name so it does not collide with the real OnWindowClose() function provided in d...
virtual void OnCharHook(wxKeyEvent &aKeyEvent)
Capture the key event before it is sent to the GUI.
virtual int GetRedoCommandCount() const
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
UNDO_REDO_CONTAINER m_undoList
virtual void OnMove(wxMoveEvent &aEvent)
virtual WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg)
Return a pointer to the window settings for this frame.
virtual void doCloseWindow()
void OnToolbarSizeChanged()
Update toolbars if desired toolbar icon changed.
void OnMenuEvent(wxMenuEvent &event)
The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't ...
virtual bool IsModal() const
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void HandleSystemColorChange()
Update the UI in response to a change in the system colors.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void ensureWindowIsOnScreen()
bool m_isNonUserClose
Set by NonUserClose() to indicate that the user did not request the current close.
void LoadWindowSettings(const WINDOW_SETTINGS *aCfg)
Load window settings from the given settings object.
std::vector< wxFileName > m_AcceptedFiles
virtual void CheckForAutoSaveFile(const wxFileName &aFileName)
Check if an auto save file exists for aFileName and takes the appropriate action depending on the use...
bool m_autoSavePermissionError
void OnKicadAbout(wxCommandEvent &event)
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
virtual void DoWithAcceptedFiles()
Execute action on accepted dropped file.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
wxWindow * findQuasiModalDialog()
static void HandleUpdateUIEvent(wxUpdateUIEvent &aEvent, EDA_BASE_FRAME *aFrame, ACTION_CONDITIONS aCond)
Handle events generated when the UI is trying to figure out the current state of the UI controls rela...
wxString m_perspective
virtual void ClearUndoORRedoList(UNDO_REDO_LIST aList, int aItemCount=-1)
Remove the aItemCount of old commands from aList and delete commands, pickers and picked items if nee...
virtual void ThemeChanged()
Process light/dark theme change.
EDA_BASE_FRAME(wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, KIWAY *aKiway, const EDA_IU_SCALE &aIuScale)
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars.
ACTION_TOOLBAR * m_tbRight
void ShowPreferences(wxString aStartPage, wxString aStartParentPage)
Display the preferences and settings of all opened editors paged dialog, starting with a particular p...
void initExitKey()
Set the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
void OnPreferences(wxCommandEvent &event)
virtual const SEARCH_STACK & sys_search()
Return a SEARCH_STACK pertaining to entire program.
WX_INFOBAR * m_infoBar
void onAutoSaveTimer(wxTimerEvent &aEvent)
Handle the auto save timer event.
void SaveWindowSettings(WINDOW_SETTINGS *aCfg)
Save window settings to the given settings object.
virtual wxString GetRedoActionDescription() const
TOOLBAR_SETTINGS * m_toolbarSettings
virtual wxString GetCurrentFileName() const
Get the full filename + path of the currently opened file in the frame.
void ChangeUserUnits(EDA_UNITS aUnits)
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Create a menu list for language choice, and add it as submenu to MasterMenu.
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
virtual void configureToolbars()
wxTimer * m_autoSaveTimer
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxAuiManager m_auimgr
void PrintMsg(const wxString &text)
void commonInit(FRAME_T aFrameType)
Collect common initialization functions used in all CTORs.
virtual bool IsContentModified() const
Get if the contents of the frame have been modified since the last save.
void ShowInfoBarWarning(const wxString &aWarningMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left ...
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual void RecreateToolbars()
std::map< int, UIUpdateHandler > m_uiUpdateMap
Map containing the UI update handlers registered with wx for each action.
std::map< std::string, ACTION_TOOLBAR_CONTROL_FACTORY > m_toolbarControlFactories
ACTION_TOOLBAR_CONTROL_FACTORY * GetCustomToolbarControlFactory(const std::string &aName)
UNDO_REDO_CONTAINER m_redoList
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
FILE_HISTORY * m_fileHistory
ACTION_TOOLBAR * m_tbLeft
SETTINGS_MANAGER * m_settingsManager
virtual void DeleteAutoSaveFile(const wxFileName &aFileName)
virtual void OnSize(wxSizeEvent &aEvent)
virtual wxString GetUndoActionDescription() const
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual bool canCloseWindow(wxCloseEvent &aCloseEvent)
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Check if aFileName can be written.
wxPoint m_normalFramePos
void OnMaximize(wxMaximizeEvent &aEvent)
virtual void ClearFileHistory()
Remove all files from the file history.
ACTION_TOOLBAR * m_tbTopAux
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handle event fired when a file is dropped to the window.
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
void onIconize(wxIconizeEvent &aEvent)
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch the file name from the file history list.
wxSize GetWindowSize()
Get the undecorated window size that can be used for restoring the window size.
int GetAutoSaveInterval() const
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void onSystemColorChange(wxSysColourChangedEvent &aEvent)
virtual int GetUndoCommandCount() const
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
ACTION_TOOLBAR * m_tbTopMain
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Add the standard KiCad help menu to the menubar.
void ReCreateMenuBar()
Recreate the menu bar.
virtual void doReCreateMenuBar()
WX_INFOBAR * GetInfoBar()
Specialization of the wxAuiPaneInfo class for KiCad panels.
This class implements a file history object to store a list of files, that can then be added to a men...
void AddFileToHistory(const wxString &aFile) override
Adds a file to the history.
The main KiCad project manager frame.
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:95
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY_HOLDER(KIWAY *aKiway, HOLDER_TYPE aType)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:286
@ FACE_SCH
eeschema DSO
Definition kiway.h:293
@ FACE_PL_EDITOR
Definition kiway.h:297
@ FACE_PCB
pcbnew DSO
Definition kiway.h:294
@ FACE_GERBVIEW
Definition kiway.h:296
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition kiway.cpp:589
WX_TREEBOOK * GetTreebook()
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
std::vector< TOOL_ACTION * > & ActionsList()
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
Definition paths.cpp:136
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:576
virtual int GetSelectedLanguageIdentifier() const
Definition pgm_base.h:229
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:125
A holder to handle information on schematic or board items.
void SaveFileState(const wxString &aFileName, const WINDOW_SETTINGS *aWindowCfg, bool aOpen)
const PROJECT_FILE_STATE * GetFileState(const wxString &aFileName)
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition project.h:210
Look for files in a number of paths.
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
virtual void CommonSettingsChanged(int aFlags=0)
Notification event that some of the common (suite-wide) settings have changed.
TOOL_MANAGER * m_toolManager
virtual void ShowChangedLanguage()
TOOL_DISPATCHER * m_toolDispatcher
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
@ REDRAW
Full drawing refresh.
Definition tool_base.h:83
UNITS_PROVIDER(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits)
void SetUserUnits(EDA_UNITS aUnits)
Simple wrapper around wxBusyCursor for used with the generic BUSY_INDICATOR interface.
A modified version of the wxInfoBar class that allows us to:
Definition wx_infobar.h:76
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
MESSAGE_TYPE
Sets the type of message for special handling if needed.
Definition wx_infobar.h:94
bool AddLazyPage(std::function< wxWindow *(wxWindow *aParent)> aLazyCtor, const wxString &text, bool bSelect=false, int imageId=NO_IMAGE)
bool AddLazySubPage(std::function< wxWindow *(wxWindow *aParent)> aLazyCtor, const wxString &text, bool bSelect=false, int imageId=NO_IMAGE)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:194
This file is part of the common library.
const int minSize
Push and Shove router track width and via size dialog.
#define _(s)
static const wxSize minSizeLookup(FRAME_T aFrameType, wxWindow *aWindow)
#define LAZY_CTOR(key)
static const wxSize defaultSize(FRAME_T aFrameType, wxWindow *aWindow)
wxWindow * findQuasiModalDialog(wxWindow *aParent)
Base window classes and related definitions.
#define KICAD_MANAGER_FRAME_NAME
#define DEFAULT_MAX_UNDO_ITEMS
std::function< void(wxUpdateUIEvent &) > UIUpdateHandler
This is the handler functor for the update UI events.
void SocketCleanup()
Must be called to clean up the socket thread used by SendCommand.
Definition eda_dde.cpp:319
DDE server & client.
EDA_UNITS
Definition eda_units.h:48
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:33
@ PANEL_PCB_GRIDS
Definition frame_type.h:96
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
@ PANEL_SYM_EDIT_GRIDS
Definition frame_type.h:73
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:35
@ PANEL_3DV_TOOLBARS
Definition frame_type.h:106
@ PANEL_SCH_FIELD_NAME_TEMPLATES
Definition frame_type.h:83
@ PANEL_DS_TOOLBARS
Definition frame_type.h:118
@ PANEL_SCH_TOOLBARS
Definition frame_type.h:82
@ PANEL_GBR_DISPLAY_OPTIONS
Definition frame_type.h:108
@ PANEL_3DV_OPENGL
Definition frame_type.h:104
@ PANEL_FP_DEFAULT_GRAPHICS_VALUES
Definition frame_type.h:92
@ PANEL_PCB_TOOLBARS
Definition frame_type.h:99
@ PANEL_PCB_ORIGINS_AXES
Definition frame_type.h:101
@ PANEL_PCB_EDIT_OPTIONS
Definition frame_type.h:97
@ PANEL_SCH_DISP_OPTIONS
Definition frame_type.h:78
@ PANEL_FP_DISPLAY_OPTIONS
Definition frame_type.h:86
@ PANEL_SCH_SIMULATOR
Definition frame_type.h:84
@ FRAME_SCH
Definition frame_type.h:34
@ PANEL_DS_COLORS
Definition frame_type.h:117
@ PANEL_PCB_COLORS
Definition frame_type.h:98
@ PANEL_SYM_TOOLBARS
Definition frame_type.h:76
@ PANEL_3DV_RAYTRACING
Definition frame_type.h:105
@ PANEL_SYM_EDIT_OPTIONS
Definition frame_type.h:74
@ PANEL_FP_GRIDS
Definition frame_type.h:87
@ PANEL_SCH_EDIT_OPTIONS
Definition frame_type.h:80
@ PANEL_FP_ORIGINS_AXES
Definition frame_type.h:93
@ PANEL_SYM_DISP_OPTIONS
Definition frame_type.h:72
@ PANEL_PCB_DISPLAY_OPTS
Definition frame_type.h:95
@ PANEL_FP_COLORS
Definition frame_type.h:89
@ PANEL_FP_DEFAULT_FIELDS
Definition frame_type.h:91
@ PANEL_SYM_COLORS
Definition frame_type.h:75
@ FRAME_PL_EDITOR
Definition frame_type.h:59
@ PANEL_GBR_GRIDS
Definition frame_type.h:111
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:43
@ FRAME_GERBER
Definition frame_type.h:57
@ PANEL_DS_GRIDS
Definition frame_type.h:116
@ FRAME_PCB_DISPLAY3D
Definition frame_type.h:47
@ PANEL_GBR_TOOLBARS
Definition frame_type.h:113
@ PANEL_FP_EDIT_OPTIONS
Definition frame_type.h:88
@ PANEL_SCH_GRIDS
Definition frame_type.h:79
@ PANEL_FP_TOOLBARS
Definition frame_type.h:90
@ PANEL_PCB_ACTION_PLUGINS
Definition frame_type.h:100
@ PANEL_3DV_DISPLAY_OPTIONS
Definition frame_type.h:103
@ PANEL_DS_DISPLAY_OPTIONS
Definition frame_type.h:115
@ PANEL_SCH_COLORS
Definition frame_type.h:81
@ PANEL_GBR_COLORS
Definition frame_type.h:112
@ PANEL_GBR_EXCELLON_OPTIONS
Definition frame_type.h:110
@ KICAD_MAIN_FRAME_T
Definition frame_type.h:68
static const std::string GerberFileExtension
static const std::string AutoSaveFilePrefix
static bool IsGerberFileExtension(const wxString &ext)
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
void ReadHotKeyConfigIntoActions(const wxString &aFileName, std::vector< TOOL_ACTION * > &aActions)
Read a hotkey config file into a list of actions.
@ ID_FILE_LIST_CLEAR
Definition id.h:62
@ ID_FILE1
Definition id.h:59
@ ID_AUTO_SAVE_TIMER
Definition id.h:54
void RemoveShutdownBlockReason(wxWindow *aWindow)
Removes any shutdown block reason set.
Definition unix/app.cpp:85
bool DuplicatePermissions(const wxString &aSrc, const wxString &aDest)
Duplicates the file security data from one file to another ensuring that they are the same between bo...
Definition unix/io.cpp:47
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:913
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition pgm_base.cpp:92
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
SELECTION_CONDITION enableCondition
Returns true if the UI control should be enabled.
SELECTION_CONDITION checkCondition
Returns true if the UI control should be checked.
SELECTION_CONDITION showCondition
Returns true if the UI control should be shown.
ACTION_CONDITIONS & Check(const SELECTION_CONDITION &aCondition)
Implement a participant in the KIWAY alchemy.
Definition kiway.h:153
struct WINDOW_STATE window
Store the common settings that are saved and loaded for each window / frame.
WINDOW_STATE state
wxString mru_path
wxString perspective
Store the window positioning/state.
unsigned int display
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)
@ RIGHT
Toolbar on the right side of the canvas.
@ LEFT
Toolbar on the left side of the canvas.
@ TOP_AUX
Toolbar on the top of the canvas.
@ TOP_MAIN
Toolbar on the top of the canvas.
#define HOTKEYS_CHANGED
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
wxLogTrace helper definitions.