KiCad PCB EDA Suite
Loading...
Searching...
No Matches
action_plugin.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) 2017-2021 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
30#ifndef CLASS_ACTION_PLUGIN_H
31#define CLASS_ACTION_PLUGIN_H
32#include <vector>
33#include <pcb_edit_frame.h>
34
39{
40public:
42 show_on_toolbar( false ) {}
43 virtual ~ACTION_PLUGIN();
44
48 virtual wxString GetCategoryName() = 0;
49
54 virtual wxString GetName() = 0;
55
59 virtual wxString GetClassName() = 0;
60
64 virtual wxString GetDescription() = 0;
65
69 virtual bool GetShowToolbarButton() = 0;
70
75 virtual wxString GetIconFileName( bool aDark ) = 0;
76
80 virtual wxString GetPluginPath() = 0;
81
87 virtual void* GetObject() = 0;
88
92 virtual void Run() = 0;
93
98 void register_action();
99
100 // association between the plugin and its menu id
101 // m_actionMenuId set to 0 means the corresponding menuitem to call this
102 // action is not yet created
104
105 // Same for button id
107
108 // Icon for the action button and menu entry
109 wxBitmap iconBitmap;
110
111 // If show_on_toolbar is true a button will be added to top toolbar
113
114};
115
116
121{
122public:
129 static void register_action( ACTION_PLUGIN* aAction );
130
138 static bool deregister_object( void* aObject );
139
144 static ACTION_PLUGIN* GetAction( const wxString& aName );
145
152 static void SetActionMenu( int aIndex, int idMenu );
153
160 static ACTION_PLUGIN* GetActionByMenu( int aMenu );
161
168 static void SetActionButton( ACTION_PLUGIN* aAction, int idButton );
169
176 static ACTION_PLUGIN* GetActionByButton( int aButton );
177
184 static ACTION_PLUGIN* GetActionByPath( const wxString& aPath );
185
190 static ACTION_PLUGIN* GetAction( int aIndex );
191
195 static int GetActionsCount();
196
200 static bool IsActionRunning();
201
205 static void SetActionRunning( bool aRunning );
206
210 static void UnloadAll();
211
212private:
216 static std::vector<ACTION_PLUGIN*> m_actionsList;
217 static bool m_actionRunning;
218};
219
220
221typedef std::variant<ACTION_PLUGIN*, const PLUGIN_ACTION*> LEGACY_OR_API_PLUGIN;
222
223#endif /* PCBNEW_ACTION_PLUGINS_H */
std::variant< ACTION_PLUGIN *, const PLUGIN_ACTION * > LEGACY_OR_API_PLUGIN
Mainly static.
static void UnloadAll()
Unload (deregister) all action plugins.
static bool deregister_object(void *aObject)
Deregister an object which builds a action.
static ACTION_PLUGIN * GetActionByMenu(int aMenu)
Find action plugin associated to a menu ID.
static ACTION_PLUGIN * GetActionByPath(const wxString &aPath)
Find action plugin by module path.
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
static int GetActionsCount()
static void register_action(ACTION_PLUGIN *aAction)
An action calls this static method when it wants to register itself into the system actions.
static ACTION_PLUGIN * GetAction(const wxString &aName)
static void SetActionButton(ACTION_PLUGIN *aAction, int idButton)
Associate a button id to an action plugin.
static void SetActionMenu(int aIndex, int idMenu)
Associate a menu id to an action plugin.
static void SetActionRunning(bool aRunning)
static bool m_actionRunning
static ACTION_PLUGIN * GetActionByButton(int aButton)
Find action plugin associated to a button ID.
static bool IsActionRunning()
This is the parent class from where any action plugin class must derive.
Definition: action_plugin.h:39
virtual wxString GetIconFileName(bool aDark)=0
wxBitmap iconBitmap
virtual wxString GetClassName()=0
void register_action()
It's the standard method of a "ACTION_PLUGIN" to register itself into the ACTION_PLUGINS singleton ma...
virtual wxString GetDescription()=0
virtual wxString GetPluginPath()=0
virtual wxString GetCategoryName()=0
virtual void * GetObject()=0
This method gets the pointer to the object from where this action constructs.
virtual ~ACTION_PLUGIN()
virtual wxString GetName()=0
virtual void Run()=0
This method the the action.
virtual bool GetShowToolbarButton()=0