Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT and Form Layout - Problems ?
XWT and Form Layout - Problems ? [message #570370] Fri, 12 March 2010 17:22 Go to next message
Frank Gualtieri is currently offline Frank Gualtieri
Messages: 20
Registered: February 2010
Junior Member
I am trying to use a FormLayout in XWT and have have limitted success. For instance the code below works as expected.

That is: attach the top of button1 to the bottom of button0
attach the left side of button 1 to the left side of button 0 + 10 pixels
attach the right side of button0 to the right side of its parent

<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt"
xmlns:c="clr-namespace:sample.hello"
xmlns:j="clr-namespace:java.lang"
x:Class="sample.hello.HelloWorld"
bounds="0,0,449,171">
<Composite.layout>
<FormLayout />
</Composite.layout>
<Button text="Button Two is attached to me" selectionEvent="sayHello" name="button0">
<Button.layoutData>
<FormData top="0,40" left="0,100"/>
</Button.layoutData>
</Button>
<Button text="Button Two" x:style="SWT.PUSH" selectionEvent="sayHello" name="button1">
<Button.layoutData>
<!--Explanation of FormData *************************************************
attach the top of button1 to the bottom of button0
attach the left side of button 1 to the left side of button 0 + 10 pixels
attach the right side of button0 to the right side of its parent
************************************************************ **************-- >
<FormData
top="{FormAttachment control={Binding ElementName=button0}, alignment=SWT.BOTTOM, offset=0}"
left="{FormAttachment control={Binding ElementName=button0}, alignment=SWT.LEFT, offset=10}"
right="100,-10"/>
</Button.layoutData>
</Button>
</Composite>

BUT I WOULD THINK that the code below would have the same result at the code above but it does not (matter of fact I don't even see button1:

<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt"
xmlns:c="clr-namespace:sample.hello"
xmlns:j="clr-namespace:java.lang"
x:Class="sample.hello.HelloWorld"
bounds="0,0,449,171">
<Composite.layout>
<FormLayout />
</Composite.layout>



<Button text="Button Two is attached to me" selectionEvent="sayHello" name="button0">
<Button.layoutData>
<FormData top="0,40" left="0,100"/>
</Button.layoutData>
</Button>
<Button text="Button Two" x:style="SWT.PUSH" selectionEvent="sayHello" name="button1">
<Button.layoutData>
<!--Explanation of FormData *************************************************
attach the top of button1 to the bottom of button0
attach the left side of button 1 to the left side of button 0 + 10 pixels
attach the right side of button0 to the right side of its parent
************************************************************ **************-- >
<FormData
top="{FormAttachment control={Binding ElementName=button0}, alignment=SWT.BOTTOM, offset=0}"
left="{FormAttachment control={Binding ElementName=button0}, alignment=SWT.LEFT, offset=10}"
right="alignment=SWT.RIGHT, offset=-10}"/> <!- THIS LINE CHANGED FROM THE EXAMPLE ABOVE -->
</Button.layoutData>
</Button>

</Composite>

ALSO, if you use the first example but move button0 so it is is after the code for button1 then button1 doesn't seem to know about button0 at all (In SWT I can define a button, use it as a control and then define how it is layed out BUT in AWT it seems that a control must precede the element that it controls)...
For example I would expect that the code below should work exactly like the first example in this post but it does not... if there a way to define an element without "laying it out" and then reference it later on and layo it out ?

<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt"
xmlns:c="clr-namespace:sample.hello"
xmlns:j="clr-namespace:java.lang"
x:Class="sample.hello.HelloWorld"
bounds="0,0,449,171">
<Composite.layout>
<FormLayout />
</Composite.layout>

<Button text="Button Two" x:style="SWT.PUSH" selectionEvent="sayHello" name="button1">
<Button.layoutData>
<!--Explanation of FormData *************************************************
attach the top of button1 to the bottom of button0
attach the left side of button 1 to the left side of button 0 + 10 pixels
attach the right side of button0 to the right side of its parent
************************************************************ **************-- >
<FormData
top="{FormAttachment control={Binding ElementName=button0}, alignment=SWT.BOTTOM, offset=0}"
left="{FormAttachment control={Binding ElementName=button0}, alignment=SWT.LEFT, offset=10}"
right="100,-10"/>
</Button.layoutData>
</Button>

<!--- WHEN button0 is defined after button1 then button1 does not know about button0...
CAN I Define button0 before button1 and then layit out later ? I've tried using creating an element
with name=button0 prior to creating button1 and then using that same name for the element after
defining button1 but that just adds an extra element-->
<Button text="Button Two is attached to me" selectionEvent="sayHello" name="button0">
<Button.layoutData>
<FormData top="0,40" left="0,100"/>
</Button.layoutData>
</Button>

</Composite>
Re: XWT and Form Layout - Problems ? [message #570410 is a reply to message #570370] Fri, 12 March 2010 23:54 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
Please report a bug in bugzilla !

Regards
Yves YANG
"Frank Gualtieri" <fgualtieri@promia.com> wrote in message
news:hneera$ii3$1@build.eclipse.org...
>I am trying to use a FormLayout in XWT and have have limitted success. For
>instance the code below works as expected.
>
> That is: attach the top of button1 to the bottom of button0 attach the
> left side of button 1 to the left side of button 0 + 10 pixels
> attach the right side of button0 to the right side of its
> parent
>
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> xmlns:c="clr-namespace:sample.hello"
> xmlns:j="clr-namespace:java.lang"
> x:Class="sample.hello.HelloWorld"
> bounds="0,0,449,171">
> <Composite.layout>
> <FormLayout />
> </Composite.layout> <Button text="Button Two is attached to me"
> selectionEvent="sayHello" name="button0">
> <Button.layoutData>
> <FormData top="0,40" left="0,100"/>
> </Button.layoutData> </Button>
> <Button text="Button Two" x:style="SWT.PUSH" selectionEvent="sayHello"
> name="button1">
> <Button.layoutData>
> <!--Explanation of FormData
> *************************************************
> attach the top of button1 to the bottom of button0 attach the left side of
> button 1 to the left side of button 0 + 10 pixels
> attach the right side of button0 to the right side of its parent
> ************************************************************
> **************-- >
> <FormData top="{FormAttachment control={Binding ElementName=button0},
> alignment=SWT.BOTTOM, offset=0}"
> left="{FormAttachment control={Binding ElementName=button0},
> alignment=SWT.LEFT, offset=10}"
> right="100,-10"/>
> </Button.layoutData> </Button>
> </Composite>
>
> BUT I WOULD THINK that the code below would have the same result at the
> code above but it does not (matter of fact I don't even see button1:
>
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> xmlns:c="clr-namespace:sample.hello"
> xmlns:j="clr-namespace:java.lang"
> x:Class="sample.hello.HelloWorld"
> bounds="0,0,449,171">
> <Composite.layout>
> <FormLayout />
> </Composite.layout>
>
>
> <Button text="Button Two is attached to me" selectionEvent="sayHello"
> name="button0">
> <Button.layoutData>
> <FormData top="0,40" left="0,100"/>
> </Button.layoutData> </Button>
> <Button text="Button Two" x:style="SWT.PUSH" selectionEvent="sayHello"
> name="button1">
> <Button.layoutData>
> <!--Explanation of FormData
> *************************************************
> attach the top of button1 to the bottom of button0 attach the left side of
> button 1 to the left side of button 0 + 10 pixels
> attach the right side of button0 to the right side of its parent
> ************************************************************
> **************-- >
> <FormData top="{FormAttachment control={Binding ElementName=button0},
> alignment=SWT.BOTTOM, offset=0}"
> left="{FormAttachment control={Binding ElementName=button0},
> alignment=SWT.LEFT, offset=10}"
> right="alignment=SWT.RIGHT, offset=-10}"/> <!- THIS LINE CHANGED FROM THE
> EXAMPLE ABOVE -->
> </Button.layoutData> </Button>
>
> </Composite>
>
> ALSO, if you use the first example but move button0 so it is is after the
> code for button1 then button1 doesn't seem to know about button0 at all
> (In SWT I can define a button, use it as a control and then define how it
> is layed out BUT in AWT it seems that a control must precede the element
> that it controls)...
> For example I would expect that the code below should work exactly like
> the first example in this post but it does not... if there a way to define
> an element without "laying it out" and then reference it later on and layo
> it out ?
>
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> xmlns:c="clr-namespace:sample.hello"
> xmlns:j="clr-namespace:java.lang"
> x:Class="sample.hello.HelloWorld"
> bounds="0,0,449,171">
> <Composite.layout>
> <FormLayout />
> </Composite.layout>
> <Button text="Button Two" x:style="SWT.PUSH" selectionEvent="sayHello"
> name="button1">
> <Button.layoutData>
> <!--Explanation of FormData
> *************************************************
> attach the top of button1 to the bottom of button0 attach the left side of
> button 1 to the left side of button 0 + 10 pixels
> attach the right side of button0 to the right side of its parent
> ************************************************************
> **************-- >
> <FormData top="{FormAttachment control={Binding ElementName=button0},
> alignment=SWT.BOTTOM, offset=0}"
> left="{FormAttachment control={Binding ElementName=button0},
> alignment=SWT.LEFT, offset=10}"
> right="100,-10"/>
> </Button.layoutData> </Button>
>
> <!--- WHEN button0 is defined after button1 then button1 does not know
> about button0...
> CAN I Define button0 before button1 and then layit out later ? I've tried
> using creating an element
> with name=button0 prior to creating button1 and then using that same name
> for the element after
> defining button1 but that just adds an extra element-->
> <Button text="Button Two is attached to me" selectionEvent="sayHello"
> name="button0">
> <Button.layoutData>
> <FormData top="0,40" left="0,100"/>
> </Button.layoutData> </Button>
>
> </Composite>
>
>
Previous Topic:e4 1.0M4: example psf still points to R0_9 and photo sample not compiling
Next Topic:XWT and Form Layout - Problems ?
Goto Forum:
  


Current Time: Thu Aug 28 19:15:45 EDT 2014

Powered by FUDForum. Page generated in 0.01779 seconds