forked from KiCad/kicad-source-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eda_base_frame.h
818 lines (693 loc) · 27.5 KB
/
eda_base_frame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009-2015 Jean-Pierre Charras, jp.charras wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <[email protected]>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eda_base_frame.h
* @brief Base window classes and related definitions.
*/
#ifndef EDA_BASE_FRAME_H_
#define EDA_BASE_FRAME_H_
#include <vector>
#include <wx/socket.h>
#include <wx/log.h>
#include <wx/wxhtml.h>
#include <wx/laywin.h>
#include <wx/aui/aui.h>
#include <wx/docview.h>
#include <wx/event.h>
#include <layers_id_colors_and_visibility.h>
#include <frame_type.h>
#include <hotkeys_basic.h>
#include <kiway_holder.h>
#include <tool/tools_holder.h>
#include <widgets/ui_common.h>
#include <undo_redo_container.h>
#include <eda_units.h>
// Option for main frames
#define KICAD_DEFAULT_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
#define KICAD_MANAGER_FRAME_NAME wxT( "KicadFrame" )
class EDA_ITEM;
class EDA_RECT;
class EDA_DRAW_PANEL_GAL;
class EDA_MSG_PANEL;
class BASE_SCREEN;
class PARAM_CFG;
class PAGE_INFO;
class PLOTTER;
class TITLE_BLOCK;
class MSG_PANEL_ITEM;
class TOOL_MANAGER;
class TOOL_DISPATCHER;
class ACTIONS;
class PAGED_DIALOG;
class DIALOG_EDIT_LIBRARY_TABLES;
class PANEL_HOTKEYS_EDITOR;
class FILE_HISTORY;
class SETTINGS_MANAGER;
class SEARCH_STACK;
class APP_SETTINGS_BASE;
class WX_INFOBAR;
struct WINDOW_SETTINGS;
struct WINDOW_STATE;
#define DEFAULT_MAX_UNDO_ITEMS 0
#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
/// This is the handler functor for the update UI events
typedef std::function< void( wxUpdateUIEvent& ) > UIUpdateHandler;
wxDECLARE_EVENT( UNITS_CHANGED, wxCommandEvent );
/**
* The base frame for deriving all KiCad main window classes.
*
* This class is not intended to be used directly. It provides support for automatic calls
* to SaveSettings() function. SaveSettings() for a derived class can choose to do nothing,
* or rely on basic SaveSettings() support in this base class to do most of the work by
* calling it from the derived class's SaveSettings(). This class is not a #KIWAY_PLAYER
* because #KICAD_MANAGER_FRAME is derived from it and that class is not a player.
*/
class EDA_BASE_FRAME : public wxFrame, public TOOLS_HOLDER, public KIWAY_HOLDER
{
public:
EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize, long aStyle,
const wxString& aFrameName, KIWAY* aKiway );
~EDA_BASE_FRAME();
/**
* Return the user units currently in use.
*/
EDA_UNITS GetUserUnits() const
{
return m_userUnits;
}
void SetUserUnits( EDA_UNITS aUnits )
{
m_userUnits = aUnits;
}
void ChangeUserUnits( EDA_UNITS aUnits );
virtual void ToggleUserUnits() { }
SETTINGS_MANAGER* GetSettingsManager() const { return m_settingsManager; }
virtual SEVERITY GetSeverity( int aErrorCode ) const { return RPT_SEVERITY_UNDEFINED; }
/**
* Override the default process event handler to implement the auto save feature.
*
* @warning If you override this function in a derived class, make sure you call down to
* this or the auto save feature will be disabled.
*/
bool ProcessEvent( wxEvent& aEvent ) override;
/**
* Capture the key event before it is sent to the GUI.
*
* The basic frame does not capture this event. Editor frames should override this event
* function to capture and filter these keys when they are used as hotkeys, and skip it if
* the key is not used as hotkey (otherwise the key events will be not sent to menus).
*/
virtual void OnCharHook( wxKeyEvent& event );
/**
* The #TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu
* events aren't captured by the menus themselves.
*/
void OnMenuEvent( wxMenuEvent& event );
/**
* Register a UI update handler for the control with ID @c aID
*
* @param aID is the control ID to register the handler for
* @param aConditions are the UI conditions to use for the control states
*/
virtual void RegisterUIUpdateHandler( int aID, const ACTION_CONDITIONS& aConditions ) override;
/**
* Unregister a UI handler for a given ID that was registered using @c RegisterUIUpdateHandler
*
* @param aID is the control ID to unregister the handler for
*/
virtual void UnregisterUIUpdateHandler( int aID ) override;
/**
* Handle events generated when the UI is trying to figure out the current state of the
* UI controls related to #TOOL_ACTIONS (e.g. enabled, checked, etc.).
*
* @param aEvent is the wxUpdateUIEvent to be processed.
* @param aFrame is the frame to get the selection from
* @param aCond are the #UI SELECTION_CONDITIONS used
*/
static void HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
ACTION_CONDITIONS aCond );
virtual void OnMove( wxMoveEvent& aEvent )
{
aEvent.Skip();
}
void OnMaximize( wxMaximizeEvent& aEvent );
void SetAutoSaveInterval( int aInterval );
int GetAutoSaveInterval() const { return m_autoSaveInterval; }
bool IsType( FRAME_T aType ) const { return m_ident == aType; }
/**
* Return a #SEARCH_STACK pertaining to entire program.
*
* This is overloaded in #KICAD_MANAGER_FRAME
*/
virtual const SEARCH_STACK& sys_search();
virtual wxString help_name();
void OnKicadAbout( wxCommandEvent& event );
void OnPreferences( wxCommandEvent& event );
void PrintMsg( const wxString& text );
void CreateInfoBar();
void FinishAUIInitialization();
/**
* @return the #WX_INFOBAR that can be displayed on the top of the canvas.
*/
WX_INFOBAR* GetInfoBar() { return m_infoBar; }
/**
* Show the #WX_INFOBAR displayed on the top of the canvas with a message and an error
* icon on the left of the infobar, and an optional closebox to the right.
*
* The infobar will be closed after a timeout.
*
* @param aErrorMsg is the message to display.
* @param aShowCloseButton true to show a close button on the right of the #WX_INFOBAR.
*/
void ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton = false );
/**
* Show the #WX_INFOBAR displayed on the top of the canvas with a message and an error
* icon on the left of the infobar, and an optional closebox to the right.
*
* The infobar will be closed after a timeout.
*
* This version accepts a callback which will be called when the infobar is dismissed
* (either as a result of user action or a timeout). This can be useful when the caller
* wants to make other decorations in the canvas to highlight the error.
*
* @param aErrorMsg is the message to display.
* @param aShowCloseButton true to show a close button on the right of the #WX_INFOBAR.
* @param aCallback a callback to be called when the infobar is dismissed.
*/
void ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
std::function<void(void)> aCallback );
/**
* Show the #WX_INFOBAR displayed on the top of the canvas with a message and a warning
* icon on the left of the infobar.
*
* The infobar will be closed after a timeout.
*
* @param aErrorMsg is the message to display.
* @param aShowCloseButton true to show a close button on the right of the #WX_INFOBAR.
*/
void ShowInfoBarWarning( const wxString& aWarningMsg, 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 the infobar.
*
* The infobar will be closed after a timeout.
*
* @param aErrorMsg is the message to display.
* @param aShowCloseButton true to show a close button on the right of the #WX_INFOBAR.
*/
void ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton = false );
/**
* Returns the settings object used in SaveSettings(), and is overloaded in
* #KICAD_MANAGER_FRAME.
*/
virtual APP_SETTINGS_BASE* config() const;
/**
* Allow a frame to load its preference panels (if any) into the preferences dialog.
*
* @param aParent a paged dialog into which the preference panels should be installed.
*/
virtual void InstallPreferences( PAGED_DIALOG* , PANEL_HOTKEYS_EDITOR* ) { }
void LoadWindowState( const wxString& aFileName );
/**
* Load window settings from the given settings object.
*
* Normally called by #LoadSettings() unless the window in question is a child window
* that* stores its settings somewhere other than #APP_SETTINGS_BASE::m_Window.
*/
void LoadWindowSettings( const WINDOW_SETTINGS* aCfg );
/**
* Save window settings to the given settings object.
*
* Normally called by #SaveSettings unless the window in question is a child window that
* stores its settings somewhere other than #APP_SETTINGS_BASE::m_Window.
*/
void SaveWindowSettings( WINDOW_SETTINGS* aCfg );
/**
* Load common frame parameters from a configuration file.
*
* Don't forget to call the base method or your frames won't remember their positions
* and sizes.
*/
virtual void LoadSettings( APP_SETTINGS_BASE* aCfg );
/**
* Save common frame parameters to a configuration data file.
*
* Don't forget to call the base class's SaveSettings() from your derived
* #SaveSettings() otherwise the frames won't remember their positions and sizes.
*/
virtual void SaveSettings( APP_SETTINGS_BASE* aCfg );
/**
* Return a pointer to the window settings for this frame.
*
* By default, points to aCfg->m_Window for top-level frames.
*
* @param aCfg is this frame's config object
*/
virtual WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg );
/**
* Load frame state info from a configuration file
*/
virtual void LoadWindowState( const WINDOW_STATE& aState );
/**
* Get the configuration base name.
*
* This is usually the name of the frame set by CTOR, except for frames shown in
* multiple modes in which case the m_configName must be set to the base name so
* that a single configuration can be used.
*
* @return a base name prefix used in Load/Save settings to build the full name of keys
* used in configuration.
*/
wxString ConfigBaseName() override
{
wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
return baseCfgName;
}
/**
* Save changes to the project settings to the project (.pro) file.
*
* The method is virtual so you can override it to call the suitable save method.
* The base method does nothing.
*
* @param aAskForSave true to open a dialog before saving the settings.
*/
virtual void SaveProjectSettings() {};
/**
* Prompt the user for a hotkey file to read, and read it.
*
* @param aActionMap current hotkey map (over which the imported hotkeys will be applied).
* @param aDefaultShortname a default short name (extension not needed) like
* Eeschema, KiCad...
*/
void ImportHotkeyConfigFromFile( std::map<std::string, TOOL_ACTION*> aActionMap,
const wxString& aDefaultShortname );
/**
* Fetches the file name from the file history list.
*
* This removes the selected file, if this file does not exist. The menu is also updated,
* if #FILE_HISTORY::UseMenu was called at initialization time.
*
* @param cmdId The command ID associated with the \a aFileHistory object.
* @param type Please document me!
* @param aFileHistory The FILE_HISTORY in use. If null, the main application file
* history is used
* @return a wxString containing the selected filename
*/
wxString GetFileFromHistory( int cmdId, const wxString& type,
FILE_HISTORY* aFileHistory = nullptr );
/**
* Removes all files from the file history.
*
* @param aFileHistory The FILE_HISTORY in use. If null, the main application file
* history is used
*/
void ClearFileHistory( FILE_HISTORY* aFileHistory = nullptr );
/**
* Update the list of recently opened files.
*
* The menu is also updated, if FILE_HISTORY::UseMenu was called at init time.
*
* @param FullFileName The full file name including the path.
* @param aFileHistory The FILE_HISTORY in use. If NULL, the main application file
* history is used.
*/
void UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory = nullptr );
/**
* Get the frame's main file history.
*
* @return the main file history
*/
FILE_HISTORY& GetFileHistory()
{
return *m_fileHistory;
}
void SetMruPath( const wxString& aPath ) { m_mruPath = aPath; }
wxString GetMruPath() const { return m_mruPath; }
/**
* Get the full filename + path of the currently opened file in the frame.
*
* If no file is open, an empty string is returned.
*
* @return the filename and full path to the open file
*/
virtual wxString GetCurrentFileName() const { return wxEmptyString; }
/**
* Recreates the menu bar.
*
* Needed when the language or icons are changed
*/
virtual void ReCreateMenuBar();
/**
* Adds the standard KiCad help menu to the menubar.
*/
void AddStandardHelpMenu( wxMenuBar* aMenuBar );
/**
* Checks if \a aFileName can be written.
*
* The function performs a number of tests on \a aFileName to verify that it can be saved.
* If \a aFileName defines a path with no file name, them the path is tested for user write
* permission. If \a aFileName defines a file name that does not exist in the path, the
* path is tested for user write permission. If \a aFileName defines a file that already
* exits, the file name is tested for user write permissions.
*>
* @note The file name path must be set or an assertion will be raised on debug builds and
* return false on release builds.
* @param aFileName The full path and/or file name of the file to test.
* @return False if \a aFileName cannot be written.
*/
bool IsWritable( const wxFileName& aFileName );
/**
* Check if an auto save file exists for \a aFileName and takes the appropriate action
* depending on the user input.
*
* If an auto save file exists for \a aFileName, the user is prompted if they wish to
* replace file \a aFileName with the auto saved file. If the user chooses to replace the
* file, the backup file of \a aFileName is removed, \a aFileName is renamed to the backup
* file name, and the auto save file is renamed to \a aFileName. If user chooses to keep
* the existing version of \a aFileName, the auto save file is removed.
*
* @param aFileName A wxFileName object containing the file name to check.
*/
void CheckForAutoSaveFile( const wxFileName& aFileName );
/**
* Update the status bar information.
*
* The status bar can draw itself. This is not a drawing function per se, but rather
* updates lines of text held by the components within the status bar which is owned
* by the wxFrame.
*/
virtual void UpdateStatusBar() { }
/**
* Redraw the menus and what not in current language.
*/
virtual void ShowChangedLanguage();
/**
* Notification event that some of the common (suite-wide) settings have changed.
* Update menus, toolbars, local variables, etc.
*/
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
/**
* Process light/dark theme change.
*/
virtual void ThemeChanged();
/**
* Notification event that the project has changed.
*/
virtual void ProjectChanged() {}
const wxString& GetAboutTitle() const { return m_aboutTitle; }
/**
* Get if the contents of the frame have been modified since the last save.
*
* @return true if the contents of the frame have not been saved
*/
virtual bool IsContentModified();
/**
* Get the undecorated window size that can be used for restoring the window size.
*
* This is needed for GTK, since the normal wxWidgets GetSize() call will return
* a window size that includes the window decorations added by the window manager.
*
* @return the undecorated window size
*/
wxSize GetWindowSize();
/**
* Remove the \a aItemCount of old commands from \a aList and delete commands, pickers
* and picked items if needed.
*
* Because picked items must be deleted only if they are not in use, this is a virtual
* pure function that must be created for #SCH_SCREEN and #PCB_SCREEN. Commands are
* deleted from the older to the last.
*
* @param aList = the #UNDO_REDO_CONTAINER of commands.
* @param aItemCount number of old commands to delete. -1 to remove all old commands
* this will empty the list of commands.
*/
enum UNDO_REDO_LIST { UNDO_LIST, REDO_LIST };
virtual void ClearUndoORRedoList( UNDO_REDO_LIST aList, int aItemCount = -1 )
{ }
/**
* Clear the undo and redo list using #ClearUndoORRedoList()
*
* Picked items are deleted by ClearUndoORRedoList() according to their status.
*/
virtual void ClearUndoRedoList();
/**
* Add a command to undo in the undo list.
*
* Delete the very old commands when the max count of undo commands is reached.
*/
virtual void PushCommandToUndoList( PICKED_ITEMS_LIST* aItem );
/**
* Add a command to redo in the redo list.
*
* Delete the very old commands when the max count of redo commands is reached.
*/
virtual void PushCommandToRedoList( PICKED_ITEMS_LIST* aItem );
/**
* Return the last command to undo and remove it from list, nothing is deleted.
*/
virtual PICKED_ITEMS_LIST* PopCommandFromUndoList();
/**
* Return the last command to undo and remove it from list, nothing is deleted.
*/
virtual PICKED_ITEMS_LIST* PopCommandFromRedoList();
virtual int GetUndoCommandCount() const { return m_undoList.m_CommandsList.size(); }
virtual int GetRedoCommandCount() const { return m_redoList.m_CommandsList.size(); }
int GetMaxUndoItems() const { return m_undoRedoCountMax; }
bool NonUserClose( bool aForce )
{
m_isNonUserClose = true;
return Close( aForce );
}
/**
* Update the UI in response to a change in the system colors.
*/
virtual void HandleSystemColorChange();
protected:
///< Default style flags used for wxAUI toolbars.
static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND;
/**
* @return the string to prepend to a file name for automatic save.
*/
static wxString GetAutoSaveFilePrefix()
{
return wxT( "_autosave-" );
}
/**
* Handle the auto save timer event.
*/
void onAutoSaveTimer( wxTimerEvent& aEvent );
/**
* Return the auto save status of the application.
*
* Override this function if your derived frame supports automatic file saving.
*/
virtual bool isAutoSaveRequired() const { return false; }
/**
* This should be overridden by the derived class to handle the auto save feature.
*
* @return true if the auto save was successful otherwise false.
*/
virtual bool doAutoSave();
virtual bool canCloseWindow( wxCloseEvent& aCloseEvent ) { return true; }
virtual void doCloseWindow() { }
void onSystemColorChange( wxSysColourChangedEvent& aEvent );
/**
* Called when when the units setting has changed to allow for any derived classes
* to handle refreshing and controls that have units based measurements in them.
*
* The default version only updates the status bar. Don't forget to call the default
* in your derived class or the status bar will not get updated properly.
*/
virtual void unitsChangeRefresh() { }
/**
* Setup the UI conditions for the various actions and their controls in this frame.
*/
virtual void setupUIConditions();
/**
* Sets the common key-pair for exiting the application (Ctrl-Q) and ties it
* to the wxID_EXIT event id.
*
* This is useful in sub-applications to pass the event up to a non-owning window.
*/
void initExitKey();
DECLARE_EVENT_TABLE()
private:
/**
* (with its unexpected name so it does not collide with the real OnWindowClose()
* function provided in derived classes) is called just before a window
* closing, and is used to call a derivation specific SaveSettings().
*
* #SaveSettings() is called for all derived wxFrames in this base class overload.
* Calling it from a destructor is deprecated since the wxFrame's position is not
* available in the destructor on linux. In other words, you should not need to
* call #SaveSettings() anywhere, except in this one function found only in this class.
*/
void windowClosing( wxCloseEvent& event );
wxWindow* findQuasiModalDialog();
/**
* Return true if the frame is shown in our modal mode and false if the frame is
* shown as an usual frame.
*
* In modal mode, the caller that created the frame is responsible to Destroy()
* this frame after closing.
*/
virtual bool IsModal() const { return false; }
protected:
FRAME_T m_ident; // Id Type (pcb, schematic, library..)
wxPoint m_framePos;
wxSize m_frameSize;
bool m_maximizeByDefault;
// These contain the frame size and position for when it is not maximized
wxPoint m_normalFramePos;
wxSize m_normalFrameSize;
wxString m_aboutTitle; // Name of program displayed in About.
wxAuiManager m_auimgr;
wxString m_perspective; // wxAuiManager perspective.
WX_INFOBAR* m_infoBar; // Infobar for the frame
wxString m_configName; // Prefix used to identify some params (frame size...)
// and to name some config files (legacy hotkey files)
SETTINGS_MANAGER* m_settingsManager;
FILE_HISTORY* m_fileHistory; // The frame's recently opened file list
bool m_hasAutoSave;
bool m_autoSaveState;
int m_autoSaveInterval; // The auto save interval time in seconds.
wxTimer* m_autoSaveTimer;
int m_undoRedoCountMax; // undo/Redo command Max depth
UNDO_REDO_CONTAINER m_undoList; // Objects list for the undo command (old data)
UNDO_REDO_CONTAINER m_redoList; // Objects list for the redo command (old data)
wxString m_mruPath; // Most recently used path.
EDA_UNITS m_userUnits;
///< Map containing the UI update handlers registered with wx for each action.
std::map<int, UIUpdateHandler> m_uiUpdateMap;
///< Set by the close window event handler after frames are asked if they can close.
///< Allows other functions when called to know our state is cleanup.
bool m_isClosing;
///< Set by #NonUserClose() to indicate that the user did not request the current close.
bool m_isNonUserClose;
};
/**
* Specialization of the wxAuiPaneInfo class for KiCad panels.
*
* Documentation for wxAui is poor at this time. The following notes spring from errors made in
* previous KiCad implementations:
*
* wxAuiPaneInfo.ToolbarPane() and .Defaults() are used to clear and then prepare the objects so
* only use them once at the beginning of configuration..
*
* Panels are organized in layers, from 0 (close to the center) and increasing outward. Note
* that for ToolbarPanes, layer 0 considered a special default value, and ToolbarPanes on
* layer 0 are pushed to layer 10 automatically. Use Layer 1 for the inner layer as a work-
* around.
*
* Each panel has rows, starting at 0. Each row has positions starting at 0. Each item in a panel
* can have it's row and position set.
*
* Eventually panels will be movable. Each initialization function sets up the panel for this,
* then after a //==// break has additional calls to anchor toolbars in a way that matches
* present functionality.
*/
class EDA_PANE : public wxAuiPaneInfo
{
public:
EDA_PANE()
{
Gripper( false );
CloseButton( false );
PaneBorder( false );
}
/**
* Turn *this to a horizontal toolbar for KiCad.
*/
EDA_PANE& HToolbar()
{
SetFlag( optionToolbar, true );
CaptionVisible( false );
TopDockable().BottomDockable();
DockFixed( true );
Movable( false );
Resizable( true ); // expand to fit available space
return *this;
}
/**
* Turn *this into a vertical toolbar for KiCad.
*/
EDA_PANE& VToolbar()
{
SetFlag( optionToolbar, true );
CaptionVisible( false );
LeftDockable().RightDockable();
DockFixed( true );
Movable( false );
Resizable( true ); // expand to fit available space
return *this;
}
/**
* Turn *this into a captioned palette suitable for a symbol tree, layers manager, etc.
*/
EDA_PANE& Palette()
{
CaptionVisible( true );
PaneBorder( true );
return *this;
}
/**
* Turn *this into an undecorated pane suitable for a drawing canvas.
*/
EDA_PANE& Canvas()
{
CaptionVisible( false );
Layer( 0 );
PaneBorder( true );
Resizable( true ); // expand to fit available space
return *this;
}
/**
* Turn *this into a messages pane for KiCad.
*/
EDA_PANE& Messages()
{
CaptionVisible( false );
BottomDockable( true );
DockFixed( true );
Movable( false );
Resizable( true ); // expand to fit available space
return *this;
}
/**
* Turn *this into a infobar for KiCad.
*/
EDA_PANE& InfoBar()
{
CaptionVisible( false );
Movable( false );
Resizable( true );
PaneBorder( false );
DockFixed( true );
return *this;
}
};
#endif // EDA_BASE_FRAME_H_