]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/gtkutil/dialog.h
[q3map2] Unwind script stack in case of script loading error.
[xonotic/netradiant.git] / libs / gtkutil / dialog.h
1 /*
2    Copyright (C) 2001-2006, William Joseph.
3    All Rights Reserved.
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_GTKUTIL_DIALOG_H )
23 #define INCLUDED_GTKUTIL_DIALOG_H
24
25 #include "generic/callback.h"
26 #include "generic/arrayrange.h"
27 #include "qerplugin.h"
28
29 typedef int gint;
30 typedef gint gboolean;
31 typedef struct _GdkEventAny GdkEventAny;
32
33
34 struct ModalDialog {
35     ModalDialog()
36             : loop(true), ret(eIDCANCEL)
37     {
38     }
39
40     bool loop;
41     EMessageBoxReturn ret;
42 };
43
44 struct ModalDialogButton {
45     ModalDialogButton(ModalDialog &dialog, EMessageBoxReturn value)
46             : m_dialog(dialog), m_value(value)
47     {
48     }
49
50     ModalDialog &m_dialog;
51     EMessageBoxReturn m_value;
52 };
53
54 typedef void ( *GCallback )(void);
55
56 typedef void *gpointer;
57
58 ui::Window create_fixedsize_modal_window(ui::Window parent, const char *title, int width, int height);
59
60 ui::Window create_dialog_window(ui::Window parent, const char *title, GCallback func, gpointer data, int default_w = -1,
61                                 int default_h = -1);
62
63 ui::Table
64 create_dialog_table(unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing,
65                     int border = 0);
66
67 ui::Button create_dialog_button(const char *label, GCallback func, gpointer data);
68
69 ui::VBox create_dialog_vbox(int spacing, int border = 0);
70
71 ui::HBox create_dialog_hbox(int spacing, int border = 0);
72
73 ui::Frame create_dialog_frame(const char *label, ui::Shadow shadow = ui::Shadow::ETCHED_IN);
74
75 ui::Button create_modal_dialog_button(const char *label, ModalDialogButton &button);
76
77 ui::Window create_modal_dialog_window(ui::Window parent, const char *title, ModalDialog &dialog, int default_w = -1,
78                                       int default_h = -1);
79
80 ui::Window
81 create_fixedsize_modal_dialog_window(ui::Window parent, const char *title, ModalDialog &dialog, int width = -1,
82                                      int height = -1);
83
84 EMessageBoxReturn modal_dialog_show(ui::Window window, ModalDialog &dialog);
85
86
87 gboolean dialog_button_ok(ui::Widget widget, ModalDialog *data);
88
89 gboolean dialog_button_cancel(ui::Widget widget, ModalDialog *data);
90
91 gboolean dialog_button_yes(ui::Widget widget, ModalDialog *data);
92
93 gboolean dialog_button_no(ui::Widget widget, ModalDialog *data);
94
95 gboolean dialog_delete_callback(ui::Widget widget, GdkEventAny *event, ModalDialog *data);
96
97 ui::Window create_simple_modal_dialog_window(const char *title, ModalDialog &dialog, ui::Widget contents);
98
99 class RadioHBox {
100 public:
101     ui::HBox m_hbox;
102     ui::RadioButton m_radio;
103
104     RadioHBox(ui::HBox hbox, ui::RadioButton radio) :
105             m_hbox(hbox),
106             m_radio(radio)
107     {
108     }
109 };
110
111 RadioHBox RadioHBox_new(StringArrayRange names);
112
113
114 class PathEntry {
115 public:
116     ui::Frame m_frame;
117     ui::Entry m_entry;
118     ui::Button m_button;
119
120     PathEntry(ui::Frame frame, ui::Entry entry, ui::Button button) :
121             m_frame(frame),
122             m_entry(entry),
123             m_button(button)
124     {
125     }
126 };
127
128 PathEntry PathEntry_new();
129
130 class BrowsedPathEntry {
131 public:
132     typedef Callback<void(const char *)> SetPathCallback;
133     typedef Callback<void(const SetPathCallback &)> BrowseCallback;
134
135     PathEntry m_entry;
136     BrowseCallback m_browse;
137
138     BrowsedPathEntry(const BrowseCallback &browse);
139 };
140
141 ui::Label DialogLabel_new(const char *name);
142
143 ui::Table DialogRow_new(const char *name, ui::Widget widget);
144
145 void DialogVBox_packRow(ui::Box vbox, ui::Widget row);
146
147
148 #endif