~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/contrib/codesnippets/editor/seditorbase.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
 
3
 * http://www.gnu.org/licenses/lgpl-3.0.html
 
4
 */
 
5
 
 
6
#ifndef SEDITORBASE_H
 
7
#define SEDITORBASE_H
 
8
 
 
9
#include <wx/hashmap.h>
 
10
#include <wx/frame.h>
 
11
#include <wx/panel.h>
 
12
#include "globals.h"
 
13
#include "settings.h"
 
14
#include "cbexception.h"
 
15
 
 
16
class wxMenu;
 
17
class SEditorBase;
 
18
class SEditorManager;
 
19
struct EditorBaseInternalData;
 
20
 
 
21
WX_DECLARE_HASH_MAP(int, SEditorBase*, wxIntegerHash, wxIntegerEqual, SSwitchToMap);
 
22
 
 
23
/** @brief Base class that all "editors" should inherit from.
 
24
  *
 
25
  * @note This class descends from wxPanel, so it provides all wxPanel methods
 
26
  * as well...
 
27
  */
 
28
//class DLLIMPORT EditorBase : public wxPanel
 
29
// ----------------------------------------------------------------------------
 
30
class SEditorBase : public wxPanel
 
31
// ----------------------------------------------------------------------------
 
32
{
 
33
    DECLARE_EVENT_TABLE()
 
34
    public:
 
35
        SEditorBase(wxWindow* parent, const wxString& filename);
 
36
        virtual ~SEditorBase();
 
37
 
 
38
        /** Don't use this. It throws an exception if you do. */
 
39
        SEditorBase(const SEditorBase& rhs) { cbThrow(_T("Can't call SEditorBase's copy ctor!!!")); }
 
40
 
 
41
        /** Don't use this. It throws an exception if you do. */
 
42
        virtual void operator=(const SEditorBase& rhs){ cbThrow(_T("Can't assign an SEditorBase* !!!")); }
 
43
 
 
44
        /** @brief Get the editor's filename (if applicable).
 
45
          *
 
46
          * @return The editor's filename.
 
47
          */
 
48
        virtual const wxString& GetFilename() const { return m_Filename; }
 
49
 
 
50
        /** @brief Sets the editor's filename.
 
51
          * @param filename The filename to set.
 
52
          */
 
53
        virtual void SetFilename(const wxString& filename){ m_Filename = filename; }
 
54
 
 
55
        /** @brief Returns the editor's short name.
 
56
          *
 
57
          * This is the name displayed on the editor's tab...
 
58
          *
 
59
          * Synonym to GetTitle().
 
60
          */
 
61
        virtual const wxString& GetShortName() const { return m_Shortname; }
 
62
 
 
63
        /** @brief Is it modified?
 
64
          *
 
65
          * @return true If editor is modified, false otherwise.
 
66
          * @note This function should always be overriden by implementations
 
67
          *       because the default implementation in SEditorBase always
 
68
          *       returns false.
 
69
          */
 
70
        virtual bool GetModified() const { return false; }
 
71
 
 
72
        /** @brief Set the modification status.
 
73
          *
 
74
          * @param modified If true, mark as modified. If false, mark as clean (unmodified).
 
75
          */
 
76
        virtual void SetModified(bool modified = true) {}
 
77
 
 
78
        /** @brief The editor's title.
 
79
          *
 
80
          * @return The editor's title.
 
81
          */
 
82
        virtual const wxString& GetTitle();
 
83
 
 
84
        /** @brief Set the editor's title.
 
85
          *
 
86
          * @param newTitle The new title to set.
 
87
          */
 
88
        virtual void SetTitle(const wxString& newTitle);
 
89
 
 
90
        /** @brief Activate this editor.
 
91
          *
 
92
          * Causes this editor to be activated, i.e. brought to front.
 
93
          */
 
94
        virtual void Activate();
 
95
 
 
96
        /** @brief Can this be closed (destroyed)?
 
97
          *
 
98
          * This is used internally and queries the editor if it is safe to
 
99
          * close it (i.e. it is not modified).
 
100
          * @return True if this editor can be closed.
 
101
          */
 
102
        virtual bool QueryClose(){ return true; }
 
103
 
 
104
        /** @brief Close this editor.
 
105
          *
 
106
          * The default implementation closes (destroys) the editor and returns true.
 
107
          * @return True if editor closed succesfully
 
108
          */
 
109
        virtual bool Close();
 
110
 
 
111
        /** @brief Save contents.
 
112
          *
 
113
          * Save the editor's contents. The default implementation does nothing
 
114
          * and returns true.
 
115
          * @return True on success, false otherwise. */
 
116
        virtual bool Save() { return true; }
 
117
 
 
118
        /** @brief Is this a built-in editor?
 
119
          *
 
120
          * Query if this is a built-in editor (a.k.a cbEditor).
 
121
          * @return True if it is a cbEditor, false otherwise.
 
122
          */
 
123
        virtual bool IsBuiltinEditor() const;
 
124
 
 
125
        /** @brief Are there other editors besides this?
 
126
          * @return True if there are more editors open, false otherwise.
 
127
          */
 
128
        virtual bool ThereAreOthers() const;
 
129
 
 
130
        /** @brief Display context menu.
 
131
          *
 
132
          * Displays the editor's context menu. This is called automatically
 
133
          * if the user right-clicks in the editor area.
 
134
          * @param position The position to popup the context menu.
 
135
          * @param type The module's type.
 
136
          */
 
137
        virtual void DisplayContextMenu(const wxPoint& position, ModuleType type = mtUnknown);
 
138
 
 
139
        /** Should this kind of editor be visible in the open files tree?
 
140
          *
 
141
          * There are rare cases where an editor should not be visible in the
 
142
          * open files tree. One such example is the "Start here" page...
 
143
          *
 
144
          * @return True if it should be visible in the open files tree, false
 
145
          *         if not.
 
146
          */
 
147
        virtual bool VisibleToTree() const { return true; }
 
148
 
 
149
        /** Move the caret at the specified line.
 
150
          *
 
151
          * @param line The line to move the caret to.
 
152
          * @param centerOnScreen If true, the line in question will be in the center
 
153
          *                       of the editor's area (if possible). If false,
 
154
          *                       it will be just made visible.
 
155
          */
 
156
        virtual void GotoLine(int line, bool centerOnScreen = true){}
 
157
 
 
158
        /** Toggle breakpoint at specified line.
 
159
          * @param line The line to toggle the breakpoint on. If @c line is -1,
 
160
          *             use current line.
 
161
          * @param notifyDebugger If true (and a debugger plugin is loaded),
 
162
          *                       tell the debugger about this breakpoint.
 
163
          */
 
164
        virtual void ToggleBreakpoint(int line = -1, bool notifyDebugger = true){}
 
165
 
 
166
        /** Does @c line has breakpoint?
 
167
          * @param line The line to check for breakpoint existence.
 
168
          * @return True if there is a breakpoint on this line, false if not.
 
169
          */
 
170
        virtual bool HasBreakpoint(int line) const { return false; }
 
171
 
 
172
        /** Go to next breakpoint. */
 
173
        virtual void GotoNextBreakpoint(){}
 
174
 
 
175
        /** Go to previous breakpoint. */
 
176
        virtual void GotoPreviousBreakpoint(){}
 
177
 
 
178
        /** Toggle bookmark at specified line.
 
179
          * @param line The line to toggle the bookmark on. If @c line is -1,
 
180
          *             use current line.
 
181
          */
 
182
        virtual void ToggleBookmark(int line = -1){}
 
183
 
 
184
        /** Does @c line has bookmark?
 
185
          * @param line The line to check for bookmark existence.
 
186
          * @return True if there is a bookmark on this line, false if not.
 
187
          */
 
188
        virtual bool HasBookmark(int line) const { return false; }
 
189
 
 
190
        /** Go to next bookmark. */
 
191
        virtual void GotoNextBookmark(){}
 
192
 
 
193
        /** Go to previous bookmark. */
 
194
        virtual void GotoPreviousBookmark(){}
 
195
 
 
196
        /** @brief Mark the debugger's active line.
 
197
          *
 
198
          * Highlight the line the debugger will execute next.
 
199
          * @param line The line in question.
 
200
          */
 
201
        virtual void SetDebugLine(int line){}
 
202
 
 
203
        /** @brief Mark line as error.
 
204
          *
 
205
          * Highlight the specified line as compiler error.
 
206
          * @param line The line in question.
 
207
          */
 
208
        virtual void SetErrorLine(int line){}
 
209
 
 
210
        /** Undo changes. */
 
211
        virtual void Undo(){}
 
212
 
 
213
        /** Redo changes. */
 
214
        virtual void Redo(){}
 
215
 
 
216
        /** Cut selected text/object to clipboard. */
 
217
        virtual void Cut(){}
 
218
 
 
219
        /** Copy selected text/object to clipboard. */
 
220
        virtual void Copy(){}
 
221
 
 
222
        /** Paste selected text/object from clipboard. */
 
223
        virtual void Paste(){}
 
224
 
 
225
        /** Is there something to undo?
 
226
          *
 
227
          * @return True if there is something to undo, false if not.
 
228
          */
 
229
        virtual bool CanUndo() const { return false; }
 
230
 
 
231
        /** Is there something to redo?
 
232
          *
 
233
          * @return True if there is something to redo, false if not.
 
234
          */
 
235
        virtual bool CanRedo() const { return false; }
 
236
 
 
237
        /** Is there a selection?
 
238
          *
 
239
          * @return True if there is text/object selected, false if not.
 
240
          */
 
241
        virtual bool HasSelection() const { return false; }
 
242
 
 
243
        /** Is there something to paste?
 
244
          *
 
245
          * @return True if there is something to paste, false if not.
 
246
          */
 
247
        virtual bool CanPaste() const { return false; }
 
248
 
 
249
        /** Is the editor read-only?
 
250
          *
 
251
          * @return True if the editor is read-only, false if not.
 
252
          */
 
253
        virtual bool IsReadOnly() const { return false; }
 
254
 
 
255
        virtual void SearchGotoLine();
 
256
        virtual void SearchFind();
 
257
        virtual void SearchFindNext(bool next = true);
 
258
        virtual void OnSearchReplace();
 
259
 
 
260
    // --------------------------------------------------------------
 
261
    protected:
 
262
    // --------------------------------------------------------------
 
263
        /** Initializes filename data.
 
264
          * @param filename The editor's filename for initialization.
 
265
          */
 
266
        virtual void InitFilename(const wxString& filename);
 
267
 
 
268
        /** Creates context submenus. See cbEditor code for details.
 
269
          * @param id An event handler's ID.
 
270
          * @return The created submenu or NULL if not applicable.
 
271
          */
 
272
        virtual wxMenu* CreateContextSubMenu(int id); // For context menus
 
273
 
 
274
        /** Creates context menu items, both before and after creating plugins menu items.
 
275
          * @param popup The popup menu.
 
276
          * @param type The module's type.
 
277
          * @param pluginsdone True if plugin menus have been created, false if not.
 
278
          */
 
279
        virtual void AddToContextMenu(wxMenu* popup, ModuleType type, bool pluginsdone) {}
 
280
 
 
281
        /** Creates unique filename when asking to save the file.
 
282
          * @return A unique filename suggestion.
 
283
          */
 
284
        virtual wxString CreateUniqueFilename();
 
285
 
 
286
        /** Informs the editor we 're just about to create a context menu.
 
287
          * Default implementation, just returns true.
 
288
          * @param position specifies the position of the popup menu.
 
289
          * @param type specifies the "ModuleType" popup menu.
 
290
          * @return If the editor returns false, the context menu creation is aborted.
 
291
          */
 
292
        virtual bool OnBeforeBuildContextMenu(const wxPoint& position, ModuleType type){ return true; }
 
293
 
 
294
        /** Informs the editor we 're done creating the context menu (just about to display it).
 
295
          * Default implementation does nothing.
 
296
          * @param type specifies the "ModuleType" context popup menu.
 
297
          */
 
298
        virtual void OnAfterBuildContextMenu(ModuleType type){}
 
299
 
 
300
        virtual SEditorManager* GetEditorManager() const {return m_pEditorManager;}
 
301
        virtual wxWindow* GetEditorParent(){return m_pParent;}
 
302
 
 
303
        bool m_IsBuiltinEditor; // do not mess with it!
 
304
        wxString m_Shortname;
 
305
        wxString m_Filename;
 
306
        EditorBaseInternalData* m_pData; ///< Use this to add new vars/functions w/out breaking the ABI
 
307
    private:
 
308
 
 
309
        /** one event handler for all popup menu entries */
 
310
        void OnContextMenuEntry(wxCommandEvent& event);
 
311
        void BasicAddToContextMenu(wxMenu* popup, ModuleType type); //pecan 2006/03/22
 
312
        SSwitchToMap m_SwitchTo;
 
313
        wxString m_WinTitle;
 
314
        wxString lastWord;
 
315
        SEditorManager* m_pEditorManager;
 
316
        wxWindow* m_pParent;
 
317
};
 
318
 
 
319
#endif // SEDITORBASE_H