kicad/pcb_calculator/pcb_calculator_frame.h

88 lines
2.4 KiB
C++

/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2021 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 3
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef PCB_CALCULATOR_H
#define PCB_CALCULATOR_H
#include "calculator_panels/calculator_panel.h"
#include "pcb_calculator_frame_base.h"
class APP_SETTINGS_BASE;
class KIWAY;
class PANEL_TRANSLINE;
/**
* PCB calculator the main frame.
*/
class PCB_CALCULATOR_FRAME : public PCB_CALCULATOR_FRAME_BASE
{
public:
PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
~PCB_CALCULATOR_FRAME();
// Pcb calculator doesn't host a tool framework
wxWindow* GetToolCanvas() const override
{
return nullptr;
}
/*
* Return the panel of given type or nullptr if there is no such panel exists.
*/
template<typename T>
T* GetCalculator()
{
std::map<const char*, CALCULATOR_PANEL*>::iterator panel = m_panelTypes.find( typeid( T ).name() );
if( panel != m_panelTypes.end() )
return static_cast<T*>( panel->second );
return nullptr;
}
void AddCalculator( CALCULATOR_PANEL *aPanel, const wxString& panelUIName );
private:
// Event handlers
void OnClosePcbCalc( wxCloseEvent& event ) override;
void OnUpdateUI( wxUpdateUIEvent& event ) override;
void onThemeChanged( wxSysColourChangedEvent& aEvent );
// Config read-write, virtual from EDA_BASE_FRAME
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
private:
int m_lastNotebookPage;
bool m_macHack;
std::vector<CALCULATOR_PANEL*> m_panels;
std::map<const char*, CALCULATOR_PANEL*> m_panelTypes;
};
extern const wxString DataFileNameExt;
#endif // PCB_CALCULATOR_H