I'm trying to get a list-box% subclass to work with min-widths and
percentage values, but I'm unable to figure out the correct total width
to calculate the actual widths.

Inside the listbox, I store the percentages in percentages and the
minimum-widths in minimum-widths:

(define/override (on-size width height)
      (set-column-dimensions))
    
(define (set-column-dimensions)
  (let-values (((w h) (get-client-size)))
    (for ([min-width (in-list minimum-widths)]
          [perc (in-list percentages)]
          [i (in-naturals)])
      (let ((perc-width (truncate (* w (/ perc 100)))))
        (set-column-width i (if (< perc-width min-width)
                              min-width
                              perc-width)
                          min-width
                          w)))))

But with this code I get errors like "set-column-width in list-box%:
given size is greater than maximum size given: 715 maximum: 596"

Question 1: get-client-size does not seem to return the maximum width of
all columns, probably because of the scrollbar. How do I get the
maximum width of all columns?

Question 2: Is on-size the right place to set the actual width
computed from the percentages?

Another problem is a bit more tricky. I believe I should calculate any
remaining percentage widths on the basis of the maximum total column
width minus the actual widths already fixed, since min-width is used
whenever perc-width is too small. I'll save that for later, though, and
would be happy if somebody could help me with calculating perc-width
correctly first.

Best,

Erich

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to