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
6
#ifndef SEDITORMANAGER_H
7
#define SEDITORMANAGER_H
10
#include <wx/treectrl.h>
11
#include <wx/hashmap.h>
15
#include "cbexception.h" // cbThrow
17
#include "printing_types.h"
20
#include "globals.h" // cbC2U
23
//DLLIMPORT extern int ID_NBEditorManager;
24
//DLLIMPORT extern int ID_EditorManager;
25
//DLLIMPORT extern int idEditorManagerCheckFiles;
26
//DLLIMPORT extern int ID_EditorManagerCloseButton;
27
extern int ID_NBSEditorManager;
28
extern int ID_SEditorManager;
29
extern int idSEditorManagerCheckFiles;
30
extern int ID_SEditorManagerCloseButton;
35
class wxAuiNotebookEvent;
37
class SEditorColourSet;
41
class cbStyledTextCtrl;
44
struct EditorManagerInternalData;
46
WX_DECLARE_STRING_HASH_MAP(wxString, SAutoCompleteMap);
49
struct cbFindReplaceData;
54
//class DLLIMPORT EditorManager : public Mgr<EditorManager>, public wxEvtHandler
55
class SEditorManager : public wxEvtHandler
57
friend class ThreadSearchFrame;
58
friend class CodeSnippetsConfig;
60
static bool s_CanShutdown;
62
//friend class SnippetsSearchFrame; // give Manager access to our private members
63
static bool CanShutdown(){ return s_CanShutdown; }
65
SEditorManager(const SEditorManager& rhs) { cbThrow(_T("Can't call SEditorManager's copy ctor!!!")); }
66
virtual void operator=(const SEditorManager& rhs){ cbThrow(_T("Can't assign an SEditorManager* !!!")); }
68
cbAuiNotebook* GetNotebook(){ return m_pNotebook; }
69
void CreateMenu(wxMenuBar* menuBar);
70
void ReleaseMenu(wxMenuBar* menuBar);
72
int GetEditorsCount();
73
SAutoCompleteMap& GetAutoCompleteMap(){ return m_AutoCompleteMap; }
75
SEditorBase* IsOpen(const wxString& filename);
76
ScbEditor* Open(const wxString& filename, int pos = 0,ProjectFile* data = 0);
77
ScbEditor* Open(LoaderBase* fileLdr, const wxString& filename, int pos = 0,ProjectFile* data = 0);
78
SEditorBase* GetEditor(int index);
79
SEditorBase* GetEditor(const wxString& filename){ return IsOpen(filename); } // synonym of IsOpen()
80
SEditorBase* GetActiveEditor();
81
ScbEditor* GetBuiltinEditor(SEditorBase* eb);
82
int FindPageFromEditor(SEditorBase* eb);
84
// "overloaded" functions for easier access
85
// they all return a cbEditor pointer if the editor is builtin, or NULL
86
ScbEditor* IsBuiltinOpen(const wxString& filename){ return GetBuiltinEditor(IsOpen(filename)); }
87
ScbEditor* GetBuiltinEditor(int index){ return GetBuiltinEditor(GetEditor(index)); }
88
ScbEditor* GetBuiltinEditor(const wxString& filename){ return IsBuiltinOpen(filename); } // synonym of IsBuiltinOpen()
89
ScbEditor* GetBuiltinActiveEditor(){ return GetBuiltinEditor(GetActiveEditor()); }
92
void ActivatePrevious();
93
void SetActiveEditor(SEditorBase* ed);
94
SEditorColourSet* GetColourSet(){ return m_Theme; }
95
void SetColourSet(SEditorColourSet* theme);
96
ScbEditor* New(const wxString& newFileName = wxEmptyString);
98
// these are used *only* for custom editors
99
void AddCustomEditor(SEditorBase* eb);
100
void RemoveCustomEditor(SEditorBase* eb);
102
bool UpdateSnippetFiles(cbProject* project);
103
bool IsHeaderSource(const wxFileName& testedFileName, const wxFileName& activeFileName, FileType ftActive);
104
wxFileName FindHeaderSource(const wxArrayString& candidateFilesArray, const wxFileName& activeFile, bool& isCandidate);
105
bool SwapActiveHeaderSource();
106
bool CloseActive(bool dontsave = false);
107
bool Close(const wxString& filename,bool dontsave = false);
108
bool Close(SEditorBase* editor,bool dontsave = false);
109
bool Close(int index,bool dontsave = false);
111
// If file is modified, queries to save (yes/no/cancel).
112
// Returns false on "cancel".
113
bool QueryClose(SEditorBase* editor);
114
bool QueryCloseAll();
115
bool CloseAll(bool dontsave=false);
116
bool CloseAllExcept(SEditorBase* editor,bool dontsave=false);
117
bool Save(const wxString& filename);
118
bool Save(int index);
120
bool SaveAs(int index);
123
int ShowFindDialog(bool replace, bool explicitly_find_in_files = false);
124
int FindNext(bool goingDown, cbStyledTextCtrl* control = 0, cbFindReplaceData* data = 0);
126
void Print(PrintScope ps, PrintColourMode pcm, bool line_numbers);
128
/** Hides the editor notebook for layout purposes */
130
/** Shows the previously hidden editor notebook */
132
/** Check if one of the open files has been modified outside the IDE. If so, ask to reload it. */
133
void CheckForExternallyModifiedFiles();
136
void FilePrint(wxWindow* parent); //ported from main.cpp
137
int GetLongestLinePixelWidth( int top_line = -1, int bottom_line = -1); //(pecan 2007/4/04)
139
void OnGenericContextMenuHandler(wxCommandEvent& event);
140
void OnPageChanged(wxAuiNotebookEvent& event);
141
void OnPageChanging(wxAuiNotebookEvent& event);
142
void OnPageClose(wxAuiNotebookEvent& event);
143
void OnTabRightUp(wxAuiNotebookEvent& event);
144
void OnClose(wxCommandEvent& event);
145
void OnCloseAll(wxCommandEvent& event);
146
void OnCloseAllOthers(wxCommandEvent& event);
147
void OnSave(wxCommandEvent& event);
148
void OnSaveAll(wxCommandEvent& event);
149
void OnSwapHeaderSource(wxCommandEvent& event);
150
void OnTabPosition(wxCommandEvent& event);
151
void OnProperties(wxCommandEvent& event);
152
void OnAppDoneStartup(wxCommandEvent& event);
153
void OnAppStartShutdown(wxCommandEvent& event);
154
void OnUpdateUI(wxUpdateUIEvent& event);
155
void OnTreeItemSelected(wxTreeEvent &event);
156
void OnTreeItemActivated(wxTreeEvent &event);
157
void OnTreeItemRightClick(wxTreeEvent &event);
158
void SetZoom(int zoom);
162
// m_EditorsList access
163
void AddEditorBase(SEditorBase* eb);
164
void RemoveEditorBase(SEditorBase* eb, bool deleteObject = true);
165
ScbEditor* InternalGetBuiltinEditor(int page);
166
SEditorBase* InternalGetEditorBase(int page);
168
void CreateSearchLog();
169
void LogSearch(const wxString& file, int line, const wxString& lineText);
171
void LoadAutoComplete();
172
void SaveAutoComplete();
174
SAutoCompleteMap m_AutoCompleteMap;
176
SEditorManager(wxWindow* parent);
180
void InitSEditorManager(wxWindow* parent);
182
void CalculateFindReplaceStartEnd(cbStyledTextCtrl* control, cbFindReplaceData* data, bool replace = false);
183
void OnCheckForModifiedFiles(wxCommandEvent& event);
184
int Find(cbStyledTextCtrl* control, cbFindReplaceData* data);
185
int FindInFiles(cbFindReplaceData* data);
186
int Replace(cbStyledTextCtrl* control, cbFindReplaceData* data);
187
int ReplaceInFiles(cbFindReplaceData* data);
189
cbAuiNotebook* m_pNotebook;
190
cbFindReplaceData* m_LastFindReplaceData;
191
SEditorColourSet* m_Theme;
192
ListCtrlLogger* m_pSearchLog;
193
int m_SearchLogIndex;
196
bool m_isCheckingForExternallyModifiedFiles;
197
friend struct EditorManagerInternalData;
198
EditorManagerInternalData* m_pData;
202
DECLARE_EVENT_TABLE()
205
#endif // SEDITORMANAGER_H