KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kiface_base.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 The 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 2
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
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KIFACE_BASE_H
21#define KIFACE_BASE_H
22
23#include <kiway.h>
24#include <bin_mod.h>
25#include <tool/action_manager.h>
26
27
34class KIFACE_BASE : public KIFACE
35{
36public:
40 virtual bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override = 0;
41
42 virtual void OnKifaceEnd() override
43 {
44 // overload this if you want, end_common() may be handy.
45 end_common();
46 }
47
48 virtual wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKIWAY,
49 int aCtlBits = 0 ) override = 0;
50
51 virtual void Reset() override{};
52
53 virtual void* IfaceOrAddress( int aDataId ) override = 0;
54
63 KIFACE_BASE( const char* aKifaceName, KIWAY::FACE_T aId ) :
64 m_start_flags( 0 ),
65 m_id( aId ),
66 m_bm( aKifaceName )
67 {
68 }
69
70 // ~KIFACE_BASE();
71
72protected:
73
75 bool start_common( int aCtlBits );
76
78 void end_common();
79
80 // From here down should probably not be in a KIFACE, even though they
81 // are DSO specific, they have nothing to do with KIWAY's use of KIFACE,
82 // so its a questionable choice to put non KIWAY client code in this class.
83
84public:
85
86 const wxString Name()
87 {
88 return wxString::FromUTF8( m_bm.m_name );
89 }
90
91 APP_SETTINGS_BASE* KifaceSettings() const { return m_bm.m_config; }
92
93 void InitSettings( APP_SETTINGS_BASE* aSettings ) { m_bm.InitSettings( aSettings ); }
94
98 int StartFlags() const { return m_start_flags; }
99
103 bool IsSingle() const { return m_start_flags & KFCTL_STANDALONE; }
104
108 const wxString& GetHelpFileName() const { return m_bm.m_help_file; }
109
112 SEARCH_STACK& KifaceSearch() { return m_bm.m_search; }
113
114 void GetActions( std::vector<TOOL_ACTION*>& aActions ) const override
115 {
117 aActions.push_back( action );
118 }
119
120protected:
122
123private:
126};
127
128
131
132#endif // KIFACE_BASE_H
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
A KIFACE implementation.
Definition kiface_base.h:35
KIFACE_BASE(const char *aKifaceName, KIWAY::FACE_T aId)
Definition kiface_base.h:63
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition kiface_base.h:93
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
virtual void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition kiface_base.h:42
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:91
KIWAY::FACE_T m_id
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
virtual bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override=0
Typically start_common() is called from here.
virtual wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKIWAY, int aCtlBits=0) override=0
Create a wxWindow for the current project.
void GetActions(std::vector< TOOL_ACTION * > &aActions) const override
Append this Kiface's registered actions to the given list.
int m_start_flags
flags provided in OnKifaceStart()
int StartFlags() const
Return whatever was passed as aCtlBits to OnKifaceStart().
Definition kiface_base.h:98
bool IsSingle() const
Is this KIFACE running under single_top?
const wxString Name()
Definition kiface_base.h:86
virtual void * IfaceOrAddress(int aDataId) override=0
Return pointer to the requested object.
BIN_MOD m_bm
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
virtual void Reset() override
Reloads global state.
Definition kiface_base.h:51
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:311
FACE_T
Known KIFACE implementations.
Definition kiway.h:317
Container for data for KiCad programs.
Definition pgm_base.h:102
Look for files in a number of paths.
Represent a single user action.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define KFCTL_STANDALONE
Running as a standalone Top.
Definition kiway.h:159
Pertains to a single program module, either an EXE or a DSO/DLL ("bin_mod").
Definition bin_mod.h:37
Implement a participant in the KIWAY alchemy.
Definition kiway.h:152