Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Equally sized widgets
Equally sized widgets [message #465148] Tue, 06 December 2005 22:05 Go to next message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
I have several windows/shells which contain several similar components
aligned vertically in a one-line GridLayout. Currently, the dimensions of
these widgets depend on their contents (in my case, they're all composites
containing a table and two buttons, with very different contents for the
tables). For example, if two tables are empty and the third one contains a
long list, the first two widgets get so small that the buttons disappear.

What I'd need is a way to assign weights to the widgets so that all three
widgets always have the same height. (I can't use fixed sizes as I'm
working on a 1920x1200 GTK system with the targets being Windows systems
with 800x600 or 1024x768 resolutions).

Any ideas are welcome.

Thx,
Marian.

--
Hofstadter's law: "It always takes longer than you think, even when you take
account of Hofstadter's law".
Re: Equally sized widgets [message #465150 is a reply to message #465148] Tue, 06 December 2005 22:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Try FillLayout instead (set its fillayout.type = FillLayout.VERTICAL).

This will make them all the same size, they will as wide as the widest
one and as tall as the tallest one.

Marian Schedenig wrote:
> I have several windows/shells which contain several similar components
> aligned vertically in a one-line GridLayout. Currently, the dimensions of
> these widgets depend on their contents (in my case, they're all composites
> containing a table and two buttons, with very different contents for the
> tables). For example, if two tables are empty and the third one contains a
> long list, the first two widgets get so small that the buttons disappear.
>
> What I'd need is a way to assign weights to the widgets so that all three
> widgets always have the same height. (I can't use fixed sizes as I'm
> working on a 1920x1200 GTK system with the targets being Windows systems
> with 800x600 or 1024x768 resolutions).
>
> Any ideas are welcome.
>
> Thx,
> Marian.
>

--
Thanks,
Rich Kulp
Re: Equally sized widgets [message #465152 is a reply to message #465150] Tue, 06 December 2005 23:01 Go to previous messageGo to next message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Rich Kulp wrote:

> Try FillLayout instead (set its fillayout.type = FillLayout.VERTICAL).
>
> This will make them all the same size, they will as wide as the widest
> one and as tall as the tallest one.

That works fine (SWT.VERTICAL instead of FillLayout.VERTICAL), except for
one problem, which I admittedly forgot to mention before: Above each of my
three table containers I also have a Text label, which of course should
keep its default height. I suppose I could add another layer of composites
two group each label/table pair and have those get the same height through
FillLayout, but perhaps there is another way?

Thanks,
Marian.

--
Hofstadter's law: "It always takes longer than you think, even when you take
account of Hofstadter's law".
Re: Equally sized widgets [message #465159 is a reply to message #465152] Wed, 07 December 2005 08:41 Go to previous messageGo to next message
Stefan Langer is currently offline Stefan LangerFriend
Messages: 236
Registered: July 2009
Senior Member
Either use GridLayout with equals column size or switch to FormLayout
and specify a percentage in vertical direction.

Regards
Stefan

Marian Schedenig wrote:
> Rich Kulp wrote:
>
>
>>Try FillLayout instead (set its fillayout.type = FillLayout.VERTICAL).
>>
>>This will make them all the same size, they will as wide as the widest
>>one and as tall as the tallest one.
>
>
> That works fine (SWT.VERTICAL instead of FillLayout.VERTICAL), except for
> one problem, which I admittedly forgot to mention before: Above each of my
> three table containers I also have a Text label, which of course should
> keep its default height. I suppose I could add another layer of composites
> two group each label/table pair and have those get the same height through
> FillLayout, but perhaps there is another way?
>
> Thanks,
> Marian.
>
Re: Equally sized widgets [message #465196 is a reply to message #465148] Thu, 08 December 2005 03:00 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
Play around with GridData (specifically grabHorizontalSpace and horizontalAlignment = SWT.FILL).
Re: Equally sized widgets [message #465297 is a reply to message #465159] Thu, 08 December 2005 17:01 Go to previous messageGo to next message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Stefan Langer wrote:

> Either use GridLayout with equals column size or switch to FormLayout
> and specify a percentage in vertical direction.

Column sizes won't help me, since I only have one column... it's the row
sizes I have trouble with. I'll play around with FormLayout though.

Thanks,
Marian.

--
Hofstadter's law: "It always takes longer than you think, even when you take
account of Hofstadter's law".
Re: Equally sized widgets [message #465299 is a reply to message #465196] Thu, 08 December 2005 17:03 Go to previous messageGo to next message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Daniel Spiewak wrote:

> Play around with GridData (specifically grabHorizontalSpace and
> horizontalAlignment = SWT.FILL).

It would have to be the vertical equivalents (I'm trying to get equal
heights, the widths are fine), but I've had no success with that when I
tried it before my original post.

*Should* I be able to do this with GridLayout & GridData at all? I would
like to stick with these, but it seems to me they just don't support my
special case.

Thx,
Marian.

--
Hofstadter's law: "It always takes longer than you think, even when you take
account of Hofstadter's law".
Re: Equally sized widgets [message #465301 is a reply to message #465299] Thu, 08 December 2005 17:41 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
GridData#grabVerticalSpace
GridData#verticalAlignment = SWT.FILL

That should give you equal heights if you assign that to every widget in the row. If it's different rows, then you'll have to do:

GridData#verticalHint = height // or heightHint? can't remember

Then you'll have to override the computeSize(int, int, boolean) method in each widget (make sure you override checkSubclass() to return true as well) and have it return the height hint as Point#y if i the height hint is not SWT.DEFAULT. Point#x should be the value of super.computeSize(int, int, boolean).x and if the value of heightHint is SWT.DEFAULT, then Point#y should be the value of super.computeSize(int, int, boolean).y

Sorry about the verbose psuedo code, I didn't want to take the time to actually develop a full fledged demo. Any help?
Re: Equally sized widgets [message #465365 is a reply to message #465301] Sat, 10 December 2005 14:56 Go to previous messageGo to next message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Daniel Spiewak wrote:

> If it's different rows, then you'll have to do:

Yes, that's what I want, perhaps I didn't explain properly.

> GridData#verticalHint = height // or heightHint? can't remember
>
> Then you'll have to override the computeSize(int, int, boolean) method in
> each widget (make sure you override checkSubclass() to return true as
> well) and have it return the height hint as Point#y if i the height hint
> is not SWT.DEFAULT.

That would give me fixed heights, specified in pixels. What I want is
different heights equally derived from the window height (also because I'm
coding on a very different system from the target system, so pixel heights
would probably cause trouble, aside from the fact that I generally dislike
fixed-size windows).

I guess I should simply look either into FormLayout or derive my own
GridLayout class which supports relative weights ala Swing's GridLayout.

Thanks for your detailed explanation though. :)
Marian.

--
Hofstadter's law: "It always takes longer than you think, even when you take
account of Hofstadter's law".
Re: Equally sized widgets [message #465367 is a reply to message #465365] Sun, 11 December 2005 01:36 Go to previous message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
There's always a resize listener. Have you tried that?
Previous Topic:CheckboxTableViewer and selection event
Next Topic:ViewForm Close Button
Goto Forum:
  


Current Time: Fri Apr 19 00:40:50 GMT 2024

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

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

Back to the top