]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/gtkutil/dialog.h
b3e5017c5a9dcce1d9e726a724b6c90ed6e445c8
[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 typedef struct _GtkWidget GtkWidget;
34 typedef struct _GtkHBox GtkHBox;
35 typedef struct _GtkVBox GtkVBox;
36 typedef struct _GtkRadioButton GtkRadioButton;
37 typedef struct _GtkFrame GtkFrame;
38 typedef struct _GtkEntry GtkEntry;
39 typedef struct _GtkButton GtkButton;
40 typedef struct _GtkLabel GtkLabel;
41 typedef struct _GtkTable GtkTable;
42
43
44 struct ModalDialog
45 {
46         ModalDialog()
47                 : loop( true ), ret( eIDCANCEL ){
48         }
49         bool loop;
50         EMessageBoxReturn ret;
51 };
52
53 struct ModalDialogButton
54 {
55         ModalDialogButton( ModalDialog& dialog, EMessageBoxReturn value )
56                 : m_dialog( dialog ), m_value( value ){
57         }
58         ModalDialog& m_dialog;
59         EMessageBoxReturn m_value;
60 };
61
62 typedef void ( *GCallback )( void );
63 typedef void* gpointer;
64 typedef struct _GtkWindow GtkWindow;
65 typedef struct _GtkTable GtkTable;
66 typedef struct _GtkButton GtkButton;
67 typedef struct _GtkVBox GtkVBox;
68 typedef struct _GtkHBox GtkHBox;
69 typedef struct _GtkFrame GtkFrame;
70
71 GtkWindow* create_fixedsize_modal_window( GtkWindow* parent, const char* title, int width, int height );
72
73 GtkWindow* create_dialog_window( GtkWindow* parent, const char* title, GCallback func, gpointer data, int default_w = -1, int default_h = -1 );
74 GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 );
75 GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data );
76 GtkVBox* create_dialog_vbox( int spacing, int border = 0 );
77 GtkHBox* create_dialog_hbox( int spacing, int border = 0 );
78 GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN );
79
80 GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button );
81 GtkWindow* create_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int default_w = -1, int default_h = -1 );
82 GtkWindow* create_fixedsize_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int width = -1, int height = -1 );
83 EMessageBoxReturn modal_dialog_show( GtkWindow* window, ModalDialog& dialog );
84
85
86 gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data );
87 gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data );
88 gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data );
89 gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data );
90 gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data );
91
92 GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents );
93
94 class RadioHBox
95 {
96 public:
97 GtkHBox* m_hbox;
98 GtkRadioButton* m_radio;
99 RadioHBox( GtkHBox* hbox, GtkRadioButton* radio ) :
100         m_hbox( hbox ),
101         m_radio( radio ){
102 }
103 };
104
105 RadioHBox RadioHBox_new( StringArrayRange names );
106
107
108 class PathEntry
109 {
110 public:
111 GtkFrame* m_frame;
112 GtkEntry* m_entry;
113 GtkButton* m_button;
114 PathEntry( GtkFrame* frame, GtkEntry* entry, GtkButton* button ) :
115         m_frame( frame ),
116         m_entry( entry ),
117         m_button( button ){
118 }
119 };
120
121 PathEntry PathEntry_new();
122
123 class BrowsedPathEntry
124 {
125 public:
126 typedef Callback1<const char*> SetPathCallback;
127 typedef Callback1<const SetPathCallback&> BrowseCallback;
128
129 PathEntry m_entry;
130 BrowseCallback m_browse;
131
132 BrowsedPathEntry( const BrowseCallback& browse );
133 };
134
135 GtkLabel* DialogLabel_new( const char* name );
136 GtkTable* DialogRow_new( const char* name, GtkWidget* widget );
137 typedef struct _GtkVBox GtkVBox;
138 void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row );
139
140
141 #endif