KiCad PCB EDA Suite
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 (C) 1992-2020 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 ) 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* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKIWAY,
53 int aCtlBits = 0 ) override = 0;
54
55 virtual void* IfaceOrAddress( int aDataId ) override = 0;
56
65 KIFACE_BASE( const char* aKifaceName, KIWAY::FACE_T aId ) :
66 m_id( aId ),
67 m_bm( aKifaceName ),
68 m_start_flags( 0 )
69 {
70 }
71
72 // ~KIFACE_BASE();
73
74protected:
75
77 bool start_common( int aCtlBits );
78
80 void end_common();
81
82 // From here down should probably not be in a KIFACE, even though they
83 // are DSO specific, they have nothing to do with KIWAY's use of KIFACE,
84 // so its a questionable choice to put non KIWAY client code in this class.
85
86public:
87
88 const wxString Name()
89 {
90 return wxString::FromUTF8( m_bm.m_name );
91 }
92
94
95 void InitSettings( APP_SETTINGS_BASE* aSettings ) { m_bm.InitSettings( aSettings ); }
96
100 int StartFlags() const { return m_start_flags; }
101
105 bool IsSingle() const { return m_start_flags & KFCTL_STANDALONE; }
106
110 const wxString& GetHelpFileName() const { return m_bm.m_help_file; }
111
115
116 void GetActions( std::vector<TOOL_ACTION*>& aActions ) const override
117 {
119 aActions.push_back( action );
120 }
121
122private:
124
126
128};
129
130
133
134#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.
Definition: app_settings.h:101
A KIFACE implementation.
Definition: kiface_base.h:39
KIFACE_BASE(const char *aKifaceName, KIWAY::FACE_T aId)
Definition: kiface_base.h:65
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition: kiface_base.h:95
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_base.h:114
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:93
KIWAY::FACE_T m_id
Definition: kiface_base.h:123
virtual bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override=0
Typically start_common() is called from here.
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_base.cpp:97
virtual wxWindow * CreateWindow(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.
Definition: kiface_base.h:116
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_base.h:127
int StartFlags() const
Return whatever was passed as aCtlBits to OnKifaceStart().
Definition: kiface_base.h:100
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:105
const wxString Name()
Definition: kiface_base.h:88
virtual void * IfaceOrAddress(int aDataId) override=0
Return pointer to the requested object.
BIN_MOD m_bm
Definition: kiface_base.h:125
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
Definition: kiface_base.h:110
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:267
FACE_T
Known KIFACE implementations.
Definition: kiway.h:273
Container for data for KiCad programs.
Definition: pgm_base.h:94
Look for files in a number of paths.
Definition: search_stack.h:42
Represent a single user action.
Definition: tool_action.h:68
int PGM_BASE * aProgram
Definition: cvpcb.cpp:110
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define KFCTL_STANDALONE
Running as a standalone Top.
Definition: kiway.h:157
Pertains to a single program module, either an EXE or a DSO/DLL ("bin_mod").
Definition: bin_mod.h:41
APP_SETTINGS_BASE * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:57
SEARCH_STACK m_search
Definition: bin_mod.h:60
wxString m_help_file
Definition: bin_mod.h:58
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:55
void InitSettings(APP_SETTINGS_BASE *aPtr)
Takes ownership of a new application settings object.
Definition: bin_mod.h:53
Implement a participant in the KIWAY alchemy.
Definition: kiway.h:150