[graphic-forms-devel] Layout workings?
Jack Unrue
jdunrue at gmail.com
Thu Sep 13 05:56:11 UTC 2007
On 9/9/07, Ken Perry <whistler at blinksoft.com> wrote:
>
> First I realize this is in alpha so if the answer is the layout mangier is
> not working fully that is fine. I just want to know how this is supposed to
> work.
You are right in two ways -- the whole thing needs much more
functionality, and there are bugs.
> If that is how it is supposed to work it is not. My list box is not the
> same length as the edit box let alone the edit box and label together.
>
> Can you take a look at this and tell me what I should be doing to line
> these controls up in this dialog?
I got something closer to what I think you were intending. My
revised version of your code is here:
http://lispwidgets.net/fruit2.lisp
Note that I used an in-package form at the top of the file, which
you may want to remove.
I changed the dialog's layout to be a border-layout. The top-panel
containing the fruit label and the edit control are placed in the top
region of the layout. The inner-panel containing the list-box is
placed in the center region. The btn-panel is placed in the bottom
region. These placements are accomplished using the setf function
for gfw:layout-attribute.
There is a bug in border-layout where spacing is not allocated to
the center region, so I had to cheat by setting a top-margin value
for the inner-layout.
The list-box is sized by a combination of setting a minimum-size
on the list-box and using a heap-layout for the inner-panel.
I got the buttons to be equal widths by including the :normalize
style for the btn-layout. This exercise revealed a second bug,
which is that I had to also include the :horizontal style keyword
explicitly, when in fact it should be the default anyway.
I realize that you had wanted the buttons to fill the available
space, but there is a limitation of the layout management system
in that I don't currently provide a way to get multiple children
to fill the available width (or height). The heap-layout sort of
works that way, but it's designed for just one visible child at a
time. Also, I don't currently provide a way to right-justify or
bottom-justify child elements within a panel. There are several
possible ways to provide these behaviors, but I haven't decided
which way to go yet. But this is why the buttons are still aligned
left in the btn-panel.
By the way, you had the :default-button style set on two of
the buttons. I changed it to just be the add button, but one
or the other is fine.
The general strategy for packing dialogs (and top-level windows)
is to allow child panels and controls to be sized according to their
preferred sizes, or set minimum or maximum sizes on them, and
let the size of the container be determined by that. You don't
want to explicitly set a size on the dialog for the scenario you
are trying to achieve.
Sorry for the long-winded reply, but there is one more comment
I should make. I totally understand that part of the issue here
is the difficulty in figuring how to use the layout managers.
Obviously I understand them, having written the code, but for
new folks it's not necessarily clear how it all fits together. This
is something I will improve over time, with better examples and
also better documentation. Not to mention bug fixes :-)
--
Jack Unrue
More information about the Graphic-forms-devel
mailing list