2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
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.
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.
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
22 #if !defined(INCLUDED_DIALOG_H)
23 #define INCLUDED_DIALOG_H
27 #include "gtkutil/dialog.h"
28 #include "generic/callback.h"
29 #include "string/string.h"
31 template<typename Environment, typename FirstArgument, void(*func)(Environment&, FirstArgument)>
32 class ReferenceCaller1;
34 inline void BoolImport(bool& self, bool value)
38 typedef ReferenceCaller1<bool, bool, BoolImport> BoolImportCaller;
40 inline void BoolExport(bool& self, const BoolImportCallback& importCallback)
44 typedef ReferenceCaller1<bool, const BoolImportCallback&, BoolExport> BoolExportCaller;
47 inline void IntImport(int& self, int value)
51 typedef ReferenceCaller1<int, int, IntImport> IntImportCaller;
53 inline void IntExport(int& self, const IntImportCallback& importCallback)
57 typedef ReferenceCaller1<int, const IntImportCallback&, IntExport> IntExportCaller;
60 inline void SizeImport(std::size_t& self, std::size_t value)
64 typedef ReferenceCaller1<std::size_t, std::size_t, SizeImport> SizeImportCaller;
66 inline void SizeExport(std::size_t& self, const SizeImportCallback& importCallback)
70 typedef ReferenceCaller1<std::size_t, const SizeImportCallback&, SizeExport> SizeExportCaller;
73 inline void FloatImport(float& self, float value)
77 typedef ReferenceCaller1<float, float, FloatImport> FloatImportCaller;
79 inline void FloatExport(float& self, const FloatImportCallback& importCallback)
83 typedef ReferenceCaller1<float, const FloatImportCallback&, FloatExport> FloatExportCaller;
86 inline void StringImport(CopiedString& self, const char* value)
90 typedef ReferenceCaller1<CopiedString, const char*, StringImport> StringImportCaller;
91 inline void StringExport(CopiedString& self, const StringImportCallback& importCallback)
93 importCallback(self.c_str());
95 typedef ReferenceCaller1<CopiedString, const StringImportCallback&, StringExport> StringExportCaller;
100 virtual void release() = 0;
101 virtual void importData() const = 0;
102 virtual void exportData() const = 0;
105 typedef struct _GtkWindow GtkWindow;
106 typedef struct _GtkToggleButton GtkToggleButton;
107 typedef struct _GtkRadioButton GtkRadioButton;
108 typedef struct _GtkSpinButton GtkSpinButton;
109 typedef struct _GtkComboBox GtkComboBox;
110 typedef struct _GtkEntry GtkEntry;
111 typedef struct _GtkAdjustment GtkAdjustment;
113 template<typename FirstArgument>
114 class CallbackDialogData;
116 typedef std::list<DLG_DATA*> DialogDataList;
121 DialogDataList m_data;
130 start modal dialog box
131 you need to use AddModalButton to select eIDOK eIDCANCEL buttons
133 EMessageBoxReturn DoModal();
134 void EndModal (EMessageBoxReturn code);
135 virtual GtkWindow* BuildDialog() = 0;
136 virtual void exportData();
137 virtual void importData();
138 virtual void PreModal() { };
139 virtual void PostModal (EMessageBoxReturn code) { };
140 virtual void ShowDlg();
141 virtual void HideDlg();
144 GtkWindow* GetWidget()
148 const GtkWindow* GetWidget() const
153 GtkWidget* addCheckBox(GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback);
154 GtkWidget* addCheckBox(GtkWidget* vbox, const char* name, const char* flag, bool& data);
155 void addCombo(GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
156 void addCombo(GtkWidget* vbox, const char* name, int& data, StringArrayRange values);
157 void addSlider(GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment);
158 void addRadio(GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
159 void addRadio(GtkWidget* vbox, const char* name, int& data, StringArrayRange names);
160 void addRadioIcons(GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
161 void addRadioIcons(GtkWidget* vbox, const char* name, int& data, StringArrayRange icons);
162 GtkWidget* addIntEntry(GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
163 GtkWidget* addEntry(GtkWidget* vbox, const char* name, int& data)
165 return addIntEntry(vbox, name, IntImportCaller(data), IntExportCaller(data));
167 GtkWidget* addSizeEntry(GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback);
168 GtkWidget* addEntry(GtkWidget* vbox, const char* name, std::size_t& data)
170 return addSizeEntry(vbox, name, SizeImportCaller(data), SizeExportCaller(data));
172 GtkWidget* addFloatEntry(GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
173 GtkWidget* addEntry(GtkWidget* vbox, const char* name, float& data)
175 return addFloatEntry(vbox, name, FloatImportCaller(data), FloatExportCaller(data));
177 GtkWidget* addPathEntry(GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback);
178 GtkWidget* addPathEntry(GtkWidget* vbox, const char* name, CopiedString& data, bool directory);
179 GtkWidget* addSpinner(GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper);
180 GtkWidget* addSpinner(GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
181 GtkWidget* addSpinner(GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
185 void AddBoolToggleData(GtkToggleButton& object, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback);
186 void AddIntRadioData(GtkRadioButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
187 void AddTextEntryData(GtkEntry& object, const StringImportCallback& importCallback, const StringExportCallback& exportCallback);
188 void AddIntEntryData(GtkEntry& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
189 void AddSizeEntryData(GtkEntry& object, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback);
190 void AddFloatEntryData(GtkEntry& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
191 void AddFloatSpinnerData(GtkSpinButton& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
192 void AddIntSpinnerData(GtkSpinButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
193 void AddIntAdjustmentData(GtkAdjustment& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
194 void AddIntComboData(GtkComboBox& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
196 void AddDialogData(GtkToggleButton& object, bool& data);
197 void AddDialogData(GtkRadioButton& object, int& data);
198 void AddDialogData(GtkEntry& object, CopiedString& data);
199 void AddDialogData(GtkEntry& object, int& data);
200 void AddDialogData(GtkEntry& object, std::size_t& data);
201 void AddDialogData(GtkEntry& object, float& data);
202 void AddDialogData(GtkSpinButton& object, float& data);
203 void AddDialogData(GtkSpinButton& object, int& data);
204 void AddDialogData(GtkAdjustment& object, int& data);
205 void AddDialogData(GtkComboBox& object, int& data);