Code::Blocks  SVN r11506
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
cbPlugin Class Reference

Base class for plugins. More...

#include <cbplugin.h>

Inheritance diagram for cbPlugin:
Collaboration diagram for cbPlugin:

Public Member Functions

 cbPlugin ()
 In default cbPlugin's constructor the associated PluginInfo structure is filled with default values. More...
 
 ~cbPlugin () override
 cbPlugin destructor. More...
 
virtual PluginType GetType () const
 The plugin must return its type on request. More...
 
virtual int GetConfigurationPriority () const
 Return the plugin's configuration priority. More...
 
virtual int GetConfigurationGroup () const
 Return the configuration group for this plugin. More...
 
virtual cbConfigurationPanelGetConfigurationPanel (cb_optional wxWindow *parent)
 Return plugin's configuration panel. More...
 
virtual cbConfigurationPanelGetProjectConfigurationPanel (cb_optional wxWindow *parent, cb_optional cbProject *project)
 Return plugin's configuration panel for projects. More...
 
virtual void BuildMenu (cb_optional wxMenuBar *menuBar)
 This method is called by Code::Blocks and is used by the plugin to add any menu items it needs on Code::Blocks's menu bar. More...
 
virtual void BuildModuleMenu (cb_optional const ModuleType type, cb_optional wxMenu *menu, cb_optional const FileTreeData *data=nullptr)
 This method is called by Code::Blocks core modules (EditorManager, ProjectManager etc) and is used by the plugin to add any menu items it needs in the module's popup menu. More...
 
virtual bool BuildToolBar (cb_optional wxToolBar *toolBar)
 This method is called by Code::Blocks and is used by the plugin to add any toolbar items it needs on Code::Blocks's toolbar. More...
 
virtual int GetToolBarPriority ()
 This method return the priority of the plugin's toolbar, the less value indicates a more preceding position when C::B starts with no configuration file. More...
 
virtual void CreateStatusField (cbStatusBar *statusBar)
 This method is called by Code::Blocks and is used by the plugin to add a field on Code::Blocks's statusbar. More...
 
bool IsAttached () const
 See whether this plugin is attached or not. More...
 
virtual bool CanDetach () const
 See whether this plugin can be detached (unloaded) or not. More...
 

Protected Member Functions

virtual void OnAttach ()
 Any descendent plugin should override this virtual method and perform any necessary initialization. More...
 
virtual void OnRelease (cb_optional bool appShutDown)
 Any descendent plugin should override this virtual method and perform any necessary de-initialization. More...
 
virtual void NotImplemented (const wxString &log) const
 This method logs a "Not implemented" message and is provided for convenience only. More...
 

Protected Attributes

PluginType m_Type
 Holds the plugin's type. More...
 
bool m_IsAttached
 Holds the "attached" state. More...
 

Private Member Functions

void Attach ()
 Attach is not a virtual function, so you can't override it. More...
 
void Release (bool appShutDown)
 Release is not a virtual function, so you can't override it. More...
 

Friends

class PluginManager
 

Detailed Description

Base class for plugins.

This is the most basic class a plugin must descend from. cbPlugin descends from wxEvtHandler, so it provides its methods as well...

It's not enough to create a new plugin. You must also provide a resource zip file containing a file named "manifest.xml". Check the manifest.xml file of existing plugins to see how to create one (it's ultra-simple).

Definition at line 84 of file cbplugin.h.

Constructor & Destructor Documentation

◆ cbPlugin()

cbPlugin::cbPlugin ( )

In default cbPlugin's constructor the associated PluginInfo structure is filled with default values.

If you inherit from cbPlugin, you should fill the m_PluginInfo members with the appropriate values.

Definition at line 51 of file cbplugin.cpp.

◆ ~cbPlugin()

cbPlugin::~cbPlugin ( )
override

cbPlugin destructor.

Definition at line 58 of file cbplugin.cpp.

Member Function Documentation

◆ Attach()

void cbPlugin::Attach ( )
private

Attach is not a virtual function, so you can't override it.

The default implementation hooks the plugin to Code::Block's event handling system, so that the plugin can receive (and process) events from Code::Blocks core library. Use OnAttach() for any initialization specific tasks.

See also
OnAttach()

Definition at line 62 of file cbplugin.cpp.

