~ubuntu-branches/ubuntu/lucid/codelite/lucid

« back to all changes in this revision

Viewing changes to Interfaces/imanager.h

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-01-12 15:46:55 UTC
  • Revision ID: james.westby@ubuntu.com-20090112154655-sdynrljcb6u167yw
Tags: upstream-1.0.2674+dfsg
ImportĀ upstreamĀ versionĀ 1.0.2674+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////////
 
2
//////////////////////////////////////////////////////////////////////////////
 
3
//
 
4
// copyright            : (C) 2008 by Eran Ifrah
 
5
// file name            : imanager.h
 
6
//
 
7
// -------------------------------------------------------------------------
 
8
// A
 
9
//              _____           _      _     _ _
 
10
//             /  __ \         | |    | |   (_) |
 
11
//             | /  \/ ___   __| | ___| |    _| |_ ___
 
12
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
 
13
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
 
14
//              \____/\___/ \__,_|\___\_____/_|\__\___|
 
15
//
 
16
//                                                  F i l e
 
17
//
 
18
//    This program is free software; you can redistribute it and/or modify
 
19
//    it under the terms of the GNU General Public License as published by
 
20
//    the Free Software Foundation; either version 2 of the License, or
 
21
//    (at your option) any later version.
 
22
//
 
23
//////////////////////////////////////////////////////////////////////////////
 
24
//////////////////////////////////////////////////////////////////////////////
 
25
 
 
26
#ifndef IMANAGER_H
 
27
#define IMANAGER_H
 
28
 
 
29
#include "ieditor.h"
 
30
#include "iconfigtool.h"
 
31
#include "ikeyboard.h"
 
32
#include "wx/treectrl.h"
 
33
#include "custom_notebook.h"
 
34
#include "optionsconfig.h"
 
35
#include "queuecommand.h"
 
36
 
 
37
class TagsManager;
 
38
class Workspace;
 
39
class EnvironmentConfig;
 
40
class JobQueue;
 
41
class wxApp;
 
42
class IPlugin;
 
43
class BuildManager;
 
44
class BuildSettingsConfig;
 
45
class NavMgr;
 
46
 
 
47
//--------------------------
 
48
//Auxulary class
 
49
//--------------------------
 
50
class TreeItemInfo
 
51
{
 
52
public:
 
53
        wxTreeItemId m_item;
 
54
        wxFileName m_fileName;  //< FileName where available (FileView & File Explorer trees)
 
55
        wxString m_text;                //< Tree item text (all)
 
56
        int     m_itemType;                     //< For FileView items (FileView only)
 
57
};
 
58
 
 
59
//---------------------------
 
60
// List of availabla trees
 
61
//---------------------------
 
62
enum TreeType {
 
63
        TreeFileView = 0,
 
64
        TreeFileExplorer,
 
65
};
 
66
 
 
67
//------------------------------------------------------------------
 
68
// Defines the interface of the manager
 
69
//------------------------------------------------------------------
 
70
/**
 
71
 * @class IManager
 
72
 * @author Eran
 
73
 * @date 05/07/08
 
74
 * @file imanager.h
 
75
 * @brief every plugin holds an instance of this class.
 
76
 * You should use this class to interact with CodeLite
 
77
 */
 
78
class IManager
 
