PDA

View Full Version : Does LayoutContainer suppose to inherit styles from the parent?



plitvak
19 Jun 2008, 6:09 AM
If I have a parent LayoutContainer with let say background-color:blue; does the child container(s) suppose to inherit this setting?
For some reason I thought it was inheriting the style in myGWT but I could be mistaking.

darrellmeyer
22 Jun 2008, 9:51 PM
The background will be visible within the child component as long as the child component does not specify a background. I would recommend using Firebug for Firefox when investigation any of these types of issues. It will show you what styles are applied to each element and where the style definition is located.

plitvak
23 Jun 2008, 4:10 AM
I figured out the source of the confusion.
The BorderLayout sets its own style (including background color) to the components it lays out (target.addStyleName("x-border-layout-ct"); ). So if I have a child container that uses BorderLayout and don't set background explicitly that child component will not inherit background from the parent but rather will be forced to the "x-border-layout-ct".
Is this expected behaviour?

darrellmeyer
23 Jun 2008, 7:07 AM
Yes. BorderLayout sets a background color, and this color will be visible to any children without a background specified.

sdc
26 Jun 2008, 5:33 AM
Should we really expect from a BorderLayout that it sets the container background ? If you ask me, I would say no. Do I miss something ?

zaccret
10 Sep 2008, 1:15 AM
Yes, this is really confusing. I don't remember such behaviour in Swing or SWT.

sdc
2 Dec 2008, 3:33 AM
At least, this is now explained in the Javadoc (in the SVN).
Quote from BorderLayout javadoc :

* <p /> Be default, this layout adds a CSS style to the parent container
* (defaults to 'x-border-layout-ct') which gives the container a background
* color.