References cbEVT_PLUGIN_ATTACHED, Manager::Get(), Manager::GetAppWindow(), m_IsAttached, OnAttach(), and Manager::ProcessEvent().

Referenced by PluginManager::AttachPlugin().

◆ BuildMenu()

virtual void cbPlugin::BuildMenu ( cb_optional wxMenuBar menuBar)
inlinevirtual

This method is called by Code::Blocks and is used by the plugin to add any menu items it needs on Code::Blocks's menu bar.


It is a pure virtual method that needs to be implemented by all plugins. If the plugin does not need to add items on the menu, just do nothing ;)

Note
This function may be called more than one time. This can happen, for example, when a plugin is installed or uninstalled.
Parameters
menuBarthe wxMenuBar to create items in

Definition at line 138 of file cbplugin.h.

Referenced by MainFrame::CreateMenubar(), and MainFrame::DoAddPlugin().

◆ BuildModuleMenu()

virtual void cbPlugin::BuildModuleMenu ( cb_optional const ModuleType  type,
cb_optional wxMenu menu,
cb_optional const FileTreeData data = nullptr 
)
inlinevirtual

This method is called by Code::Blocks core modules (EditorManager, ProjectManager etc) and is used by the plugin to add any menu items it needs in the module's popup menu.

For example, when the user right-clicks on a project file in the project tree, ProjectManager prepares a popup menu to display with context sensitive options for that file. Before it displays this popup menu, it asks all attached plugins (by asking PluginManager to call this method), if they need to add any entries in that menu. This method is called.
If the plugin does not need to add items in the menu, just do nothing ;)

Parameters
typethe module that's preparing a popup menu
menupointer to the popup menu
datapointer to FileTreeData object (to access/modify the file tree)

Definition at line 155 of file cbplugin.h.

Referenced by PluginManager::AskPluginsForModuleMenu().

◆ BuildToolBar()

virtual bool cbPlugin::BuildToolBar ( cb_optional wxToolBar toolBar)
inlinevirtual

This method is called by Code::Blocks and is used by the plugin to add any toolbar items it needs on Code::Blocks's toolbar.


It is a pure virtual method that needs to be implemented by all plugins. If the plugin does not need to add items on the toolbar, just do nothing ;)

Parameters
toolBarthe wxToolBar to create items on
Returns
The plugin should return true if it needed the toolbar, false if not

Definition at line 165 of file cbplugin.h.

Referenced by MainFrame::DoAddPluginToolbar().

◆ CanDetach()

virtual bool cbPlugin::CanDetach ( ) const
inlinevirtual

See whether this plugin can be detached (unloaded) or not.

This function is called usually when the user requests to uninstall or disable a plugin. Before disabling/uninstalling it, Code::Blocks asks the plugin if it can be detached or not. In other words, it checks to see if it can be disabled/uninstalled safely...

A plugin should return true if it can be detached at this moment, false if not.
Returns
The default implementation returns true.

Definition at line 198 of file cbplugin.h.

◆ CreateStatusField()

virtual void cbPlugin::CreateStatusField ( cbStatusBar statusBar)
inlinevirtual

This method is called by Code::Blocks and is used by the plugin to add a field on Code::Blocks's statusbar.


If the plugin does not need to add items on the statusbar, just do nothing ;)

Parameters
statusBarthe cbStatusBar to create items on

Definition at line 179 of file cbplugin.h.

Referenced by MainFrame::DoAddPluginStatusField().

◆ GetConfigurationGroup()

virtual int cbPlugin::GetConfigurationGroup ( ) const
inlinevirtual

Return the configuration group for this plugin.

Default is cgUnknown. Notice that you can logically AND more than one configuration groups, so you could set it, for example, as "cgCompiler | cgContribPlugin".

Reimplemented in CompilerGCC, and CodeCompletion.

Definition at line 110 of file cbplugin.h.

References cgUnknown.

Referenced by PluginManager::GetConfigurationPanels().

◆ GetConfigurationPanel()

virtual cbConfigurationPanel* cbPlugin::GetConfigurationPanel ( cb_optional wxWindow parent)
inlinevirtual

Return plugin's configuration panel.

Parameters
parentThe parent window.
Returns
A pointer to the plugin's cbConfigurationPanel. It is deleted by the caller.

Definition at line 116 of file cbplugin.h.

Referenced by PluginManager::GetConfigurationPanels().

