A medium is the destination for graphic output in CLIM. Different medium classes correspond to different devices, such as displays and printers, allowing graphics to be rendered in a variety of ways depending on the medium and its drawing options.
An application pane (AKA an extended-stream-pane) is a kind of medium that can be supplied to drawing functions. For example we can make the word application frame, access it's pane, and then access drawing options that are part of the pane because it is a medium.
CLIM-USER(8): (setq *word* (make-application-frame 'word)) #<WORD @ #x4b2478a> CLIM-USER(9): (setq pane (get-frame-pane *word* 'document)) #<APPLICATION-PANE @ #x4b24af2> CLIM-USER(10): (medium-foreground pane) #<CLIM-UTILS:GRAY-COLOR Black @ #x41432ca> CLIM-USER(11): (medium-background pane) #<CLIM-UTILS:GRAY-COLOR White @ #x4142792>
Within a pane description, the pane option
:display-function
specifies the function that will draw
the output for that pane.
Below we have modified the word application frame.
Notice the slot doc-title
was added to store the title
of the current document. Also notice a display function for the pane
called title
was added. The supplied function,
display-doc-title
, takes two arguments: an application
frame and a medium.
(define-application-frame word ;name
() ;superclasses
((doc-title ;slots
:accessor doc-title
:initarg :doc-title))
;; options
(:panes
(title ;pane name
:application ;pane type
;; pane options
:display-function #'display-doc-title
:initial-cursor-visibility nil)
(document ;pane name
:application)) ;pane type
(:layouts
(default ;name of the layout
(vertically () ;layout macros
(1/4 title)
(3/4 document)))))
(defmethod display-doc-title ((frame word) stream)
(draw-text* stream "Document:" 10 15)
(if (slot-boundp frame 'doc-title)
(draw-text* stream (doc-title frame) 20 40)
(draw-text* stream "Untitled" 20 40)))
(make-application-frame 'word
:height 300
:width 300
:doc-title "Microcrock's Business Plan")
Notice that the origin of the coordinate system of the drawing plane is in the top left corner of the window with positive x extending to the right and positive y extending down toward the bottom of the window.
(make-application-frame 'word
:height 300 :width 400
:doc-title "Microcrock's Business Plan")
doc-title
from the word application frame, and add a slot called
current-file
.
display-doc-title
so that it displays the
value of current-file
instead of
doc-title
.
#'display-document
to the document pane description of the word application
frame.
current-file
onto the document pane. Use the
do-file
macro provided in word.lisp to iterate
over the lines of a the file. To find out the height of a
line, use the line-height
function provided in
word.lisp. Use clim:draw-rectangle* to draw a black line
around the all of the text.
(make-application-frame 'word
:height 300 :width 400
:current-file "word.lisp")
Next: Formatted Output