]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/dialog.h
[q3map2] Unwind script stack in case of script loading error.
[xonotic/netradiant.git] / radiant / dialog.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_DIALOG_H )
23 #define INCLUDED_DIALOG_H
24
25 #include <list>
26 #include <uilib/uilib.h>
27 #include "property.h"
28
29 #include "generic/callback.h"
30 #include "gtkutil/dialog.h"
31 #include "generic/callback.h"
32 #include "string/string.h"
33
34 struct DLG_DATA {
35     virtual ~DLG_DATA() = default;
36
37     virtual void release() = 0;
38
39     virtual void importData() const = 0;
40
41     virtual void exportData() const = 0;
42 };
43
44
45 template<typename FirstArgument>
46 class CallbackDialogData;
47
48 typedef std::list<DLG_DATA *> DialogDataList;
49
50 class Dialog {
51     ui::Window m_window;
52     DialogDataList m_data;
53 public:
54     ModalDialog m_modal;
55     ui::Window m_parent;
56
57     Dialog();
58
59     virtual ~Dialog();
60
61 /*!
62    start modal dialog box
63    you need to use AddModalButton to select eIDOK eIDCANCEL buttons
64  */
65     EMessageBoxReturn DoModal();
66
67     void EndModal(EMessageBoxReturn code);
68
69     virtual ui::Window BuildDialog() = 0;
70
71     virtual void exportData();
72
73     virtual void importData();
74
75     virtual void PreModal()
76     {};
77
78     virtual void PostModal(EMessageBoxReturn code)
79     {};
80
81     virtual void ShowDlg();
82
83     virtual void HideDlg();
84
85     void Create();
86
87     void Destroy();
88
89     ui::Window GetWidget()
90     {
91         return m_window;
92     }
93
94     const ui::Window GetWidget() const
95     {
96         return m_window;
97     }
98
99     ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, Property<bool> const &cb);
100
101     ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, bool &data);
102
103     void addCombo(ui::VBox vbox, const char *name, StringArrayRange values, Property<int> const &cb);
104
105     void addCombo(ui::VBox vbox, const char *name, int &data, StringArrayRange values);
106
107     void addSlider(ui::VBox vbox, const char *name, int &data, gboolean draw_value, const char *low, const char *high,
108                    double value, double lower, double upper, double step_increment, double page_increment);
109
110     void addRadio(ui::VBox vbox, const char *name, StringArrayRange names, Property<int> const &cb);
111
112     void addRadio(ui::VBox vbox, const char *name, int &data, StringArrayRange names);
113
114     void addRadioIcons(ui::VBox vbox, const char *name, StringArrayRange icons, Property<int> const &cb);
115
116     void addRadioIcons(ui::VBox vbox, const char *name, int &data, StringArrayRange icons);
117
118     ui::Widget addIntEntry(ui::VBox vbox, const char *name, Property<int> const &cb);
119
120     ui::Widget addEntry(ui::VBox vbox, const char *name, int &data)
121     {
122         return addIntEntry(vbox, name, make_property(data));
123     }
124
125     ui::Widget addSizeEntry(ui::VBox vbox, const char *name, Property<std::size_t> const &cb);
126
127     ui::Widget addEntry(ui::VBox vbox, const char *name, std::size_t &data)
128     {
129         return addSizeEntry(vbox, name, make_property(data));
130     }
131
132     ui::Widget addFloatEntry(ui::VBox vbox, const char *name, Property<float> const &cb);
133
134     ui::Widget addEntry(ui::VBox vbox, const char *name, float &data)
135     {
136         return addFloatEntry(vbox, name, make_property(data));
137     }
138
139     ui::Widget addPathEntry(ui::VBox vbox, const char *name, bool browse_directory, Property<const char *> const &cb);
140
141     ui::Widget addPathEntry(ui::VBox vbox, const char *name, CopiedString &data, bool directory);
142
143     ui::SpinButton addSpinner(ui::VBox vbox, const char *name, int &data, double value, double lower, double upper);
144
145     ui::SpinButton
146     addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, Property<int> const &cb);
147
148     ui::SpinButton
149     addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, Property<float> const &cb);
150
151 protected:
152
153     void AddBoolToggleData(ui::ToggleButton object, Property<bool> const &cb);
154
155     void AddIntRadioData(ui::RadioButton object, Property<int> const &cb);
156
157     void AddTextEntryData(ui::Entry object, Property<const char *> const &cb);
158
159     void AddIntEntryData(ui::Entry object, Property<int> const &cb);
160
161     void AddSizeEntryData(ui::Entry object, Property<std::size_t> const &cb);
162
163     void AddFloatEntryData(ui::Entry object, Property<float> const &cb);
164
165     void AddFloatSpinnerData(ui::SpinButton object, Property<float> const &cb);
166
167     void AddIntSpinnerData(ui::SpinButton object, Property<int> const &cb);
168
169     void AddIntAdjustmentData(ui::Adjustment object, Property<int> const &cb);
170
171     void AddIntComboData(ui::ComboBox object, Property<int> const &cb);
172
173     void AddDialogData(ui::ToggleButton object, bool &data);
174
175     void AddDialogData(ui::RadioButton object, int &data);
176
177     void AddDialogData(ui::Entry object, CopiedString &data);
178
179     void AddDialogData(ui::Entry object, int &data);
180
181     void AddDialogData(ui::Entry object, std::size_t &data);
182
183     void AddDialogData(ui::Entry object, float &data);
184
185     void AddDialogData(ui::SpinButton object, float &data);
186
187     void AddDialogData(ui::SpinButton object, int &data);
188
189     void AddDialogData(ui::Adjustment object, int &data);
190
191     void AddDialogData(ui::ComboBox object, int &data);
192 };
193
194 #endif