core/vgui/vgui_event_server.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_event_server.h
00002 #ifndef vgui_event_server_h_
00003 #define vgui_event_server_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  Procedural event grabbing from a tableau
00010 // \author Philip C. Pritchett, Robotics Research Group, University of Oxford
00011 // \date   11 Sep 99
00012 //
00013 //  Contains class  vgui_event_server
00014 //
00015 // \verbatim
00016 //  Modifications
00017 //   11-SEP-1999 P.Pritchett - Initial version.
00018 //   26-APR-2002 K.Y.McGaul - Converted to and added doxygen style comments.
00019 // \endverbatim
00020 
00021 #include <vgui/vgui_event.h>
00022 #include <vgui/vgui_menu.h>
00023 #include <vgui/vgui_tableau.h>
00024 #include <vgui/vgui_tableau_sptr.h>
00025 class vgui_event_server_interpose_tableau;
00026 
00027 //: Procedural event grabbing from a tableau
00028 //
00029 //  vgui_event_server allows you to grab events intended for a tableau in a
00030 //  procedural way, (i.e. in a "for" loop), in order to temporarily take control
00031 //  of a tableau's event stream.  This is useful for modal operations such as
00032 //  picking (- or maybe not, see below).
00033 //
00034 //  WARNING: This class is not as useful as it first appears!!
00035 //   If we look at events outside the handle function of a tableau (e.g. by
00036 //   using a vgui_event_server) then the gl state associated with those events
00037 //   will have changed.  This means for a draw_overlay event we would end up
00038 //   drawing into the wrong buffer. For a mouse event we may not be able to get
00039 //   the position in the image using the projection_inspector (if e.g. the image
00040 //   was zoomed) since all the gl matrices would have been reset.  I guess
00041 //   you could use it to get key presses! - kym
00042 class vgui_event_server
00043 {
00044  public:
00045   //: Constructor - collects events from the given tableau.
00046   vgui_event_server(vgui_tableau_sptr const&);
00047 
00048   void reset();
00049 
00050   //: Move on to the next event in the event queue.
00051   bool next();
00052 
00053   void set_popup(const vgui_menu&);
00054 
00055   //: Returns the last event.
00056   vgui_event last_event() { return last_event_; }
00057 
00058  protected:
00059  ~vgui_event_server();
00060 
00061  private:
00062   friend class vgui_event_server_interpose_tableau;
00063   vgui_event_server_interpose_tableau* grabber_;
00064   vgui_tableau_sptr grabber_reference_;
00065   vgui_event last_event_;
00066   bool use_event_;
00067   vgui_menu menu;
00068 };
00069 
00070 #endif // vgui_event_server_h_