From: Christopher C. Stacy
Subject: CAPI questions
Date: 
Message-ID: <uy9cpdw71.fsf@grant.org>
1. If I have defined more than one layout in my interface
   how do I switch between them?

2. How can I compute the width of some text that I would like
   to display in some pane?

   Do I want to compute it from a GP?
   How do I get the GP associated with a pane?

3. I had to call an undocumented internal function to find
   the width of a pane's font?

4. I had to call an undocumented internal function to find
   find the visible-max-width of a pane?

5. When I put a bunch of text into a DISPLAY-PANE,
   the interface grows vertically past the :visible-max-height 
   of both the pane and the containing interface.  While the pane
   itself appears to be have been limited correctly, there is blank 
   (background colored) space below it, where it wanted to grow!
   How can I control this properly?

6. How can I turn the scroll bars in my pane on and off
   (to make them appear and disappear as needed)?

From: Clive Tong
Subject: Re: CAPI questions
Date: 
Message-ID: <u8z4l3qs9.fsf@scientia.com>
······@grant.org (Christopher C. Stacy) writes:

> 1. If I have defined more than one layout in my interface
>    how do I switch between them?

Put them all inside a switchable-layout, and use this to swap between
the layouts. 

> 2. How can I compute the width of some text that I would like
>    to display in some pane?

  If the pane in question is an output-pane (and hence you're going
to use the gp functions for drawing the text), then
gp:port-string-width
 
>    Do I want to compute it from a GP?
>    How do I get the GP associated with a pane?

  Some panes are graphics ports eg capi:output-pane allowing general
  user drawing operations. Other panes like the display pane map to
  the OS widget and don't have a graphics port associated with them.

> 3. I had to call an undocumented internal function to find
>    the width of a pane's font?
> 
> 4. I had to call an undocumented internal function to find
>    find the visible-max-width of a pane?
> 
> 5. When I put a bunch of text into a DISPLAY-PANE,
>    the interface grows vertically past the :visible-max-height 
>    of both the pane and the containing interface.  While the pane
>    itself appears to be have been limited correctly, there is blank 
>    (background colored) space below it, where it wanted to grow!
>    How can I control this properly?

  Do you have an example of this.

> 6. How can I turn the scroll bars in my pane on and off
>    (to make them appear and disappear as needed)?

The scrollbars are controlled using the :horizontal-scroll and
:vertical-scroll initargs to the class. I don't think they can be
dynamically manipulated.
From: Christopher C. Stacy
Subject: Re: CAPI questions
Date: 
Message-ID: <u7kk4peky.fsf@grant.org>
Clive, Thank You!

>>>>> On 09 Jul 2002 15:43:50 +0100, Clive Tong ("Clive") writes:
 >> 6. How can I turn the scroll bars in my pane on and off
 >> (to make them appear and disappear as needed)?

 Clive> The scrollbars are controlled using the :horizontal-scroll and
 Clive> :vertical-scroll initargs to the class. I don't think they can be
 Clive> dynamically manipulated.

Yeah, I was kind of hoping for 
 :horizontal-scroll :as-needed 
or else code the dynamic behaviour up myself.

For the latter, I guess I can think of a sort of awful way to do it
using switchable layouts (as you suggested above for the other purpose),
but I was hoping for a way to get hold of the control or the window
pane it was attached to, and telling it to turn on and off.
From: Simon Katz
Subject: Re: CAPI questions
Date: 
Message-ID: <agh68h$l22q2$1@ID-131024.news.dfncis.de>
"Christopher C. Stacy" <······@grant.org> wrote in message
··················@grant.org...
> Yeah, I was kind of hoping for
>  :horizontal-scroll :as-needed
> or else code the dynamic behaviour up myself.

If I do these one by one:

(defparameter *lp* (make-instance 'capi:list-panel
                          :items '(a b c d e f g h i j k l m)
                          :visible-min-height 50))
(capi:contain *lp*)
(setf (capi:collection-items *lp*) '(a b c d))
(setf (capi:collection-items *lp*) '(a b c d e f g h i j k l m))

the vertical scroll bar in the list panel appears and disappears
as needed.

Also, if I adjust the height of the resulting window via the GUI
controls, the scroll bar appears and disappears as needed.

Is that not what you want?

(BTW, for a list panel :VERTICAL-SCROLL T is the default, which
is why it's not stated in the above code.)
From: Christopher C. Stacy
Subject: Re: CAPI questions
Date: 
Message-ID: <u3cuspe42.fsf@grant.org>
>>>>> On 09 Jul 2002 15:43:50 +0100, Clive Tong ("Clive") writes:
 >> 5. When I put a bunch of text into a DISPLAY-PANE,
 >> the interface grows vertically past the :visible-max-height 
 >> of both the pane and the containing interface.  While the pane
 >> itself appears to be have been limited correctly, there is blank 
 >> (background colored) space below it, where it wanted to grow!
 >> How can I control this properly?

 Clive>   Do you have an example of this.

(capi:define-interface loser-gui ()
  ()
  (:panes
   (answer-pane
    capi:display-pane
    :text nil
    :vertical-scroll t
    :horizontal-scroll nil
    :max-height '(:character 40)
    :visible-max-height '(:character 40)
    :visible-max-width '(:character 100)))
  (:layouts
   (main capi:column-layout
         '(answer-pane)))
  (:default-initargs 
   :title "Loser"
   :max-height '(:character 40)
   :visible-max-height '(:character 40)
   :auto-menus nil))

(defun lose (&optional (lines 50))
  (let ((gui (make-instance 'loser-gui)))
    (capi:display gui)
    (with-slots (answer-pane) gui
      (setf (capi:display-pane-text answer-pane)
            (make-string lines :initial-element #\Newline)))))
From: Clive Tong
Subject: Re: CAPI questions
Date: 
Message-ID: <u3cur4z4h.fsf@scientia.com>
······@grant.org (Christopher C. Stacy) writes:

> >>>>> On 09 Jul 2002 15:43:50 +0100, Clive Tong ("Clive") writes:
>  >> 5. When I put a bunch of text into a DISPLAY-PANE,
>  >> the interface grows vertically past the :visible-max-height 
>  >> of both the pane and the containing interface.  While the pane
>  >> itself appears to be have been limited correctly, there is blank 
>  >> (background colored) space below it, where it wanted to grow!
>  >> How can I control this properly?
> 
>  Clive>   Do you have an example of this.
> 
> ....

I think that the problem is that the display-pane has a predefined
hint of :min-height set to :text-height 

[see (slot-value (capi:contain (make-instance 'capi:display-pane)) 'capi::hint-table)]

The constraints you are setting on the display pane cause a conflict
between this min-height and the max-height constraint and the layout
goes wrong. If you add
  :min-height '(min :text-height (:character 40)) 
as another initarg to the display-pane, then the constraints don't
conflict and you don't get the problem.

[See the documentation for capi:element for other useful hint
combiners]