[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CLIM question: modifying Highlighting
Date: Mon, 20 Jul 1992 14:52 EDT
From: jclose@chesapeake.ads.com (Jeff Close)
I apologize in advance if this is inappropriate for this list (I'm not
sure if we try to cover CLIM or not).
Sure, why not. Although there is a CLIM-specific list: CLIM@BBN.com.
I want to modify the highlighting of a presentation in CLIM. If I
knew the methods used I could put an :around or :after on the right
method. Any ideas about this or any other approach? Thanks much for
any help.
Use the CLIM defining macro DEFINE-PRESENTATION-METHOD to define a
HIGHLIGHT-PRESENTATION method on your presentation type. This will
replace the default method; it is not an :around or :after method.
Here is an example of making the ticks of a ruler highlight with their
number.
;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10; Package: CLIM-USER -*-
(define-presentation-type tick ())
(define-presentation-method highlight-presentation ((type tick) record stream state)
state
(multiple-value-bind (left top right) (clim:bounding-rectangle* record)
(let ((sn (princ-to-string (presentation-object record))))
(draw-string* stream sn
(round (+ left right) 2) (+ top -1)
:align-x :center :align-y :bottom :ink +flipping-ink+))))
(defun ruler-test (&key (tick-width 20) (margin 40) (n-ticks 10) (stream *standard-output*))
(let ((y+ 100) (y- 85)
(xl margin) (xr (+ margin (* n-ticks tick-width)))
(tw/2 (round tick-width 2)))
(draw-line* stream xl y+ xr y+)
(loop for i from 0 to n-ticks
for x = (+ (* i tick-width) xl)
for x- = (- x tw/2) for x+ = (+ x tw/2) do
(with-output-as-presentation (:stream stream
:object i
:type 'tick)
(draw-rectangle* stream x- y- x+ y+ :ink +white+)
(draw-line* stream x y+ x y-))))
(accept 'tick :stream stream :prompt nil))