40 likes | 183 Views
Handling Area in The Drawingarea. Sung-Ju Kang Department of Physics Kangwon National University. We will handle the area in the drawingarea widget. The area is determined by GDK event. and we can handle the area. We use the dialog box for the area handling. Select The Area.
E N D
Handling Area in The Drawingarea. Sung-Ju Kang Department of Physics Kangwon National University We will handle the area in the drawingarea widget. The area is determined by GDK event. and we can handle the area. We use the dialog box for the area handling.
Select The Area To select the area is to find two points. We use the GDK event. GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK gboolean on_drawingarea1_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { X1 = (event->x); Y1 = (event->y); coords = g_strdup_printf("%5.3lf, %5.3lf\n",X1,Y1); gtk_label_set( GTK_LABEL(user_data), coords ); return TRUE; }
void gdk_draw_rectangle (GdkDrawable *drawable, GdkGC *gc, gint filled, gint x, gint y, gint width, gint height); Coordinate of the left top edge of the rectangle. The width of the rectangle. The height of the rectangle. Express The Area as The Rectangle Description the gdk_draw_rectangle gboolean on_drawingarea1_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer drawingarea1) { GdkGC *plot_gc plot_gc=GTK_WIDGET(drawingarea1)->style->black_gc; gdk_draw_rectangle(GTK_WIDGET(drawingarea1)->window,plot_gc,FALSE,X1,Y1,100,100); }
Toolbar Rectangle Coordinate The Result of The Area as The Rectangle