core/vgui/internals/vgui_dialog_impl.cxx

Go to the documentation of this file.
00001 // This is core/vgui/internals/vgui_dialog_impl.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author Philip C. Pritchett, RRG, University of Oxford
00008 // \date   25 Oct 99
00009 // \brief  See vgui_dialog_impl.h for a description of this file
00010 //
00011 
00012 #include "vgui_dialog_impl.h"
00013 #include <vcl_iostream.h>
00014 #include <vcl_cassert.h>
00015 #include <vgui/internals/vgui_simple_field.h>
00016 #include <vgui/internals/vgui_string_field.h>
00017 #include <vgui/internals/vgui_file_field.h>
00018 #include <vgui/vgui_tableau_sptr.h>
00019 
00020 vgui_dialog_impl::vgui_dialog_impl(const char* n)
00021   : name(n)
00022   , cancel_button_text_("Cancel")
00023   , ok_button_text_("OK")
00024 {
00025   assert(n);
00026 }
00027 
00028 
00029 vgui_dialog_impl::~vgui_dialog_impl()
00030 {
00031   for (vcl_vector<element>::iterator iter = elements.begin();
00032        iter != elements.end(); ++iter)
00033   {
00034     delete iter->field;
00035   }
00036 }
00037 
00038 //------------------------------------------------------------------------------
00039 //: Add a boolean field to the dialog box.
00040 void vgui_dialog_impl::bool_field(const char* txt, bool& val)
00041 {
00042   vgui_bool_field *field = new vgui_bool_field(txt, val);
00043 
00044   element l;
00045   l.type = bool_elem;
00046   l.widget = bool_field_widget(txt, val);
00047   l.field = field;
00048 
00049   elements.push_back(l);
00050 }
00051 
00052 //------------------------------------------------------------------------------
00053 //: Add an integer field to the dialog box.
00054 void vgui_dialog_impl::int_field(const char* txt, int& val)
00055 {
00056   vgui_int_field *field = new vgui_int_field(txt, val);
00057 
00058   element l;
00059   l.type = int_elem;
00060   l.widget = int_field_widget(txt, val);
00061   l.field = field;
00062 
00063   elements.push_back(l);
00064 }
00065 
00066 //------------------------------------------------------------------------------
00067 //: Add a long field to the dialog box.
00068 void vgui_dialog_impl::long_field(const char* txt, long& val)
00069 {
00070   vgui_long_field *field = new vgui_long_field(txt, val);
00071 
00072   element l;
00073   l.type = long_elem;
00074   l.widget = long_field_widget(txt, val);
00075   l.field = field;
00076 
00077   elements.push_back(l);
00078 }
00079 
00080 //------------------------------------------------------------------------------
00081 //: Add a float field to the dialog box.
00082 void vgui_dialog_impl::float_field(const char* txt, float& val)
00083 {
00084   vgui_float_field *field = new vgui_float_field(txt, val);
00085 
00086   element l;
00087   l.type = float_elem;
00088   l.widget = float_field_widget(txt, val);
00089   l.field = field;
00090 
00091   elements.push_back(l);
00092 }
00093 
00094 //------------------------------------------------------------------------------
00095 //: Add a double field to the dialog box.
00096 void vgui_dialog_impl::double_field(const char* txt, double& val)
00097 {
00098   vgui_double_field *field = new vgui_double_field(txt, val);
00099 
00100   element l;
00101   l.type = double_elem;
00102   l.widget = double_field_widget(txt, val);
00103   l.field = field;
00104 
00105   elements.push_back(l);
00106 }
00107 
00108 //------------------------------------------------------------------------------
00109 //: Add a vcl_string field to the dialog box.
00110 void vgui_dialog_impl::string_field(const char* txt, vcl_string& val)
00111 {
00112   vgui_string_field *field = new vgui_string_field(txt, val);
00113 
00114   element l;
00115   l.type = string_elem;
00116   l.widget = string_field_widget(txt, val);
00117   l.field = field;
00118 
00119   elements.push_back(l);
00120 }
00121 
00122 //------------------------------------------------------------------------------
00123 //: Add a choice field to the dialog box.
00124 void vgui_dialog_impl::choice_field(const char* txt,
00125                                     const vcl_vector<vcl_string>& labels, int& val)
00126 {
00127   vgui_int_field *field = new vgui_int_field(txt, val);
00128 
00129   element l;
00130   l.type = choice_elem;
00131   l.widget = choice_field_widget(txt, labels, val);
00132   l.field = field;
00133 
00134   elements.push_back(l);
00135 }
00136 
00137 void vgui_dialog_impl::file_browser(const char* txt, vcl_string& regexp, vcl_string& val)
00138 {
00139   vgui_file_field *field = new vgui_file_field(txt, regexp, val);
00140 
00141   element l;
00142   l.type = file_bsr;
00143   l.widget = file_browser_widget(txt, regexp, val);
00144   l.field = field;
00145 
00146   elements.push_back(l);
00147 }
00148 
00149 void vgui_dialog_impl::inline_file_browser(const char *txt,vcl_string & regexp,
00150                                            vcl_string& val)
00151 {
00152   vgui_file_field *field = new vgui_file_field(txt, regexp, val);
00153 
00154   element l;
00155   l.type = inline_file_bsr;
00156   l.widget = inline_file_browser_widget(txt, regexp, val);
00157   l.field = field;
00158 
00159   elements.push_back(l);
00160 }
00161 
00162 void vgui_dialog_impl::color_chooser(const char* txt, vcl_string& val)
00163 {
00164   vgui_string_field *field = new vgui_string_field(txt, val);
00165 
00166   element l;
00167   l.type = color_csr;
00168   l.widget = color_chooser_widget(txt, val);
00169   l.field = field;
00170 
00171   elements.push_back(l);
00172 }
00173 
00174 void vgui_dialog_impl::inline_color_chooser(const char* txt, vcl_string& val)
00175 {
00176   vgui_string_field *field = new vgui_string_field(txt, val);
00177 
00178   element l;
00179   l.type = inline_color_csr;
00180   l.widget = inline_color_chooser_widget(txt, val);
00181   l.field = field;
00182 
00183   elements.push_back(l);
00184 }
00185 
00186 void vgui_dialog_impl::inline_tab(const vgui_tableau_sptr tab, unsigned width,
00187                                   unsigned height)
00188 {
00189   // kym - don't use the field - store the tableau in the widget variable(?).
00190   // Since the OpenGL window in the inline tableau doesn't have any
00191   //variables, it doesn't make sense for it to have a field.
00192 
00193   element l;
00194   l.type = inline_tabl;
00195   l.widget = inline_tableau_widget(tab, width, height);
00196   l.field = 0;
00197 
00198   elements.push_back(l);
00199 }
00200 
00201 //------------------------------------------------------------------------------
00202 //: Add a text message to the dialog box.
00203 void vgui_dialog_impl::text_message(const char* txt)
00204 {
00205   int dummy_int = 0;
00206   vgui_int_field *field = new vgui_int_field(txt, dummy_int);
00207 
00208   element l;
00209   l.type = text_msg;
00210   l.widget = text_message_widget(txt);
00211   l.field = field;
00212 
00213   elements.push_back(l);
00214 }
00215 
00216 void* vgui_dialog_impl::bool_field_widget(const char*, bool&) { return 0; }
00217 void* vgui_dialog_impl::int_field_widget(const char*, int&) { return 0; }
00218 void* vgui_dialog_impl::long_field_widget(const char*, long&) { return 0; }
00219 void* vgui_dialog_impl::float_field_widget(const char*, float&) { return 0; }
00220 void* vgui_dialog_impl::double_field_widget(const char*, double&) { return 0; }
00221 void* vgui_dialog_impl::string_field_widget(const char*, vcl_string&) { return 0; }
00222 void* vgui_dialog_impl::choice_field_widget(const char*, const vcl_vector<vcl_string>&, int&) { return 0; }
00223 void* vgui_dialog_impl::text_message_widget(const char*) { return 0; }
00224 void* vgui_dialog_impl::file_browser_widget(const char*, vcl_string&, vcl_string&) { return 0; }
00225 void* vgui_dialog_impl::inline_file_browser_widget(const char*, vcl_string&, vcl_string&) { return 0; }
00226 void* vgui_dialog_impl::color_chooser_widget(const char* txt, vcl_string& val) { return string_field_widget(txt, val); }
00227 void* vgui_dialog_impl::inline_color_chooser_widget(const char* txt, vcl_string& val) { return string_field_widget(txt, val); }
00228 void* vgui_dialog_impl::inline_tableau_widget(const vgui_tableau_sptr, unsigned /*width*/, unsigned /*height*/) { return 0; }
00229 
00230 //------------------------------------------------------------------------------
00231 //: Changes the modality of the dialog.  True makes the dialog modal
00232 // (i.e. the dialog 'grabs' all events), this is the default.
00233 // False makes the dialog non-modal.
00234 void vgui_dialog_impl::modal(bool)
00235 {
00236   vcl_cerr << "No function defined to change dialog modality, by default dialogs are modal\n";
00237 }

Generated on Mon Mar 8 05:12:26 2010 for core/vgui by  doxygen 1.5.1