KiCad PCB EDA Suite
pcb_calculator_frame.h
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) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef PCB_CALCULATOR_FRAME_H_
21 #define PCB_CALCULATOR_FRAME_H_
22 
24 #include <kiway_player.h>
25 
26 class wxMenuBar;
27 class wxNotebook;
28 class wxBoxSizer;
29 
30 class APP_SETTINGS_BASE;
31 class KIWAY;
32 class PANEL_TRANSLINE;
33 
34 
39 {
40 public:
41  PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
43 
44  // Pcb calculator doesn't host a tool framework
45  wxWindow* GetToolCanvas() const override
46  {
47  return nullptr;
48  }
49 
50  /*
51  * Return the panel of given type or nullptr if there is no such panel exists.
52  */
53  template<typename T>
55  {
56  std::map<std::size_t, CALCULATOR_PANEL*>::iterator panel = m_panelTypes.find( typeid( T ).hash_code() );
57 
58  if( panel != m_panelTypes.end() )
59  return static_cast<T*>( panel->second );
60 
61  return nullptr;
62  }
63 
64  void AddCalculator( CALCULATOR_PANEL *aPanel, const wxString& panelUIName );
65 
66 private:
67  // Event handlers
68  void OnClosePcbCalc( wxCloseEvent& event );
69 
70  void OnUpdateUI( wxUpdateUIEvent& event );
71 
72  void onThemeChanged( wxSysColourChangedEvent& aEvent );
73 
74  // Config read-write, virtual from EDA_BASE_FRAME
75  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
76  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
77 
78 private:
79  wxMenuBar* m_menubar;
80  wxNotebook* m_notebook;
81  wxBoxSizer* m_mainSizer;
82 
84  bool m_macHack;
85 
86  std::vector<CALCULATOR_PANEL*> m_panels;
87  std::map<std::size_t, CALCULATOR_PANEL*> m_panelTypes;
88 
89 
90 };
91 
92 
93 extern const wxString DataFileNameExt;
94 
95 #endif // PCB_CALCULATOR_H
const wxString DataFileNameExt
PCB calculator the main frame.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
void AddCalculator(CALCULATOR_PANEL *aPanel, const wxString &panelUIName)
void OnClosePcbCalc(wxCloseEvent &event)
PCB_CALCULATOR_FRAME(KIWAY *aKiway, wxWindow *aParent)
std::map< std::size_t, CALCULATOR_PANEL * > m_panelTypes
std::vector< CALCULATOR_PANEL * > m_panels
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
void OnUpdateUI(wxUpdateUIEvent &event)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
wxWindow * GetToolCanvas() const override
Canvas access.
void onThemeChanged(wxSysColourChangedEvent &aEvent)