Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Resize composites.(How calculate available space.)
Resize composites. [message #495525] Thu, 05 November 2009 09:12
David Crecente is currently offline David CrecenteFriend
Messages: 18
Registered: July 2009
Junior Member
Hi all!,
I've been fighting with a problem for two days and I can't fix it.

What I need:

1. When the screen is shown I need to show several bars with information. These bars need to get all the available space (It could be that sometimes they have 800 px or 1100 px or...). And the information's size drawn in the bars is calculated depending on the space available.

2. If the screen changes its size the bars must update its size as well. And the information's size shown in the bars needs to be calculated again.

Components I use:

* Composite
* MigLayout

Some constraints I've tried:
* fillx, growx, pushx

I've been focused in computeSize and constraints of MigLayout.

I don't know is this kind of behaviour is possible.
At this moment I've got the bars change its size but the veritcal height is failing.

I think that my main problem is that I can't do any calculation because of the layouts and computeSize are calculated before the layout appear and take its sizet. And I need to know how many space is available before.

The bars are situated in a custom composite:

public class ExpandableComposite extends Composite {
......

public ExpandableComposite (Composite parent, int style) {
super(parent, style);
}

/* (non-Javadoc)
* @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean)
*/
@Override
public Point computeSize(int wHint, int hHint) {
Point pMe = super.computeSize(wHint, hHint);
Point pParent = this.getParent().getSize();

int x = (pParent .x-anchoDescontar_ > 0)? pParent .x-(a number): pParent .x;
int y = (pMe .y-altoDescontar_ > 0)? pMe .y-(a number): pMe .y;

return new Point(x, y);
}

/* (non-Javadoc)
* @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean)
*/
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
Point pMe = super.computeSize(wHint, hHint, changed);
Point pParent = this.getParent().getSize();

int x = (pParent .x-(a number)> 0)? pParent .x-(a number): pParent .x;
int y = (pMe .y-(a number)> 0)? pMe .y-(a number): pMe .y;

return new Point(x, y);
}

Even I don't think that the above code is right because the child is calling to the computeSize method in the parent to know how many space is available. But it's working right now but the height that doesn't work well.

Any suggestion about my current code or any other point of view about this problem will be appreciated.

Thanks in advance.
Previous Topic:Button loses selection event after disabled it
Next Topic:FIRE/PROPAGATE EVENTS TO SPECIFIC CONTROLS
Goto Forum:
  


Current Time: Fri Apr 19 01:18:53 GMT 2024

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

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

Back to the top