22 #if GTK_MAJOR_VERSION>2 // if using GTK3 or more recent, then don't use GdkPixmaps, use cairo surfaces 23 #undef PIXMAP_ORIG_VER 26 #ifndef PIXMAP_ORIG_VER 27 #include <cairo/cairo.h> 34 #ifdef PIXMAP_ORIG_VER 49 #if GTK_MAJOR_VERSION==2 50 int width=widget->allocation.width, height=widget->allocation.height;
52 GtkAllocation widgetAlloc;
53 gtk_widget_get_allocation(widget, &widgetAlloc);
54 int width=widgetAlloc.width, height=widgetAlloc.height;
58 #ifdef PIXMAP_ORIG_VER 60 da->setPixmap(gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, -1));
61 gdk_draw_rectangle(da->getPixmap(), widget->style->black_gc, TRUE, 0, 0, width, height);
64 da->
setSurface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height));
67 cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
68 cairo_set_source_surface(cr, da->
getSurface(), 0., 0.);
92 #ifdef PIXMAP_ORIG_VER 93 gdk_draw_drawable(gtk_widget_get_window(widget), widget->style->fg_gc[gtk_widget_get_state (widget)], da->getPixmap(),
event->area.x,
event->area.y,
event->area.x,
event->area.y,
94 event->area.width,
event->area.height);
96 cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
97 cairo_set_source_surface (cr, da->
getSurface(), 0, 0);
111 #ifdef PIXMAP_ORIG_VER 113 void destroyPixmap(
void){
115 g_object_unref(pixmap);
124 cairo_surface_destroy(surface);
134 void init(
int width,
int height){
135 #ifdef PIXMAP_ORIG_VER 140 widget=gtk_drawing_area_new ();
154 g_signal_connect(G_OBJECT(
widget),
"damage-event", callback,
this);
175 #ifdef PIXMAP_ORIG_VER 187 #ifdef PIXMAP_ORIG_VER 191 GdkPixmap *getPixmap(
void){
return pixmap;}
196 void setPixmap(GdkPixmap *pixmap_){
219 cairo_set_source_rgb(cr, 0., 0., 0.);
virtual gboolean configureEvent(GdkEventConfigure *event)
GtkWidget * getWidget(void)
cairo_surface_t * surface
The backing surface for the drawing area.
static gboolean exposeEventStatic(GtkWidget *widget, GdkEventExpose *event, gpointer data)
void connectDamagedCallback(GCallback callback, void *data)
static gboolean configureEventStatic(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
void destroySurface(void)
cairo_surface_t * getSurface(void)
void setSurface(cairo_surface_t *surface_)
void init(int width, int height)
virtual bool exposeEvent()
Surface(int width, int height)