core/vgui/impl/glut/vgui_glut_adaptor.h
Go to the documentation of this file.
00001 // This is core/vgui/impl/glut/vgui_glut_adaptor.h
00002 #ifndef vgui_glut_adaptor_h_
00003 #define vgui_glut_adaptor_h_
00004 //:
00005 // \file
00006 // \brief  The GLUT (OpenGL Utility Toolkit) implementation of vgui_adaptor.
00007 // \author fsm
00008 //
00009 // \verbatim
00010 //  Modifications
00011 //   17-Sep-2002 K.Y.McGaul - Converted to doxygen style documentation.
00012 // \endverbatim
00013 
00014 #include <vcl_vector.h>
00015 #include <vgui/vgui_adaptor.h>
00016 struct vgui_command;
00017 struct vgui_overlay_helper;
00018 struct vgui_glut_popup_impl;
00019 
00020 //: The GLUT (OpenGL Utility Toolkit) implementation of vgui_adaptor.
00021 struct vgui_glut_adaptor : vgui_adaptor
00022 {
00023   vgui_glut_adaptor( vgui_window *win_, int id_ );
00024   ~vgui_glut_adaptor();
00025 
00026   int get_id() const { return id; }
00027 
00028   // implement virtual vgui_adaptor interface :
00029   vgui_window *get_window() const { return win; }
00030   void post_redraw();
00031   void post_overlay_redraw();
00032   void post_timer(float, int);
00033   void post_destroy();
00034   void swap_buffers();
00035   void make_current();
00036   void bind_popups(vgui_modifier ,vgui_button );
00037   unsigned get_width() const;
00038   unsigned get_height() const;
00039 
00040   void get_popup_bindings(vgui_modifier &m, vgui_button &b) const
00041   { m = popup_modifier; b = popup_button; }
00042 
00043  private:
00044   int id;
00045   vgui_window *win;
00046 
00047   vgui_modifier popup_modifier;
00048   vgui_button popup_button;
00049 
00050   // Overlay state. Before any overlay specific code may run, the overlay
00051   // has to be established by calling establish_overlays(). This means
00052   // either that GLUT creates a hardware overlay plane or that emulation
00053   // overlays are used (via a vgui_overlay_helper object).
00054   bool ovl_established;              // True if overlays have been established
00055   vgui_overlay_helper *ovl_helper;   // If ovl_established, this is 0 when using
00056   void establish_overlays();         // hardware overlays.
00057 
00058   // Performs conversion of event position from window coordinates to
00059   // viewport coordinates. Then dispatches either to the overlay_helper
00060   // or to dispatch_to_tableau() on the base class.
00061   bool glut_dispatch(vgui_event &e);
00062 
00063   //
00064   void  register_static_callbacks();
00065 
00066   // super and sub
00067   vgui_glut_adaptor *super; // 0 if none.
00068   vcl_vector<vgui_glut_adaptor*> sub_contexts;
00069 
00070   // popup things
00071   friend struct vgui_glut_popup_impl;
00072   vgui_glut_popup_impl *popup;
00073   void make_popup();
00074   static void pre_menu_hook(int );
00075   //static void queue_command(vgui_command *);
00076 
00077   // dynamic callbacks :
00078   virtual void         display();
00079   virtual void overlay_display();
00080   virtual void         reshape(int width,int height);
00081   virtual void        keyboard(unsigned char,int,int);
00082   virtual void           mouse(int button,int state,int x,int y);
00083   virtual void          motion(int x,int y);
00084   virtual void  passive_motion(int x,int y);
00085   virtual void           entry(int);
00086   virtual void      visibility(int state);
00087   //virtual void            idle();
00088   virtual void           timer(int);
00089   virtual void         special(int,int,int);
00090   virtual void     keyboard_up(unsigned char,int,int);
00091   virtual void      special_up(int,int,int);
00092 
00093   //
00094   static vcl_vector<vgui_glut_adaptor*> &all();
00095   static vgui_glut_adaptor *get_adaptor(int window_id);
00096 
00097   // static callbacks :
00098   static void         display_callback();
00099   static void overlay_display_callback();
00100   static void         reshape_callback(int width,int height);
00101   static void        keyboard_callback(unsigned char,int,int);
00102   static void           mouse_callback(int button,int state,int x,int y);
00103   static void          motion_callback(int x,int y);
00104   static void  passive_motion_callback(int x,int y);
00105   static void           entry_callback(int);
00106   static void      visibility_callback(int state);
00107   //static void            idle_callback();
00108   static void           timer_callback(int);
00109   static void         special_callback(int,int,int);
00110   static void     keyboard_up_callback(unsigned char,int,int);
00111   static void      special_up_callback(int,int,int);
00112   static void      menustatus_callback(int,int,int);
00113 };
00114 
00115 #endif // vgui_glut_adaptor_h_