Package: gtk
Class gtk:drawing-area
Superclassesgtk:widget, gobject:initially-unowned, gtk:accessible, gtk:buildable, gtk:constraint-target, gobject:object, common-lisp:standard-object, common-lisp:t Documented Subclasses
None
Direct SlotsDetails The gtk:drawing-area widget is a widget that allows drawing with
Cairo.
It is essentially a blank widget. You can draw on it. ![]() Figure: GtkDrawingArea After creating a drawing area, the application may want to connect to:
The available routines for drawing are documented in the Cairo documentation. GDK offers additional API to integrate with Cairo, like the gdk:cairo-set-source-rgba or gdk:cairo-set-source-pixbuf functions. To receive mouse events on a drawing area, you will need to use event controllers. To receive keyboard events, you will need to set the can-focus property on the drawing area, and you should probably draw some user-visible indication that the drawing area is focused. If you need more complex control over your widget, you should consider creating your own GtkWidget subclass. Examples
(defun do-drawing-area (&optional application)
(let* ((area (make-instance 'gtk:drawing-area))
(window (make-instance 'gtk:window
:application application
:child area
:title "Drawing Area"
:default-width 400
:default-height 300)))
;; Set a drawing function
(gtk:drawing-area-set-draw-func area
(lambda (widget cr width height)
(let ((color (gtk:widget-color widget)))
(gdk:cairo-set-source-rgba cr color)
;; Draw and fill a circle on the drawing area
(cairo:arc cr
(/ width 2.0)
(/ height 2.0)
(- (/ (min width height) 2.0) 12)
0.0
(* 2.0 pi))
(cairo:fill cr))))
;; Show the window
(setf (gtk:widget-visible window) t))) Signal DetailsThe "resize" signallambda (area width height) :run-last
| Returned bySlot Access FunctionsInherited Slot Access Functions |
2025-07-24
