Lisp HUG Maillist Archive

Controlling widths in PROMPT-WITH-LIST &C

I have an application which calls CAPI:PROMPT-WITH-LIST with a list of
potentially very long strings.  This results in a rather silly
dialogue box...  There must be a way to control the width of it short
of truncating the strings (which is bad, because they are displayed in
a proportional width font, so any truncation either needs to take that
into account or look terrible) but I can't work it out.  Can anyone
help?

Thanks

--tim

PS Dave Fox wrote in another thread: 

    Yes we will indeed be addressing many of the documentation gaps,
    especially for the CAPI, FLI and EDITOR packages. These are the
    areas which the 'wish list' feedback on this mailing list last
    year identified as most in need of better documentation.

I'd just like to say that I think better documentation is terribly
important and I'm really pleased that this is being addressed!  I
spend far too long trying to find stuff in the CAPI (particularly)
documentation.




Re: Controlling widths in PROMPT-WITH-LIST &C

----- Original Message -----
From: "Tim Bradshaw" <tfb@cley.com>
To: <lisp-hug@xanalys.com>
Sent: Wednesday, February 12, 2003 2:35 PM
Subject: Controlling widths in PROMPT-WITH-LIST &C


> I have an application which calls CAPI:PROMPT-WITH-LIST with a list of
> potentially very long strings.  This results in a rather silly
> dialogue box...  There must be a way to control the width of it short
> of truncating the strings (which is bad, because they are displayed in
> a proportional width font, so any truncation either needs to take that
> into account or look terrible) but I can't work it out.  Can anyone
> help?

You can write your own dialog, here is a fairly functional start

(capi:define-interface list-panel-dialog ()
  ((list-max-width :initarg :list-max-width :initform nil)
   (list-min-width :initarg :list-min-width :initform 150)
   (list-font :initarg :list-font :initform nil)
   (items :initarg :items :initform nil))
  (:panes
   (list-panel capi:list-panel  :items items :max-width list-max-width
               :min-width list-min-width
               :max-width list-max-width
               :max-height :screen-height
               :font list-font
               :callback-type :interface
               :items items
               :action-callback
               (lambda (interface)
                 (capi:exit-dialog (capi:choice-selected-item (slot-value interface
'list-panel)))))
   (ok-button capi:push-button :max-width :screen-width :text "OK"
              :callback-type :interface
              :callback (lambda (interface)
                          (capi:exit-dialog (capi:choice-selected-item (slot-value
interface 'list-panel)))))
   (cancel-button capi:push-button :max-width :screen-width :text "Cancel"
                  :callback-type :interface
                  :callback
                  (lambda (interface)
                    (declare (ignore interface))
                    (capi:abort-dialog))))
  (:layouts
   (main capi:row-layout '(list-panel buttons))
   (buttons capi:column-layout '(ok-button cancel-button)))
  (:default-initargs
   :min-height 250
   :max-height :screen-height))


CL-USER 20 > (capi:display-dialog (make-instance 'list-panel-dialog :items '(1 2 3 4 5 6 7
8 9 10 12 "Really, really, really, lonngngnngngng string") :list-min-width 300))
NIL
NIL

CL-USER 21 > (capi:display-dialog (make-instance 'list-panel-dialog :items '(1 2 3 4 5 6 7
8 9 10 12 "Really, really, really, lonngngnngngng string") :list-min-width 150))
NIL
NIL

CL-USER 22 > (capi:display-dialog (make-instance 'list-panel-dialog :items '(1 2 3 4 5 6 7
8 9 10 12 "Really, really, really, lonngngnngngng string") :list-min-width 150 :min-height
400))
1
T

Wade


Re: Controlling widths in PROMPT-WITH-LIST &C

A way do to this (controlling widths) using PROMPT-WITH-LIST turns out
to be:

(prompt-with-list l prompt
                  :pane-args '(:visible-min-width ...)
                  :horizontal-scroll t
                  ...)

You don't need the horizontal-scroll bit unless you want to be able to
see the stuff that is off the right of the list panel.  It's not clear
to me why the scroll specification is not part of the pane args rather
than an argument to the function itself (maybe because the surrounding
container thingy is the one that does the scrolling?).

Thanks to Wade & Nick Levine for pointing me in the right direction.

--tim



Updated at: 2020-12-10 09:00 UTC