]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/modules/lseditor/wxsdefs.h
small makefile.vc fixes.
[wxWidgets.git] / utils / wxPython / modules / lseditor / wxsdefs.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: No names yet.
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
5 // Modified by:
6 // Created: 24/04/1999
7 // RCS-ID: $Id$
8 // Copyright: (c) Aleskandars Gluchovas
9 // Licence: GNU General Public License
10 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __WXSDEFS_G__
12 #define __WXSDEFS_G__
13
14 #include <config.h>
15
16
17 #include "controlarea.h"
18
19 #ifdef wxUSE_TEMPLATE_STL
20 #include <vector>
21 #include <map>
22 //using std::map;
23 //using std::vector;
24 using namespace std;
25 #else
26 #include "wxstldefs.h" // imports predefine StrListT, IntListT containers
27 #include "wxstlac.h"
28 #endif
29 class wxsProject;
30 class wxsComponent;
31 class wxsWorkplace;
32 class wxsOpenedFileInfo;
33 class wxsWorkplaceListener;
34 class wxsSourceEditorPlugin;
35 class wxsSourceInfoPlugin;
36 class wxsAppListener;
37 class wxsAppInterface;
38
39 class wxFrame;
40
41 typedef wxsWorkplaceListener* wxsWorkplaceListenerPtrT;
42
43 #ifdef wxUSE_TEMPLATE_STL
44 typedef vector<wxsWorkplaceListenerPtrT> wxsWorkplaceListenerListT;
45 #else
46 typedef WXSTL_VECTOR_SHALLOW_COPY( wxsWorkplaceListenerPtrT ) wxsWorkplaceListenerListT;
47 #endif
48
49 // IDs for the controls and the menu commands
50 enum
51 {
52 // menu items
53 WXS_Quit = 3300, // FIXEM:: ids..
54 WXS_About,
55 WXS_Open,
56 WXS_Close,
57 WXS_OpenWorkplace,
58 WXS_Save,
59 WXS_SaveAs,
60 WXS_SaveAll,
61 WXS_CloseWorkplace,
62 WXS_SaveWorkplace,
63 WXS_NewProject,
64
65 WXS_ShowTips,
66
67 WXS_Undo = 9000,
68 WXS_NextWindow,
69 WXS_PreviousWindow,
70 WXS_CloseWindow,
71 WXS_ListWindows,
72 WXS_UpdateBrowser,
73 WXS_ToggleWorkplaceWindow,
74
75 WXS_InsertFiles,
76 WXS_Test,
77 WXS_Settings,
78
79 WXS_ClassView,
80 WXS_FileView,
81 WXS_GotoEditor,
82
83 WXS_Test1,
84 WXS_Test2,
85
86 // controls start here (the numbers are, of course, arbitrary)
87 WXS_Text = 1000,
88
89 ID_EDIT_UNDO,
90 ID_EDIT_REDO,
91 ID_EDIT_CUT,
92 ID_EDIT_COPY,
93 ID_EDIT_PASTE,
94 ID_EDIT_DELETE,
95 ID_EDIT_SELECT_ALL,
96 ID_EDIT_FIND,
97 ID_EDIT_FIND_NEXT,
98 ID_EDIT_REPLACE,
99 ID_EDIT_GOTO,
100 ID_EDIT_TOGGLE_BM,
101 ID_EDIT_NEXT_BM,
102 ID_EDIT_PREV_BM,
103 ID_EDIT_TOGGLE_BRKPNT,
104 ID_EDIT_BOOKMARKS,
105 ID_EDIT_SETFONT,
106 ID_LEFT_SASH,
107 ID_BOTTOM_SASH
108 };
109
110 // bitmaps/icons
111 enum WXS_ICON_ENUM{
112 WXS_ICON_class = 1,
113 WXS_ICON_priv_mtd,
114 WXS_ICON_prot_mtd,
115 WXS_ICON_pub_mtd,
116 WXS_ICON_priv_mtd_def,
117 WXS_ICON_prot_mtd_def,
118 WXS_ICON_pub_mtd_def,
119 WXS_ICON_priv_var,
120 WXS_ICON_prot_var,
121 WXS_ICON_pub_var,
122 WXS_ICON_pub_pure_mtd,
123 WXS_ICON_file,
124 WXS_ICON_folder,
125 WXS_ICON_mru_folder,
126 WXS_ICON_class_gray,
127 WXS_ICON_file_gray,
128 };
129
130
131 typedef char* CharPtrT;
132
133 struct UU_cmp
134 {
135 inline int operator()(const CharPtrT x, const CharPtrT y ) const { return 0; }
136 };
137
138 typedef wxBitmap* wxBitmapPtrT;
139 #ifdef wxUSE_TEMPLATE_STL
140 typedef map<WXS_ICON_ENUM, wxBitmapPtrT> WXS_BitmapsMapT;
141 #else
142 typedef WXSTL_MAP( WXS_ICON_ENUM, wxBitmapPtrT,
143 LESS_THEN_FUNCTOR(WXS_ICON_ENUM) ) WXS_BitmapsMapT;
144 #endif
145
146 extern WXS_BitmapsMapT WXS_Bitmaps;
147 #define WXS_ICON(name) (*WXS_Bitmaps[WXS_ICON_##name])
148
149
150 // very general file categories
151
152 enum WXS_FILE_CATEGORY
153 {
154 WXS_UNKNOWN_FILE,
155 WXS_SOURCE_FILE,
156 WXS_RESOURCE_FILE,
157 WXS_DOCUMENTATION_FILE,
158 WXS_CONFIGURAITON_FILE
159 };
160
161 enum WXS_PLUGIN_TYPE
162 {
163 WXS_UNKNOWN_PLUGIN,
164 WXS_EDITOR_PLUGIN,
165 WXS_CLASSINFO_PLUGIN,
166 WXS_CLASSBROWSER_PLUGIN,
167 WXS_FILEBROWSER_PLUGIN,
168 WXS_TOOL_PLUGIN,
169 WXS_OUTPUTTOOL_PLUGIN
170 };
171
172
173
174 class wxsAppListener
175 {
176 public:
177 virtual void OnWindowSwitched( wxWindow* fromWnd, wxWindow* toWnd ) {};
178 virtual bool OnCloseWindow( wxWindow* wnd ) { return TRUE; }
179 virtual void OnTabSwitched() {};
180 virtual void OnPageSwitched() {};
181 };
182
183 class wxsAppInterface
184 {
185 public:
186 virtual void SetAppListener(wxsAppListener* pLsn) = 0;
187
188 virtual void AddEditor(wxsSourceEditorPlugin* editor,wxString title,wxBitmap* pImage = NULL) = 0;
189 virtual void ActivateEditor( wxsSourceEditorPlugin* editor ) = 0;
190 virtual void CloseEditor( wxsSourceEditorPlugin* editor ) = 0;
191
192 virtual void ShowNextWindow() = 0;
193 virtual void ShowPreviousWindow() = 0;
194 virtual void CloseActiveWindow() = 0;
195 virtual void CloseWindow( wxWindow* wnd ) = 0;
196 virtual void ShowWindowList() = 0;
197 virtual wxWindow* GetActiveWindow() = 0;
198 virtual wxTabbedWindow* GetTabbedWindow() = 0;
199 virtual void AddTab(wxsComponent* pContent, wxString tabText, wxBitmap* pImage = NULL) = 0;
200 virtual void ShowNextTab() = 0;
201 virtual wxPaggedWindow* GetPaggedWindow() = 0;
202 virtual void AddPage(wxsComponent* pContent, wxString tabText, wxBitmap* pImage = NULL) = 0;
203 virtual void ShowNextPage() = 0;
204 virtual wxFrame* GetMainFrame() = 0;
205 virtual void SetStatusText( const string& text ) = 0;
206
207 static wxsAppInterface& GetInstance();
208
209 protected:
210 static wxsAppInterface* mpInstance;
211 friend wxsAppInterface& wxsGetApp();
212 };
213
214 // short-cut for wxsAppInterface::GetInstance()
215
216 wxsAppInterface& wxsGetApp();
217
218 class wxsWorkplaceListener : public wxObject
219 {
220 public:
221 virtual void OnSubprojectAdded( wxsProject& subPrj, wxsProject& toPrj ) {}
222 virtual void OnSubprojectRemoved( wxsProject& subPrj, wxsProject& fromPrj ) {}
223 virtual void OnProjectCreated( wxsProject& prj ) {}
224 virtual void OnRootProjectLoaded() {}
225 virtual void OnRootProjectClosed() {}
226 virtual void OnFilesAddedToProject( wxsProject& prj, StrListT& files, WXS_FILE_CATEGORY cat ) {}
227 virtual void OnFilesRemovedFromProject( wxsProject& prj, StrListT& files, WXS_FILE_CATEGORY cat ) {}
228
229 virtual void OnFileContentChanged( wxsProject& prj, const string& file, WXS_FILE_CATEGORY cat,
230 char* newContent, size_t len ) {}
231
232 virtual void OnFileOpened( wxsOpenedFileInfo& file ) {}
233 };
234
235 typedef wxsProject* wxsProjectPtrT;
236 #ifdef wxUSE_TEMPLATE_STL
237 typedef vector<wxsProjectPtrT> wxsProjectListT;
238 #else
239 typedef WXSTL_VECTOR_SHALLOW_COPY( wxsProjectPtrT ) wxsProjectListT;
240 #endif
241
242 class wxsProject : public wxObject
243 {
244 public:
245 // Basic project info
246 virtual void SetName(const string& name) = 0;
247 virtual void SetFileName(const string& fname) = 0;
248 virtual void SetDescription(const string& desc) = 0;
249 virtual void SetLanguage(const string& lang) = 0;
250 virtual string GetName() = 0;
251 virtual string GetFileName() = 0;
252 virtual string GetDescription() = 0;
253 virtual string GetLanguage() = 0;
254 // File manipulation
255 virtual bool AddFile( const string& file) = 0;
256 virtual bool RemoveFile ( const string& file ) = 0;
257 virtual StrListT GetFiles() = 0;
258 // Sub-Project manipulation
259 virtual void AddSubproject( wxsProject* subPrj) = 0;
260 virtual void RemoveSubproject( wxsProject* subPrj) = 0;
261 virtual wxsProjectListT& GetSubprojects() = 0;
262 // Transient information (parent only exists when loaded
263 virtual void SetParent( wxsProject* parentPrj) = 0;
264 virtual wxsProject* GetParent() = 0;
265 // configuration info storage
266 virtual string CreateConfig ( const string& file = "" ) = 0;
267 virtual bool SetCurrentConfig ( const string& configkey ) = 0;
268 virtual bool AddConfigValue( const string& key, string& value) = 0;
269 virtual bool SetConfigValue( const string& key, string& value) = 0;
270 virtual bool RemoveConfigValue( const string& key ) = 0;
271 virtual string GetConfigValue ( const string& key ) = 0;
272
273
274 };
275
276 class wxsOpenedFileInfo : public wxObject
277 {
278 public:
279 string mFullName;
280 wxsProject* mpProject; // NULL, if file does not belong to any project
281 wxsSourceEditorPlugin* mpEditor;
282 WXS_FILE_CATEGORY mCategory;
283 bool mIsSaved;
284
285 public:
286 wxsOpenedFileInfo() : mIsSaved( TRUE ), mpProject( NULL ) {}
287
288 wxsProject* GetProject() { return mpProject; }
289 const string& GetFullName() { return mFullName; }
290 wxsSourceEditorPlugin& GetEditor() { return *mpEditor; }
291 WXS_FILE_CATEGORY GetCategory() { return mCategory; }
292 };
293
294 typedef wxsOpenedFileInfo* wxsOpenedFileInfoPtrT;
295 #ifdef wxUSE_TEMPLATE_STL
296 typedef vector<wxsOpenedFileInfoPtrT> wxsOpenedFileInfoListT;
297 #else
298 typedef WXSTL_VECTOR_SHALLOW_COPY( wxsOpenedFileInfoPtrT ) wxsOpenedFileInfoListT;
299 #endif
300
301 // abstract interface
302
303 class wxsWorkplace : public wxObject
304 {
305 public:
306 virtual void CreateProject( const string& name, const string& projectFile, const wxsProject* parent=NULL) = 0;
307
308 virtual void LoadRootProject( const string& projectFile ) = 0;
309 virtual void SaveProject( wxsProject& prj ) = 0;
310 virtual void CloseRootProject() = 0;
311
312 virtual wxsProject& GetRootProject() = 0;
313 virtual wxsProject* FindProjectByName( const string& name ) = 0;
314 virtual wxsOpenedFileInfo* FindFileByEditor( wxsSourceEditorPlugin& editor ) = 0;
315
316 virtual void AddWorkpalceListener( wxsWorkplaceListener* pListener ) = 0;
317
318 virtual void AddSubproject( wxsProject& intoPrj,const string& projectFile ) = 0;
319 virtual void RemoveSubproject( wxsProject& prj ) = 0;
320
321 virtual void AddFilesToProject( wxsProject& prj, StrListT& files ) = 0;
322 virtual void RemoveFilesFromProject( wxsProject& prj, StrListT& files ) = 0;
323
324 virtual void NotifyFileContentChanged( wxsProject& prj, const string& file,
325 char* newContent, size_t len ) = 0;
326
327 virtual void NotifyFileContentChanged( wxsOpenedFileInfo& info ) = 0;
328 virtual void NotifyEditorDeactivated( wxsSourceEditorPlugin& editor ) = 0;
329
330 // if pPrj is NULL, the specified file does not belong to any projects,
331 // i.e. it blongs to the workplace
332
333 virtual wxsOpenedFileInfo*
334 OpenFileInEditor( const string& file, wxsProject* pPrj = NULL,
335 int line = -1, int column = -1) = 0;
336
337 virtual void GetCurrentFileContent( wxsProject& prj, const string& file,
338 char** buf, size_t& len
339 ) = 0;
340
341 // returns FALSE, if source was already up-to-date
342 virtual bool SyncSourceInfo() = 0;
343
344 virtual wxsProject* FindSubproject( wxsProject& parentPrj, const string& prjName ) = 0;
345 virtual wxsOpenedFileInfo* FindOpenedFile( const string& name ) = 0;
346 virtual bool FileIsOpened( wxsProject& prj, const string& file ) = 0;
347 virtual wxsSourceEditorPlugin* GetSourceEditor( wxsProject& prj, const string& file ) = 0;
348 virtual wxsSourceInfoPlugin* GetSourceInfoPlugin() = 0;
349
350 static wxsWorkplace& GetInstance() { return *wxsWorkplace::mpInstance; }
351
352 virtual wxsOpenedFileInfoListT& GetOpenedFiles() = 0;
353 virtual wxsOpenedFileInfo* GetActiveFile() = 0;
354
355 virtual void SaveFile( wxsOpenedFileInfo& info ) = 0;
356 virtual void SaveAllFiles() = 0;
357
358 virtual bool CloseFile( wxsOpenedFileInfo& info, bool closeWindow = TRUE ) = 0;
359 virtual bool CloseAllFiles() = 0;
360
361 virtual bool CloseInProgress() = 0;
362
363 virtual WXS_FILE_CATEGORY GetFileCategory( const string& file ) = 0;
364
365 protected:
366 static wxsWorkplace* mpInstance;
367 friend wxsWorkplace& wxsGetWorkplace();
368 };
369
370 // short-cut for wxsWorkplace::GetInstance()
371
372 wxsWorkplace& wxsGetWorkplace();
373
374 #endif