From: Rafael León Franco
Subject: Scroll with Capi
Date: 
Message-ID: <3BD82DDD.7BEBA4EB@albireo.lcc.uma.es>
Does anyone know how to control the scroll bars of a
capi:pinboard-layout?  I wolud like to detect when an user moves them
and how much he has moved.

Bye,
Rafa.

From: Clive Tong
Subject: Re: Scroll with Capi
Date: 
Message-ID: <u7ktj1xi2.fsf@scientia.com>
Rafael =?iso-8859-1?Q?Le=F3n?= Franco <····@albireo.lcc.uma.es> writes:

> Does anyone know how to control the scroll bars of a
> capi:pinboard-layout?  I wolud like to detect when an user moves them
> and how much he has moved.
> 

capi:simple-pane has a :scroll-callback that can be used for this purpose.

For example, try the following

(capi:contain
 (make-instance 'capi:pinboard-layout 
                :description (list (make-instance 'capi:line-pinboard-object :min-width 300 :min-height 1000)) 
                :horizontal-scroll t
                :vertical-scroll t
                :scroll-callback #'(lambda (&rest args) (format mp:*background-standard-output* "~S~%" args))))
From: Rafael León Franco
Subject: Re: Scroll with Capi
Date: 
Message-ID: <3BDD7C6F.37B0F09@albireo.lcc.uma.es>
Clive Tong wrote:

> For example, try the following
>
> (capi:contain
>  (make-instance 'capi:pinboard-layout
>                 :description (list (make-instance 'capi:line-pinboard-object :min-width 300 :min-height 1000))
>                 :horizontal-scroll t
>                 :vertical-scroll t
>                 :scroll-callback #'(lambda (&rest args) (format mp:*background-standard-output* "~S~%" args))))

How can i know how many pixels must i count when i do a :STEP or a :PAGE movement? Thank you.

Rafa.
From: Clive Tong
Subject: Re: Scroll with Capi
Date: 
Message-ID: <u3d3tcodc.fsf@scientia.com>
Rafael =?iso-8859-1?Q?Le=F3n?= Franco <····@albireo.lcc.uma.es> writes:

> How can i know how many pixels must i count when i do a :STEP or a :PAGE movement? Thank you.

I think these are available in the geometry of pinboard-layout as
capi:%scroll-...-page-size% and capi:%scroll-...-step-size%

(capi:contain
 (setq *pane*
       (make-instance 
        'capi:pinboard-layout
        :description (list (make-instance 'capi:line-pinboard-object :min-width 300 :min-height 1000))
        :horizontal-scroll t
        :vertical-scroll t
        :scroll-callback #'(lambda (pane &rest args)
                             (format mp:*background-standard-output* "~S~%" args)
                             (capi:with-geometry pane
                               (format mp:*background-standard-output* "~S~%"
                                       (list
                                        capi:%scroll-x%
                                        capi:%scroll-y%
                                        capi:%scroll-vertical-page-size%
                                        capi:%scroll-vertical-step-size%
                                        )))))))
From: Rafael León Franco
Subject: Re: Scroll with Capi
Date: 
Message-ID: <3BDE6E61.EBC77C33@albireo.lcc.uma.es>
Clive Tong wrote:

> capi:simple-pane has a :scroll-callback that can be used for this purpose.
>
> For example, try the following
>
> (capi:contain
>  (make-instance 'capi:pinboard-layout
>                 :description (list (make-instance 'capi:line-pinboard-object :min-width 300 :min-height 1000))
>                 :horizontal-scroll t
>                 :vertical-scroll t
>                 :scroll-callback #'(lambda (&rest args) (format mp:*background-standard-output* "~S~%" args))))

I have tried the following code, but the function set-scroll-position does not work (the scroll bars are in the 0,0
when the window displays). I have the same problem in the program i'm working. Do you have any idea? Thank you.

Rafa

(setq grafico (make-instance 'capi:pinboard-layout
                :description (list (make-instance 'capi:line-pinboard-object :min-width 300 :min-height 1000))
                :min-width 500
                :min-height 500
                :horizontal-scroll t
                :vertical-scroll t
                :scroll-callback #'(lambda (&rest args)
                                     (format mp:*background-standard-output* "~S~%" args))))

(capi:set-scroll-position grafico 0 100)

(capi:contain grafico)
From: Clive Tong
Subject: Re: Scroll with Capi
Date: 
Message-ID: <uzo61b9ab.fsf@scientia.com>
Rafael =?iso-8859-1?Q?Le=F3n?= Franco <····@albireo.lcc.uma.es> writes:

> I have tried the following code, but the function set-scroll-position does not work (the scroll bars are in the 0,0
> when the window displays). I have the same problem in the program i'm working. Do you have any idea? Thank you.
> 
> Rafa
> 
> (setq grafico (make-instance 'capi:pinboard-layout
>                 :description (list (make-instance 'capi:line-pinboard-object :min-width 300 :min-height 1000))
>                 :min-width 500
>                 :min-height 500
>                 :horizontal-scroll t
>                 :vertical-scroll t
>                 :scroll-callback #'(lambda (&rest args)
>                                      (format mp:*background-standard-output* "~S~%" args))))
> 
> (capi:set-scroll-position grafico 0 100)

If the element hasn't been created on the screen, you can set the initial scroll position using
the :scroll-initial-y initarg

(setq grafico (make-instance 'capi:pinboard-layout
                :description (list (make-instance 'capi:line-pinboard-object :min-width 300 :min-height 1000))
                :min-width 500
                :min-height 500
                :horizontal-scroll t
                :vertical-scroll t
                :scroll-initial-y 100   ;;; <<< set via an initarg
                :scroll-callback #'(lambda (&rest args)
                                     (format mp:*background-standard-output* "~S~%" args))))
 
or setting a hint 

(capi:set-geometric-hint grafico :scroll-initial-y 100)

> (capi:contain grafico)