Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How is it possible to layout shell with CoolBar in?
How is it possible to layout shell with CoolBar in? [message #436395] Tue, 18 May 2004 12:05 Go to next message
Eclipse UserFriend
Originally posted by: baranetskyy.NOSPAM.prosilog.com

Hi,
I have a problem with the CoolBar...
After the creation of the CoolBar if an user
change the CoolItem's placement for the multi-lines
form, then any Control which is placed under CoolBar
will be truncated without do layout...
Does it exist any possibility to layout the Control after
any changes?

Thanx a lot,
V.

P.S. Here you can find the exemple:

package testAndTest;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.CoolBar;

public class Test
{
public static void main(String[] args)
{
Display display = new Display ();
Shell shell = new Shell();
{
final GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
shell.setLayout(layout);
}
{
final CoolBar coolBar = new CoolBar(shell, SWT.NONE);
coolBar.setLayoutData(new
GridData(GridData.HORIZONTAL_ALIGN_FILL));
for(int i = 0; i < 10; i++)
{
final CoolItem coolItem = new CoolItem(coolBar,
SWT.DROP_DOWN);
final Button button = new Button(coolBar, SWT.FLAT);
button.setText("Button " + i);
coolItem.setControl(button);
coolItem.setSize(coolItem.computeSize(SWT.DEFAULT,
SWT.DEFAULT));
}
}
{
new Label(shell,
SWT.SEPARATOR|SWT.HORIZONTAL).setLayoutData(new
GridData(GridData.FILL_HORIZONTAL));
}
{
new Composite(shell, SWT.BORDER).setLayoutData(new
GridData(GridData.FILL_BOTH));
}
shell.open ();

while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Re: How is it possible to layout shell with CoolBar in? [message #436405 is a reply to message #436395] Tue, 18 May 2004 13:13 Go to previous messageGo to next message
Eclipse UserFriend
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet150.html

"Vasyl Baranetskyy" <baranetskyy@NOSPAM.prosilog.com> wrote in message
news:c8dbis$n1k$1@eclipse.org...
> Hi,
> I have a problem with the CoolBar...
> After the creation of the CoolBar if an user
> change the CoolItem's placement for the multi-lines
> form, then any Control which is placed under CoolBar
> will be truncated without do layout...
> Does it exist any possibility to layout the Control after
> any changes?
>
> Thanx a lot,
> V.
>
> P.S. Here you can find the exemple:
>
> package testAndTest;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.CoolItem;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Label;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.CoolBar;
>
> public class Test
> {
> public static void main(String[] args)
> {
> Display display = new Display ();
> Shell shell = new Shell();
> {
> final GridLayout layout = new GridLayout();
> layout.numColumns = 1;
> layout.marginHeight = 0;
> layout.marginWidth = 0;
> layout.horizontalSpacing = 0;
> layout.verticalSpacing = 0;
> shell.setLayout(layout);
> }
> {
> final CoolBar coolBar = new CoolBar(shell, SWT.NONE);
> coolBar.setLayoutData(new
> GridData(GridData.HORIZONTAL_ALIGN_FILL));
> for(int i = 0; i < 10; i++)
> {
> final CoolItem coolItem = new CoolItem(coolBar,
> SWT.DROP_DOWN);
> final Button button = new Button(coolBar, SWT.FLAT);
> button.setText("Button " + i);
> coolItem.setControl(button);
> coolItem.setSize(coolItem.computeSize(SWT.DEFAULT,
> SWT.DEFAULT));
> }
> }
> {
> new Label(shell,
> SWT.SEPARATOR|SWT.HORIZONTAL).setLayoutData(new
> GridData(GridData.FILL_HORIZONTAL));
> }
> {
> new Composite(shell, SWT.BORDER).setLayoutData(new
> GridData(GridData.FILL_BOTH));
> }
> shell.open ();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
Re: How is it possible to layout shell with CoolBar in? [message #436566 is a reply to message #436405] Wed, 19 May 2004 11:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: baranetskyy.NOSPAM.prosilog.com

Thnaks, but I found another solution for all layouts:
it needs just to add:
coolBar.addListener(SWT.Resize, new Listener()
{
void handleEvent(Event e)
{
shell.layout();
}
});

Now I have other question: How can I force the repaint event for the
Control. The solution such as control.getParent().layout(true/false)
does not solve my problem.

Thanx a lot.
V.

Steve Northover wrote:
> http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet150.html
Re: How is it possible to layout shell with CoolBar in? [message #436639 is a reply to message #436566] Fri, 21 May 2004 08:43 Go to previous message
Eclipse UserFriend
Control.redraw() will cause a paint to be queued in the operating system.
Control.update() will flush outstanding paints. Composite.layout() deals
with positioning and resizing only.

Question: Why does everyone get this wrong and assume that layout() causes
repaints (even when no sizes change)? Does AWT do it this way?

"Vasyl Baranetskyy" <baranetskyy@NOSPAM.prosilog.com> wrote in message
news:c8fsr8$n2f$1@eclipse.org...
> Thnaks, but I found another solution for all layouts:
> it needs just to add:
> coolBar.addListener(SWT.Resize, new Listener()
> {
> void handleEvent(Event e)
> {
> shell.layout();
> }
> });
>
> Now I have other question: How can I force the repaint event for the
> Control. The solution such as control.getParent().layout(true/false)
> does not solve my problem.
>
> Thanx a lot.
> V.
>
> Steve Northover wrote:
> >
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet150.html
Previous Topic:Easy Question SWT Geting Controls names and types
Next Topic:change toolbar image programatically
Goto Forum:
  


Current Time: Thu Nov 06 15:13:34 EST 2025

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

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

Back to the top