1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 a widget for custom user interface elements.
7 <!-- ##### SECTION Long_Description ##### -->
10 The #GtkDrawingArea widget is used for creating custom user interface
11 elements. It's essentially a blank widget; you can draw on
12 <literal>widget->window</literal>. After creating a drawing area,
13 the application may want to connect to:
18 Mouse and button press signals to respond to input from
19 the user. (Use gtk_widget_add_events() to enable events
25 The "realize" signal to take any necessary actions
26 when the widget is instantiated on a particular display.
27 (Create GDK resources in response to this signal.)
32 The "configure_event" signal to take any necessary actions
33 when the widget changes size.
38 The "expose_event" signal to handle redrawing the
39 contents of the widget.
45 The following code portion demonstrates using a drawing
46 area to display a circle in the normal widget foreground
48 Note that GDK automatically clears the exposed area
49 to the background color before sending the expose event, and
50 that drawing is implicitly clipped to the exposed area.
53 <title>Simple <structname>GtkDrawingArea</structname> usage.</title>
56 expose_event_callback (GdkWidget *widget, GdkEventExpose *event, gpointer data)
58 gdk_draw_arc (widget->window,
59 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
61 0, 0, widget->allocation.width, widget->allocation.height,
67 GtkWidget *drawing_area = gtk_drawing_area_new (<!>);
68 gtk_widget_set_size_request (drawing_area, 100, 100);
69 g_signal_connect (G_OBJECT (drawing_area), "expose_event",
70 G_CALLBACK (expose_event_callback), NULL);
75 Expose events are normally delivered when a drawing area first comes
76 onscreen, or when it's covered by another window and then uncovered
77 (exposed). You can also force an expose event by adding to the "damage
78 region" of the drawing area's window; gtk_widget_queue_draw_area() and
79 gdk_window_invalidate_rect() are equally good ways to do this. You'll
80 then get an expose event for the invalid region.
84 To receive mouse events on a drawing area, you will need to enable
85 them with gtk_widget_add_events(). To receive keyboard events,
86 you will need to set the #GTK_CAN_FOCUS flag on the drawing area, and
87 should probably draw some user-visible indication that the drawing
88 area is focused. See gtk_paint_focus() for one way to draw focus.
91 <!-- ##### SECTION See_Also ##### -->
96 <!-- ##### STRUCT GtkDrawingArea ##### -->
98 The #GtkDrawingArea struct contains private data only, and
99 should be accessed using the functions below.
103 <!-- ##### FUNCTION gtk_drawing_area_new ##### -->
105 Creates a new drawing area.
108 @Returns: a new #GtkDrawingArea
111 <!-- ##### FUNCTION gtk_drawing_area_size ##### -->
113 Sets the size that the drawing area will request
114 in response to a "size_request" signal. The
115 drawing area may actually be allocated a size
116 larger than this depending on how it is packed
117 within the enclosing containers.
120 @darea: a #GtkDrawingArea.
121 @width: the width to request.
122 @height: the height to request.