Hi Melody,
I can see your UI now, which as you say is big help understanding
where you are coming from.
> Also the CSS styles cannot be static. I have a web designer who is
> responsible for setting the CSS and styling the application. It would
> be a travesty for me to have to ask him not to set margins and padding
> and borders (especially borders) just because the application cannot
> size itself correctly.
I think you should reconsider this view. Unlike the old JSP/Struts
situation where there was a pretty good division of responsibility
between "java programmers" and "web page designers" in GWT there isn't
really. I think it is fine for your web designer to for example knock
up HTML prototypes of the desired UI layout, but after that I think
you should work together within GWT on how to implement it (and don't
give up!). I just don't think it's viable for your web designer to
change e.g. CSS properties independently and expect your GWT code to
accommodate it just like that.
I can see exactly why you want to grab the CSS padding/margin/border
settings programmatically for resizing algorithms. I tried to do this
too originally but I couldn't find a way to do it either, so where I
needed to know the size of these decorations, I used constants to
reflect the CSS values. Because I hated copying values like this, I
got very niggardly about it, and this led to me working out how to
reduce and simplify the algorithms necessary to resize the UI and get
the right fit across the browsers. I got rid of most of them in the
end.
> Also I hear you about fixing the size of the app. I dont think it
> would fly so we have indeed labored to ensure that whatever the user
> does to resize the app, the containers and widgets inside them do
> resize correctly to fit.
Bear in mind that once you get the thing right (which may take a bit
of experimentation) you will probably find a) you can certainly do
what you want and b) it will probably be simpler than you fear it will
be at the moment. Don't give up.
> As for quirks mode, no I dont specifially need quirks mode but I have
> run into some more problems when I removed the quirks mode. Maybe
> someday we will move to standards mode when IE (6 7,8 and newer)
> interpret standards mode correctly without hassles.
I think stick with quirks mode - I've just been looking at a
discussion over on the contributors group about strict mode issues,
and it seems to be a nightmare. I don't think it's a way forward for
you here.
> Maybe a quick peek at the application my help you see what I am
> dealing with.
>
Yep, I think you may have fallen into something like the same traps I
did last autumn doing something similar. Basically I didn't realize a)
that getting widgets to size up correctly is not straight forward, and
b) the real shocker, that the browsers didn't behave the same way
doing it.
What I do now, having been severely bitten on the backside myself by
this, is to follow this procedure:
1) Design the principle layout components up front. I use pencil,
paper and rubber, but HTML editors are good for this too. By this I
mean a primary container for the layout (say a DockPanel) and the the
main secondary components (e.g. a header for tool bars/menus/logos
etc), a navigation section, a main data display panel, and a footer).
2) Especially identify any a) Horizontal/VerticalSplitPanels,
StackPanels and internal ScrollPanels needed as these are the most
difficult to get right
3) Build a main Composite class based on, say, DockPanel, that will
manage the main secondary components.
4) Build a set of secondary Composites for the main UI elements that
will act primarily as containers for the real widgets.
5) Build a set of test widgets to mock up what will eventually be used
- by this I mean things like an example Tree, a Table, a StackPanel
etc.
6) Work on the styling of this framework to get the look I want
7) Test this framework extensively against all browsers for resizing
and styling problems until it's right.
I find that if these secondary components are managed within the
primary container, a single sizing method can manage all of them
mostly driven from a resize listener.Once you have this main resizing
method working correctly so all the main "container boxes" look and
resize right, most widgets can be coaxed into filling their containers
properly on the basis of simple percentage widths and heights.
The exception is ScrollPanels. For example in your app you seem to
have a navigation tree top left, and you have a set of navigation
buttons bottom left. So if the tree gets big I assume you will want to
put it in a ScrolPanel so that the buttons don't scroll off the bottom
of the screen. AFAIK you have to give ScrollPanels a straight pixel
value for height (width is OK percentage-wise though) so in this case
you would need to cascade a ScrollPanel.setHeight(..) instruction from
the main resizing method to get the Tree to scroll properly within
it's alloted container.
Also I note you haven't used Horizontal/VerticalSplitPanels: if there
is any danger of you wanting to introduce some of these then I think
you should do so now rather than later. They take some controlling
because they have their own internal ScrollPanels which you often want
to override.
Anyway, to continue my story, I got myself into a hell of a mess over
this. My code was all over the place as a disparately tried to get the
thing to resize properly but once I found that fixing one problem
caused another problem to pop up (sort of "whack-a-rat" style) I
stopped and decided to cut my losses and start over a new iteration as
I described above. In fact it only took me about two days to get the
outer framework working right across the browsers, and I found I could
reuse most of what I had written before for the trees, tabs, tables
etc and just slot it in. In the end I had a working app that looked
much better, had about 25% less code that was _much_ more readable.
Actually to be a bit more precise about this, what I did was to start
a new project to figure out how to get the main framework to resize
properly with the intention of refactoring the lessons learned back
into the original project (to get round the "whack-a-rat" problem).
However I was so pleased with the structure of the new code I that I
did it the other way round.
Anyway, I hope these ramblings are of some help. Remember Martin
Fowler's first law of refactoring: where it is clear that a system
would benefit from refactoring, and there is a danger management won't
agree to it, don't tell them.
regards
gregor