[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scroll-bar-dialog-item



>scroll-bar-dialog-item seems to ignore its setting keyword argument.
>
>(Unless I'm completely wrong about its purpose.)
>
>Here is a patch.
?[...]

This is a known bug. I fixed it by patching the initialize-instance
method as follows. This also allows the length and width to be
specified by the :VIEW-SIZE initarg:

----------------------------------------------------------------------------

(defmethod initialize-instance ((item scroll-bar-dialog-item) &rest initargs
                                &key (min 0) (max 100) (setting 0) width
                                (direction :vertical) length scrollee
                                pane-splitter (pane-splitter-length 7) view-size
                                view-position view-container)
  (declare (dynamic-extent initargs))
  (setq max (max min max)
        setting (min (max setting min) max))
  (if (and view-size (or length width))
    (error "Both ~s and ~s were specified."
           ':view-size (if length :length :width)))
  (unless length
    (setq length
          (if view-size
            (ecase direction
              (:vertical (point-v view-size))
              (:horizontal (point-h view-size)))
            100)))
  (unless width
    (setq width
          (if view-size
            (ecase direction
              (:vertical (point-h view-size))
              (:horizontal (point-v view-size)))
            16)))
  (when pane-splitter
    (let* ((splitter (make-instance 'pane-splitter 
                                    :direction direction
                                    :width width
                                    :length pane-splitter-length
                                    :scroll-bar item
                                    :scrollee scrollee))
           (size (view-size splitter))
           (h (point-h size))
           (v (point-v size)))
      (setf (pane-splitter item) splitter)
      (if (eq direction :vertical)
        (progn
          (decf length v)
          (when view-position
            (let ((p-h (point-h view-position))
                  (p-v (point-v view-position)))
              (if (eq pane-splitter :top)
                (progn
                  (set-view-position splitter view-position)
                  (setq view-position (make-point p-h (+ p-v v))))
                (progn
                  (set-view-position splitter p-h (+ p-v length)))))))
        (progn
          (decf length h)
          (when view-position
            (let ((p-h (point-h view-position))
                  (p-v (point-v view-position)))
              (if (eq pane-splitter :left)
                (progn
                  (set-view-position splitter view-position)
                  (setq view-position (make-point (+ p-h h) p-v)))
                (progn
                  (set-view-position splitter (+ p-h length) p-v)))))))))
  (apply #'call-next-method
         item
         :min min
         :max max
         :setting setting
         :direction direction
         :length length
         :view-container nil
         :view-position view-position
         :view-size
         (case direction
           (:vertical (make-point width length))
           (:horizontal (make-point length width))
           (t (error "illegal :direction ~a (must be :vertical or :horizontal)."
                     direction)))
         initargs)
  (when (and pane-splitter view-container (not view-position))
    (set-default-size-and-position item view-container)
    (set-view-position item (view-position item)))
  (when view-container
    (set-view-container item view-container))
  (when scrollee
    (add-view-scroll-bar scrollee item)))