KiCad PCB EDA Suite
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 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 
41 {
42 public:
43  // association between the plugin and its menu id
44  // m_actionMenuId set to 0 means the corresponding menuitem to call this
45  // action is not yet created
47  // Same for button id
49  // Icon for the action button and menu entry
50  wxBitmap iconBitmap;
51  // If show_on_toolbar is true a button will be added to top toolbar
53 
54 public:
56  show_on_toolbar( false ) {}
57  virtual ~ACTION_PLUGIN();
58 
63  virtual wxString GetCategoryName() = 0;
64 
70  virtual wxString GetName() = 0;
71 
76  virtual wxString GetDescription() = 0;
77 
82  virtual bool GetShowToolbarButton() = 0;
83 
89  virtual wxString GetIconFileName( bool aDark ) = 0;
90 
95  virtual wxString GetPluginPath() = 0;
96 
102  virtual void* GetObject() = 0;
103 
108  virtual void Run() = 0;
109 
115  void register_action();
116 };
117 
118 
124 {
125 private:
129  static std::vector<ACTION_PLUGIN*> m_actionsList;
130  static bool m_actionRunning;
131 public:
139  static void register_action( ACTION_PLUGIN* aAction );
140 
149  static bool deregister_object( void* aObject );
150 
156  static ACTION_PLUGIN* GetAction( const wxString& aName );
157 
164  static void SetActionMenu( int aIndex, int idMenu );
165 
172  static ACTION_PLUGIN* GetActionByMenu( int aMenu );
173 
180  static void SetActionButton( ACTION_PLUGIN* aAction, int idButton );
181 
188  static ACTION_PLUGIN* GetActionByButton( int aButton );
189 
196  static ACTION_PLUGIN* GetActionByPath( const wxString& aPath );
197 
203  static ACTION_PLUGIN* GetAction( int aIndex );
204 
209  static int GetActionsCount();
210 
215  static bool IsActionRunning();
216 
221  static void SetActionRunning( bool aRunning );
222 
226  static void UnloadAll();
227 };
228 
229 #endif /* PCBNEW_ACTION_PLUGINS_H */
virtual wxString GetName()=0
Function GetName.
ACTION_PLUGIN This is the parent class from where any action plugin class must derive.
Definition: action_plugin.h:40
static bool m_actionRunning
static bool IsActionRunning()
Function IsActionRunning.
static ACTION_PLUGIN * GetActionByPath(const wxString &aPath)
Function GetActionByPath find action plugin by module path.
virtual bool GetShowToolbarButton()=0
Function GetShowToolbarButton.
ACTION_PLUGINS Mainly static.
virtual wxString GetDescription()=0
Function GetDescription.
wxBitmap iconBitmap
Definition: action_plugin.h:50
void register_action()
Function register_action It's the standard method of a "ACTION_PLUGIN" to register itself into the AC...
virtual ~ACTION_PLUGIN()
static void UnloadAll()
Unloads (deregisters) all action plugins.
virtual wxString GetPluginPath()=0
Function GetPluginPath.
virtual wxString GetIconFileName(bool aDark)=0
Function GetIconFileName.
virtual void Run()=0
Function Run This method the the action.
static ACTION_PLUGIN * GetActionByMenu(int aMenu)
Function GetActionByMenu find action plugin associated to a menu id.
bool show_on_toolbar
Definition: action_plugin.h:52
static int GetActionsCount()
Function GetActionsCount.
static void register_action(ACTION_PLUGIN *aAction)
Function register_action An action calls this static method when it wants to register itself into the...
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
virtual wxString GetCategoryName()=0
Function GetCategoryName.
static void SetActionButton(ACTION_PLUGIN *aAction, int idButton)
Function SetActionButton Associate a button id to an action plugin.
static ACTION_PLUGIN * GetAction(const wxString &aName)
Function GetAction.
static void SetActionMenu(int aIndex, int idMenu)
Function SetActionMenu Associate a menu id to an action plugin.
static bool deregister_object(void *aObject)
Function deregister_object Anyone calls this method to deregister an object which builds a action,...
static ACTION_PLUGIN * GetActionByButton(int aButton)
Function GetActionByButton find action plugin associated to a button id.
static void SetActionRunning(bool aRunning)
Function SetActionRunning.
virtual void * GetObject()=0
Function GetObject This method gets the pointer to the object from where this action constructs.