core/vgui/internals/vgui_dialog_impl.h

Go to the documentation of this file.
00001 // This is core/vgui/internals/vgui_dialog_impl.h
00002 #ifndef vgui_dialog_impl_h_
00003 #define vgui_dialog_impl_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief vgui_dialog_impl is the abstract base class for dialog implementation.
00010 // \author Philip C. Pritchett, RRG, University of Oxford
00011 // \date   25 Oct 99
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //   K.Y.McGaul  25-JAN-00    Moved field functions to this class to save repetition.
00016 //                            Added virtual ..._widget functions.
00017 //                            Added text_message function.
00018 //   K.Y.McGaul  27-JAN-00    Added modal function.
00019 //   Marko Bacic 11-JUL-00    Added support for inline file browser
00020 //   Marko Bacic 12-JUL-00    Added support for inline color chooser
00021 //   Joris S.    09-NOV-00    Fixed weird color browser things
00022 //   K.Y.McGaul  22-MAY-01    Added tableau field.
00023 // \endverbatim
00024 
00025 #include <vcl_string.h>
00026 #include <vcl_vector.h>
00027 #include <vgui/vgui_tableau.h>
00028 
00029 class vgui_dialog_field;
00030 
00031 //: vgui_dialog_impl is the abstract base class for dialog implementation.
00032 //
00033 //  It contains methods for adding fields corresponding to those in
00034 //  vgui_dialog. It also contains a vcl_vector of elements which are tuples of
00035 //  vgui_dialog_field and a variable indicating what type of field they are. The
00036 //  elements also contain void* for implementors to add any gui specific
00037 //  information/class to the element.
00038 class vgui_dialog_impl
00039 {
00040  public:
00041   //: Constructor - create an empty dialog with the given title.
00042   vgui_dialog_impl(const char* dialog_name);
00043 
00044   //: Destructor - delete this dialog box.
00045   virtual ~vgui_dialog_impl();
00046 
00047   //: Add a boolean field to the dialog box.
00048   void bool_field(const char*, bool&);
00049 
00050   //: Add an integer field to the dialog box.
00051   void int_field(const char*, int&);
00052 
00053   //: Add a long integer field to the dialog box.
00054   void long_field(const char*, long&);
00055 
00056   //: Add a float field to the dialog box.
00057   void float_field(const char*, float&);
00058 
00059   //: Add a double field to the dialog box.
00060   void double_field(const char*, double&);
00061 
00062   //: Add a vcl_string field to the dialog box.
00063   void string_field(const char*, vcl_string&);
00064 
00065   //: Add a choice (selection box) to the dialog box.
00066   void choice_field(const char*, const vcl_vector<vcl_string>&, int&);
00067 
00068   //: Add a text message to the dialog box.
00069   void text_message(const char*);
00070 
00071   //: Add a popup file browser to the dialog box.
00072   void file_browser(const char*, vcl_string&, vcl_string&);
00073 
00074   //: Add an inline file browser to the dialog box.
00075   void inline_file_browser(const char *, vcl_string&, vcl_string&);
00076 
00077   //: Add a popup colour chooser to the dialog box.
00078   void color_chooser(const char*, vcl_string&);
00079 
00080   //: Add an inline colour chooser to the dialog box.
00081   void inline_color_chooser(const char*, vcl_string&);
00082 
00083   //: Add a tableau (OpenGL area) to the dialog box.
00084   void inline_tab(const vgui_tableau_sptr tab, unsigned width, unsigned height);
00085 
00086   //: Pointer to a GUI widget for a bool field.
00087   virtual void* bool_field_widget(const char*, bool&);
00088 
00089   //: Pointer to a GUI widget for a integer field.
00090   virtual void* int_field_widget(const char*, int&);
00091 
00092   //: Pointer to a GUI widget for a long integer field.
00093   virtual void* long_field_widget(const char*, long&);
00094 
00095   //: Pointer to a GUI widget for a float field.
00096   virtual void* float_field_widget(const char*, float&);
00097 
00098   //: Pointer to a GUI widget for a double field.
00099   virtual void* double_field_widget(const char*, double&);
00100 
00101   //: Pointer to a GUI widget for a string field.
00102   virtual void* string_field_widget(const char*, vcl_string&);
00103 
00104   //: Pointer to a GUI widget for a choice field.
00105   virtual void* choice_field_widget(const char*, const vcl_vector<vcl_string>&, int&);
00106 
00107   //: Pointer to a GUI widget for a text message.
00108   virtual void* text_message_widget(const char*);
00109 
00110   //: Pointer to a GUI widget for a file browser.
00111   virtual void* file_browser_widget(const char*, vcl_string&, vcl_string&);
00112 
00113   //: Pointer to a GUI widget for an inline file browser.
00114   virtual void* inline_file_browser_widget(const char *,vcl_string&, vcl_string&);
00115 
00116   //: Pointer to a GUI widget for a colour chooser.
00117   virtual void* color_chooser_widget(const char*, vcl_string&);
00118 
00119   //: Pointer to a GUI widget for an inline colour chooser.
00120   virtual void* inline_color_chooser_widget(const char *,vcl_string&);
00121 
00122   //: Pointer to a GUI widget for a tableau (OpenGL area).
00123   virtual void* inline_tableau_widget(const vgui_tableau_sptr tab, unsigned width, unsigned height);
00124 
00125   //: Set the modality of the dialog box.
00126   //  True makes the dialog modal (i.e. the dialog 'grabs' all events) and
00127   //  this is the default.  WARNING: It is dangerous to make a dialog that
00128   //  changes data non-modal, only messages should be non-modal.
00129   virtual void modal(bool);
00130 
00131   //: Set the text on the cancel button.
00132   virtual void set_cancel_button(const char* msg) { cancel_button_text_ = msg ? msg : ""; }
00133 
00134   //: Set the text on the OK button.
00135   virtual void set_ok_button(const char* msg) { ok_button_text_ = msg?msg:""; }
00136 
00137   //: Display the dialog box and collect data from the user.
00138   virtual bool ask() = 0;
00139 
00140   //: Enum of possible element types.
00141   enum element_type {bool_elem, int_elem, long_elem, float_elem,
00142                      double_elem, string_elem, choice_elem, text_msg,
00143                      file_bsr, color_csr,inline_file_bsr,inline_color_csr,
00144                      inline_tabl, dir_bsr, line_br, unknown};
00145 
00146   //: Data associated with each field in the dialog box.
00147   //  The representation of a dialog box in vgui is simply as a list
00148   //  of these elements.
00149   struct element
00150   {
00151     //: What type of field this is (int, bool, file browser, etc)
00152     element_type type;
00153     //: A pointer to a GUI widget for this field, if one exists.
00154     //  This is null in most cases since it is easier to construct
00155     //  widgets as we need them, except perhaps for something
00156     //  complicated like a file browser or colour chooser. The GUI
00157     //  implementation is completely responsible for this pointer
00158     //  (i.e. ensuring memory deallocation when the dialog closes,
00159     //  etc.)
00160     void *widget;
00161     //: Field to collect data from the user.
00162     // The derived GUI implementation should not delete these.
00163     vgui_dialog_field *field;
00164 
00165     element() : type(unknown), widget(0), field(0) {}
00166   };
00167 
00168  protected:
00169   vcl_string name;
00170   vcl_vector<element> elements;
00171   vcl_string cancel_button_text_;
00172   vcl_string ok_button_text_;
00173 };
00174 
00175 #endif // vgui_dialog_impl_h_

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