79
{
 
80
public:
 
81
        IManager() {}
 
82
        virtual ~IManager() {}
 
83
 
 
84
        //return the current editor
 
85
        /**
 
86
         * @brief return the active editor
 
87
         * @return pointer to the current editor, or NULL incase the active editor is not of type LEditor or no active editor open
 
88
         */
 
89
        virtual IEditor *GetActiveEditor() = 0;
 
90
        /**
 
91
         * @brief open file and make it the active editor
 
92
         * @param fileName the file to open - use absolute path
 
93
         * @param projectName project to associate this file - can be wxEmptyString
 
94
         * @param lineno if lineno is not wxNOT_FOUD, the caret will placed on this line number
 
95
     * @return true if file opened
 
96
         */
 
97
        virtual bool OpenFile(const wxString &fileName, const wxString &projectName = wxEmptyString, int lineno = wxNOT_FOUND) = 0;
 
98
 
 
99
        /**
 
100
         * @brief Open file using browsing record
 
101
         * @param rec browsing record
 
102
         * @return true on success false otherwise
 
103
         */
 
104
        virtual bool OpenFile(const BrowseRecord &rec) = 0;
 
105
 
 
106
        /**
 
107
         * @brief return a pointer to the configuration tool
 
108
         * @sa IConfigTool
 
109
         */
 
110
        virtual IConfigTool *GetConfigTool() = 0;
 
111
 
 
112
        /**
 
113
         * @brief return TreeItemInfo for the selected tree item
 
114
         * @param type the tree we are interested in
 
115
         * @sa TreeItemInfo
 
116
         * @sa TreeType
 
117
         */
 
118
        virtual TreeItemInfo GetSelectedTreeItemInfo(TreeType type) = 0;
 
119
        /**
 
120
         * @brief returns a pointer to wxTreeCtrl by type
 
121
         * @param type the type of tree
 
122
         * @sa TreeType
 
123
         */
 
124
        virtual wxTreeCtrl *GetTree(TreeType type) = 0;
 
125
        /**
 
126
         * @brief return a pointer to the workspace pane notebook (the one with the 'workspace' title)
 
127
         * @return pointer to Notebook
 
128
         * @sa Notebook
 
129
         */
 
130
        virtual Notebook *GetWorkspacePaneNotebook() = 0;
 
131
        /**
 
132
         * @brief return a pointer to the output pane notebook (the one with the 'output' title)
 
133
         * @return pointer to Notebook
 
134
         * @sa Notebook
 
135
         */
 
136
        virtual Notebook *GetOutputPaneNotebook() = 0;
 
137
        /**
 
138
         * @brief return the startup directory of CodeLite which is also the base directory for searching installation files
 
139
         * @return a full path to the startup directory
 
140
         */
 
141
        virtual wxString GetStartupDirectory() const = 0;
 
142
 
 
143
        /**
 
144
         * @brief return the installation directory of codelite
 
145
         * @return a full path to codelite installation
 
146
         */
 
147
        virtual wxString GetInstallDirectory() const = 0;
 
148
 
 
149
        /**
 
150
         * @brief add project to the workspace
 
151
         * @param path full path to the project to add
 
152
         */
 
153
        virtual void AddProject(const wxString & path) = 0;
 
154
 
 
155
        /**
 
156
         * @brief return true of a workspace is already open
 
157
         */
 
158
        virtual bool IsWorkspaceOpen() const = 0;
 
159
 
 
160
        /**
 
161
         * @brief return an instance to the tags manager - which allows access to CodeLite CodeCompletion API
 
162
         * @return a pointer to the tags manager
 
163
         * @sa TagsManager
 
164
         */
 
165
        virtual TagsManager *GetTagsManager() = 0;
 
166
        /**
 
167
         * @brief return a pointer to the workspace manager
 
168
         * @sa Workspace
 
169
         */
 
170
        virtual Workspace *GetWorkspace() = 0;
 
171
 
 
172
        /**
 
173
         * @brief add files to a virtual folder in the project
 
174
         * @param item a tree item which represents the tree item of the virtual folder
 
175
         * @param paths an array of files to add
 
176
         * @return true on sucesss, false otherwise
 
177
         */
 
178
        virtual bool AddFilesToVirtualFolder(wxTreeItemId &item, wxArrayString &paths) = 0;
 
179
 
 
180
        /**
 
181
         * @brief add files to a virtual folder in the project
 
182
         * @param vdFullPath virtual directory full path in the form of <project>:vd1:vd2:...:vdN
 
183
         * @param paths an array of files to add
 
184
         * @return true on sucesss, false otherwise
 
185
         */
 
186
        virtual bool AddFilesToVirtualFolder(const wxString &vdFullPath, wxArrayString &paths) = 0;
 
187
 
 
188
        /**
 
189
         * @brief create virtual folder to parentPath
 
190
         * @param parentPath parent virtual directory full path in the form of <project>:vd1:vd2:...:vdN which must exist
 
191
         * @param vdName child VD name
 
192
         * @return true on success, false otherwise
 
193
         */
 
194
        virtual bool CreateVirtualDirectory(const wxString& parentPath, const wxString& vdName) = 0;
 
195
 
 
196
        /**
 
197
         * @brief return the size of the icons used by CodeLite
 
198
         * @return 16 or 24
 
199
         */
 
200
        virtual int GetToolbarIconSize() = 0;
 
201
 
 
202
        /**
 
203
         * @brief return true if toobars are allowed for plugins. This is useful for the Mac port of
 
204
         * codelite. On Mac, only single toolbar is allowed in the application (otherwise, the application
 
205
         * does not feet into the environment)
 
206
         * @return true if plugin can create a toolbar, false otherwise
 
207
         */
 
208
        virtual bool AllowToolbar() = 0;
 
209
 
 
210
        /**
 
211
         * @brief return a pointer to the docking manager (wxAUI)
 
212
         */
 
213
        virtual wxAuiManager* GetDockingManager() = 0;
 
214
        /**
 
215
         * @brief return a pointer to the environment manager
 
216
         * @sa EnvironmentConfig
 
217
         */
 
218
        virtual EnvironmentConfig *GetEnv() = 0;
 
219
        /**
 
220
         * @brief return a pointer to the job queue manager
 
221
         * @return job queue manager
 
222
         */
 
223
        virtual JobQueue *GetJobQueue() = 0;
 
224
 
 
225
        /**
 
226
         * @brief return the project execution command as set in the project's settings
 
227
         * @param projectName the project
 
228
         * @param wd starting dirctory
 
229
         * @return the execution command or wxEmptyString if the project does not exist
 
230
         */
 
231
        virtual wxString GetProjectExecutionCommand(const wxString &projectName, wxString &wd) = 0;
 
232
 
 
233
        /**
 
234
         * @brief return the application
 
235
         */
 
236
        virtual wxApp *GetTheApp() = 0;
 
237
 
 
238
        /**
 
239
         * @brief reload the current workspace, this function does not do anything if a workspace is not opened
 
240
         */
 
241
        virtual void ReloadWorkspace() = 0;
 
242
 
 
243
        /**
 
244
         * @brief search for loaded plugin by its name, if the plugin is loaded returns its pointer
 
245
         * @param pluginName plugin to search
 
246
         * @return pointer to the plugin or NULL if it is not loaded
 
247
         */
 
248
        virtual IPlugin *GetPlugin(const wxString &pluginName) = 0;
 
249
 
 
250
        /**
 
251
         * @brief output window for receiving async cmd events
 
252
         */
 
253
        virtual wxEvtHandler *GetOutputWindow() = 0;
 
254
 
 
255
        /**
 
256
         * @brief save all modified files
 
257
         */
 
258
        virtual bool SaveAll() = 0;
 
259
 
 
260
        /**
 
261
         * @brief return the keyboard manager
 
262
         */
 
263
        virtual IKeyboard *GetKeyboardManager() = 0;
 
264
 
 
265
        /**
 
266
         * @brief return the editor's settings object
 
267
         */
 
268
    virtual OptionsConfigPtr GetEditorSettings() = 0;
 
269
 
 
270
    /**
 
271
     * @brief search for pattern in active editor and select name if found
 
272
     */
 
273
    virtual void FindAndSelect(const wxString& pattern, const wxString& name) = 0;
 
274
 
 
275
    /**
 
276
     * @brief return tag at caret in active editor (if ambiguous, user will get a selection dialog)
 
277
     * @param scoped whether to do scope-aware lookup
 
278
     * @param impl whether to return declaration (false) or definition (true)
 
279
     * @return the found tag or NULL
 
280
     */
 
281
    virtual TagEntryPtr GetTagAtCaret(bool scoped, bool impl) = 0;
 
282
    
 
283
    /**
 
284
     * @brief show a (short) message in the status bar
 
285
     */
 
286
    virtual void SetStatusMessage(const wxString &msg, int col, int id) = 0;
 
287
 
 
288
        /**
 
289
         * @brief start processing commands from the queue
 
290
         */
 
291
        virtual void ProcessCommandQueue() = 0;
 
292
 
 
293
        /**
 
294
         * @brief place a command on the internal queue of codelite to be processed. Each command is executed on
 
295
         * a separated process. The queue will not start processing, until a call to ProcessCommandQueue() is issued
 
296
         * @param cmd command to process
 
297
         */
 
298
        virtual void PushQueueCommand(const QueueCommand &cmd) = 0;
 
299
 
 
300
        /**
 
301
         * @brief stop the current process execution and clear all commands from the queue
 
302
         */
 
303
        virtual void StopAndClearQueue() = 0;
 
304
 
 
305
        /**
 
306
         * @brief return the project name of a file
 
307
         * @param fullPathFileName file to search
 
308
         * @return project name or wxEmptyString if the search failed
 
309
         */
 
310
        virtual wxString GetProjectNameByFile( const wxString &fullPathFileName ) = 0;
 
311
 
 
312
        /**
 
313
         * @brief accessor to singleton object in the application
 
314
         */
 
315
        virtual BuildManager *GetBuildManager() = 0;
 
316
 
 
317
        /**
 
318
         * @brief accessor to singleton object in the application
 
319
         */
 
320
        virtual BuildSettingsConfig *GetBuildSettingsConfigManager() = 0;
 
321
 
 
322
        /**
 
323
         * @brief return the singleton object of the navigation manager
 
324
         */
 
325
        virtual NavMgr *GetNavigationMgr() = 0;
 
326
 
 
327
    void SetStatusMessage(const wxString &msg, int id)
 
328
        { SetStatusMessage(msg, 0, id); }
 
329
 
 
330
    /**
 
331
     * @brief close the named page in the mainbook
 
332
     */
 
333
    virtual bool ClosePage(const wxString &text) = 0;
 
334
 
 
335
    /**
 
336
     * @brief return named window in mainbook
 
337
     */
 
338
    virtual wxWindow *FindPage(const wxString &text) = 0;
 
339
 
 
340
    /**
 
341
     * @brief add a page to the mainbook
 
342
     */
 
343
    virtual bool AddPage(wxWindow *win, const wxString &text, const wxBitmap &bmp = wxNullBitmap, bool selected = false) = 0;
 
344
 
 
345
    /**
 
346
     * @brief select a window in mainbook
 
347
     */
 
348
    virtual bool SelectPage(wxWindow *win) = 0;
 
349
};
 
