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

Re- Scroller's thumbs probl



                      Re: Scroller's thumbs problem

Mark Tapia wrote:

>The following code works correctly and is simpler:
>(require 'scrolling-window "Examples:scrolling-window")

>(setq *w* (make-instance 'ccl::scrolling-window
>            :view-size #@(200 200)
>            ))
 
>;(set-view-size *w* 400 400)
>;(set-view-size *w* 100 100)

The scroller I used must be  one of the subviews in a dialog.  Therefore, it's
screen size is fixed.  
But the scrollable size  can be  changed at run time, depending on the user's
clicking on the 
contents of the scroller.  (For example, a tree initially displays only 20
nodes.  
After some clickings, it explodes to 1000 nodes.  Clicking also allows to
reduce to 1 node, too.)
Scrolling-window, therefore,  is not quite I want.


> (require 'scrollers)

> (defclass myscroller (ccl::scroller)
>  ((limits :initform (cons nil nil)
>           :reader scroll-bar-limits-slot)))

>(defmethod view-click-event-handler ((self myscroller) where)
>  (declare (ignore where))
>  (print (point-string (make-point (scroll-bar-max (ccl::h-scroller self))
> (scroll-bar-max (ccl::v-scroller self)))))
>  (call-next-method))

>(setq *w* (make-instance 'window
>            :view-size #@(200 200)
>            ))

>(setq *myscroller* 
>           (make-instance 'myscroller
>             :view-container *w*
>             :track-thumb-p t
>             :view-size #@(184 184)
>             :view-position #@(0 0)
>      ))

>(defmethod scroll-bar-limits ((self myscroller))
>  (let ((limits (scroll-bar-limits-slot self))
>        (size (view-size self)))
>    (values
>     (or (car limits) (point-h size))
>     (or (cdr limits) (point-v size)))))

>(defmethod resize ((self myscroller) x y)
>  (let ((limits (scroll-bar-limits-slot self)))
>    (setf (car limits) (make-point 0 x))
>    (setf (cdr limits) (make-point 0 y)))
>  (update-scroll-bar-limits self)   
;;;; Question:  should update-scroll-bar-limit be scroll-bar-limits?? 
>>)

(resize *myscroller* 400 400)

I am not sure if Bill St. Clair's code works because if you click inside the
*myscroller*,
it always  reports #@(184 184), not #@(400 400).

I tried to add   
(setf (scroll-bar-max (ccl::h-scroller self)) x)
 (setf (scroll-bar-max (ccl::v-scroller self)) y)
to the resize method.  

Now, Clicking initially  shows #@(400 400).  
But moving the thumb away and back to 0, the scroll-bar-max is 184 again.

I said  I am not sure because I did not know how scroll-bar-limits works.
Particularly, what's the relationship between scroll-bar-limits and
scroll-bar-max?
Setting scroll-bar-limits does not seem to set scroll-bar-max. 

 
Sheldon Shen