00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef VRS_GTK_GTK_CANVAS_H
00030 #define VRS_GTK_GTK_CANVAS_H
00031
00032 #include <vrs/gtk/config.h>
00033 #include <vrs/opengl/glcanvas.h>
00034
00035 #include <gtk/gtk.h>
00036 #include <gdk/gdkkeysyms.h>
00037
00038 #include <gtk/gtkgl.h>
00039
00040
00041 namespace VRS {
00042
00043
00044 class VRS_GTK_API GtkCanvas : public GLCanvas {
00046
00047 public:
00048
00049 GtkCanvas (void);
00050 virtual ~GtkCanvas ();
00055
00056 virtual void setSize(unsigned int width, unsigned int height);
00058
00059
00060 virtual unsigned int getWidth() const;
00062
00063
00064 virtual unsigned int getHeight() const;
00066
00067
00068 virtual int getProperties() const;
00072
00073
00074
00075 virtual void makeContextCurrent();
00076
00077
00078 GtkWidget * gtkobj() const { return drawingSurface_; }
00080
00081 VRS_TYPEINFO(GtkCanvas, GLCanvas);
00082
00083 protected:
00084
00085 void initgl();
00086 virtual void finishRedisplay();
00087
00088 gboolean button_press_event(GdkEventButton*);
00089 gboolean button_release_event(GdkEventButton*);
00090 gboolean motion_notify_event(GdkEventMotion*);
00091 gboolean key_press_event(GdkEventKey*);
00092 gboolean key_release_event(GdkEventKey*);
00093 gboolean enter_notify_event(GdkEventCrossing*);
00094 gboolean leave_notify_event(GdkEventCrossing*);
00095 void realize();
00096 gboolean expose_event(GdkEventExpose*);
00097 gboolean configure_event(GdkEventConfigure*);
00098 gboolean map_event(GdkEventAny *);
00099 gboolean umap_event(void);
00100
00101 InputEvent::Modifier convertState (guint);
00102 InputEvent::Button convertButton (guint);
00103 VRSTime convertTime (guint32);
00104
00105
00106 static gboolean buttonPressCB(GtkWidget*, GdkEventButton*, gpointer);
00107 static gboolean buttonReleaseCB(GtkWidget*, GdkEventButton*, gpointer);
00108 static gboolean motionCB(GtkWidget*, GdkEventMotion*, gpointer);
00109 static gboolean keyPressCB(GtkWidget*, GdkEventKey*, gpointer);
00110 static gboolean keyReleaseCB(GtkWidget*, GdkEventKey*, gpointer);
00111 static gboolean enterCB(GtkWidget*, GdkEventCrossing*, gpointer);
00112 static gboolean leaveCB(GtkWidget*, GdkEventCrossing*, gpointer);
00113 static void realizeCB(GtkWidget*, gpointer);
00114 static gboolean exposeCB(GtkWidget*, GdkEventExpose*, gpointer);
00115 static gboolean configureCB(GtkWidget*, GdkEventConfigure*, gpointer);
00116 static gboolean mapCB(GtkWidget*, GdkEventAny *event, gpointer);
00117 static gboolean umapCB(GtkWidget*, GdkEventAny *, gpointer);
00118
00119 private:
00120 GtkWidget *drawingSurface_;
00121 bool configured_;
00122 int lastX_, lastY_;
00123 unsigned int width_, height_;
00124 };
00125
00126 }
00127
00128 #endif // VRS_GTK_GTK_CANVAS_H