core/vgui/vgui_dialog.h

Go to the documentation of this file.
00001 // This is core/vgui/vgui_dialog.h
00002 #ifndef vgui_dialog_h_
00003 #define vgui_dialog_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Philip C. Pritchett, Robotics Research Group, University of Oxford
00010 // \date   23 Oct 1999
00011 // \brief  Abstract dialog class.
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //   23-OCT-1999 P.Pritchet - Initial version.
00016 //   25-JAN-2000 K.Y.McGaul - Added message() to allow text messages in dialogs.
00017 //   27-JAN-2000 K.Y.McGaul - Added set_modal() to allow non-modal dialogs.
00018 //   24-FEB-2000 K.Y.McGaul - Added file browser and color chooser.
00019 //   11-JUL-2000 Marko Bacic - Added inline file browser
00020 //   12-JUL-2000 Marko Bacic - Added inline color chooser
00021 //   26-APR-2002 K.Y.McGaul - Converted to doxygen style comments.
00022 // \endverbatim
00023 
00024 #include <vcl_string.h>
00025 #include <vcl_vector.h>
00026 #include <vgui/vgui_tableau.h>
00027 class vgui_dialog_impl;
00028 
00029 //: Abstract dialog class
00030 //
00031 // vgui_dialog allows the user to build a dialog from a collection of fields.
00032 // A field in this context consists of a vcl_string label and a variable.
00033 // The dialog is then posted using the ask() method. If ask returns true then
00034 // any changes to the fields in the dialog are used to update the variables.
00035 // Each vgui_dialog contains an instance of a concrete subclass of
00036 // vgui_dialog_impl. The type of the subclass will be determined by the GUI
00037 // being used.
00038 //
00039 // \par Example
00040 // \code
00041 //   vgui_dialog params("My params");
00042 //   params.field("Table number", the_table);
00043 //   params.choice("Dressing", "French", "Thousand Island", the_dressing);
00044 //   params.checkbox("Mayo?", has_mayo);
00045 //   params.message("No smoking is allowed in the restaurant!");
00046 //   if (!params.ask())
00047 //     return; // cancelled
00048 //   send_order(the_table, the_dressing, has_mayo);
00049 // \endcode
00050 
00051 class vgui_dialog
00052 {
00053  public:
00054 
00055   //: Constructor - takes the title of the dialog box.
00056   vgui_dialog(const char* name);
00057  virtual ~vgui_dialog();
00058 
00059   void checkbox(const char*, bool&);
00060 
00061   void field(const char*, int&);
00062   void field(const char* c, unsigned int& v) { field(c,*reinterpret_cast<int*>(&v)); }
00063   void field(const char*, long&);
00064   void field(const char*, float&);
00065   void field(const char*, double&);
00066   void field(const char*, vcl_string&);
00067 
00068   //: Multiple choice - with two options.
00069   void choice(const char* label, const char* option1,
00070               const char* option2, int& chosen);
00071 
00072   //: Multiple choice - with three options.
00073   void choice(const char* label, const char* option1,
00074               const char* option2, const char* option3, int& chosen);
00075 
00076   //: Multiple choice - with the list of options given.
00077   void choice(const char*, const vcl_vector<vcl_string>&, int &);
00078 
00079   void choice(const char*s, const vcl_vector<vcl_string>&v, unsigned &r)
00080   { choice(s,v,*reinterpret_cast<int*>(&r)); }
00081 
00082   //: File browsers
00083   void file (const char* label, vcl_string& regexp, vcl_string& filepath);
00084 
00085   //: inline file browser
00086   void inline_file(const char* label, vcl_string& regexp,vcl_string& filepath);
00087 
00088   //: Color chooser
00089   void color (const char* label, vcl_string&);
00090 
00091   //: Inline color chooser
00092   void inline_color(const char *label, vcl_string &);
00093 
00094   //: Text message
00095   void message(const char*);
00096 
00097   //: Display a tableau in the dialog
00098   void inline_tableau(const vgui_tableau_sptr tab, unsigned width,
00099                       unsigned height);
00100 
00101   //: Set the labels on each button, if 0 that button does not appear.
00102   void set_cancel_button(const char* label);
00103 
00104   //: Set the labels on each button, if 0 that button does not appear.
00105   void set_ok_button(const char* label);
00106 
00107   //: A "modal" dialog captures all events sent to the application.
00108   void set_modal(const bool);
00109 
00110   //: Display the dialog box and wait for the users response.
00111   //  Returns true if the user clicks on the 'OK' button and false if the
00112   //  user clicks on the 'Cancel' button.
00113   bool ask();
00114 
00115  protected:
00116   vgui_dialog() {}
00117   vgui_dialog_impl* impl;
00118 };
00119 
00120 #endif // vgui_dialog_h_

Generated on Mon Nov 23 05:11:58 2009 for core/vgui by  doxygen 1.5.1