core/vgui/vgui_active_tableau.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_active_tableau.h
00002 #ifndef vgui_active_tableau_h_
00003 #define vgui_active_tableau_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  Tableau which toggles between visible/invisible and active/inactive.
00010 // \author Philip C. Pritchett, Robotics Research Group, University of Oxford
00011 // \date   25 Jan 00
00012 //
00013 //  Contains classes  vgui_active_tableau  vgui_active_tableau_new
00014 //
00015 // \verbatim
00016 //  Modifications
00017 //   25-JAN-2000 P.Pritchett - Initial version.
00018 //   07-AUG-2002 K.Y.McGaul - Changed to and added Doxygen style comments.
00019 //   01-OCT-2002 K.Y.McGaul - Moved vgui_active_visible to vgui_active_tableau.
00020 // \endverbatim
00021 
00022 #include "vgui_active_tableau_sptr.h"
00023 #include "vgui_wrapper_tableau.h"
00024 
00025 //: Tableau which can toggle between visible/invisible and active/inactive.
00026 //
00027 //  By calling toggle_active and toggle_visible this tableau
00028 //  (or rather a tableau derived from it) can appear visible or
00029 //  invisible, and active or inactive.
00030 //
00031 //  Functions to toggle these can appear on the popup menu for the tableau.
00032 //
00033 //  When the tableau is invisible, all vgui_DRAW and vgui_DRAW_OVERLAY
00034 //  mevents are passed to the child tableau.
00035 //
00036 //  When the tableau is inactive, all events apart from draw events
00037 //  are passed directly to the child tableau.
00038 class vgui_active_tableau : public vgui_wrapper_tableau
00039 {
00040  public:
00041   //: Constructor - don't use this, use vgui_active_tableau_new.
00042   vgui_active_tableau(vgui_tableau_sptr const &, bool name_in_menu = false);
00043 
00044   //: Return the name of this tableau ('vgui_active_tableau').
00045   vcl_string type_name() const;
00046 
00047   //: Handle all events sent to this tableau.
00048   //  If visible, then use drawing events, else pass them to the child tableau.
00049   //  If active, use non-drawing events, else pass them to the child tableau.
00050   bool handle(const vgui_event&);
00051 
00052   //: Add option to the popup menu to toggle active and visible.
00053   void add_popup(vgui_menu&);
00054 
00055   //: Toggle between active (using events) and inactive (passing events on).
00056   void toggle_active();
00057 
00058   //: Toggle between visible (using drawing events) and invisible.
00059   void toggle_visible();
00060 
00061   //: Return true if the tableau is active.
00062   bool get_active() const { return active_; }
00063 
00064   //: Return true if the tableau is visible.
00065   bool get_visible() const { return visible_; }
00066 
00067   //: True makes the tableau active, false makes it inactive.
00068   void set_active(bool v) { active_ = v; }
00069 
00070   //: True makes the tableau visible, false makes it invisible.
00071   void set_visible(bool v) { visible_ = v; }
00072 
00073  protected:
00074  ~vgui_active_tableau();
00075   bool active_;
00076   bool visible_;
00077   bool name_in_menu_;
00078 };
00079 
00080 //: Create a smart-pointer to a vgui_active_tableau tableau.
00081 struct vgui_active_tableau_new : public vgui_active_tableau_sptr
00082 {
00083   typedef vgui_active_tableau_sptr base;
00084 
00085   //: Constructor - make a tableau with the given child and name.
00086   vgui_active_tableau_new(vgui_tableau_sptr const &a, bool name=false)
00087     : base(new vgui_active_tableau(a,name)) { }
00088 };
00089 
00090 #endif // vgui_active_tableau_h_