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
26class wxTreebook;
27class wxTreebookEvent;
28class wxBoxSizer;
29
31class KIWAY;
32class PANEL_TRANSLINE;
33
34
39{
40public:
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
66private:
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
78private:
79 wxBoxSizer* m_mainSizer;
80 wxTreebook* m_treebook;
81
83
84 std::vector<CALCULATOR_PANEL*> m_panels;
85 std::map<std::size_t, CALCULATOR_PANEL*> m_panelTypes;
86
87 void OnPageChanged ( wxTreebookEvent& aEvent );
88};
89
90
91extern const wxString DataFileNameExt;
92
93#endif // PCB_CALCULATOR_H
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:273
PCB calculator the main frame.
void OnPageChanged(wxTreebookEvent &aEvent)
wxWindow * GetToolCanvas() const override
Canvas access.
PCB_CALCULATOR_FRAME(KIWAY *aKiway, wxWindow *aParent)
std::vector< CALCULATOR_PANEL * > m_panels
void OnUpdateUI(wxUpdateUIEvent &event)
void onThemeChanged(wxSysColourChangedEvent &aEvent)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void OnClosePcbCalc(wxCloseEvent &event)
void AddCalculator(CALCULATOR_PANEL *aPanel, const wxString &panelUIName)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
std::map< std::size_t, CALCULATOR_PANEL * > m_panelTypes
const wxString DataFileNameExt