core/vgui/vgui_listmanager2D_tableau.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_listmanager2D_tableau.h
00002 #ifndef vgui_listmanager2D_tableau_h_
00003 #define vgui_listmanager2D_tableau_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  Tableau which manages a set of vgui_displaylist2D_tableau children
00010 // \author Philip C. Pritchett, Robotics Research Group, University of Oxford
00011 // \date   21 Oct 99
00012 //
00013 //  Contains classes vgui_listmanager2D_tableau  vgui_listmanager2D_tableau_new
00014 //
00015 // \verbatim
00016 //  Modifications
00017 //   21-OCT-1999 P.Pritchett - Initial version.
00018 //   16-SEP-2002 K.Y.McGaul - Changed to and added Doxygen style documentation.
00019 //   01-OCT-2002 K.Y.McGaul - Moved listmanager2D to listmanager2D_tableau.
00020 // \endverbatim
00021 
00022 #include <vgui/vgui_observable.h>
00023 #include <vgui/vgui_tableau.h>
00024 #include <vgui/vgui_parent_child_link.h>
00025 #include <vgui/vgui_event.h>
00026 #include <vgui/vgui_displaylist2D_tableau.h>
00027 #include <vgui/vgui_listmanager2D_tableau_sptr.h>
00028 
00029 class vgui_event;
00030 class vgui_displaylist2D_tableau;
00031 class vgui_soview2D;
00032 
00033 //: Tableau which manages a set of vgui_displaylist2D_tableau children
00034 //
00035 //  It behaves like an acetate, but is more efficient.
00036 class vgui_listmanager2D_tableau : public vgui_tableau
00037 {
00038  public:
00039   //: Constructor - don't use this, use vgui_listmanager2D_tableau_new.
00040   //  Creates an empty vgui_listmanager2D_tableau.
00041   vgui_listmanager2D_tableau();
00042 
00043   //: Destructor.
00044  ~vgui_listmanager2D_tableau();
00045 
00046   //: Returns the type of this tableau ('vgui_listmanager2D_tableau').
00047   vcl_string type_name() const;
00048 
00049   //: Add given vgui_displaylist2D_tableau to the end of the list of children.
00050   void add(vgui_displaylist2D_tableau_sptr const&);
00051 
00052   //: Remove the given vgui_displaylist2D_tableau from the list of children.
00053   void remove(vgui_displaylist2D_tableau_sptr const&);
00054 
00055   //: Observers to be notified when a child is added or removed.
00056   vgui_observable observers;
00057 
00058   //: Make child at given index position active/inactive.
00059   void set_active(int, bool);
00060 
00061   //: Make child at given index position visible/invisible.
00062   void set_visible(int, bool);
00063 
00064   //: Return true if the child at the given index is active.
00065   bool is_active(int);
00066 
00067   //: Return true if the child at the given index is visible.
00068   bool is_visible(int);
00069 
00070   //: Handle all events sent to this tableau.
00071   //  In particular, use draw events to draw the child tableaux.
00072   bool handle(const vgui_event&);
00073 
00074   //: Print info on this tableau on cerr.
00075   bool help();
00076 
00077   //: Called when a key is pressed inside the rendering area.
00078   //  Uses key presses '1' to '9' to toggle the child tableau.
00079   bool key_press(int /*x*/, int /*y*/, vgui_key key, vgui_modifier);
00080 
00081   //: Called when the mouse is pressed inside the rendering area.
00082   bool mouse_down(int x, int y, vgui_button button, vgui_modifier modifier);
00083 
00084   //: Called when the mouse is moved inside the rendering area.
00085   bool motion(int x, int y);
00086 
00087  protected:
00088 
00089   // helper
00090   bool index_ok(int);
00091 
00092   // data
00093   vcl_vector<vgui_parent_child_link> children;
00094   vcl_vector<bool> active;
00095   vcl_vector<bool> visible;
00096 
00097   vgui_displaylist2D_tableau_sptr highlight_list;
00098   vgui_soview2D *highlight_so;
00099   vgui_event saved_event_;
00100 
00101   vgui_displaylist2D_tableau_sptr contains_hit(vcl_vector<unsigned> const& names);
00102   void get_hits(float x, float y, vcl_vector<vcl_vector<unsigned> >* hits);
00103   void find_closest(float x, float y, vcl_vector<vcl_vector<unsigned> >* hits,
00104                     vgui_soview2D** closest_so,
00105                     vgui_displaylist2D_tableau_sptr * closest_display);
00106 };
00107 
00108 //: Creates a smart-pointer to a new vgui_listmanager2D_tableau.
00109 struct vgui_listmanager2D_tableau_new : public vgui_listmanager2D_tableau_sptr
00110 {
00111   //: Creates a smart-pointer to a new empty vgui_listmanager2D_tableau.
00112   vgui_listmanager2D_tableau_new() :
00113     vgui_listmanager2D_tableau_sptr(new vgui_listmanager2D_tableau) { }
00114 };
00115 
00116 #endif // vgui_listmanager2D_tableau_h_