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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef KIFACE_BASE_H
25#define KIFACE_BASE_H
26
27#include <kiway.h>
28#include <bin_mod.h>
29#include <tool/action_manager.h>
30
31
38class KIFACE_BASE : public KIFACE
39{
40public:
44 virtual bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override = 0;
45
46 virtual void OnKifaceEnd() override
47 {
48 // overload this if you want, end_common() may be handy.
49 end_common();
50 }
51
52 virtual wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKIWAY,
53 int aCtlBits = 0 ) override = 0;
54
55 virtual void Reset() override{};
56
57 virtual void* IfaceOrAddress( int aDataId ) override = 0;
58
67 KIFACE_BASE( const char* aKifaceName, KIWAY::FACE_T aId ) :
68 m_start_flags( 0 ),
69 m_id( aId ),
70 m_bm( aKifaceName )
71 {
72 }
73
74 // ~KIFACE_BASE();
75
76protected:
77
79 bool start_common( int aCtlBits );
80
82 void end_common();
83
84 // From here down should probably not be in a KIFACE, even though they
85 // are DSO specific, they have nothing to do with KIWAY's use of KIFACE,
86 // so its a questionable choice to put non KIWAY client code in this class.
87
88public:
89
90 const wxString Name()
91 {
92 return wxString::FromUTF8( m_bm.m_name );
93 }
94
95 APP_SETTINGS_BASE* KifaceSettings() const { return m_bm.m_config; }
96
97 void InitSettings( APP_SETTINGS_BASE* aSettings ) { m_bm.InitSettings( aSettings ); }
98
102 int StartFlags() const { return m_start_flags; }
103
107 bool IsSingle() const { return m_start_flags & KFCTL_STANDALONE; }
108
112 const wxString& GetHelpFileName() const { return m_bm.m_help_file; }
113
116 SEARCH_STACK& KifaceSearch() { return m_bm.m_search; }
117
118 void GetActions( std::vector<TOOL_ACTION*>& aActions ) const override
119 {
121 aActions.push_back( action );
122 }
123
124protected:
126
127private:
130};
131
132
135
136#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:39
KIFACE_BASE(const char *aKifaceName, KIWAY::FACE_T aId)
Definition kiface_base.h:67
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition kiface_base.h:97
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:46
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:95
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().
bool IsSingle() const
Is this KIFACE running under single_top?
const wxString Name()
Definition kiface_base.h:90
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:55
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:286
FACE_T
Known KIFACE implementations.
Definition kiway.h:292
Container for data for KiCad programs.
Definition pgm_base.h:103
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:160
Pertains to a single program module, either an EXE or a DSO/DLL ("bin_mod").
Definition bin_mod.h:41
Implement a participant in the KIWAY alchemy.
Definition kiway.h:153