350
 
 
351
 
 
352
class PluginStatusMessage
 
353
{
 
354
    IManager *m_mgr;
 
355
    int m_col;
 
356
    int m_id;
 
357
public:
 
358
    PluginStatusMessage(IManager *mgr, const wxString &msg, int col, int id)
 
359
        : m_mgr(mgr)
 
360
        , m_col(col)
 
361
        , m_id(id)
 
362
        { mgr->SetStatusMessage(msg, col, id); }
 
363
    PluginStatusMessage(IManager *mgr, const wxString &msg, int id)
 
364
        : m_mgr(mgr)
 
365
        , m_col(0)
 
366
        , m_id(id)
 
367
        { mgr->SetStatusMessage(msg, 0, id); }
 
368
    ~PluginStatusMessage()
 
369
        { m_mgr->SetStatusMessage(wxEmptyString, m_col, m_id); }
 
370
};
 
371
 
 
372
 
 
373
class PluginBusyMessage : public PluginStatusMessage, public wxBusyCursor
 
374
{
 
375
public:
 
376
    PluginBusyMessage(IManager *mgr, const wxString &msg, int col, int id)
 
377
        : PluginStatusMessage(mgr, msg, col, id)
 
378
        { }
 
379
    PluginBusyMessage(IManager *mgr, const wxString &msg, int id)
 
380
        : PluginStatusMessage(mgr, msg, id)
 
381
        { }
 
382
};
 
383
 
 
384
 
 
385
#endif //IMANAGER_H