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:
55  ACTION_PLUGIN() : m_actionMenuId( 0 ), m_actionButtonId( 0 ),
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 
88  virtual wxString GetIconFileName() = 0;
89 
94  virtual wxString GetPluginPath() = 0;
95 
101  virtual void* GetObject() = 0;
102 
107  virtual void Run() = 0;
108 
114  void register_action();
115 };
116 
117 
123 {
124 private:
128  static std::vector<ACTION_PLUGIN*> m_actionsList;
129  static bool m_actionRunning;
130 public:
138  static void register_action( ACTION_PLUGIN* aAction );
139 
148  static bool deregister_object( void* aObject );
149 
155  static ACTION_PLUGIN* GetAction( const wxString& aName );
156 
163  static void SetActionMenu( int aIndex, int idMenu );
164 
171  static ACTION_PLUGIN* GetActionByMenu( int aMenu );
172 
179  static void SetActionButton( ACTION_PLUGIN* aAction, int idButton );
180 
187  static ACTION_PLUGIN* GetActionByButton( int aButton );
188 
195  static ACTION_PLUGIN* GetActionByPath( const wxString& aPath );
196 
202  static ACTION_PLUGIN* GetAction( int aIndex );
203 
208  static int GetActionsCount();
209 
214  static bool IsActionRunning();
215 
220  static void SetActionRunning( bool aRunning );
221 };
222 
223 #endif /* PCBNEW_ACTION_PLUGINS_H */
virtual wxString GetName()=0
Function GetName.
Class ACTION_PLUGIN This is the parent class from where any action plugin class must derive...
Definition: action_plugin.h:40
static bool m_actionRunning
virtual bool GetShowToolbarButton()=0
Function GetShowToolbarButton.
Class ACTION_PLUGINS Mainly static.
virtual wxString GetDescription()=0
Function GetDescription.
wxBitmap iconBitmap
Definition: action_plugin.h:50
void register_action()
Function register_action It&#39;s the standard method of a "ACTION_PLUGIN" to register itself into the AC...
virtual ~ACTION_PLUGIN()
bool IsActionRunning()
Are we currently in an action plugin?
virtual wxString GetPluginPath()=0
Function GetPluginPath.
virtual void Run()=0
Function Run This method the the action.
bool show_on_toolbar
Definition: action_plugin.h:52
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
virtual wxString GetCategoryName()=0
Function GetCategoryName.
virtual wxString GetIconFileName()=0
Function GetIconFileName.
virtual void * GetObject()=0
Function GetObject This method gets the pointer to the object from where this action constructs...