Package: gtk
Class gtk:print-context
Superclassesgobject:object, common-lisp:standard-object, common-lisp:t Documented Subclasses
None
Direct Slots
None
Details The gtk:print-context object encapsulates context information that
is required when drawing pages for printing, such as the Cairo context and
important parameters like page size and resolution. It also lets you create pango:layout and pango:context objects
that match the font metrics of the Cairo surface. The gtk:print-context object gets passed to the "begin-print", "end-print", "request-page-setup" and "draw-page" signal handlers on the print operation. Examples(defun draw-page (operation context pagenr) (declare (ignore operation pagenr)) (let ((cr (gtk:print-context-cairo-context context)) (layout (gtk:print-context-create-pango-layout context))) ;; Draw a red rectangle, as wide as the paper (inside the margins) (cairo:set-source-rgb cr 1.0 0 0) (cairo:rectangle cr 0 0 (gtk:print-context-width context) 50) (cairo:fill cr) ;; Draw some lines (cairo:move-to cr 20 10) (cairo:line-to cr 40 20) (cairo:arc cr 60 60 20 0 3.14) (cairo:line-to cr 80 20) (cairo:set-source-rgb cr 0 0 0) (cairo:set-line-width cr 5) (cairo:set-line-cap cr :round) (cairo:set-line-join cr :round) (cairo:stroke cr) ;; Draw some text (setf (pango:layout-text layout) "Hello World! Printing is easy") (setf (pango:layout-font-description layout) (pango:font-description-from-string "sans 28")) (cairo:move-to cr 30 20) (pango:cairo-layout-path cr layout) ;; Font Outline (cairo:set-source-rgb cr 0.93 1.0 0.47) (cairo:set-line-width cr 0.5) (cairo:stroke-preserve cr) ;; Font Fill (cairo:set-source-rgb cr 0 0.0 1.0) (cairo:fill cr))) | Inherited Slot Access FunctionsSee also |
2024-2-16