00001
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
00009
00010
00011
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
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
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();
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
00055
00056 bool do_idle();
00057
00058
00059 void post_idle_request();
00060
00061
00062 vgui_window* get_window() const;
00063
00064
00065 GtkWidget *get_glarea_widget() { return widget; }
00066
00067 private:
00068
00069 static gint handle(GtkWidget *, GdkEvent *, gpointer);
00070
00071
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
00077 bool redraw_requested;
00078 bool destroy_requested;
00079
00080
00081 bool idle_request_posted_;
00082
00083
00084 GtkWidget *widget;
00085
00086
00087 vgui_gtk2_window* win_;
00088
00089
00090 vgui_overlay_helper *ovl_helper;
00091
00092
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
00103 vcl_map<int, internal_timer> timers_;
00104
00105
00106
00107 static vgui_menu last_popup;
00108
00109
00110 int last_mouse_x, last_mouse_y;
00111 };
00112
00113 #endif // vgui_gtk2_adaptor_h_