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 (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, 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
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
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.
Definition: app_settings.h:92
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.
Definition: kiface_base.h:116
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_base.cpp:42
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
Definition: kiface_base.h:128
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_base.cpp:32
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.
Definition: kiface_base.h:118
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_base.h:125
int StartFlags() const
Return whatever was passed as aCtlBits to OnKifaceStart().
Definition: kiface_base.h:102
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:107
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
Definition: kiface_base.h:129
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
Definition: kiface_base.h:112
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:284
FACE_T
Known KIFACE implementations.
Definition: kiway.h:290
Container for data for KiCad programs.
Definition: pgm_base.h:102
Look for files in a number of paths.
Definition: search_stack.h:43
Represent a single user action.
Definition: tool_action.h:269
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define KFCTL_STANDALONE
Running as a standalone Top.
Definition: kiway.h:158
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:151