]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/qerplugin.h
Purge GTK forward declarations
[xonotic/netradiant.git] / include / qerplugin.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 // QERadiant PlugIns
23 //
24 //
25
26 #ifndef __QERPLUGIN_H__
27 #define __QERPLUGIN_H__
28
29 #include "uilib/uilib.h"
30 #include "generic/constant.h"
31
32
33 // ========================================
34 // GTK+ helper functions
35
36 // NOTE: parent can be 0 in all functions but it's best to set them
37
38 // this API does not depend on gtk+ or glib
39
40 enum EMessageBoxType
41 {
42         eMB_OK,
43         eMB_OKCANCEL,
44         eMB_YESNO,
45         eMB_YESNOCANCEL,
46         eMB_NOYES,
47 };
48
49 enum EMessageBoxIcon
50 {
51         eMB_ICONDEFAULT,
52         eMB_ICONERROR,
53         eMB_ICONWARNING,
54         eMB_ICONQUESTION,
55         eMB_ICONASTERISK,
56 };
57
58 enum EMessageBoxReturn
59 {
60         eIDOK,
61         eIDCANCEL,
62         eIDYES,
63         eIDNO,
64 };
65
66 // simple Message Box, see above for the 'type' flags
67
68 typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Widget parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ );
69
70 // file and directory selection functions return null if the user hits cancel
71 // - 'title' is the dialog title (can be null)
72 // - 'path' is used to set the initial directory (can be null)
73 // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples
74 typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Widget parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ );
75
76 // returns a gchar* string that must be g_free'd by the user
77 typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Widget parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ );
78
79 // return true if the user closed the dialog with 'Ok'
80 // 'color' is used to set the initial value and store the selected value
81 template<typename Element> class BasicVector3;
82 typedef BasicVector3<float> Vector3;
83 typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Widget parent, Vector3& color,
84                                                                                   const char* title /* = "Choose Color"*/ );
85
86 // load a .bmp file and create a GtkImage widget from it
87 // NOTE: 'filename' is relative to <radiant_path>/plugins/bitmaps/
88 typedef ui::Image ( *PFN_QERAPP_NEWIMAGE )( const char* filename );
89
90 // ========================================
91
92 namespace scene
93 {
94 class Node;
95 }
96
97 class ModuleObserver;
98
99 #include "signal/signalfwd.h"
100 #include "windowobserver.h"
101 #include "generic/vector.h"
102
103 typedef SignalHandler3<const WindowVector&, ButtonIdentifier, ModifierFlags> MouseEventHandler;
104 typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
105
106 enum VIEWTYPE
107 {
108         YZ = 0,
109         XZ = 1,
110         XY = 2
111 };
112
113 // the radiant core API
114 struct _QERFuncTable_1
115 {
116         INTEGER_CONSTANT( Version, 1 );
117         STRING_CONSTANT( Name, "radiant" );
118
119         const char* ( *getEnginePath )( );
120         const char* ( *getLocalRcPath )( );
121         const char* ( *getGameToolsPath )( );
122         const char* ( *getAppPath )( );
123         const char* ( *getSettingsPath )( );
124         const char* ( *getMapsPath )( );
125
126         const char* ( *getGameFile )( );
127         const char* ( *getGameName )( );
128         const char* ( *getGameMode )( );
129
130         const char* ( *getMapName )( );
131         scene::Node& ( *getMapWorldEntity )( );
132         float ( *getGridSize )();
133
134         const char* ( *getGameDescriptionKeyValue )(const char* key);
135         const char* ( *getRequiredGameDescriptionKeyValue )(const char* key);
136
137         SignalHandlerId ( *XYWindowDestroyed_connect )( const SignalHandler& handler );
138         void ( *XYWindowDestroyed_disconnect )( SignalHandlerId id );
139         MouseEventHandlerId ( *XYWindowMouseDown_connect )( const MouseEventHandler& handler );
140         void ( *XYWindowMouseDown_disconnect )( MouseEventHandlerId id );
141         VIEWTYPE ( *XYWindow_getViewType )();
142         Vector3 ( *XYWindow_windowToWorld )( const WindowVector& position );
143         const char* ( *TextureBrowser_getSelectedShader )( );
144
145         // GTK+ functions
146         PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
147         PFN_QERAPP_FILEDIALOG m_pfnFileDialog;
148         PFN_QERAPP_DIRDIALOG m_pfnDirDialog;
149         PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
150         PFN_QERAPP_NEWIMAGE m_pfnNewImage;
151
152 };
153
154 #include "modulesystem.h"
155
156 template<typename Type>
157 class GlobalModule;
158 typedef GlobalModule<_QERFuncTable_1> GlobalRadiantModule;
159
160 template<typename Type>
161 class GlobalModuleRef;
162 typedef GlobalModuleRef<_QERFuncTable_1> GlobalRadiantModuleRef;
163
164 inline _QERFuncTable_1& GlobalRadiant(){
165         return GlobalRadiantModule::getTable();
166 }
167
168 #endif