◆ GetConfigurationPriority()

virtual int cbPlugin::GetConfigurationPriority ( ) const
inlinevirtual

Return the plugin's configuration priority.

This is a number (default is 50) that is used to sort plugins in configuration dialogs. Lower numbers mean the plugin's configuration is put higher in the list.

Reimplemented in CompilerGCC.

Definition at line 104 of file cbplugin.h.

◆ GetProjectConfigurationPanel()

virtual cbConfigurationPanel* cbPlugin::GetProjectConfigurationPanel ( cb_optional wxWindow parent,
cb_optional cbProject project 
)
inlinevirtual

Return plugin's configuration panel for projects.

The panel returned from this function will be added in the project's configuration dialog.

Parameters
parentThe parent window.
projectThe project that is being edited.
Returns
A pointer to the plugin's cbConfigurationPanel. It is deleted by the caller.

Definition at line 125 of file cbplugin.h.

Referenced by PluginManager::GetProjectConfigurationPanels().

◆ GetToolBarPriority()

virtual int cbPlugin::GetToolBarPriority ( )
inlinevirtual

This method return the priority of the plugin's toolbar, the less value indicates a more preceding position when C::B starts with no configuration file.

Reimplemented in CodeCompletion, and CompilerGCC.

Definition at line 170 of file cbplugin.h.

Referenced by MainFrame::DoAddPluginToolbar().

◆ GetType()

virtual PluginType cbPlugin::GetType ( ) const
inlinevirtual

◆ IsAttached()

bool cbPlugin::IsAttached ( ) const
inline

◆ NotImplemented()

void cbPlugin::NotImplemented ( const wxString log) const
protectedvirtual

This method logs a "Not implemented" message and is provided for convenience only.

Definition at line 109 of file cbplugin.cpp.

References _T, LogManager::DebugLog(), Manager::Get(), and Manager::GetLogManager().

◆ OnAttach()

virtual void cbPlugin::OnAttach ( )
inlineprotectedvirtual

Any descendent plugin should override this virtual method and perform any necessary initialization.

This method is called by Code::Blocks (PluginManager actually) when the plugin has been loaded and should attach in Code::Blocks. When Code::Blocks starts up, it finds and loads all plugins but does not activate (attaches) them. It then activates all plugins that the user has selected to be activated on start-up.
This means that a plugin might be loaded but not activated...
Think of this method as the actual constructor...

Reimplemented in cbSmartIndentPlugin, cbDebuggerPlugin, Wiz, CompilerGCC, and CodeCompletion.

Definition at line 210 of file cbplugin.h.

Referenced by Attach().

◆ OnRelease()

virtual void cbPlugin::OnRelease ( cb_optional bool  appShutDown)
inlineprotectedvirtual

Any descendent plugin should override this virtual method and perform any necessary de-initialization.

This method is called by Code::Blocks (PluginManager actually) when the plugin has been loaded, attached and should de-attach from Code::Blocks.
Think of this method as the actual destructor...

Parameters
appShutDownIf true, the application is shutting down. In this case don't use Manager::Get()->Get...() functions or the behaviour is undefined...

Definition at line 221 of file cbplugin.h.

Referenced by Release().

◆ Release()

void cbPlugin::Release ( bool  appShutDown)
private

Release is not a virtual function, so you can't override it.

The default implementation un-hooks the plugin from Code::Blocks's event handling system. Use OnRelease() for any clean-up specific tasks.

Parameters
appShutDownIf true, the application is shutting down. In this case don't use Manager::Get()->Get...() functions or the behaviour is undefined...
See also
OnRelease()

Definition at line 82 of file cbplugin.cpp.

References cbEVT_PLUGIN_RELEASED, Manager::Get(), Manager::GetAppWindow(), m_IsAttached, OnRelease(), and Manager::ProcessEvent().

Referenced by PluginManager::DetachPlugin().

Friends And Related Function Documentation

◆ PluginManager

friend class PluginManager
friend

Definition at line 235 of file cbplugin.h.

Member Data Documentation

◆ m_IsAttached

bool cbPlugin::m_IsAttached
protected

Holds the "attached" state.

Definition at line 232 of file cbplugin.h.

Referenced by Attach(), and Release().

◆ m_Type

PluginType cbPlugin::m_Type
protected

The documentation for this class was generated from the following files: