What does setWidth("*") do in CSS / SmartGWT?
I've come across some legacy code which uses SmartGWT. I suspect the API is present in standard GWT too.
widget.setWidth("*");
Keeping in mind that the same bit of code has:
otherWidget.setWidth100();
I'm not aware that CSS has a开发者_开发百科nything like:
width: *;
So... is this code legitimate and if so what does it do... or not?!
Thanks in advance.
In SmartGWT .setWidth("*")
means take up the rest of the available width. For example, if you have a HPanel
with two children and one of the children has setWidth("10%")
then implicitly the child with setWidth("*"
) will have 90% width. This allows you to change the width of one child without having to update the other setWidth
call.
Consider that you have a Panel
with two children. Now if you set setWidth("*")
for both child then the first child will take the required width and the second child will get whatever is left.
If you set setWidth("60%")
for the first child and setWidth("*")
for the second child then first child will take 60% of the width of the Panel and the second child will get the remaining 40%.
.setWidth100();
and .setHeight100();
these 2 make the component fill the canvas it is in. This mean set width & height 100% which is equivalent to setWidth("100%")
and setHeight("100%")
respectively.
This is basically used when you don't specifically want to set the widths of the child panel's. You specify a rough width of the first child panel and the width of the second child is automatically set.
精彩评论