Package: gtk
Class gtk-drawing-area
SuperclassesDocumented Subclasses
None
Direct Slots
None
Details The gtk-drawing-area widget is used for creating custom user
interface elements. It is essentially a blank widget. You can draw on it.
After creating a drawing area, the application may want to connect to:
To receive mouse events on a drawing area, you will need to enable them with the gtk-widget-add-events function. 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. Use the gtk-widget-has-focus function in your expose event handler to decide whether to draw the focus indicator. See the function for one way to draw focus. ExampleNote that GDK automatically clears the exposed area before sending the expose event, and that drawing is implicitly clipped to the exposed area. If you want to have a theme-provided background, you need to call the gtk-render-background function in your "draw" signal handler. (defun example-drawing-area () (within-main-loop (let ((window (make-instance 'gtk-window :type :toplevel :title "Example Drawing Area" :default-width 400 :default-height 300)) ;; Create the drawing area (area (make-instance 'gtk-drawing-area))) ;; Signal handler for the drawing area (g-signal-connect area "draw" (lambda (widget cr) (let* ((cr (pointer cr)) (width (gtk-widget-allocated-width widget)) (height (gtk-widget-allocated-height widget)) (context (gtk-widget-style-context widget)) (color (gtk-style-context-color context :focused))) ;; Set the color from the style context of the 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) ;; Destroy the Cairo context (cairo-destroy cr)))) ;; Signal handler for the window to handle the signal "destroy" (g-signal-connect window "destroy" (lambda (widget) (declare (ignore widget)) (leave-gtk-main))) ;; Show the window (gtk-container-add window area) (gtk-widget-show-all window)))) | Inherited Slot Access FunctionsSee also |
*2021-11-30