PDA

View Full Version : MarginData + Padding extends Margins



Arno.Nyhm
27 Aug 2009, 5:15 AM
i see there is a MarginData:

MarginData (http://extjs.com/forum/../deploy/gxtdocs/com/extjs/gxt/ui/client/widget/layout/MarginData.html#MarginData%28com.extjs.gxt.ui.client.util.Margins%29)(Margins (http://extjs.com/forum/../deploy/gxtdocs/com/extjs/gxt/ui/client/util/Margins.html) margins)


and a Padding:
public class Paddingextends Margins (http://extjs.com/forum/../deploy/gxtdocs/com/extjs/gxt/ui/client/util/Margins.html)

so i can theoreticaly add also the Padding to MarginData. but this is not used in layout... :-?

Layout.java:266

LayoutData data = component.getLayoutData();
if (data != null && data instanceof MarginData) {
MarginData ld = (MarginData) data;
applyMargins(component.el(), ld.getMargins());
}

so why is there no PaddingData...


and next question: what if i like to have Paddings AND Margins? then i need 2 panels?

sven
27 Aug 2009, 5:19 AM
Padding and Margins are two completly different things. Only layouts that need to handle this are handling it.

Arno.Nyhm
27 Aug 2009, 6:48 AM
yes.


but i think this is possible for example - and it is a allowed syntax:

i take this from HBoxLayoutExample:


LayoutContainer c = new LayoutContainer();
HBoxLayout layout = new HBoxLayout();
layout.setPadding(new Padding(5));
layout.setHBoxLayoutAlign(HBoxLayoutAlign.TOP);
c.setLayout(layout);

c.add(new Button(button1Text), new HBoxLayoutData(new Margins(0, 5, 0, 0)));

c.add(new Button(button1Text), new HBoxLayoutData(new Padding(0, 5, 0, 0))); // <----- this is possible!

and when its possible it should be used.

Arno.Nyhm
27 Aug 2009, 7:07 AM
it makes more sense like this:


Margins extends Region
Padding extends Region

or


abstract Spacing extends Region
Margins extends Spacing
Padding extends Spacing

Arno.Nyhm
10 Nov 2009, 9:21 AM
i am still interested in having proper Paddings and Margins ;-)


i used in the old gwt-ext library the methods setPaddings / setMargins many times.

i see in GXT is a Paddings and a Margins object also in Layout is there a applyMargins / applyPaddings methods.

instead of writing
myComponent.setStyleAttribute("padding", "10px 10px 10px 10px");“ it would be nice to use this already existing Objects / Functions.

something like
myComponent.setStyle(new Paddings(10))

i think this looks cleaner like setting it with the setStyleAttribute.