ui/gtk/draw_cairo.c

changeset 42
9af327d0e0e4
parent 0
2483f517c562
child 44
473954dc6b74
equal deleted inserted replaced
41:7ada3db4cfa8 42:9af327d0e0e4
31 31
32 #include "container.h" 32 #include "container.h"
33 33
34 #include "draw_cairo.h" 34 #include "draw_cairo.h"
35 35
36 #ifdef UI_GTK3 36 #if UI_GTK3 || UI_GTK4
37 gboolean ui_drawingarea_expose(GtkWidget *w, cairo_t *cr, void *data) { 37 gboolean ui_drawingarea_expose(GtkWidget *w, cairo_t *cr, void *data) {
38 UiCairoGraphics g; 38 UiCairoGraphics g;
39 #ifdef UI_GTK4
40 g.g.width = gtk_widget_get_width(w);
41 g.g.height = gtk_widget_get_height(w);
42 #else
39 g.g.width = gtk_widget_get_allocated_width(w); 43 g.g.width = gtk_widget_get_allocated_width(w);
40 g.g.height = gtk_widget_get_allocated_height(w); 44 g.g.height = gtk_widget_get_allocated_height(w);
45 #endif
41 g.widget = w; 46 g.widget = w;
42 g.cr = cr; 47 g.cr = cr;
43 48
44 UiDrawEvent *event = data; 49 UiDrawEvent *event = data;
45 UiEvent ev; 50 UiEvent ev;
49 54
50 event->callback(&ev, &g.g, event->userdata); 55 event->callback(&ev, &g.g, event->userdata);
51 56
52 return FALSE; 57 return FALSE;
53 } 58 }
54 #else 59 #endif
60 #ifdef UI_GTK2
55 gboolean ui_canvas_expose(GtkWidget *w, GdkEventExpose *e, void *data) { 61 gboolean ui_canvas_expose(GtkWidget *w, GdkEventExpose *e, void *data) {
56 UiCairoGraphics g; 62 UiCairoGraphics g;
57 g.g.width = w->allocation.width; 63 g.g.width = w->allocation.width;
58 g.g.height = w->allocation.height; 64 g.g.height = w->allocation.height;
59 g.widget = w; 65 g.widget = w;
72 #endif 78 #endif
73 79
74 // function from graphics.h 80 // function from graphics.h
75 81
76 void ui_connect_draw_handler(GtkWidget *widget, UiDrawEvent *event) { 82 void ui_connect_draw_handler(GtkWidget *widget, UiDrawEvent *event) {
77 #ifdef UI_GTK3 83 #if UI_GTK3 || UI_GTK4
78 g_signal_connect(G_OBJECT(widget), 84 g_signal_connect(G_OBJECT(widget),
79 "draw", 85 "draw",
80 G_CALLBACK(ui_drawingarea_expose), 86 G_CALLBACK(ui_drawingarea_expose),
81 event); 87 event);
82 #else 88 #else

mercurial