dialog.h

Go to the documentation of this file.
00001 /*
00002  Copyright (C) 2001-2006, William Joseph.
00003  All Rights Reserved.
00004 
00005  This file is part of GtkRadiant.
00006 
00007  GtkRadiant is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by
00009  the Free Software Foundation; either version 2 of the License, or
00010  (at your option) any later version.
00011 
00012  GtkRadiant is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU General Public License for more details.
00016 
00017  You should have received a copy of the GNU General Public License
00018  along with GtkRadiant; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #if !defined(INCLUDED_GTKUTIL_DIALOG_H)
00023 #define INCLUDED_GTKUTIL_DIALOG_H
00024 
00025 #include "generic/callback.h"
00026 #include "generic/arrayrange.h"
00027 #include "iradiant.h"
00028 #include <gtk/gtkenums.h>
00029 #include <string>
00030 
00031 typedef int gint;
00032 typedef gint gboolean;
00033 typedef struct _GdkEventAny GdkEventAny;
00034 typedef struct _GtkWidget GtkWidget;
00035 typedef struct _GtkHBox GtkHBox;
00036 typedef struct _GtkVBox GtkVBox;
00037 typedef struct _GtkRadioButton GtkRadioButton;
00038 typedef struct _GtkFrame GtkFrame;
00039 typedef struct _GtkEntry GtkEntry;
00040 typedef struct _GtkButton GtkButton;
00041 typedef struct _GtkLabel GtkLabel;
00042 typedef struct _GtkTable GtkTable;
00043 
00044 struct ModalDialog
00045 {
00046         ModalDialog () :
00047             loop(true), ret(eIDCANCEL)
00048         {
00049         }
00050         bool loop;
00051         EMessageBoxReturn ret;
00052 };
00053 
00054 struct ModalDialogButton
00055 {
00056         ModalDialogButton (ModalDialog& dialog, EMessageBoxReturn value) :
00057             m_dialog(dialog), m_value(value)
00058         {
00059         }
00060         ModalDialog& m_dialog;
00061         EMessageBoxReturn m_value;
00062 };
00063 
00064 typedef void (*GCallback) (void);
00065 typedef void* gpointer;
00066 typedef struct _GtkWindow GtkWindow;
00067 typedef struct _GtkTable GtkTable;
00068 typedef struct _GtkButton GtkButton;
00069 typedef struct _GtkVBox GtkVBox;
00070 typedef struct _GtkHBox GtkHBox;
00071 typedef struct _GtkFrame GtkFrame;
00072 
00073 GtkWindow* create_fixedsize_modal_window (GtkWindow* parent, const std::string& title, int width, int height);
00074 
00075 GtkWindow* create_dialog_window (GtkWindow* parent, const std::string& title, GCallback func, gpointer data, int default_w =
00076         -1, int default_h = -1);
00077 GtkTable* create_dialog_table (unsigned int rows, unsigned int columns, unsigned int row_spacing,
00078         unsigned int col_spacing, int border = 0);
00079 GtkButton* create_dialog_button (const std::string& label, GCallback func, gpointer data);
00080 GtkVBox* create_dialog_vbox (int spacing, int border = 0);
00081 GtkHBox* create_dialog_hbox (int spacing, int border = 0);
00082 GtkFrame* create_dialog_frame (const std::string& frameHeadline, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN);
00083 
00084 GtkButton* create_modal_dialog_button (const std::string& label, ModalDialogButton& button);
00085 GtkWindow* create_modal_dialog_window (GtkWindow* parent, const std::string& title, ModalDialog& dialog, int default_w = -1,
00086         int default_h = -1);
00087 GtkWindow* create_fixedsize_modal_dialog_window (GtkWindow* parent, const std::string& title, ModalDialog& dialog, int width =
00088         -1, int height = -1);
00089 EMessageBoxReturn modal_dialog_show (GtkWindow* window, ModalDialog& dialog);
00090 
00091 gboolean dialog_button_ok (GtkWidget *widget, ModalDialog* data);
00092 gboolean dialog_button_cancel (GtkWidget *widget, ModalDialog* data);
00093 gboolean dialog_button_yes (GtkWidget *widget, ModalDialog* data);
00094 gboolean dialog_button_no (GtkWidget *widget, ModalDialog* data);
00095 gboolean dialog_delete_callback (GtkWidget *widget, GdkEventAny* event, ModalDialog* data);
00096 
00097 GtkWindow* create_simple_modal_dialog_window (const std::string& title, ModalDialog& dialog, GtkWidget* contents);
00098 
00099 class RadioHBox
00100 {
00101     public:
00102         GtkHBox* m_hbox;
00103         GtkRadioButton* m_radio;
00104         RadioHBox (GtkHBox* hbox, GtkRadioButton* radio) :
00105             m_hbox(hbox), m_radio(radio)
00106         {
00107         }
00108 };
00109 
00110 RadioHBox RadioHBox_new (StringArrayRange names);
00111 
00112 class PathEntry
00113 {
00114     public:
00115         GtkFrame* m_frame;
00116         GtkEntry* m_entry;
00117         GtkButton* m_button;
00118         PathEntry (GtkFrame* frame, GtkEntry* entry, GtkButton* button) :
00119             m_frame(frame), m_entry(entry), m_button(button)
00120         {
00121         }
00122 };
00123 
00124 PathEntry PathEntry_new ();
00125 
00126 class BrowsedPathEntry
00127 {
00128     public:
00129         typedef Callback1<std::string> SetPathCallback;
00130         typedef Callback1<const SetPathCallback&> BrowseCallback;
00131 
00132         PathEntry m_entry;
00133         BrowseCallback m_browse;
00134 
00135         BrowsedPathEntry (const BrowseCallback& browse);
00136 };
00137 
00138 GtkLabel* DialogLabel_new (const std::string& name);
00139 GtkTable* DialogRow_new (const std::string& name, GtkWidget* widget);
00140 typedef struct _GtkVBox GtkVBox;
00141 void DialogVBox_packRow (GtkVBox* vbox, GtkWidget* row);
00142 
00143 namespace gtkutil
00144 {
00145     // Display a modal error dialog
00146     void errorDialog (GtkWindow*, const std::string&);
00147     // Display a modal info dialog
00148     void infoDialog (GtkWindow*, const std::string&);
00149     // Display a modal error dialog and quit immediately
00150     void fatalErrorDialog (GtkWindow* window, const std::string& errorText);
00151 }
00152 
00153 #endif

Generated by  doxygen 1.6.2