anchor.diff:  			      :height *scrollbar-thickness*
   			      :min-width (* 3 *scrollbar-thickness*)
   			      :width (* 4 *scrollbar-thickness*))))
  -
  -(defmethod repaint-sheet ((sb scroll-bar-pane) region)
  -  (declare (ignore region))
  -  (with-bounding-rectangle* (minx miny maxx maxy) (sheet-region sb)
  -    (with-special-choices (sb)
  -      (draw-rectangle* sb minx miny maxx maxy :filled t :ink (medium-background sb))
  -      (let ((width (- maxx minx (* 2 *scrollbar-thickness*)))
  -	    (height (- maxy miny (* 2 *scrollbar-thickness*)))
  -	    (pos (/ (- (gadget-value sb)
  -		       (gadget-min-value sb))
  -		    (gadget-range sb)))
  -	    (len (/ (if (eq (gadget-orientation sb) :vertical)
  -			(- maxy miny)
  -		      (- maxx minx))
  -		    (gadget-range sb)))
  -	    (highlight +white+)
  -	    (shadow +black+)
  -	    (thickness 2))
  -	(cond
  -	 ((eq (gadget-orientation sb) :vertical)
  -	  (let ((points (list (/ (- maxx minx) 2) miny
  -			      (1- maxx) (1- *scrollbar-thickness*)
  -			      minx (1- *scrollbar-thickness*))))
  -	    (draw-polygon* sb points
  -			   :filled t :ink (medium-foreground sb))
  -	    (draw-polygon* sb points
  -			   :closed nil :filled nil :line-thickness thickness :ink shadow)
  -	    (draw-line* sb
  -			(first points) (second points)
  -			(fifth points) (sixth points)
  -			:line-thickness thickness :ink highlight))
  -	  (let ((x-min minx)
  -		(y-min (+ miny
  -			  (* height pos)
  -			  *scrollbar-thickness*))
  -		(x-max (1- maxx))
  -		(y-max (1- (min (+ miny
  -				   (* height (+ pos len))
  -				   *scrollbar-thickness*)
  -				(- maxy *scrollbar-thickness*)))))
  -	    (draw-rectangle* sb
  -			     x-min y-min x-max y-max
  -			     :filled t :ink (medium-foreground sb))
  -	    (draw-line* sb
  -			x-max y-min x-max y-max
  -			:line-thickness thickness :ink shadow)
  -	    (draw-line* sb
  -			x-min y-max x-max y-max
  -			:line-thickness thickness :ink shadow)
  -	    (draw-line* sb
  -			x-min y-min x-max y-min
  -			:line-thickness thickness :ink highlight)
  -	    (draw-line* sb
  -			x-min y-min x-min y-max
  -			:line-thickness thickness :ink highlight))
  -	  (let ((points (list (/ (- maxx minx) 2) (1- maxy)
  -			      minx (- maxy *scrollbar-thickness*)
  -			      (1- maxx) (- maxy *scrollbar-thickness*))))
  -	    (draw-polygon* sb points
  -			   :filled t :ink (medium-foreground sb))
  -	    (draw-line* sb
  -			(first points) (second points)
  -			(fifth points) (sixth points)
  -			:line-thickness thickness :ink shadow)
  -	    (draw-polygon* sb points
  -			   :closed nil :filled nil :line-thickness thickness :ink highlight)))
  -	 (t
  -	  (let ((points (list (1- *scrollbar-thickness*) miny
  -			      minx (/ (+ miny maxy) 2)
  -			      (1- *scrollbar-thickness*) (1- maxy))))
  -	    (draw-polygon* sb points
  -			   :filled t :ink (medium-foreground sb))
  -	    (draw-line* sb
  -			(first points) (second points)
  -			(fifth points) (sixth points)
  -			:line-thickness thickness :ink shadow)
  -	    (draw-polygon* sb points
  -			   :closed nil :filled nil :line-thickness thickness :ink highlight))
  -	  (let ((x-min (+ minx
  -			  (* width pos)
  -			  *scrollbar-thickness*))
  -		(y-min miny)
  -		(x-max (1- (min (+ minx
  -				   (* width (+ pos len))
  -				   *scrollbar-thickness*)
  -				(- maxx *scrollbar-thickness*))))
  -		(y-max (1- maxy)))
  -	    (draw-rectangle* sb
  -			     x-min y-min x-max y-max
  -			     :filled t :ink (medium-foreground sb))
  -	    (draw-line* sb
  -			x-max y-min x-max y-max
  -			:line-thickness thickness :ink shadow)
  -	    (draw-line* sb
  -			x-min y-max x-max y-max
  -			:line-thickness thickness :ink shadow)
  -	    (draw-line* sb
  -			x-min y-min x-max y-min
  -			:line-thickness thickness :ink highlight)
  -	    (draw-line* sb
  -			x-min y-min x-min y-max
  -			:line-thickness thickness :ink highlight))
  -	  (let ((points (list (- maxx *scrollbar-thickness*) miny
  -			      (1- maxx) (/ (+ minx maxx) 2)
  -			      (- maxx *scrollbar-thickness*) (1- maxy))))
  -	    (draw-polygon* sb points
  -			   :filled t :ink (medium-foreground sb))
  -	    (draw-polygon* sb points
  -			   :closed nil :filled nil :line-thickness thickness :ink shadow)
  -	    (draw-line* sb
  -			(first points) (second points)
  -			(fifth points) (sixth points)
  -			:line-thickness thickness :ink highlight))))))))
  +;;; Utilities
  +
  +;; We think all scroll bars as vertically oriented, therefore we have
  +;; SCROLL-BAR-TRANSFORMATION, which should make every scroll bar
  +;; look like being vertically oriented -- simplifies much code.
  +
  +(defmethod scroll-bar-transformation ((sb scroll-bar))
  +  (ecase (gadget-orientation sb)
  +    (:vertical   +identity-transformation+)
  +    (:horizontal (make-transformation 0 1 1 0 0 0))))
  +
  +(defun translate-range-value (a mina maxa mino maxo)
  +  "When \arg{a} is some value in the range from \arg{mina} to \arg{maxa},
  +   proportionally translate the value into the range \arg{mino} to \arg{maxo}."
  +  (+ mino (* (/ (- a mina) (- maxa mina)) (- maxo mino))))
  +
  +;;; Scroll-bar's sub-regions
  +
  +(defmethod scroll-bar-up-region ((sb scroll-bar-pane))
  +  (with-bounding-rectangle* (minx miny maxx maxy) (transform-region (scroll-bar-transformation sb)
  +                                                                    (pane-inner-region sb))
  +    (declare (ignore maxy))
  +    (make-rectangle* minx miny
  +                     maxx (+ miny (- maxx minx)))))
  +
  +(defmethod scroll-bar-down-region ((sb scroll-bar-pane))
  +  (with-bounding-rectangle* (minx miny maxx maxy) (transform-region (scroll-bar-transformation sb)
  +                                                                    (pane-inner-region sb))
  +    (declare (ignore miny))
  +    (make-rectangle* minx (- maxy (- maxx minx))
  +                     maxx maxy)))
  +
  +(defmethod scroll-bar-thumb-bed-region ((sb scroll-bar-pane))
  +  (with-bounding-rectangle* (minx miny maxx maxy) (transform-region (scroll-bar-transformation sb)
  +                                                                    (pane-inner-region sb))
  +    (make-rectangle* minx (+ miny (- maxx minx) 1)
  +                     maxx (- maxy (- maxx minx) 1))))
  +
  +(defmethod scroll-bar-thumb-region ((sb scroll-bar-pane))
  +  (with-bounding-rectangle* (x1 y1 x2 y2) (scroll-bar-thumb-bed-region sb)
  +    (multiple-value-bind (minv maxv) (gadget-range* sb)
  +      (multiple-value-bind (v) (gadget-value sb)
  +        (let ((ts (* 1/3 (- maxv minv))))
  +          (let ((ya (translate-range-value v minv (+ maxv ts) y1 y2))
  +                (yb (translate-range-value (+ v ts) minv (+ maxv ts) y1 y2)))
  +            (make-rectangle* x1 ya x2 yb)))))))
  +
  +#||
  +;; alternative:
  +
  +(defmethod scroll-bar-up-region ((sb scroll-bar-pane))
  +  (with-bounding-rectangle* (minx miny maxx maxy) (transform-region (scroll-bar-transformation sb)
  +                                                                    (sheet-region sb))
  +    (make-rectangle* (+ minx 2) (- (- maxy (* 2 (- maxx minx))) 2)
  +                     (- maxx 2) (- (- maxy (- maxx minx)) 2))))
  +
  +(defmethod scroll-bar-down-region ((sb scroll-bar-pane))
  +  (with-bounding-rectangle* (minx miny maxx maxy) (transform-region (scroll-bar-transformation sb)
  +                                                                    (sheet-region sb))
  +    (make-rectangle* (+ minx 2) (+ (- maxy (- maxx minx)) 2)
  +                     (- maxx 2) (-  maxy 2))))
  +
  +(defmethod scroll-bar-thumb-bed-region ((sb scroll-bar-pane))
  +  (with-bounding-rectangle* (minx miny maxx maxy) (transform-region (scroll-bar-transformation sb)
  +                                                                    (sheet-region sb))
  +    (make-rectangle* (+ minx 2) (+ miny 2 )
  +                     (- maxx 2) (- maxy 2 (* 2 (- maxx minx)) 2))))
  +
  +(defmethod scroll-bar-thumb-region ((sb scroll-bar-pane))
  +  (with-bounding-rectangle* (x1 y1 x2 y2) (scroll-bar-thumb-bed-region sb)
  +    (multiple-value-bind (minv maxv) (gadget-range* sb)
  +      (multiple-value-bind (v) (gadget-value sb)
  +        (let ((ts (* 1/3 (- maxv minv))))
  +          (let ((ya (translate-range-value v minv (+ maxv ts) y1 y2))
  +                (yb (translate-range-value (+ v ts) minv (+ maxv ts) y1 y2)))
  +            (make-rectangle* x1 ya x2 yb)))))))
  +||#
  +
  +
  +;;; Event handlers
   
   (defmethod handle-event ((sb scroll-bar-pane) (event window-repaint-event))
     (dispatch-repaint sb (sheet-region sb)))
   
  +#||
   (defmethod handle-event ((sb scroll-bar-pane) (event pointer-enter-event))
     (declare (ignorable event))
     (with-slots (armed) sb
  
positive.code:      (when armed
         (setf armed nil)
         (disarmed-callback sb (gadget-client sb) (gadget-id sb)))))
  
  (defun get-orientation-dependant-informations (scroll-bar-pane)
    (if (eq (gadget-orientation scroll-bar-pane) :vertical)
        (values (- (bounding-rectangle-height (sheet-region scroll-bar-pane))
  		 (* 2 *scrollbar-thickness*))
                #'pointer-event-y)
        (values (- (bounding-rectangle-width (sheet-region scroll-bar-pane))
  		 (* 2 *scrollbar-thickness*))
                #'pointer-event-x)))
  
  (defmethod dispatch-callbacks ((sb scroll-bar-pane) event)
    (multiple-value-bind (sb-length pos-func)
        (get-orientation-dependant-informations sb)
      (with-slots (value min-value max-value) sb
        (let* ((position (funcall pos-func event))
  	     (value-clicked (/ (- position *scrollbar-thickness*) sb-length)))
          (cond
  	 ((< position *scrollbar-thickness*)
  	  (scroll-up-line-callback sb (gadget-client sb) (gadget-id sb)))
  	 ((> position (+ sb-length *scrollbar-thickness*))
  	  (scroll-down-line-callback sb (gadget-client sb) (gadget-id sb)))
  	 ((< value-clicked (/ (- value min-value)
  			 (- max-value min-value)))
  	  (scroll-up-page-callback sb (gadget-client sb) (gadget-id sb)))
  	 ((< (+ (/ (- value min-value)
  			 (- max-value min-value))
  		 (/ sb-length
  			  (gadget-range sb)))
  	      value-clicked)
  	  (scroll-down-page-callback sb (gadget-client sb) (gadget-id sb))))))))
  
  (defmethod handle-event ((sb scroll-bar-pane) (event pointer-button-press-event))
    (with-slots (armed) sb
      (unless armed
        (armed-callback sb (gadget-client sb) (gadget-id sb)))
      (setf armed ':button-press))
    (dispatch-callbacks sb event))
  
  (defmethod handle-event ((sb scroll-bar-pane) (event pointer-motion-event))
    (with-slots (armed dragged) sb
      (when (eq armed ':button-press)
        (multiple-value-bind (sb-length pos-func)
            (get-orientation-dependant-informations sb)
          (drag-callback sb (gadget-client sb) (gadget-id sb)
                         (min (max (+ (gadget-min-value sb)
  				    (* (gadget-range sb)
  				       (/ (- (funcall pos-func event) *scrollbar-thickness*)
  					  sb-length)))
  				 0)
  			    (gadget-max-value sb))))
        (unless dragged
          (setf dragged t)))))
  
  (defmethod handle-event ((sb scroll-bar-pane) (event pointer-button-release-event))
    (declare (ignorable event))
    (with-slots (armed dragged) sb
       (when (eq armed ':button-press)
         (setf armed t)
         (when dragged
           (setf dragged nil)
           (multiple-value-bind (sb-length pos-func)
               (get-orientation-dependant-informations sb)
             (value-changed-callback sb (gadget-client sb) (gadget-id sb)
                                     (/ (funcall pos-func event) sb-length)))
           (disarmed-callback sb (gadget-client sb) (gadget-id sb))))))
  
  
  ;;
  ;; SLIDER gadget
  
negative.code: 	  (draw-label pane (gadget-label pane) (round w 2) (round h 2)))))))
  
  
  ;;;;
  ;;;; SCROLL-BAR gadget
  ;;;;
  
  (defgeneric drag-callback (pane client gadget-id value))
  (defgeneric scroll-to-top-callback (scroll-bar client gadget-id))
  