17 #ifndef DRAWINGAREA_H_ 18 #define DRAWINGAREA_H_ 39 if (event->button == 1 && da->
getSurface() != NULL)
40 da->
draw(widget, event->x, event->y);
41 if (event->button == 3 && da->
getSurface() != NULL)
42 da->
erase(widget, event->x, event->y);
51 GdkModifierType state;
54 gdk_window_get_pointer (event->window, &x, &y, &state);
58 state = (GdkModifierType)event->state;
61 if (state & GDK_BUTTON1_MASK && da->
getSurface() != NULL)
62 da->
draw (widget, x, y);
63 else if (state & GDK_BUTTON3_MASK && da->
getSurface() != NULL)
64 da->
erase (widget, x, y);
66 da->
move (widget, x, y);
85 gtk_widget_set_events (
widget, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
111 GdkRectangle update_rect;
113 update_rect.x = x - 5;
114 update_rect.y = y - 5;
115 update_rect.width = 10;
116 update_rect.height = 10;
117 cairo_t *cr=cairo_create(
surface);
118 cairo_set_source_rgb(cr, 1., 1., 1.);
119 cairo_rectangle(cr, update_rect.x, update_rect.y, update_rect.width, update_rect.height);
122 gtk_widget_queue_draw_area (widget, update_rect.x, update_rect.y, update_rect.width, update_rect.height);
134 GdkRectangle update_rect;
136 update_rect.x = x - 5;
137 update_rect.y = y - 5;
138 update_rect.width = 10;
139 update_rect.height = 10;
140 cairo_t *cr=cairo_create(
surface);
141 cairo_set_source_rgb(cr, 0., 0., 0.);
142 cairo_rectangle(cr, update_rect.x, update_rect.y, update_rect.width, update_rect.height);
145 gtk_widget_queue_draw_area (widget, update_rect.x, update_rect.y, update_rect.width, update_rect.height);
169 connectAfter(
"button_press_event", G_CALLBACK(callBack), data);
172 #endif // DRAWINGAREA_H_
static gint leaveEventStatic(GtkWidget *widget, GdkEventMotion *event, gpointer data)
static gint motionNotifyEvent(GtkWidget *widget, GdkEventMotion *event, gpointer data)
cairo_surface_t * surface
The backing surface for the drawing area.
virtual void draw(GtkWidget *widget, gdouble x, gdouble y)
virtual void erase(GtkWidget *widget, gdouble x, gdouble y)
void connectDrawEvent(GCallback callBack, gpointer data)
cairo_surface_t * getSurface(void)
virtual void move(GtkWidget *widget, gdouble x, gdouble y)
DrawingArea(int width, int height)
virtual void leaveEvent()
virtual ~DrawingArea(void)
static gint buttonPressEvent(GtkWidget *widget, GdkEventButton *event, gpointer data)