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 ){
37 typedef ReferenceCaller1<bool, bool, BoolImport> BoolImportCaller;
39 inline void BoolExport( bool& self, const BoolImportCallback& importCallback ){
40 importCallback( self );
42 typedef ReferenceCaller1<bool, const BoolImportCallback&, BoolExport> BoolExportCaller;
45 inline void IntImport( int& self, int value ){
48 typedef ReferenceCaller1<int, int, IntImport> IntImportCaller;
50 inline void IntExport( int& self, const IntImportCallback& importCallback ){
51 importCallback( self );
53 typedef ReferenceCaller1<int, const IntImportCallback&, IntExport> IntExportCaller;
56 inline void SizeImport( std::size_t& self, std::size_t value ){
59 typedef ReferenceCaller1<std::size_t, std::size_t, SizeImport> SizeImportCaller;
61 inline void SizeExport( std::size_t& self, const SizeImportCallback& importCallback ){
62 importCallback( self );
64 typedef ReferenceCaller1<std::size_t, const SizeImportCallback&, SizeExport> SizeExportCaller;
67 inline void FloatImport( float& self, float value ){
70 typedef ReferenceCaller1<float, float, FloatImport> FloatImportCaller;
72 inline void FloatExport( float& self, const FloatImportCallback& importCallback ){
73 importCallback( self );
75 typedef ReferenceCaller1<float, const FloatImportCallback&, FloatExport> FloatExportCaller;
78 inline void StringImport( CopiedString& self, const char* value ){
81 typedef ReferenceCaller1<CopiedString, const char*, StringImport> StringImportCaller;
82 inline void StringExport( CopiedString& self, const StringImportCallback& importCallback ){
83 importCallback( self.c_str() );
85 typedef ReferenceCaller1<CopiedString, const StringImportCallback&, StringExport> StringExportCaller;
90 virtual void release() = 0;
91 virtual void importData() const = 0;
92 virtual void exportData() const = 0;
95 typedef struct _GtkWindow GtkWindow;
96 typedef struct _GtkToggleButton GtkToggleButton;
97 typedef struct _GtkRadioButton GtkRadioButton;
98 typedef struct _GtkSpinButton GtkSpinButton;
99 typedef struct _GtkComboBox GtkComboBox;
100 typedef struct _GtkEntry GtkEntry;
101 typedef struct _GtkAdjustment GtkAdjustment;
103 template<typename FirstArgument>
104 class CallbackDialogData;
106 typedef std::list<DLG_DATA*> DialogDataList;
111 DialogDataList m_data;
120 start modal dialog box
121 you need to use AddModalButton to select eIDOK eIDCANCEL buttons
123 EMessageBoxReturn DoModal();
124 void EndModal( EMessageBoxReturn code );
125 virtual GtkWindow* BuildDialog() = 0;
126 virtual void exportData();
127 virtual void importData();
128 virtual void PreModal() { };
129 virtual void PostModal( EMessageBoxReturn code ) { };
130 virtual void ShowDlg();
131 virtual void HideDlg();
134 GtkWindow* GetWidget(){
137 const GtkWindow* GetWidget() const {
141 GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback );
142 GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data );
143 void addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
144 void addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values );
145 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 );
146 void addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
147 void addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names );
148 void addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
149 void addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons );
150 GtkWidget* addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
151 GtkWidget* addEntry( GtkWidget* vbox, const char* name, int& data ){
152 return addIntEntry( vbox, name, IntImportCaller( data ), IntExportCaller( data ) );
154 GtkWidget* addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback );
155 GtkWidget* addEntry( GtkWidget* vbox, const char* name, std::size_t& data ){
156 return addSizeEntry( vbox, name, SizeImportCaller( data ), SizeExportCaller( data ) );
158 GtkWidget* addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
159 GtkWidget* addEntry( GtkWidget* vbox, const char* name, float& data ){
160 return addFloatEntry( vbox, name, FloatImportCaller( data ), FloatExportCaller( data ) );
162 GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback );
163 GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, CopiedString& data, bool directory );
164 GtkWidget* addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper );
165 GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
166 GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
170 void AddBoolToggleData( GtkToggleButton& object, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback );
171 void AddIntRadioData( GtkRadioButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
172 void AddTextEntryData( GtkEntry& object, const StringImportCallback& importCallback, const StringExportCallback& exportCallback );
173 void AddIntEntryData( GtkEntry& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
174 void AddSizeEntryData( GtkEntry& object, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback );
175 void AddFloatEntryData( GtkEntry& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
176 void AddFloatSpinnerData( GtkSpinButton& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
177 void AddIntSpinnerData( GtkSpinButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
178 void AddIntAdjustmentData( GtkAdjustment& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
179 void AddIntComboData( GtkComboBox& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
181 void AddDialogData( GtkToggleButton& object, bool& data );
182 void AddDialogData( GtkRadioButton& object, int& data );
183 void AddDialogData( GtkEntry& object, CopiedString& data );
184 void AddDialogData( GtkEntry& object, int& data );
185 void AddDialogData( GtkEntry& object, std::size_t& data );
186 void AddDialogData( GtkEntry& object, float& data );
187 void AddDialogData( GtkSpinButton& object, float& data );
188 void AddDialogData( GtkSpinButton& object, int& data );
189 void AddDialogData( GtkAdjustment& object, int& data );
190 void AddDialogData( GtkComboBox& object, int& data );