]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/mainframe.h
Merge commit '48410b113dd2036e69dbf723a39ec9af02fc9b12'
[xonotic/netradiant.git] / radiant / mainframe.h
1 /*
2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 #if !defined(INCLUDED_MAINFRAME_H)
23 #define INCLUDED_MAINFRAME_H
24
25 #include "gtkutil/window.h"
26 #include "gtkutil/idledraw.h"
27 #include "gtkutil/widget.h"
28 #include "string/string.h"
29
30 #include "qerplugin.h"
31
32 class IPlugIn;
33 class IToolbarButton;
34
35 class XYWnd;
36 class CamWnd;
37 class ZWnd;
38
39 typedef struct _GtkWidget GtkWidget;
40 typedef struct _GtkWindow GtkWindow;
41
42 const int c_command_status = 0;
43 const int c_position_status = 1;
44 const int c_brushcount_status = 2;
45 const int c_texture_status = 3;
46 const int c_grid_status = 4;
47 const int c_count_status = 5;
48
49 class MainFrame
50 {
51 public:
52   enum EViewStyle
53   {
54     eRegular = 0,
55     eFloating = 1,
56     eSplit = 2,
57     eRegularLeft = 3,
58   };
59
60   MainFrame();
61   ~MainFrame();
62
63   GtkWindow* m_window;
64
65   CopiedString m_command_status;
66   CopiedString m_position_status;
67   CopiedString m_brushcount_status;
68   CopiedString m_texture_status;
69   CopiedString m_grid_status;
70 private:
71
72   void Create();
73   void SaveWindowInfo();
74   void Shutdown();
75
76   GtkWidget* m_vSplit;
77   GtkWidget* m_hSplit;
78   GtkWidget* m_vSplit2;
79
80   XYWnd* m_pXYWnd;
81   XYWnd* m_pYZWnd;
82   XYWnd* m_pXZWnd;
83   CamWnd* m_pCamWnd;
84   ZWnd* m_pZWnd;
85   XYWnd* m_pActiveXY;
86
87   bool m_bSleeping;
88
89   GtkWidget *m_pStatusLabel[c_count_status];
90
91
92   EViewStyle m_nCurrentStyle;
93   WindowPositionTracker m_position_tracker;
94
95   IdleDraw m_idleRedrawStatusText;
96
97 public:
98
99   bool IsSleeping()
100   {
101     return m_bSleeping;
102   }
103   void OnSleep();
104
105   void SetStatusText(CopiedString& status_text, const char* pText);
106   void UpdateStatusText();
107   void RedrawStatusText();
108   typedef MemberCaller<MainFrame, &MainFrame::RedrawStatusText> RedrawStatusTextCaller;
109
110   void SetGridStatus();
111   typedef MemberCaller<MainFrame, &MainFrame::SetGridStatus> SetGridStatusCaller;
112
113   void SetActiveXY(XYWnd* p);
114   XYWnd* ActiveXY()
115   {
116     return m_pActiveXY;
117   };
118   XYWnd* GetXYWnd()
119   {
120     return m_pXYWnd;
121   }
122   XYWnd* GetXZWnd()
123   {
124     return m_pXZWnd;
125   }
126   XYWnd* GetYZWnd()
127   {
128     return m_pYZWnd;
129   }
130   ZWnd* GetZWnd()
131   {
132     return m_pZWnd;
133   }
134   CamWnd* GetCamWnd()
135   {
136     return m_pCamWnd;
137   }
138
139   void ReleaseContexts();
140   void CreateContexts();
141
142   EViewStyle CurrentStyle()
143   {
144     return m_nCurrentStyle;
145   };
146   bool FloatingGroupDialog()
147   {
148     return CurrentStyle() == eFloating || CurrentStyle() == eSplit;
149   };
150 };
151
152 extern MainFrame* g_pParentWnd;
153
154 GtkWindow* MainFrame_getWindow();
155
156 enum EMouseButtonMode
157 {
158   ETwoButton = 0,
159   EThreeButton = 1,
160 };
161
162 struct glwindow_globals_t
163 {
164   int m_nMouseType;
165
166   glwindow_globals_t() :
167     m_nMouseType(EThreeButton)
168   {
169   }
170 };
171
172 void GLWindow_Construct();
173 void GLWindow_Destroy();
174
175 extern glwindow_globals_t g_glwindow_globals;
176 template<typename Value>
177 class LatchedValue;
178 typedef LatchedValue<bool> LatchedBool;
179 extern LatchedBool g_Layout_enableDetachableMenus;
180
181 void deleteSelection();
182
183
184 void Sys_Status(const char* status);
185
186
187 void ScreenUpdates_Disable(const char* message, const char* title);
188 void ScreenUpdates_Enable();
189 bool ScreenUpdates_Enabled();
190 void ScreenUpdates_process();
191
192 class ScopeDisableScreenUpdates
193 {
194 public:
195   ScopeDisableScreenUpdates(const char* message, const char* title)
196   {
197     ScreenUpdates_Disable(message, title);
198   }
199   ~ScopeDisableScreenUpdates()
200   {
201     ScreenUpdates_Enable();
202   }
203 };
204
205
206 void EnginePath_Realise();
207 void EnginePath_Unrealise();
208
209 class ModuleObserver;
210
211 void Radiant_attachEnginePathObserver(ModuleObserver& observer);
212 void Radiant_detachEnginePathObserver(ModuleObserver& observer);
213
214 void Radiant_attachGameToolsPathObserver(ModuleObserver& observer);
215 void Radiant_detachGameToolsPathObserver(ModuleObserver& observer);
216
217 extern CopiedString g_strEnginePath;
218 void EnginePath_verify();
219 const char* EnginePath_get();
220 const char* QERApp_GetGamePath();
221
222 extern CopiedString g_strAppPath;
223 const char* AppPath_get();
224
225 extern CopiedString g_strSettingsPath;
226 const char* SettingsPath_get();
227
228 const char* LocalRcPath_get(void);
229
230 const char* const g_pluginsDir = "plugins/"; ///< name of plugins directory, always sub-directory of toolspath
231 const char* const g_modulesDir = "modules/"; ///< name of modules directory, always sub-directory of toolspath
232
233 extern CopiedString g_strGameToolsPath;
234 const char* GameToolsPath_get();
235
236 void Radiant_Initialise();
237 void Radiant_Shutdown();
238
239 void SaveMapAs();
240
241
242 void XY_UpdateAllWindows();
243 void UpdateAllWindows();
244
245
246 void ClipperChangeNotify();
247
248 void DefaultMode();
249
250 const char* basegame_get();
251 const char* gamename_get();
252 void gamename_set(const char* gamename);
253 void Radiant_attachGameNameObserver(ModuleObserver& observer);
254 void Radiant_detachGameNameObserver(ModuleObserver& observer);
255 const char* gamemode_get();
256 void gamemode_set(const char* gamemode);
257 void Radiant_attachGameModeObserver(ModuleObserver& observer);
258 void Radiant_detachGameModeObserver(ModuleObserver& observer);
259
260
261
262 void VFS_Construct();
263 void VFS_Destroy();
264
265 void HomePaths_Construct();
266 void HomePaths_Destroy();
267 void Radiant_attachHomePathsObserver(ModuleObserver& observer);
268 void Radiant_detachHomePathsObserver(ModuleObserver& observer);
269
270
271 void MainFrame_Construct();
272 void MainFrame_Destroy();
273
274
275 extern float (*GridStatus_getGridSize)();
276 extern int (*GridStatus_getRotateIncrement)();
277 extern int (*GridStatus_getFarClipDistance)();
278 extern bool (*GridStatus_getTextureLockEnabled)();
279 void GridStatus_onTextureLockEnabledChanged();
280
281 SignalHandlerId XYWindowDestroyed_connect(const SignalHandler& handler);
282 void XYWindowDestroyed_disconnect(SignalHandlerId id);
283 MouseEventHandlerId XYWindowMouseDown_connect(const MouseEventHandler& handler);
284 void XYWindowMouseDown_disconnect(MouseEventHandlerId id);
285
286 extern GtkWidget* g_page_entity;
287
288 #endif