Lisp HUG Maillist Archive

Using capi:tab-layout in a dialog

I'm trying to figure out the correct way to display a capi:tab-layout within a dialog box, but my lack of understanding of how to properly work with layouts is resulting in a mess.  Here's what I intended:  create a dialog box of fixed dimensions that contains several controls spread across 3 tabs.  The tabs would "fill" the available space in the dialog so that they would have a constant size.

Sounds simple enough, but when I navigate from one tab to the next, the minimize/maximize buttons turn off/on, and/or the dialog box re-sizes.  I attempted to force each tab to be the same size using a combination of :visible-min-height and :visible-min-width, but like I said, the result is kind of a mess.

Any hints (or criticisms) are appreciated.  A sample dialog box that shows this behavior (on Win32 + LW 4.4.6) is listed below.

Thanks,

Jon

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

(in-package :capi)

(define-interface sample-dialog ()
  ()
  (:panes
   ;; tab 1 controls
   (t1-radio-buttons
    radio-button-panel
    :items '("option 1" "option 2")
    :layout-args '(:y-gap 10)
    :layout-class 'column-layout
    :max-height t
    :max-width t)
   (t1-input1
    text-input-pane)
   (t1-input2
    text-input-pane
    :visible-max-width '(:character 6))

   ;; tab 2 controls
   (t2-range
    text-input-range
    :start 1
    :end 500)
   (t2-radio
    radio-button-panel
    :items '("A" "B" "C")
    :max-height t
    :max-width t)

   ;; tab 3 controls
   (t3-list
    list-panel
    :title "List Items:"
    :visible-max-height '(:character 3))
   (t3-radio1
    radio-button-panel
    :items '("option A" "option B")
    :layout-args '(:y-gap 10)
    :layout-class 'column-layout
    :max-height t
    :max-width t)
   (t3-range
    text-input-range
    :start 1
    :end 500)
   (t3-radio2
    radio-button-panel
    :items '("one" "two" "three")
    :max-height t
    :max-width t)
   (t3-button
    push-button
    :text "Test Button")

   ;; dialog controls
   (ok-cancel-buttons
    push-button-panel
    :cancel-button "Cancel"
    :default-button "OK"
    :items '("OK" "Cancel")
    :callbacks '(abort-dialog abort-dialog)
    :callback-type :interface
    :layout-args '(:x-uniform-size-p t)
    :max-height t
    :max-width t))
 
  (:layouts
   ;; main dialog layout
   (top-layout
    column-layout
    '(settings-tabs ok-cancel-buttons)
    :x-adjust :right
    :internal-border 5)
   (settings-tabs
    tab-layout
    ()
    :items '(("Tab 1" tab1)
             ("Tab 2" tab2)

             ("Tab 3" tab3))
    :print-function 'car
    :visible-child-function 'second
    :visible-min-height 375)

   ;;tab 1 layout
   (tab1
    column-layout
    '(tab1-group1)
    :internal-border 10)
   (tab1-group1
    column-layout
    '(t1-radio-buttons tab1-group1-section1)
    :border t
    :y-gap 10
    :title "Tab 1 Group 1"
    :title-position :frame
    :internal-border 7)
   (tab1-group1-section1
    grid-layout
    '("Value A:" t1-input1 "Value b:"   t1-input2)
    :columns 2)

   ;; tab 2 layout
   (tab2
    column-layout
    '(tab2-group1)
    :gap 10
    :internal-border 10)
   (tab2-group1
    column-layout
    '(tab2-group2-section1)
    :y-gap 10
    :title "Tab 2 Group 1"
    :title-position :frame
    :visible-min-width 338
    :internal-border 7)
   (tab2-group2-section1
    row-layout
    '(t2-range t2-radio)
    :gap 10
    :y-adjust :center)

   ;; tab 3 layout
   (tab3
    column-layout
    '(tab3-group1 tab3-group2 tab3-group3)
    :gap 10
    :internal-border 10)
   (tab3-group1
    column-layout
    '(tab3-group1-section1)
    :y-gap 10
    :title "Tab 3 Group 1"
    :title-position :frame
    :internal-border 7)
   (tab3-group1-section1
    row-layout
    '(t3-list))
   (tab3-group2
    column-layout
    '(t3-radio1 tab3-group2-section1)
    :y-gap 10
    :title "Tab 3 Group 2"
    :title-position :frame
    :visible-min-width 338
    :internal-border 7)
   (tab3-group2-section1
    row-layout
    '(t3-range t3-radio2)
    :gap 10
    :y-adjust :center)
   (tab3-group3
    column-layout
    '(tab3-group3-section1)
    :y-gap 10
    :title "Tab 3 Group 3"
    :title-position :frame
    :visible-min-width 338
    :internal-border 7)
   (tab3-group3-section1
    row-layout
    '(t3-button "Warning: this could take a long time.")
    :y-adjust :center))

  (:default-initargs
   :best-height 450
   :best-width 410
   :layout 'top-layout
   :title "Sample"
   :auto-menus nil))

(defun show-sample ()
  (display-dialog (make-instance 'sample-dialog)))

Re: Using capi:tab-layout in a dialog

On Monday 27 March 2006 06:04 pm, Jon Israelson wrote:
> I'm trying to figure out the correct way to display a capi:tab-layout
....
> minimize/maximize buttons turn off/on, and/or the dialog box re-sizes.  I
> attempted to force each tab to be the same size using a combination of
>
> :visible-min-height and :visible-min-width, but like I said, the result is

I don't know what the problem is, but I will confirm that I see your described 
behaviour in LWW, and different behaviour in LWL.

In LWW, the dialog first comes up with just a "close" (x) button (top left).  
If you click on the 2nd tab, the dialog resizes slightly and displays only a 
"close" button (no minimize or maximize buttons).  If you click on the 3rd 
tab, the dialog resizes slightly and you get all three buttons - minimize, 
maximize, close.  

If you go back to tab 1, the minimize and maximize buttons are present (recap: 
they weren't there when the dialog was first displayed) and the dialog 
resizes slightly.

In LWL, the behaviour is different.  All of the tabs give you a maximize and 
close button, but no minimize button.  When you click from the 1st tab to the 
2nd or 3rd, the dialog resizes slightly (larger).  Going back to the 1st tab 
does not resize.

I haven't parsed all of your code.  I suspect that the problem is that you've 
over-specified (and, maybe, you've hit a bug due to over-specification).

Start by commenting out all of the size specifications and see what the result 
is.

Then, look at :external-max-width and :external-min-width to see if they can 
help you.

pt


Re: Using capi:tab-layout in a dialog

OK, I've finally had some time to play around with this, and I'm starting to think that there is a problem with column-layout when used in a tabbed dialog.  I simplified my sample code to the bare basics and removed almost all sizing constraints, but still get some odd behavior.  Here's the code:

;;--------------------------------------------------------

(in-package :capi)

(define-interface sample-dialog ()
  ()
  (:panes
   (t1-input
    text-input-pane)
   (t2-input1
    text-input-pane)
   (t2-input2
    text-input-pane)
   (t3-input
    text-input-pane)
   (t3-radio
    radio-button-panel
    :items '("one" "two" "three"))
   (ok-cancel-buttons
    push-button-panel
    :cancel-button "Cancel"
    :default-button "OK"
    :items '("OK" "Cancel")
    :callbacks '(abort-dialog abort-dialog)
    :callback-type :interface
    :layout-args '(:x-uniform-size-p t)))
 
  (:layouts
   (top-layout
    column-layout
    '(tabs ok-cancel-buttons)
    :x-adjust :right)
   (tabs
    tab-layout
    ()
    :items '(("Tab 1" tab1)
             ("Tab 2" tab2)
             ("Tab 3" tab3))
    :print-function 'first
    :visible-child-function 'second
    :visible-max-width nil
    :visible-max-height nil)
   (tab1
    column-layout
    '(t1-input))
   (tab2
    row-layout
    '(t2-input1 t2-input2))
   (tab3
    row-layout
    '(t3-input t3-radio)))

  (:default-initargs
   :best-height 400
   :best-width 375
   :layout 'top-layout
   :title "Sample"
   :auto-menus nil))

(defun show-sample ()
  (display-dialog (make-instance 'sample-dialog)))

;;--------------------------------------------------------

Moving from "tab 1" to "tab 2" works fine, but moving to "tab 3" causes the dialog minimize/maximize buttons to appear.  If you change the "tab 2" layout from row-layout to column-layout, then the minimize/maximize buttons will also show up when going from "tab 1" to "tab 2".  Although "tab 3" uses a row-layout, I'm guessing that the radio-button-panel uses a column layout internally.  Maybe someone at LispWorks could check into this.

BTW, I've been testing with LWW 4.4.6.

Jon

Re: Using capi:tab-layout in a dialog


FWIW adding size constraints to the layouts stops the dialog 
minimize/maximize buttons appearing - see code below.

I think it would be useful if the CAPI had support for making the tab 
dialogs the same size without you having to specify what the size is. Other 
layouts support this via the :uniform-size-p initarg but I don't think 
there is a mechanism for tab-layout. Does anyone knows of a way to do this ?

cheers

paulm

(define-interface sample-dialog ()
   ()
   (:panes
    (t1-input
     text-input-pane)
    (t2-input1
     text-input-pane)
    (t2-input2
     text-input-pane)
    (t3-input
     text-input-pane)
    (t3-radio
     radio-button-panel
     :items '("one" "two" "three"))
    (ok-cancel-buttons
     push-button-panel
     :cancel-button "Cancel"
     :default-button "OK"
     :items '("OK" "Cancel")
     :callbacks '(abort-dialog abort-dialog)
     :callback-type :interface
     :layout-args '(:x-uniform-size-p t)))

   (:layouts
    (top-layout
     column-layout
     '(tabs ok-cancel-buttons)
     :x-adjust :right)
    (tabs
     tab-layout
     ()
     :items '(("Tab 1" tab1)
              ("Tab 2" tab2)
              ("Tab 3" tab3))
     :print-function 'first
     :visible-child-function 'second)
    (tab1
     column-layout
     '(t1-input)
     :visible-min-width 350
     :visible-min-height 280
     :visible-max-width t
     :visible-max-height t)
    (tab2
     column-layout ;;row-layout
     '(t2-input1 t2-input2)
     :visible-min-width 350
     :visible-min-height 280
     :visible-max-width t
     :visible-max-width t)
    (tab3
     row-layout
     '(t3-input t3-radio)
     :visible-min-width 350
     :visible-min-height 280
     :visible-max-width t
     :visible-max-width t))

   (:default-initargs
    :best-height 400
    :best-width 375
    :layout 'top-layout
    :title "Sample"
    :auto-menus nil))


At 19:25 07/04/2006, Jon Israelson wrote:
>OK, I've finally had some time to play around with this, and I'm starting 
>to think that there is a problem with column-layout when used in a tabbed 
>dialog.  I simplified my sample code to the bare basics and removed almost 
>all sizing constraints, but still get some odd behavior.  Here's the code:
>
>;--------------------------------------------------------
>
>(in-package :capi)
>
>(define-interface sample-dialog ()
>   ()
>   (:panes
>    (t1-input
>     text-input-pane)
>    (t2-input1
>     text-input-pane)
>    (t2-input2
>     text-input-pane)
>    (t3-input
>     text-input-pane)
>    (t3-radio
>     radio-button-panel
>     :items '("one" "two" "three"))
>    (ok-cancel-buttons
>     push-button-panel
>     :cancel-button "Cancel"
>     :default-button "OK"
>     :items '("OK" "Cancel")
>     :callbacks '(abort-dialog abort-dialog)
>     :callback-type :interface
>     :layout-args '(:x-uniform-size-p t)))
>
>   (:layouts
>    (top-layout
>     column-layout
>     '(tabs ok-cancel-buttons)
>     :x-adjust :right)
>    (tabs
>     tab-layout
>     ()
>     :items '(("Tab 1" tab1)
>              ("Tab 2" tab2)
>              ("Tab 3" tab3))
>     :print-function 'first
>     :visible-child-function 'second
>     :visible-max-width nil
>     :visible-max-height nil)
>    (tab1
>     column-layout
>     '(t1-input))
>    (tab2
>     row-layout
>     '(t2-input1 t2-input2))
>    (tab3
>     row-layout
>     '(t3-input t3-radio)))
>
>   (:default-initargs
>    :best-height 400
>    :best-width 375
>    :layout 'top-layout
>    :title "Sample"
>    :auto-menus nil))
>
>(defun show-sample ()
>   (display-dialog (make-instance 'sample-dialog)))
>
>;--------------------------------------------------------
>
>Moving from "tab 1" to "tab 2" works fine, but moving to "tab 3" causes 
>the dialog minimize/maximize buttons to appear.  If you change the "tab 2" 
>layout from row-layout to column-layout, then the minimize/maximize 
>buttons will also show up when going from "tab 1" to "tab 2".  Although 
>"tab 3" uses a row-layout, I'm guessing that the radio-button-panel uses a 
>column layout internally.  Maybe someone at LispWorks could check into this.
>
>BTW, I've been testing with LWW 4.4.6.
>
>Jon



Re: Using capi:tab-layout in a dialog

Paul,

Thanks for your help; your solution takes care of my problem.  I guess that I need to spend some more time looking at how the various width and height settings interact.

Jon

On 4/9/06, Paul Miller <paulm@xanalys.com> wrote:

FWIW adding size constraints to the layouts stops the dialog
minimize/maximize buttons appearing - see code below.

I think it would be useful if the CAPI had support for making the tab
dialogs the same size without you having to specify what the size is. Other
layouts support this via the :uniform-size-p initarg but I don't think
there is a mechanism for tab-layout. Does anyone knows of a way to do this ?

cheers

paulm

(define-interface sample-dialog ()
   ()
   (:panes
    (t1-input
     text-input-pane)
    (t2-input1
     text-input-pane)
    (t2-input2
     text-input-pane)
    (t3-input
     text-input-pane)
    (t3-radio
     radio-button-panel
     :items '("one" "two" "three"))
    (ok-cancel-buttons
     push-button-panel
     :cancel-button "Cancel"
     :default-button "OK"
     :items '("OK" "Cancel")
     :callbacks '(abort-dialog abort-dialog)
     :callback-type :interface
     :layout-args '(:x-uniform-size-p t)))

   (:layouts
    (top-layout
     column-layout
     '(tabs ok-cancel-buttons)
     :x-adjust :right)
    (tabs
     tab-layout
     ()
     :items '(("Tab 1" tab1)
              ("Tab 2" tab2)
              ("Tab 3" tab3))
     :print-function 'first
     :visible-child-function 'second)
    (tab1
     column-layout
     '(t1-input)
     :visible-min-width 350
     :visible-min-height 280
     :visible-max-width t
     :visible-max-height t)
    (tab2
     column-layout ;;row-layout
     '(t2-input1 t2-input2)
     :visible-min-width 350
     :visible-min-height 280
     :visible-max-width t
     :visible-max-width t)
    (tab3
     row-layout
     '(t3-input t3-radio)
     :visible-min-width 350
     :visible-min-height 280
     :visible-max-width t
     :visible-max-width t))

   (:default-initargs
    :best-height 400
    :best-width 375
    :layout 'top-layout
    :title "Sample"
    :auto-menus nil))


At 19:25 07/04/2006, Jon Israelson wrote:
>OK, I've finally had some time to play around with this, and I'm starting
>to think that there is a problem with column-layout when used in a tabbed
>dialog.  I simplified my sample code to the bare basics and removed almost
>all sizing constraints, but still get some odd behavior.  Here's the code:
>
>;;--------------------------------------------------------
>
>(in-package :capi)
>
>(define-interface sample-dialog ()
>   ()
>   (:panes
>    (t1-input
>     text-input-pane)
>    (t2-input1
>     text-input-pane)
>    (t2-input2
>     text-input-pane)
>    (t3-input
>     text-input-pane)
>    (t3-radio
>     radio-button-panel
>     :items '("one" "two" "three"))
>    (ok-cancel-buttons
>     push-button-panel
>     :cancel-button "Cancel"
>     :default-button "OK"
>     :items '("OK" "Cancel")
>     :callbacks '(abort-dialog abort-dialog)
>     :callback-type :interface
>     :layout-args '(:x-uniform-size-p t)))
>
>   (:layouts
>    (top-layout
>     column-layout
>     '(tabs ok-cancel-buttons)
>     :x-adjust :right)
>    (tabs
>     tab-layout
>     ()
>     :items '(("Tab 1" tab1)
>              ("Tab 2" tab2)
>              ("Tab 3" tab3))
>     :print-function 'first
>     :visible-child-function 'second
>     :visible-max-width nil
>     :visible-max-height nil)
>    (tab1
>     column-layout
>     '(t1-input))
>    (tab2
>     row-layout
>     '(t2-input1 t2-input2))
>    (tab3
>     row-layout
>     '(t3-input t3-radio)))
>
>   (:default-initargs
>    :best-height 400
>    :best-width 375
>    :layout 'top-layout
>    :title "Sample"
>    :auto-menus nil))
>
>(defun show-sample ()
>   (display-dialog (make-instance 'sample-dialog)))
>
>;;--------------------------------------------------------
>
>Moving from "tab 1" to "tab 2" works fine, but moving to "tab 3" causes
>the dialog minimize/maximize buttons to appear.  If you change the "tab 2"
>layout from row-layout to column-layout, then the minimize/maximize
>buttons will also show up when going from "tab 1" to "tab 2".  Although
>"tab 3" uses a row-layout, I'm guessing that the radio-button-panel uses a
>column layout internally.  Maybe someone at LispWorks could check into this.
>
>BTW, I've been testing with LWW 4.4.6.
>
>Jon



Updated at: 2020-12-10 08:48 UTC