forked from eranif/codelite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.h
199 lines (180 loc) · 6 KB
/
plugin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : plugin.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef PLUGIN_H
#define PLUGIN_H
// Windows headers define it
#ifdef __WXMSW__
#ifdef Yield
#undef Yield
#endif
#endif
#include <wx/app.h>
#include "imanager.h"
#include "wx/toolbar.h"
#include <wx/pen.h>
#include "cl_aui_tb_are.h"
#include "cl_defs.h"
#if USE_AUI_TOOLBAR
#include <wx/aui/auibar.h>
#endif
#include "wx/event.h"
#include "wx/notebook.h"
#include "plugindata.h"
#include "plugin_version.h"
#include "codelite_events.h"
#ifdef _WIN32
#define STDCALL __stdcall
#define EXPORT __declspec(dllexport)
#else
#define STDCALL
#define EXPORT
#endif
class IManager;
/**
* Possible popup menu
*/
enum MenuType {
MenuTypeFileExplorer = 0,
MenuTypeFileView_Workspace,
MenuTypeFileView_Project,
MenuTypeFileView_Folder,
MenuTypeFileView_File,
MenuTypeEditor
};
//------------------------------------------------------------------
//each plugin must implement this interface
//------------------------------------------------------------------
/**
* @class IPlugin
* @author Eran
* @date 05/07/08
* @file plugin.h
* @brief The interface that defines a plugin for CodeLite. each plugin must implement the pure virtual methods of this
* interface. The plugin gains access to CodeLite data by using the m_mgr member
* @sa IManager
*/
class IPlugin : public wxEvtHandler
{
protected:
wxString m_shortName;
wxString m_longName;
IManager *m_mgr;
public:
IPlugin(IManager *manager) : m_mgr(manager) {}
virtual ~IPlugin() {}
//-----------------------------------------------
//The interface
//-----------------------------------------------
/**
* @brief return the plugin's short name
* @return
*/
virtual const wxString &GetShortName() const {
return m_shortName;
}
/**
* @brief return the plugin's long and more descriptive name
* @return
*/
virtual const wxString &GetLongName() const {
return m_longName;
}
/**
* When LiteEditor loads all the plugins, this function is called. If toolbar
* is provided by the plugin, the Plugin Manager will palce it in the appropriate
* place on the toolbar pane.
* \param parent toolbar parent, usually this is the main frame
* \return toolbar or NULL
*/
virtual clToolBar *CreateToolBar(wxWindow *parent) = 0;
/**
* Every plugin can place a sub menu in the 'Plugins' Menu at the menu bar
* \param pluginsMenu
*/
virtual void CreatePluginMenu(wxMenu *pluginsMenu) = 0;
/**
* \brief Call the plugin "shutdown" function
*/
virtual void UnPlug() = 0;
/**
* Override this method to allow the plugin to
* hook the popup menu by adding its entries.
* \param menu menu to hook
* \param type menu type
* \sa MenuType
*/
virtual void HookPopupMenu(wxMenu *menu, MenuType type) {
wxUnusedVar(type);
wxUnusedVar(menu);
};
/**
* @brief load image file from /path/to/install/plugins/resources/
* @param name file name (name+extension)
* @return Bitmap of wxNullBitmap if no match was found
*/
virtual wxBitmap LoadBitmapFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_PNG) {
wxBitmap bmp;
#ifdef __WXGTK__
wxString pluginsDir(PLUGINS_DIR, wxConvUTF8);
#else
wxString pluginsDir(m_mgr->GetInstallDirectory() + wxT( "/plugins" ));
#endif
wxString basePath(pluginsDir + wxT("/resources/"));
bmp.LoadFile(basePath + name, type);
if (bmp.IsOk()) {
return bmp;
}
return wxNullBitmap;
}
/**
* @brief allow the plugins to hook a tab in the project settings
* @param notebook the parent
* @param configName the associated configuration name
*/
virtual void HookProjectSettingsTab(wxBookCtrlBase *notebook, const wxString &projectName, const wxString &configName) {
wxUnusedVar( notebook );
wxUnusedVar( projectName );
wxUnusedVar( configName );
}
/**
* @brief Unhook any tab from the project settings dialog
* @param notebook the parent
* @param configName the associated configuration name
*/
virtual void UnHookProjectSettingsTab(wxBookCtrlBase *notebook, const wxString &projectName, const wxString &configName) {
wxUnusedVar( notebook );
wxUnusedVar( projectName );
wxUnusedVar( configName );
}
};
#define CHECK_CL_SHUTDOWN(){\
if(m_mgr->IsShutdownInProgress())\
return;\
}
//Every dll must contain at least this function
typedef IPlugin* (*GET_PLUGIN_CREATE_FUNC) (IManager*);
typedef PluginInfo (*GET_PLUGIN_INFO_FUNC) ();
typedef int (*GET_PLUGIN_INTERFACE_VERSION_FUNC) ();
#endif //PLUGIN_H