Code::Blocks  SVN r11506
editorbase.h
Go to the documentation of this file.
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 EDITORBASE_H
7 #define EDITORBASE_H
8 
9 #include "prep.h"
10 
11 #include <wx/hashmap.h>
12 #include <wx/frame.h>
13 #include <wx/panel.h>
14 #include "globals.h"
15 #include "settings.h"
16 #include "cbexception.h"
17 
18 class wxMenu;
19 class EditorBase;
21 class cbDebuggerPlugin;
22 
23 WX_DECLARE_HASH_MAP(int, EditorBase*, wxIntegerHash, wxIntegerEqual, SwitchToMap);
24 
31 {
32  DECLARE_EVENT_TABLE()
33  public:
34  EditorBase(wxWindow* parent, const wxString& filename);
35  ~EditorBase() override;
36 
39  void operator=(cb_optional const EditorBase& rhs){ cbThrow(_T("Can't assign an EditorBase* !!!")); }
40 
45  virtual const wxString& GetFilename() const { return m_Filename; }
46 
50  virtual void SetFilename(const wxString& filename){ m_Filename = filename; }
51 
58  virtual const wxString& GetShortName() const { return m_Shortname; }
59 
67  virtual bool GetModified() const { return false; }
68 
73  virtual void SetModified(bool /*modified*/ = true) {}
74 
79  virtual const wxString& GetTitle();
80 
85  virtual void SetTitle(const wxString& newTitle);
86 
91  virtual void Activate();
92 
99  virtual bool QueryClose();
100 
106  virtual bool Close();
107 
113  virtual bool Save() { return true; }
114 
120  virtual bool SaveAs() { return true; }
121 
127  virtual bool IsBuiltinEditor() const;
128 
132  virtual bool ThereAreOthers() const;
133 
141  virtual void DisplayContextMenu(const wxPoint& position, ModuleType type = mtUnknown);
142 
151  virtual bool VisibleToTree() const { return true; }
152 
160  virtual void GotoLine(int /*line*/, bool /*centerOnScreen*/ = true){}
161 
163  virtual void Undo(){}
164 
166  virtual void Redo(){}
167 
169  virtual void ClearHistory(){}
170 
172  virtual void GotoNextChanged(){}
173 
175  virtual void GotoPreviousChanged(){}
176 
178  virtual void SetChangeCollection(cb_optional bool collectChange){}
179 
181  virtual void Cut(){}
182 
184  virtual void Copy(){}
185 
187  virtual void Paste(){}
188 
193  virtual bool CanUndo() const { return false; }
194 
199  virtual bool CanRedo() const { return false; }
200 
205  virtual bool HasSelection() const { return false; }
206 
211  virtual bool CanPaste() const { return false; }
212 
217  virtual bool IsReadOnly() const { return false; }
218 
223  virtual void SetReadOnly(bool /*readonly*/ = true) {}
224 
229  virtual bool CanSelectAll() const { return false; }
230 
233  virtual void SelectAll() { return; }
234 
239  virtual bool IsContextMenuOpened() const;
240  protected:
244  virtual void InitFilename(const wxString& filename);
245 
250  virtual wxMenu* CreateContextSubMenu(long id); // For context menus
251 
257  virtual void AddToContextMenu(cb_optional wxMenu* popup, cb_optional ModuleType type, cb_optional bool pluginsdone) {}
258 
262  virtual wxString CreateUniqueFilename();
263 
270  virtual bool OnBeforeBuildContextMenu(cb_optional const wxPoint& position, cb_optional ModuleType type){ return true; }
271 
276  virtual void OnAfterBuildContextMenu(cb_optional ModuleType type){}
277 
278  bool m_IsBuiltinEditor; // do not mess with it!
282  private:
283  EditorBase(cb_unused const EditorBase& rhs); // prevent copy construction
284 
286  void OnContextMenuEntry(wxCommandEvent& event);
287  void BasicAddToContextMenu(wxMenu* popup, ModuleType type); //pecan 2006/03/22
288  SwitchToMap m_SwitchTo;
291 };
292 
293 #endif // EDITORBASE_H
virtual const wxString & GetShortName() const
Returns the editor&#39;s short name.
Definition: editorbase.h:58
virtual void SetReadOnly(bool=true)
Set the editor read-only.
Definition: editorbase.h:223
virtual bool CanPaste() const
Is there something to paste?
Definition: editorbase.h:211
virtual bool HasSelection() const
Is there a selection?
Definition: editorbase.h:205
virtual void OnAfterBuildContextMenu(cb_optional ModuleType type)
Informs the editor we &#39;re done creating the context menu (just about to display it).
Definition: editorbase.h:276
Base class for debugger plugins.
Definition: cbplugin.h:397
virtual void AddToContextMenu(cb_optional wxMenu *popup, cb_optional ModuleType type, cb_optional bool pluginsdone)
Creates context menu items, both before and after creating plugins menu items.
Definition: editorbase.h:257
bool m_IsBuiltinEditor
Definition: editorbase.h:278
wxString lastWord
Definition: editorbase.h:290
virtual void SelectAll()
Select everything in the editor.
Definition: editorbase.h:233
virtual bool IsReadOnly() const
Is the editor read-only?
Definition: editorbase.h:217
virtual void Redo()
Redo changes.
Definition: editorbase.h:166
virtual void SetChangeCollection(cb_optional bool collectChange)
Enable or disable changebar.
Definition: editorbase.h:178
virtual void Paste()
Paste selected text/object from clipboard.
Definition: editorbase.h:187
wxString m_Shortname
Definition: editorbase.h:279
EditorBaseInternalData * m_pData
Use this to add new vars/functions w/out breaking the ABI.
Definition: editorbase.h:281
#define _T(string)
virtual bool CanRedo() const
Is there something to redo?
Definition: editorbase.h:199
SwitchToMap m_SwitchTo
Definition: editorbase.h:288
virtual void Copy()
Copy selected text/object to clipboard.
Definition: editorbase.h:184
#define DLLIMPORT
Definition: settings.h:16
WX_DECLARE_HASH_MAP(int, EditorBase *, wxIntegerHash, wxIntegerEqual, SwitchToMap)
virtual void SetModified(bool=true)
Set the modification status.
Definition: editorbase.h:73
virtual const wxString & GetFilename() const
Get the editor&#39;s filename (if applicable).
Definition: editorbase.h:45
virtual bool VisibleToTree() const
Should this kind of editor be visible in the open files tree?
Definition: editorbase.h:151
ModuleType
The type of module offering a context menu.
Definition: globals.h:38
virtual bool SaveAs()
Save editor contents under a different filename.
Definition: editorbase.h:120
Base class that all "editors" should inherit from.
Definition: editorbase.h:30
virtual void SetFilename(const wxString &filename)
Sets the editor&#39;s filename.
Definition: editorbase.h:50
virtual void Undo()
Undo changes.
Definition: editorbase.h:163
#define cbThrow(message)
Definition: cbexception.h:42
wxString m_WinTitle
Definition: editorbase.h:289
virtual bool GetModified() const
Is it modified?
Definition: editorbase.h:67
void operator=(cb_optional const EditorBase &rhs)
Don&#39;t use this.
Definition: editorbase.h:39
virtual void ClearHistory()
Clear Undo- (and Changebar-) history.
Definition: editorbase.h:169
wxString m_Filename
Definition: editorbase.h:280
virtual void GotoLine(int, bool=true)
Move the caret at the specified line.
Definition: editorbase.h:160
virtual void Cut()
Cut selected text/object to clipboard.
Definition: editorbase.h:181
virtual bool CanSelectAll() const
Can the editor select everything?
Definition: editorbase.h:229
virtual bool OnBeforeBuildContextMenu(cb_optional const wxPoint &position, cb_optional ModuleType type)
Informs the editor we &#39;re just about to create a context menu.
Definition: editorbase.h:270
virtual bool CanUndo() const
Is there something to undo?
Definition: editorbase.h:193
virtual bool Save()
Save contents.
Definition: editorbase.h:113
virtual void GotoPreviousChanged()
Goto previous changed line.
Definition: editorbase.h:175
virtual void GotoNextChanged()
Goto next changed line.
Definition: editorbase.h:172