Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » FormLayout calculating location of formData.bottom
FormLayout calculating location of formData.bottom [message #461765] Thu, 29 September 2005 19:18 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
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 Go to previous message
Eclipse UserFriend
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
>
>
>
Previous Topic:ModalContext.run error
Next Topic:StyledText(ScrollBars problem)
Goto Forum:
  


Current Time: Thu Oct 19 09:32:26 GMT 2017

Powered by FUDForum. Page generated in 0.01703 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software