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 "iradiant.h" 28 #include <gtk/gtkenums.h> 29 #include <string> 30 31 typedef int gint; 32 typedef gint gboolean; 33 typedef void (*GCallback) (void); 34 typedef void* gpointer; 35 typedef struct _GdkEventAny GdkEventAny; 36 typedef struct _GtkWidget GtkWidget; 37 typedef struct _GtkEntry GtkEntry; 38 typedef struct _GtkButton GtkButton; 39 typedef struct _GtkLabel GtkLabel; 40 typedef struct _GtkTable GtkTable; 41 typedef struct _GtkWindow GtkWindow; 42 typedef struct _GtkVBox GtkVBox; 43 typedef struct _GtkHBox GtkHBox; 44 typedef struct _GtkFrame GtkFrame; 45 46 struct ModalDialog 47 { ModalDialogModalDialog48 ModalDialog () : 49 loop(true), ret(eIDCANCEL) 50 { 51 } 52 bool loop; 53 EMessageBoxReturn ret; 54 }; 55 56 struct ModalDialogButton 57 { ModalDialogButtonModalDialogButton58 ModalDialogButton (ModalDialog& dialog, EMessageBoxReturn value) : 59 m_dialog(dialog), m_value(value) 60 { 61 } 62 ModalDialog& m_dialog; 63 EMessageBoxReturn m_value; 64 }; 65 66 GtkButton* create_dialog_button (const std::string& label, GCallback func, gpointer data); 67 GtkVBox* create_dialog_vbox (int spacing, int border = 0); 68 GtkHBox* create_dialog_hbox (int spacing, int border = 0); 69 GtkFrame* create_dialog_frame (const std::string& frameHeadline, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN); 70 71 GtkButton* create_modal_dialog_button (const std::string& label, ModalDialogButton& button); 72 GtkWindow* create_fixedsize_modal_dialog_window (GtkWindow* parent, const std::string& title, ModalDialog& dialog, int width = 73 -1, int height = -1); 74 EMessageBoxReturn modal_dialog_show (GtkWindow* window, ModalDialog& dialog); 75 76 gboolean dialog_button_ok (GtkWidget *widget, ModalDialog* data); 77 gboolean dialog_button_cancel (GtkWidget *widget, ModalDialog* data); 78 gboolean dialog_delete_callback (GtkWidget *widget, GdkEventAny* event, ModalDialog* data); 79 80 GtkWindow* create_simple_modal_dialog_window (const std::string& title, ModalDialog& dialog, GtkWidget* contents); 81 82 class PathEntry 83 { 84 public: 85 GtkFrame* m_frame; 86 GtkEntry* m_entry; 87 GtkButton* m_button; PathEntry(GtkFrame * frame,GtkEntry * entry,GtkButton * button)88 PathEntry (GtkFrame* frame, GtkEntry* entry, GtkButton* button) : 89 m_frame(frame), m_entry(entry), m_button(button) 90 { 91 } 92 }; 93 94 PathEntry PathEntry_new (); 95 96 GtkLabel* DialogLabel_new (const std::string& name); 97 GtkTable* DialogRow_new (const std::string& name, GtkWidget* widget); 98 typedef struct _GtkVBox GtkVBox; 99 void DialogVBox_packRow (GtkVBox* vbox, GtkWidget* row); 100 101 namespace gtkutil 102 { 103 // Display a modal error dialog 104 void errorDialog (const std::string&); 105 // Display a modal info dialog 106 void infoDialog (const std::string&); 107 // Display a modal error dialog and quit immediately 108 void fatalErrorDialog (const std::string& errorText); 109 } 110 111 #endif 112