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
14
# include <wx/msw/wrapwin.h> // Needed to prevent Yield define bug.
18
#include <wx/cmdline.h>
20
#include "sdk_events.h"
21
#include "cbfunctor.h"
32
class PersonalityManager;
36
class UserVariableManager;
37
class ScriptingManager;
42
class DLLIMPORT Manager
44
void OnMenu(wxCommandEvent& event);
45
wxFrame* m_pAppWindow;
46
static bool appShuttingDown;
47
static bool blockYields;
49
static wxCmdLineParser m_CmdLineParser;
55
static void SetBatchBuild(bool is_batch);
56
static bool IsBatchBuild(){ return isBatch; }
57
/// Blocks/unblocks Manager::Yield(). Be carefull when using it. Actually, do *not* use it ;)
58
static void BlockYields(bool block);
59
/// Whenever you need to call wxYield(), call Manager::Yield(). It's safer.
61
static void ProcessPendingEvents();
62
static void Shutdown();
64
bool ProcessEvent(CodeBlocksEvent& event);
65
bool ProcessEvent(CodeBlocksDockEvent& event);
66
bool ProcessEvent(CodeBlocksLayoutEvent& event);
67
bool ProcessEvent(CodeBlocksLogEvent& event);
70
/** Use Manager::Get() to get a pointer to its instance
71
* Manager::Get() is guaranteed to never return an invalid pointer.
73
static Manager* Get();
74
/** Never, EVER, call this function! It is the last function called on shutdown.... */
77
wxFrame* GetAppFrame() const;
78
wxWindow* GetAppWindow() const;
80
static bool IsAppShuttingDown();
81
static bool isappShuttingDown(){return Manager::IsAppShuttingDown();};
83
/** Functions returning pointers to the respective sub-manager instances.
84
* During application startup as well as during runtime, these functions will always return a valid pointer.
85
* During application shutdown, these functions will continue to return a valid pointer until the requested manager shuts down.
86
* From that point, the below functions will return null. If there is any chance that your code might execute
87
* during application shutdown, you MUST check for a null pointer.
88
* The one notable exception to this rule is ConfigManager, which has the same lifetime as Manager itself.
90
* The order of destruction is:
91
* ----------------------------
92
* ToolsManager, TemplateManager, PluginManager,
93
* ScriptingManager, ProjectManager, EditorManager,
94
* PersonalityManager, MacrosManager, UserVariableManager,
96
* The ConfigManager is destroyed immediately before the applicaton terminates, so it can be
97
* considered being omnipresent.
99
* For plugin developers, this means that most managers (except for the ones you probably don't use anyway)
100
* will be available throughout the entire lifetime of your plugins.
103
ProjectManager* GetProjectManager() const;
104
EditorManager* GetEditorManager() const;
105
LogManager* GetLogManager() const;
106
PluginManager* GetPluginManager() const;
107
ToolsManager* GetToolsManager() const;
108
MacrosManager* GetMacrosManager() const;
109
PersonalityManager* GetPersonalityManager() const;
110
UserVariableManager* GetUserVariableManager() const;
111
ScriptingManager* GetScriptingManager() const;
112
ConfigManager* GetConfigManager(const wxString& name_space) const;
113
FileManager* GetFileManager() const;
117
/////// XML Resource functions ///////
118
/// Inits XML Resource system
119
static void Initxrc(bool force=false);
120
/// Loads XRC file(s) using data_path
121
static void Loadxrc(wxString relpath);
122
static bool LoadResource(const wxString& file);
124
/// Loads Menubar from XRC
125
static wxMenuBar* LoadMenuBar(wxString resid,bool createonfailure=false);
126
/// Loads Menu from XRC
127
static wxMenu* LoadMenu(wxString menu_id,bool createonfailure=false);
128
/// Loads ToolBar from XRC
129
static wxToolBar *LoadToolBar(wxFrame *parent,wxString resid,bool defaultsmall=true);
130
/// Loads ToolBarAddOn from XRC into existing Toolbar
132
// Do not use this, use Get()
133
static Manager* Get(wxFrame* appWindow);
135
static void AddonToolBar(wxToolBar* toolBar,wxString resid);
136
static bool isToolBar16x16(wxToolBar* toolBar);
138
static wxCmdLineParser* GetCmdLineParser();
141
void RegisterEventSink(wxEventType eventType, IEventFunctorBase<CodeBlocksEvent>* functor);
142
void RegisterEventSink(wxEventType eventType, IEventFunctorBase<CodeBlocksDockEvent>* functor);
143
void RegisterEventSink(wxEventType eventType, IEventFunctorBase<CodeBlocksLayoutEvent>* functor);
144
void RegisterEventSink(wxEventType eventType, IEventFunctorBase<CodeBlocksLogEvent>* functor);
145
void RemoveAllEventSinksFor(void* owner);
149
typedef std::vector< IEventFunctorBase<CodeBlocksEvent>* > EventSinksArray;
150
typedef std::map< wxEventType, EventSinksArray > EventSinksMap;
151
typedef std::vector< IEventFunctorBase<CodeBlocksDockEvent>* > DockEventSinksArray;
152
typedef std::map< wxEventType, DockEventSinksArray > DockEventSinksMap;
153
typedef std::vector< IEventFunctorBase<CodeBlocksLayoutEvent>* > LayoutEventSinksArray;
154
typedef std::map< wxEventType, LayoutEventSinksArray > LayoutEventSinksMap;
155
typedef std::vector< IEventFunctorBase<CodeBlocksLogEvent>* > LogEventSinksArray;
156
typedef std::map< wxEventType, LogEventSinksArray > LogEventSinksMap;
158
EventSinksMap m_EventSinks;
159
DockEventSinksMap m_DockEventSinks;
160
LayoutEventSinksMap m_LayoutEventSinks;
161
LogEventSinksMap m_LogEventSinks;
164
template <class MgrT> class Mgr
166
static MgrT *instance;
167
static bool isShutdown;
168
explicit Mgr(const Mgr<MgrT>&){};
169
Mgr<MgrT>& operator=(Mgr<MgrT> const&){};
173
Mgr(){assert(Mgr<MgrT>::instance == 0);}
174
virtual ~Mgr(){Mgr<MgrT>::instance = 0;}
178
static inline bool Valid(){return instance;}
180
static inline MgrT* Get()
182
if(instance == 0 && isShutdown == false)
183
instance = new MgrT();