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

« back to all changes in this revision

Viewing changes to src/plugins/contrib/codesnippets/editor/seditormanager.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 SEDITORMANAGER_H
 
7
#define SEDITORMANAGER_H
 
8
 
 
9
#include <wx/list.h>
 
10
#include <wx/treectrl.h>
 
11
#include <wx/hashmap.h>
 
12
 
 
13
#include "settings.h"
 
14
#include "manager.h"
 
15
#include "cbexception.h" // cbThrow
 
16
 
 
17
#include "printing_types.h"
 
18
 
 
19
#ifndef CB_PRECOMP
 
20
    #include "globals.h" // cbC2U
 
21
#endif
 
22
 
 
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;
 
31
 
 
32
// forward decls
 
33
class SEditorBase;
 
34
class cbAuiNotebook;
 
35
class wxAuiNotebookEvent;
 
36
class wxMenuBar;
 
37
class SEditorColourSet;
 
38
class cbProject;
 
39
class ProjectFile;
 
40
class ScbEditor;
 
41
class cbStyledTextCtrl;
 
42
class ListCtrlLogger;
 
43
class LoaderBase;
 
44
struct EditorManagerInternalData;
 
45
 
 
46
WX_DECLARE_STRING_HASH_MAP(wxString, SAutoCompleteMap);
 
47
 
 
48
// forward decl
 
49
struct cbFindReplaceData;
 
50
 
 
51
/*
 
52
 * No description
 
53
 */
 
54
//class DLLIMPORT EditorManager : public Mgr<EditorManager>, public wxEvtHandler
 
55
class SEditorManager : public wxEvtHandler
 
56
{
 
57
        friend class ThreadSearchFrame;
 
58
        friend class CodeSnippetsConfig;
 
59
 
 
60
        static bool s_CanShutdown;
 
61
    public:
 
62
        //friend class SnippetsSearchFrame; // give Manager access to our private members
 
63
        static bool CanShutdown(){ return s_CanShutdown; }
 
64
 
 
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* !!!")); }
 
67
 
 
68
        cbAuiNotebook* GetNotebook(){ return m_pNotebook; }
 
69
        void CreateMenu(wxMenuBar* menuBar);
 
70
        void ReleaseMenu(wxMenuBar* menuBar);
 
71
        void Configure();
 
72
        int GetEditorsCount();
 
73
        SAutoCompleteMap& GetAutoCompleteMap(){ return m_AutoCompleteMap; }
 
74
 
 
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);
 
83
 
 
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()); }
 
90
 
 
91
        void ActivateNext();
 
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);
 
97
 
 
98
        // these are used *only* for custom editors
 
99
        void AddCustomEditor(SEditorBase* eb);
 
100
        void RemoveCustomEditor(SEditorBase* eb);
 
101
 
 
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);
 
110
 
 
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);
 
119
        bool SaveActive();
 
120
        bool SaveAs(int index);
 
121
        bool SaveActiveAs();
 
122
        bool SaveAll();
 
123
        int ShowFindDialog(bool replace,  bool explicitly_find_in_files = false);
 
124
        int FindNext(bool goingDown, cbStyledTextCtrl* control = 0, cbFindReplaceData* data = 0);
 
125
 
 
126
        void Print(PrintScope ps, PrintColourMode pcm, bool line_numbers);
 
127
 
 
128
        /** Hides the editor notebook for layout purposes */
 
129
        void HideNotebook();
 
130
        /** Shows the previously hidden editor notebook */
 
131
        void ShowNotebook();
 
132
        /** Check if one of the open files has been modified outside the IDE. If so, ask to reload it. */
 
133
        void CheckForExternallyModifiedFiles();
 
134
 
 
135
        int GetManagerID();
 
136
        void FilePrint(wxWindow* parent); //ported from main.cpp
 
137
        int GetLongestLinePixelWidth( int top_line = -1, int bottom_line = -1); //(pecan 2007/4/04)
 
138
 
 
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);
 
159
        int GetZoom()const;
 
160
 
 
161
    protected:
 
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);
 
167
 
 
168
        void CreateSearchLog();
 
169
        void LogSearch(const wxString& file, int line, const wxString& lineText);
 
170
 
 
171
        void LoadAutoComplete();
 
172
        void SaveAutoComplete();
 
173
 
 
174
        SAutoCompleteMap m_AutoCompleteMap;
 
175
    public:
 
176
        SEditorManager(wxWindow* parent);
 
177
        ~SEditorManager();
 
178
    private:
 
179
        SEditorManager();
 
180
        void InitSEditorManager(wxWindow* parent);
 
181
 
 
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);
 
188
 
 
189
        cbAuiNotebook* m_pNotebook;
 
190
        cbFindReplaceData* m_LastFindReplaceData;
 
191
        SEditorColourSet* m_Theme;
 
192
        ListCtrlLogger* m_pSearchLog;
 
193
        int m_SearchLogIndex;
 
194
        int m_SashPosition;
 
195
        int m_zoom;
 
196
        bool m_isCheckingForExternallyModifiedFiles;
 
197
        friend struct EditorManagerInternalData;
 
198
        EditorManagerInternalData* m_pData;
 
199
 
 
200
        wxWindow* m_pParent;
 
201
 
 
202
        DECLARE_EVENT_TABLE()
 
203
};
 
204
 
 
205
#endif // SEDITORMANAGER_H
 
206
 
 
207