core/vgui/impl/gtk2/vgui_gtk2_adaptor.h

Go to the documentation of this file.
00001 // This is core/vgui/impl/gtk2/vgui_gtk2_adaptor.h
00002 #ifndef vgui_gtk2_adaptor_h_
00003 #define vgui_gtk2_adaptor_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   19 Dec 99
00011 // \brief  The GTK implementation of vgui_adaptor.
00012 
00013 #include <vgui/vgui_adaptor.h>
00014 #include <vgui/internals/vgui_adaptor_mixin.h>
00015 #include <vcl_map.h>
00016 
00017 #include <gtk/gtk.h>
00018 
00019 struct vgui_overlay_helper;
00020 class vgui_gtk2_window;
00021 
00022 //: The GTK implementation of vgui_adaptor.
00023 class vgui_gtk2_adaptor : public vgui_adaptor, public vgui_adaptor_mixin
00024 {
00025  public:
00026   typedef vgui_adaptor_mixin mixin;
00027 
00028   vgui_gtk2_adaptor(vgui_gtk2_window* win = 0);
00029   ~vgui_gtk2_adaptor();
00030 
00031   // vgui_adaptor methods
00032   void swap_buffers();
00033   void make_current();
00034   void post_redraw();
00035   void post_overlay_redraw();
00036   void post_timer(float,int);
00037   void post_destroy();  // schedules destruction of parent vgui_window
00038 
00039   void kill_timer(int);
00040 
00041   unsigned get_width() const {return mixin::width;}
00042   unsigned get_height() const {return mixin::height;}
00043   void bind_popups(vgui_modifier m, vgui_button b)
00044   { mixin::popup_modifier = m; mixin::popup_button = b; }
00045   void get_popup_bindings(vgui_modifier &m, vgui_button &b) const
00046   { m = mixin::popup_modifier; b = mixin::popup_button; }
00047 
00048   void set_default_popup(vgui_menu);
00049   vgui_menu get_popup();
00050 
00051   void draw();
00052   void reshape();
00053 
00054   // Do any idle processing that needs to be done.
00055   // Return true if idle processing is not complete
00056   bool do_idle();
00057 
00058   //: Flags than a child requests idle processing
00059   void post_idle_request();
00060 
00061   // Returns NULL if the empty constructor was used
00062   vgui_window* get_window() const;
00063 
00064   // gtk stuff
00065   GtkWidget *get_glarea_widget() { return widget; }
00066 
00067  private:
00068   // main GDK-to-vgui event dispatcher
00069   static gint handle(GtkWidget *, GdkEvent *, gpointer);
00070 
00071   // idle callbacks which service pending redraw/destroy posts
00072   static gint idle_callback_for_redraw(gpointer data);
00073   static gint idle_callback_for_tableaux(gpointer data);
00074   static gint idle_callback_for_destroy(gpointer data);
00075 
00076   // Flags to prevent queuing of multiple redraw/destroy callbacks
00077   bool redraw_requested;
00078   bool destroy_requested;
00079 
00080   //: True while an idle time has been requested but not implemented.
00081   bool idle_request_posted_;
00082 
00083   // pointer to the gtkglarea widget
00084   GtkWidget *widget;
00085 
00086   // pointer to the window which contains this adaptor
00087   vgui_gtk2_window* win_;
00088 
00089   // pointer to overlay emulation data
00090   vgui_overlay_helper *ovl_helper;
00091 
00092   //: internal struct for timer
00093   struct internal_timer{
00094     gint real_id_;
00095     void* callback_ptr_;
00096     
00097     internal_timer() : real_id_(0), callback_ptr_(0) { }
00098     internal_timer(gint id, void* p) 
00099     : real_id_(id), callback_ptr_(p) { }
00100   };
00101     
00102   // map of timers currently in use
00103   vcl_map<int, internal_timer>  timers_;
00104   
00105   // This is a place to store any menu passed in,
00106   // so that it doesn't go out of scope while the popup is on screen.
00107   static vgui_menu last_popup;
00108 
00109   // last position where mouse was seen.
00110   int last_mouse_x, last_mouse_y;
00111 };
00112 
00113 #endif // vgui_gtk2_adaptor_h_

Generated on Mon Mar 8 05:12:25 2010 for core/vgui by  doxygen 1.5.1