1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleskandars Gluchovas
9 // Licence: GNU General Public License
10 /////////////////////////////////////////////////////////////////////////////
17 #include "controlarea.h"
19 #ifdef wxUSE_TEMPLATE_STL
26 #include "wxstldefs.h" // imports predefine StrListT, IntListT containers
32 class wxsOpenedFileInfo
;
33 class wxsWorkplaceListener
;
34 class wxsSourceEditorPlugin
;
35 class wxsSourceInfoPlugin
;
37 class wxsAppInterface
;
41 typedef wxsWorkplaceListener
* wxsWorkplaceListenerPtrT
;
43 #ifdef wxUSE_TEMPLATE_STL
44 typedef vector
<wxsWorkplaceListenerPtrT
> wxsWorkplaceListenerListT
;
46 typedef WXSTL_VECTOR_SHALLOW_COPY( wxsWorkplaceListenerPtrT
) wxsWorkplaceListenerListT
;
49 // IDs for the controls and the menu commands
53 WXS_Quit
= 3300, // FIXEM:: ids..
73 WXS_ToggleWorkplaceWindow
,
86 // controls start here (the numbers are, of course, arbitrary)
103 ID_EDIT_TOGGLE_BRKPNT
,
116 WXS_ICON_priv_mtd_def
,
117 WXS_ICON_prot_mtd_def
,
118 WXS_ICON_pub_mtd_def
,
122 WXS_ICON_pub_pure_mtd
,
131 typedef char* CharPtrT
;
135 inline int operator()(const CharPtrT x
, const CharPtrT y
) const { return 0; }
138 typedef wxBitmap
* wxBitmapPtrT
;
139 #ifdef wxUSE_TEMPLATE_STL
140 typedef map
<WXS_ICON_ENUM
, wxBitmapPtrT
> WXS_BitmapsMapT
;
142 typedef WXSTL_MAP( WXS_ICON_ENUM
, wxBitmapPtrT
,
143 LESS_THEN_FUNCTOR(WXS_ICON_ENUM
) ) WXS_BitmapsMapT
;
146 extern WXS_BitmapsMapT WXS_Bitmaps
;
147 #define WXS_ICON(name) (*WXS_Bitmaps[WXS_ICON_##name])
150 // very general file categories
152 enum WXS_FILE_CATEGORY
157 WXS_DOCUMENTATION_FILE
,
158 WXS_CONFIGURAITON_FILE
165 WXS_CLASSINFO_PLUGIN
,
166 WXS_CLASSBROWSER_PLUGIN
,
167 WXS_FILEBROWSER_PLUGIN
,
169 WXS_OUTPUTTOOL_PLUGIN
177 virtual void OnWindowSwitched( wxWindow
* fromWnd
, wxWindow
* toWnd
) {};
178 virtual bool OnCloseWindow( wxWindow
* wnd
) { return TRUE
; }
179 virtual void OnTabSwitched() {};
180 virtual void OnPageSwitched() {};
183 class wxsAppInterface
186 virtual void SetAppListener(wxsAppListener
* pLsn
) = 0;
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;
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;
207 static wxsAppInterface
& GetInstance();
210 static wxsAppInterface
* mpInstance
;
211 friend wxsAppInterface
& wxsGetApp();
214 // short-cut for wxsAppInterface::GetInstance()
216 wxsAppInterface
& wxsGetApp();
218 class wxsWorkplaceListener
: public wxObject
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
) {}
229 virtual void OnFileContentChanged( wxsProject
& prj
, const string
& file
, WXS_FILE_CATEGORY cat
,
230 char* newContent
, size_t len
) {}
232 virtual void OnFileOpened( wxsOpenedFileInfo
& file
) {}
235 typedef wxsProject
* wxsProjectPtrT
;
236 #ifdef wxUSE_TEMPLATE_STL
237 typedef vector
<wxsProjectPtrT
> wxsProjectListT
;
239 typedef WXSTL_VECTOR_SHALLOW_COPY( wxsProjectPtrT
) wxsProjectListT
;
242 class wxsProject
: public wxObject
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;
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;
276 class wxsOpenedFileInfo
: public wxObject
280 wxsProject
* mpProject
; // NULL, if file does not belong to any project
281 wxsSourceEditorPlugin
* mpEditor
;
282 WXS_FILE_CATEGORY mCategory
;
286 wxsOpenedFileInfo() : mIsSaved( TRUE
), mpProject( NULL
) {}
288 wxsProject
* GetProject() { return mpProject
; }
289 const string
& GetFullName() { return mFullName
; }
290 wxsSourceEditorPlugin
& GetEditor() { return *mpEditor
; }
291 WXS_FILE_CATEGORY
GetCategory() { return mCategory
; }
294 typedef wxsOpenedFileInfo
* wxsOpenedFileInfoPtrT
;
295 #ifdef wxUSE_TEMPLATE_STL
296 typedef vector
<wxsOpenedFileInfoPtrT
> wxsOpenedFileInfoListT
;
298 typedef WXSTL_VECTOR_SHALLOW_COPY( wxsOpenedFileInfoPtrT
) wxsOpenedFileInfoListT
;
301 // abstract interface
303 class wxsWorkplace
: public wxObject
306 virtual void CreateProject( const string
& name
, const string
& projectFile
, const wxsProject
* parent
=NULL
) = 0;
308 virtual void LoadRootProject( const string
& projectFile
) = 0;
309 virtual void SaveProject( wxsProject
& prj
) = 0;
310 virtual void CloseRootProject() = 0;
312 virtual wxsProject
& GetRootProject() = 0;
313 virtual wxsProject
* FindProjectByName( const string
& name
) = 0;
314 virtual wxsOpenedFileInfo
* FindFileByEditor( wxsSourceEditorPlugin
& editor
) = 0;
316 virtual void AddWorkpalceListener( wxsWorkplaceListener
* pListener
) = 0;
318 virtual void AddSubproject( wxsProject
& intoPrj
,const string
& projectFile
) = 0;
319 virtual void RemoveSubproject( wxsProject
& prj
) = 0;
321 virtual void AddFilesToProject( wxsProject
& prj
, StrListT
& files
) = 0;
322 virtual void RemoveFilesFromProject( wxsProject
& prj
, StrListT
& files
) = 0;
324 virtual void NotifyFileContentChanged( wxsProject
& prj
, const string
& file
,
325 char* newContent
, size_t len
) = 0;
327 virtual void NotifyFileContentChanged( wxsOpenedFileInfo
& info
) = 0;
328 virtual void NotifyEditorDeactivated( wxsSourceEditorPlugin
& editor
) = 0;
330 // if pPrj is NULL, the specified file does not belong to any projects,
331 // i.e. it blongs to the workplace
333 virtual wxsOpenedFileInfo
*
334 OpenFileInEditor( const string
& file
, wxsProject
* pPrj
= NULL
,
335 int line
= -1, int column
= -1) = 0;
337 virtual void GetCurrentFileContent( wxsProject
& prj
, const string
& file
,
338 char** buf
, size_t& len
341 // returns FALSE, if source was already up-to-date
342 virtual bool SyncSourceInfo() = 0;
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;
350 static wxsWorkplace
& GetInstance() { return *wxsWorkplace::mpInstance
; }
352 virtual wxsOpenedFileInfoListT
& GetOpenedFiles() = 0;
353 virtual wxsOpenedFileInfo
* GetActiveFile() = 0;
355 virtual void SaveFile( wxsOpenedFileInfo
& info
) = 0;
356 virtual void SaveAllFiles() = 0;
358 virtual bool CloseFile( wxsOpenedFileInfo
& info
, bool closeWindow
= TRUE
) = 0;
359 virtual bool CloseAllFiles() = 0;
361 virtual bool CloseInProgress() = 0;
363 virtual WXS_FILE_CATEGORY
GetFileCategory( const string
& file
) = 0;
366 static wxsWorkplace
* mpInstance
;
367 friend wxsWorkplace
& wxsGetWorkplace();
370 // short-cut for wxsWorkplace::GetInstance()
372 wxsWorkplace
& wxsGetWorkplace();