FormLayout calculating location of formData.bottom [message #461765] |
Thu, 29 September 2005 19:18 |
Eclipse User |
|
|
|
Originally posted by: tmcguire.go-integral.com
In building a form with the FormLayout, I spent a bunch of time this
morning trying to programatically set FormData.bottom on an element of
my form. I want a multi-lined text field with height of 40. I think I
should be able to use the numerator field of the FormAttachment for the
top of the control.
if (controlType.equals("text-multi")){
ctrl = new Text(frmComposite, SWT.MULTI);
FormData formData = new FormData();
formData.top = new FormAttachment(controlAbove,layoutMargin);
int t = formData.top.numerator; // this returns 0, why?
formData.bottom = new FormAttachment(t + 40, layoutMargin);
}
I see that numerator always returns 0 and denominator always returns 100.
Is this not the proper use of FormAttachment.numerator? If so, what
means can I use to calculate where the bottom of my text box would be?
right now, even though I say SWT.MULTI, I am getting a single line text box.
I'm brand new to SWT, so any hints would be great.
Tim
|
|
|
Re: FormLayout calculating location of formData.bottom [message #461767 is a reply to message #461765] |
Thu, 29 September 2005 19:52 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
To make your widget 40 pixels tall use formData.height = 40.
Numerator and denominator are only filled in if you use FormAttachment (int
numerator, int offset) or FormAttachment (int numerator, int denominator,
int offset) .
"Tim McGuire" <tmcguire@go-integral.com> wrote in message
news:dhhekp$nd7$1@news.eclipse.org...
> In building a form with the FormLayout, I spent a bunch of time this
> morning trying to programatically set FormData.bottom on an element of my
> form. I want a multi-lined text field with height of 40. I think I
> should be able to use the numerator field of the FormAttachment for the
> top of the control.
>
> if (controlType.equals("text-multi")){
> ctrl = new Text(frmComposite, SWT.MULTI);
> FormData formData = new FormData();
> formData.top = new FormAttachment(controlAbove,layoutMargin);
> int t = formData.top.numerator; // this returns 0, why?
> formData.bottom = new FormAttachment(t + 40, layoutMargin);
> }
>
> I see that numerator always returns 0 and denominator always returns 100.
> Is this not the proper use of FormAttachment.numerator? If so, what means
> can I use to calculate where the bottom of my text box would be?
>
> right now, even though I say SWT.MULTI, I am getting a single line text
> box.
>
> I'm brand new to SWT, so any hints would be great.
> Tim
|
|
|
Re: FormLayout calculating location of formData.bottom [message #461810 is a reply to message #461767] |
Fri, 30 September 2005 14:04 |
Eclipse User |
|
|
|
Originally posted by: tmcguire.go-integral.com
Thanks! That is what I was looking for.
Tim
Veronika Irvine wrote:
> To make your widget 40 pixels tall use formData.height = 40.
>
> Numerator and denominator are only filled in if you use FormAttachment (int
> numerator, int offset) or FormAttachment (int numerator, int denominator,
> int offset) .
>
> "Tim McGuire" <tmcguire@go-integral.com> wrote in message
> news:dhhekp$nd7$1@news.eclipse.org...
>
>>In building a form with the FormLayout, I spent a bunch of time this
>>morning trying to programatically set FormData.bottom on an element of my
>>form. I want a multi-lined text field with height of 40. I think I
>>should be able to use the numerator field of the FormAttachment for the
>>top of the control.
>>
>>if (controlType.equals("text-multi")){
>>ctrl = new Text(frmComposite, SWT.MULTI);
>>FormData formData = new FormData();
>>formData.top = new FormAttachment(controlAbove,layoutMargin);
>>int t = formData.top.numerator; // this returns 0, why?
>>formData.bottom = new FormAttachment(t + 40, layoutMargin);
>>}
>>
>>I see that numerator always returns 0 and denominator always returns 100.
>>Is this not the proper use of FormAttachment.numerator? If so, what means
>>can I use to calculate where the bottom of my text box would be?
>>
>>right now, even though I say SWT.MULTI, I am getting a single line text
>>box.
>>
>>I'm brand new to SWT, so any hints would be great.
>>Tim
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.01826 seconds