]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/gtkutil/dialog.h
b5f235c2aa07efb7888b1cdfdd7dd4d0b9124dfd
[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 #include <gtk/gtk.h>
29
30 typedef int gint;
31 typedef gint gboolean;
32 typedef struct _GdkEventAny GdkEventAny;
33
34
35 struct ModalDialog
36 {
37         ModalDialog()
38                 : loop( true ), ret( eIDCANCEL ){
39         }
40         bool loop;
41         EMessageBoxReturn ret;
42 };
43
44 struct ModalDialogButton
45 {
46         ModalDialogButton( ModalDialog& dialog, EMessageBoxReturn value )
47                 : m_dialog( dialog ), m_value( value ){
48         }
49         ModalDialog& m_dialog;
50         EMessageBoxReturn m_value;
51 };
52
53 typedef void ( *GCallback )( void );
54 typedef void* gpointer;
55
56 ui::Window create_fixedsize_modal_window( ui::Window parent, const char* title, int width, int height );
57
58 ui::Window create_dialog_window( ui::Window parent, const char* title, GCallback func, gpointer data, int default_w = -1, int default_h = -1 );
59 ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 );
60 ui::Button create_dialog_button( const char* label, GCallback func, gpointer data );
61 ui::VBox create_dialog_vbox( int spacing, int border = 0 );
62 ui::HBox create_dialog_hbox( int spacing, int border = 0 );
63 ui::Frame create_dialog_frame( const char* label, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN );
64
65 ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button );
66 ui::Window create_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int default_w = -1, int default_h = -1 );
67 ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width = -1, int height = -1 );
68 EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog );
69
70
71 gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data );
72 gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data );
73 gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data );
74 gboolean dialog_button_no( ui::Widget widget, ModalDialog* data );
75 gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data );
76
77 ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents );
78
79 class RadioHBox
80 {
81 public:
82 ui::HBox m_hbox;
83 ui::RadioButton m_radio;
84 RadioHBox( ui::HBox hbox, ui::RadioButton radio ) :
85         m_hbox( hbox ),
86         m_radio( radio ){
87 }
88 };
89
90 RadioHBox RadioHBox_new( StringArrayRange names );
91
92
93 class PathEntry
94 {
95 public:
96 ui::Frame m_frame;
97 ui::Entry m_entry;
98 ui::Button m_button;
99 PathEntry( ui::Frame frame, ui::Entry entry, ui::Button button ) :
100         m_frame( frame ),
101         m_entry( entry ),
102         m_button( button ){
103 }
104 };
105
106 PathEntry PathEntry_new();
107
108 class BrowsedPathEntry
109 {
110 public:
111 typedef Callback1<const char*> SetPathCallback;
112 typedef Callback1<const SetPathCallback&> BrowseCallback;
113
114 PathEntry m_entry;
115 BrowseCallback m_browse;
116
117 BrowsedPathEntry( const BrowseCallback& browse );
118 };
119
120 ui::Label DialogLabel_new( const char* name );
121 ui::Table DialogRow_new( const char* name, ui::Widget widget );
122 void DialogVBox_packRow( ui::VBox vbox, ui::Widget row );
123
124
125 #endif