Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Weird behaviour of GridLayout
Weird behaviour of GridLayout [message #449990] Thu, 03 February 2005 10:58 Go to next message
Tobias Klein is currently offline Tobias KleinFriend
Messages: 2
Registered: July 2009
Junior Member
Hey folks,

I'm currently testing the capabilities of
org.eclipse.swt.layout.GridLayout. I think I've already reached the
limits of that layout.

First I extended org.eclipse.swt.widgets.Composite to get a Widget with
individual borders.

That's the layout of my extended Composite:


---------------------------------
| Border-Top |
---------------------------------
| | | |
| | | |
| | Main-Composite | |
| | | |
|Border-Left |Border-Right
| | | |
| | | |
| | | |
| | | |
---------------------------------
| Border-Bottom |
---------------------------------

Each Border is a Composite with a black Background. These five
Composites are inserted in one "Parent-Composite".

The extended class follows here:

/*********** CODE STARTS HERE **************/

package com.vipco.spe.swtextension;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;

/**
* @author tk
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class BorderedComposite extends Composite {

private static final int style = SWT.NONE;

private Composite myParent;
private Color myBorderColor;
private int myTopMargin;
private int myBottomMargin;
private int myLeftMargin;
private int myRightMargin;
private int myFillType;
private int myNumColumns;

private GridLayout myLayout;
private GridData myGridData;

private Composite myCenterComposite;

private Composite myTopMarginComposite;
private Composite myBottomMarginComposite;

private Composite myLeftMarginComposite;
private Composite myInnerComposite;
private Composite myRightMarginComposite;

private GridData myCenterGridData;
private GridData myTopGridData;
private GridData myBottomGridData;
private GridData myLeftGridData;
private GridData myRightGridData;

private GridLayout myCenterLayout;

private GridLayout myInnerLayout;
private GridData myInnerGridData;
private Color myInnerColor;


/**
* @param parent
* @param style
*/
public BorderedComposite(Composite parent, Color borderColor, int
topMargin, int bottomMargin,
int leftMargin, int rightMargin, int fillType, int numColumns) {

super(parent, style);

init(parent, borderColor, topMargin, bottomMargin, leftMargin,
rightMargin, fillType, numColumns);
render();
}

private void init(Composite parent, Color borderColor,
int topMargin, int bottomMargin, int leftMargin, int rightMargin, int
fillType, int numColumns) {
myParent = parent;
myBorderColor = borderColor;

myTopMargin = topMargin;
myBottomMargin = bottomMargin;
myLeftMargin = leftMargin;
myRightMargin = rightMargin;

myFillType = fillType;

myNumColumns = numColumns;

myLayout = new GridLayout();
myGridData = new GridData(fillType);

myTopMarginComposite = new Composite(this, style);

myCenterComposite = new Composite(this,style);

myLeftMarginComposite = new Composite(myCenterComposite, style);
myInnerComposite = new Composite(myCenterComposite, style);
myRightMarginComposite = new Composite(myCenterComposite, style);

myBottomMarginComposite = new Composite(this, style);

myCenterGridData = new GridData(GridData.FILL_BOTH);
myTopGridData = new GridData(GridData.FILL_HORIZONTAL);
myLeftGridData = new GridData(GridData.FILL_VERTICAL);
myInnerGridData = new GridData(GridData.FILL_BOTH);
myRightGridData = new GridData(GridData.FILL_VERTICAL);
myBottomGridData = new GridData(GridData.FILL_HORIZONTAL);

myCenterLayout = new GridLayout();

myInnerLayout = new GridLayout();
myInnerColor = new Color(myParent.getDisplay(), 255, 255, 255);
}

private void render() {
myLayout.numColumns = 1;
myLayout.horizontalSpacing = 0;
myLayout.verticalSpacing = 0;
myLayout.marginWidth = 0;
myLayout.marginHeight = 0;

setLayout(myLayout);
setLayoutData(myGridData);

myCenterLayout.numColumns = 3;
myCenterLayout.horizontalSpacing = 0;
myCenterLayout.verticalSpacing = 0;
myCenterLayout.marginHeight = 0;
myCenterLayout.marginWidth = 0;

myCenterComposite.setLayout(myCenterLayout);
myCenterComposite.setLayoutData(myCenterGridData);

myInnerLayout.numColumns = myNumColumns;
myInnerLayout.marginWidth = 0;
myInnerLayout.marginHeight = 0;
myInnerLayout.horizontalSpacing = 0;
myInnerLayout.verticalSpacing = 0;

myInnerComposite.setLayout(myInnerLayout);

myLeftGridData.widthHint = myLeftMargin;
myRightGridData.horizontalAlignment = GridData.END;

myTopGridData.heightHint = myTopMargin;
myTopGridData.horizontalSpan = 1;
myBottomGridData.heightHint = myBottomMargin;
myBottomGridData.horizontalSpan = 1;
myRightGridData.widthHint = myRightMargin;

myTopMarginComposite.setLayoutData(myTopGridData);
myLeftMarginComposite.setLayoutData(myLeftGridData);
myInnerComposite.setLayoutData(myInnerGridData);
myRightMarginComposite.setLayoutData(myRightGridData);
myBottomMarginComposite.setLayoutData(myBottomGridData);

myTopMarginComposite.setBackground(myBorderColor);
myLeftMarginComposite.setBackground(myBorderColor);
myInnerComposite.setBackground(myInnerColor);
myRightMarginComposite.setBackground(myBorderColor);
myBottomMarginComposite.setBackground(myBorderColor);
}

public Composite getInnerComposite() {
return myInnerComposite;
}
}

/***************** CODE ENDS HERE ***************/

The first tests of my extended Composite showed a positive result - it
rendered just as I wanted it to be.

But after increasing the depth of nested Composites I've got very weird
results.

See the following Screenshots of several "states" after playing with the
size of the Eclipse window.

http://tklein-home.de/tmp/eclipse_1.jpg
http://tklein-home.de/tmp/eclipse_2.jpg
http://tklein-home.de/tmp/eclipse_3.jpg


Is that a bug in GridLayout??


Test Code follows:

/*************** CODE STARTS HERE ****************/

package com.vipco.spe.editor;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;

import com.vipco.spe.swtextension.BorderedComposite;

public class StructogramEditor extends EditorPart {
private Composite myStaticComposite;

public StructogramEditor() {

}

/*
* (non-Javadoc)
*
* @see
org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime .IProgressMonitor)
*/
public void doSave(IProgressMonitor monitor) {
// TODO Auto-generated method stub

}

/*
* (non-Javadoc)
*
* @see org.eclipse.ui.ISaveablePart#doSaveAs()
*/
public void doSaveAs() {
// TODO Auto-generated method stub

}

/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
* org.eclipse.ui.IEditorInput)
*/
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {

setSite(site);
setInput(input);

// TODO Auto-generated method stub

}

/*
* (non-Javadoc)
*
* @see org.eclipse.ui.ISaveablePart#isDirty()
*/
public boolean isDirty() {
// TODO Auto-generated method stub
return false;
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
*/
public boolean isSaveAsAllowed() {
// TODO Auto-generated method stub
return false;
}
/*
* (non-Javadoc)
*
* @see
org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse. swt.widgets.Composite)
*/
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub

GridLayout myParentGrid = new GridLayout();
myParentGrid.numColumns = 2;
myParentGrid.horizontalSpacing = 0;
myParentGrid.verticalSpacing = 0;
myParentGrid.marginHeight = 0;
myParentGrid.marginWidth = 0;

parent.setLayout(myParentGrid);

BorderedComposite myComposite1 = new BorderedComposite(parent, new
Color(parent.getDisplay(), 0, 0, 0),
2, 0, 2, 2, GridData.FILL_BOTH, 1);

BorderedComposite myComposite2 = new BorderedComposite(parent, new
Color(parent.getDisplay(), 0, 0, 0),
2, 0, 0, 2, GridData.FILL_BOTH, 1);

BorderedComposite myComposite3 = new BorderedComposite(parent, new
Color(parent.getDisplay(), 0, 0, 0),
2, 2, 2, 2, GridData.FILL_BOTH, 2);

BorderedComposite myComposite4 = new BorderedComposite(parent, new
Color(parent.getDisplay(), 0, 0, 0),
2, 2, 0, 2, GridData.FILL_BOTH, 2);

BorderedComposite myComposite5 = new
BorderedComposite(myComposite4.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 2, GridData.FILL_BOTH, 1);

BorderedComposite myComposite6 = new
BorderedComposite(myComposite4.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 0, GridData.FILL_BOTH, 1);

BorderedComposite myComposite7 = new
BorderedComposite(myComposite4.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
2, 0, 0, 2, GridData.FILL_BOTH, 2);

BorderedComposite myComposite8 = new
BorderedComposite(myComposite4.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
2, 0, 0, 0, GridData.FILL_BOTH, 1);

BorderedComposite myComposite9 = new
BorderedComposite(myComposite7.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 2, GridData.FILL_BOTH, 2);

BorderedComposite myComposite10 = new
BorderedComposite(myComposite7.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 0, GridData.FILL_BOTH, 1);

BorderedComposite myComposite11 = new
BorderedComposite(myComposite3.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 2, GridData.FILL_BOTH, 1);

BorderedComposite myComposite12 = new
BorderedComposite(myComposite3.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 0, GridData.FILL_BOTH, 1);

BorderedComposite myComposite15 = new
BorderedComposite(myComposite1.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 2, 0, 0, GridData.FILL_BOTH, 2);

BorderedComposite myComposite16 = new
BorderedComposite(myComposite1.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 0, GridData.FILL_BOTH, 1);

BorderedComposite myComposite17 = new
BorderedComposite(myComposite15.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 2, GridData.FILL_BOTH, 1);

BorderedComposite myComposite18 = new
BorderedComposite(myComposite15.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 0, GridData.FILL_BOTH, 1);

BorderedComposite myComposite19 = new
BorderedComposite(myComposite18.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 2, 0, 0, GridData.FILL_BOTH, 1);

BorderedComposite myComposite20 = new
BorderedComposite(myComposite18.getInnerComposite(), new
Color(parent.getDisplay(), 0, 0, 0),
0, 0, 0, 0, GridData.FILL_BOTH, 2);

parent.pack();
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPart#setFocus()
*/
public void setFocus() {
// TODO Auto-generated method stub

}
}
Re: Weird behaviour of GridLayout [message #449995 is a reply to message #449990] Thu, 03 February 2005 15:42 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Are you running with Eclipse 3.0?

I ran the following example below on Windows XP with the latest 3.1 Eclipse
build and it worked fine. In 3.1, the GridLayout was reworked and a number
of bugs were fixed. If you are using 3.0, please give 3.1 a try and see if
this fixes your problem.

public static void main (String [] args) {
Display display = new Display ();
Color green = display.getSystemColor(SWT.COLOR_GREEN);
Color red = display.getSystemColor(SWT.COLOR_RED);
Color blue = display.getSystemColor(SWT.COLOR_BLUE);
Color cyan = display.getSystemColor(SWT.COLOR_CYAN);
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());

Composite parent = new Composite(shell, SWT.NONE);
GridLayout myParentGrid = new GridLayout();
myParentGrid.numColumns = 2;
myParentGrid.horizontalSpacing = 0;
myParentGrid.verticalSpacing = 0;
myParentGrid.marginHeight = 0;
myParentGrid.marginWidth = 0;

parent.setLayout(myParentGrid);

BorderedComposite myComposite1 = new BorderedComposite(parent, green, 2,
0, 2, 2, GridData.FILL_BOTH, 1);

BorderedComposite myComposite2 = new BorderedComposite(parent, green, 2,
0, 0, 2, GridData.FILL_BOTH, 1);

BorderedComposite myComposite3 = new BorderedComposite(parent, green, 2,
2, 2, 2, GridData.FILL_BOTH, 2);

BorderedComposite myComposite4 = new BorderedComposite(parent, green, 2,
2, 0, 2, GridData.FILL_BOTH, 2);

BorderedComposite myComposite5 = new
BorderedComposite(myComposite4.getInnerComposite(), blue, 0, 0, 0, 2,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite6 = new
BorderedComposite(myComposite4.getInnerComposite(), blue, 0, 0, 0, 0,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite7 = new
BorderedComposite(myComposite4.getInnerComposite(), blue, 2, 0, 0, 2,
GridData.FILL_BOTH, 2);

BorderedComposite myComposite8 = new
BorderedComposite(myComposite4.getInnerComposite(), blue, 2, 0, 0, 0,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite9 = new
BorderedComposite(myComposite7.getInnerComposite(), red, 0, 0, 0, 2,
GridData.FILL_BOTH, 2);

BorderedComposite myComposite10 = new
BorderedComposite(myComposite7.getInnerComposite(), red, 0, 0, 0, 0,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite11 = new
BorderedComposite(myComposite3.getInnerComposite(), cyan, 0, 0, 0, 2,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite12 = new
BorderedComposite(myComposite3.getInnerComposite(), cyan, 0, 0, 0, 0,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite15 = new
BorderedComposite(myComposite1.getInnerComposite(), blue, 0, 2, 0, 0,
GridData.FILL_BOTH, 2);

BorderedComposite myComposite16 = new
BorderedComposite(myComposite1.getInnerComposite(), blue, 0, 0, 0, 0,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite17 = new
BorderedComposite(myComposite15.getInnerComposite(), red, 0, 0, 0, 2,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite18 = new
BorderedComposite(myComposite15.getInnerComposite(), red, 0, 0, 0, 0,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite19 = new
BorderedComposite(myComposite18.getInnerComposite(), cyan, 0, 2, 0, 0,
GridData.FILL_BOTH, 1);

BorderedComposite myComposite20 = new
BorderedComposite(myComposite18.getInnerComposite(), cyan, 0, 0, 0, 0,
GridData.FILL_BOTH, 2);

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}


"Tobias Klein" <tklein_news@online.de> wrote in message
news:ctt05g$t00$1@www.eclipse.org...
> Hey folks,
>
> I'm currently testing the capabilities of
> org.eclipse.swt.layout.GridLayout. I think I've already reached the limits
> of that layout.
>
> First I extended org.eclipse.swt.widgets.Composite to get a Widget with
> individual borders.
>
> That's the layout of my extended Composite:
>
>
> ---------------------------------
> | Border-Top |
> ---------------------------------
> | | | |
> | | | |
> | | Main-Composite | |
> | | | |
> |Border-Left |Border-Right
> | | | |
> | | | |
> | | | |
> | | | |
> ---------------------------------
> | Border-Bottom |
> ---------------------------------
>
> Each Border is a Composite with a black Background. These five Composites
> are inserted in one "Parent-Composite".
>
> The extended class follows here:
>
> /*********** CODE STARTS HERE **************/
>
> package com.vipco.spe.swtextension;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.Color;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Composite;
>
> /**
> * @author tk
> *
> * TODO To change the template for this generated type comment go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> public class BorderedComposite extends Composite {
>
> private static final int style = SWT.NONE;
>
> private Composite myParent;
> private Color myBorderColor;
> private int myTopMargin;
> private int myBottomMargin;
> private int myLeftMargin;
> private int myRightMargin;
> private int myFillType;
> private int myNumColumns;
>
> private GridLayout myLayout;
> private GridData myGridData;
>
> private Composite myCenterComposite;
>
> private Composite myTopMarginComposite;
> private Composite myBottomMarginComposite;
>
> private Composite myLeftMarginComposite;
> private Composite myInnerComposite;
> private Composite myRightMarginComposite;
>
> private GridData myCenterGridData;
> private GridData myTopGridData;
> private GridData myBottomGridData;
> private GridData myLeftGridData;
> private GridData myRightGridData;
>
> private GridLayout myCenterLayout;
>
> private GridLayout myInnerLayout;
> private GridData myInnerGridData;
> private Color myInnerColor;
>
>
> /**
> * @param parent
> * @param style
> */ public BorderedComposite(Composite parent, Color borderColor, int
> topMargin, int bottomMargin,
> int leftMargin, int rightMargin, int fillType, int numColumns) {
>
> super(parent, style);
>
> init(parent, borderColor, topMargin, bottomMargin, leftMargin,
> rightMargin, fillType, numColumns);
> render();
> }
>
> private void init(Composite parent, Color borderColor,
> int topMargin, int bottomMargin, int leftMargin, int rightMargin, int
> fillType, int numColumns) {
> myParent = parent;
> myBorderColor = borderColor;
>
> myTopMargin = topMargin;
> myBottomMargin = bottomMargin;
> myLeftMargin = leftMargin;
> myRightMargin = rightMargin;
>
> myFillType = fillType;
>
> myNumColumns = numColumns;
>
> myLayout = new GridLayout();
> myGridData = new GridData(fillType);
>
> myTopMarginComposite = new Composite(this, style);
>
> myCenterComposite = new Composite(this,style);
>
> myLeftMarginComposite = new Composite(myCenterComposite, style);
> myInnerComposite = new Composite(myCenterComposite, style);
> myRightMarginComposite = new Composite(myCenterComposite, style);
>
> myBottomMarginComposite = new Composite(this, style);
>
> myCenterGridData = new GridData(GridData.FILL_BOTH);
> myTopGridData = new GridData(GridData.FILL_HORIZONTAL);
> myLeftGridData = new GridData(GridData.FILL_VERTICAL);
> myInnerGridData = new GridData(GridData.FILL_BOTH);
> myRightGridData = new GridData(GridData.FILL_VERTICAL); myBottomGridData =
> new GridData(GridData.FILL_HORIZONTAL);
>
> myCenterLayout = new GridLayout();
>
> myInnerLayout = new GridLayout();
> myInnerColor = new Color(myParent.getDisplay(), 255, 255, 255);
> }
>
> private void render() {
> myLayout.numColumns = 1;
> myLayout.horizontalSpacing = 0;
> myLayout.verticalSpacing = 0;
> myLayout.marginWidth = 0;
> myLayout.marginHeight = 0;
>
> setLayout(myLayout);
> setLayoutData(myGridData);
>
> myCenterLayout.numColumns = 3;
> myCenterLayout.horizontalSpacing = 0;
> myCenterLayout.verticalSpacing = 0;
> myCenterLayout.marginHeight = 0;
> myCenterLayout.marginWidth = 0;
>
> myCenterComposite.setLayout(myCenterLayout);
> myCenterComposite.setLayoutData(myCenterGridData);
>
> myInnerLayout.numColumns = myNumColumns;
> myInnerLayout.marginWidth = 0;
> myInnerLayout.marginHeight = 0;
> myInnerLayout.horizontalSpacing = 0;
> myInnerLayout.verticalSpacing = 0;
>
> myInnerComposite.setLayout(myInnerLayout);
>
> myLeftGridData.widthHint = myLeftMargin;
> myRightGridData.horizontalAlignment = GridData.END;
>
> myTopGridData.heightHint = myTopMargin;
> myTopGridData.horizontalSpan = 1; myBottomGridData.heightHint =
> myBottomMargin;
> myBottomGridData.horizontalSpan = 1; myRightGridData.widthHint =
> myRightMargin;
>
> myTopMarginComposite.setLayoutData(myTopGridData);
> myLeftMarginComposite.setLayoutData(myLeftGridData);
> myInnerComposite.setLayoutData(myInnerGridData);
> myRightMarginComposite.setLayoutData(myRightGridData);
> myBottomMarginComposite.setLayoutData(myBottomGridData);
>
> myTopMarginComposite.setBackground(myBorderColor);
> myLeftMarginComposite.setBackground(myBorderColor);
> myInnerComposite.setBackground(myInnerColor);
> myRightMarginComposite.setBackground(myBorderColor);
> myBottomMarginComposite.setBackground(myBorderColor);
> }
>
> public Composite getInnerComposite() {
> return myInnerComposite;
> }
> }
>
> /***************** CODE ENDS HERE ***************/
>
> The first tests of my extended Composite showed a positive result - it
> rendered just as I wanted it to be.
>
> But after increasing the depth of nested Composites I've got very weird
> results.
>
> See the following Screenshots of several "states" after playing with the
> size of the Eclipse window.
>
> http://tklein-home.de/tmp/eclipse_1.jpg
> http://tklein-home.de/tmp/eclipse_2.jpg
> http://tklein-home.de/tmp/eclipse_3.jpg
>
>
> Is that a bug in GridLayout??
>
>
> Test Code follows:
>
> /*************** CODE STARTS HERE ****************/
>
> package com.vipco.spe.editor;
>
> import org.eclipse.core.runtime.IProgressMonitor;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.custom.StyledText;
> import org.eclipse.swt.graphics.Color;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.layout.RowLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Group;
> import org.eclipse.ui.IEditorInput;
> import org.eclipse.ui.IEditorSite;
> import org.eclipse.ui.PartInitException;
> import org.eclipse.ui.part.EditorPart;
>
> import com.vipco.spe.swtextension.BorderedComposite;
>
> public class StructogramEditor extends EditorPart {
> private Composite myStaticComposite;
>
> public StructogramEditor() {
>
> }
>
> /*
> * (non-Javadoc)
> *
> * @see
> org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime .IProgressMonitor)
> */
> public void doSave(IProgressMonitor monitor) {
> // TODO Auto-generated method stub
>
> }
>
> /*
> * (non-Javadoc)
> *
> * @see org.eclipse.ui.ISaveablePart#doSaveAs()
> */
> public void doSaveAs() {
> // TODO Auto-generated method stub
>
> }
>
> /*
> * (non-Javadoc)
> *
> * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
> * org.eclipse.ui.IEditorInput)
> */
> public void init(IEditorSite site, IEditorInput input)
> throws PartInitException {
>
> setSite(site);
> setInput(input);
>
> // TODO Auto-generated method stub
>
> }
>
> /*
> * (non-Javadoc)
> *
> * @see org.eclipse.ui.ISaveablePart#isDirty()
> */
> public boolean isDirty() {
> // TODO Auto-generated method stub
> return false;
> }
>
> /*
> * (non-Javadoc)
> *
> * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
> */
> public boolean isSaveAsAllowed() {
> // TODO Auto-generated method stub
> return false;
> }
> /*
> * (non-Javadoc)
> *
> * @see
> org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse. swt.widgets.Composite)
> */
> public void createPartControl(Composite parent) {
> // TODO Auto-generated method stub
>
> GridLayout myParentGrid = new GridLayout();
> myParentGrid.numColumns = 2;
> myParentGrid.horizontalSpacing = 0;
> myParentGrid.verticalSpacing = 0;
> myParentGrid.marginHeight = 0;
> myParentGrid.marginWidth = 0;
>
> parent.setLayout(myParentGrid);
> BorderedComposite myComposite1 = new BorderedComposite(parent, new
> Color(parent.getDisplay(), 0, 0, 0),
> 2, 0, 2, 2, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite2 = new BorderedComposite(parent, new
> Color(parent.getDisplay(), 0, 0, 0),
> 2, 0, 0, 2, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite3 = new BorderedComposite(parent, new
> Color(parent.getDisplay(), 0, 0, 0),
> 2, 2, 2, 2, GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite4 = new BorderedComposite(parent, new
> Color(parent.getDisplay(), 0, 0, 0),
> 2, 2, 0, 2, GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite5 = new
> BorderedComposite(myComposite4.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 2, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite6 = new
> BorderedComposite(myComposite4.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 0, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite7 = new
> BorderedComposite(myComposite4.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 2, 0, 0, 2, GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite8 = new
> BorderedComposite(myComposite4.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 2, 0, 0, 0, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite9 = new
> BorderedComposite(myComposite7.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 2, GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite10 = new
> BorderedComposite(myComposite7.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 0, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite11 = new
> BorderedComposite(myComposite3.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 2, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite12 = new
> BorderedComposite(myComposite3.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 0, GridData.FILL_BOTH, 1);
> BorderedComposite myComposite15 = new
> BorderedComposite(myComposite1.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 2, 0, 0, GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite16 = new
> BorderedComposite(myComposite1.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 0, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite17 = new
> BorderedComposite(myComposite15.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 2, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite18 = new
> BorderedComposite(myComposite15.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 0, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite19 = new
> BorderedComposite(myComposite18.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 2, 0, 0, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite20 = new
> BorderedComposite(myComposite18.getInnerComposite(), new
> Color(parent.getDisplay(), 0, 0, 0),
> 0, 0, 0, 0, GridData.FILL_BOTH, 2);
>
> parent.pack();
> }
>
> /*
> * (non-Javadoc)
> *
> * @see org.eclipse.ui.IWorkbenchPart#setFocus()
> */
> public void setFocus() {
> // TODO Auto-generated method stub
>
> }
> }
Re: Weird behaviour of GridLayout [message #450013 is a reply to message #449995] Fri, 04 February 2005 08:42 Go to previous messageGo to next message
Tobias Klein is currently offline Tobias KleinFriend
Messages: 2
Registered: July 2009
Junior Member
Yes I've been using Eclipse 3.0. After reading your message I've also
tested with Eclipse 3.1 (under Win2K). But the problems are nearly the
same. When resizing the Eclipse Window the lines are not further
rendered correctly.

Would it make a difference when I run the code in an independent shell
outside of the Eclipse Workbench?

Please add a few more nested BorderedComposites. When I expanded the
hierarchy of our example with one more nested BorderedComposite I've got
completely strange results. The new Composites hasn't even been shown
anymore.

Thanks for help,

Tobias.


Veronika Irvine wrote:
> Are you running with Eclipse 3.0?
>
> I ran the following example below on Windows XP with the latest 3.1 Eclipse
> build and it worked fine. In 3.1, the GridLayout was reworked and a number
> of bugs were fixed. If you are using 3.0, please give 3.1 a try and see if
> this fixes your problem.
>
> public static void main (String [] args) {
> Display display = new Display ();
> Color green = display.getSystemColor(SWT.COLOR_GREEN);
> Color red = display.getSystemColor(SWT.COLOR_RED);
> Color blue = display.getSystemColor(SWT.COLOR_BLUE);
> Color cyan = display.getSystemColor(SWT.COLOR_CYAN);
> Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
>
> Composite parent = new Composite(shell, SWT.NONE);
> GridLayout myParentGrid = new GridLayout();
> myParentGrid.numColumns = 2;
> myParentGrid.horizontalSpacing = 0;
> myParentGrid.verticalSpacing = 0;
> myParentGrid.marginHeight = 0;
> myParentGrid.marginWidth = 0;
>
> parent.setLayout(myParentGrid);
>
> BorderedComposite myComposite1 = new BorderedComposite(parent, green, 2,
> 0, 2, 2, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite2 = new BorderedComposite(parent, green, 2,
> 0, 0, 2, GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite3 = new BorderedComposite(parent, green, 2,
> 2, 2, 2, GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite4 = new BorderedComposite(parent, green, 2,
> 2, 0, 2, GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite5 = new
> BorderedComposite(myComposite4.getInnerComposite(), blue, 0, 0, 0, 2,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite6 = new
> BorderedComposite(myComposite4.getInnerComposite(), blue, 0, 0, 0, 0,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite7 = new
> BorderedComposite(myComposite4.getInnerComposite(), blue, 2, 0, 0, 2,
> GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite8 = new
> BorderedComposite(myComposite4.getInnerComposite(), blue, 2, 0, 0, 0,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite9 = new
> BorderedComposite(myComposite7.getInnerComposite(), red, 0, 0, 0, 2,
> GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite10 = new
> BorderedComposite(myComposite7.getInnerComposite(), red, 0, 0, 0, 0,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite11 = new
> BorderedComposite(myComposite3.getInnerComposite(), cyan, 0, 0, 0, 2,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite12 = new
> BorderedComposite(myComposite3.getInnerComposite(), cyan, 0, 0, 0, 0,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite15 = new
> BorderedComposite(myComposite1.getInnerComposite(), blue, 0, 2, 0, 0,
> GridData.FILL_BOTH, 2);
>
> BorderedComposite myComposite16 = new
> BorderedComposite(myComposite1.getInnerComposite(), blue, 0, 0, 0, 0,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite17 = new
> BorderedComposite(myComposite15.getInnerComposite(), red, 0, 0, 0, 2,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite18 = new
> BorderedComposite(myComposite15.getInnerComposite(), red, 0, 0, 0, 0,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite19 = new
> BorderedComposite(myComposite18.getInnerComposite(), cyan, 0, 2, 0, 0,
> GridData.FILL_BOTH, 1);
>
> BorderedComposite myComposite20 = new
> BorderedComposite(myComposite18.getInnerComposite(), cyan, 0, 0, 0, 0,
> GridData.FILL_BOTH, 2);
>
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
Re: Weird behaviour of GridLayout [message #450098 is a reply to message #450013] Mon, 07 February 2005 21:35 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
What version of Eclipse 3.1 did you use?

Please enter a bug report against Platform SWT with a modified version of
the code below that shows the problem. Thanks.

"Tobias Klein" <tklein_news@online.de> wrote in message
news:ctvcjq$k9o$1@www.eclipse.org...
> Yes I've been using Eclipse 3.0. After reading your message I've also
> tested with Eclipse 3.1 (under Win2K). But the problems are nearly the
> same. When resizing the Eclipse Window the lines are not further rendered
> correctly.
>
> Would it make a difference when I run the code in an independent shell
> outside of the Eclipse Workbench?
>
> Please add a few more nested BorderedComposites. When I expanded the
> hierarchy of our example with one more nested BorderedComposite I've got
> completely strange results. The new Composites hasn't even been shown
> anymore.
>
> Thanks for help,
>
> Tobias.
>
>
> Veronika Irvine wrote:
>> Are you running with Eclipse 3.0?
>>
>> I ran the following example below on Windows XP with the latest 3.1
>> Eclipse build and it worked fine. In 3.1, the GridLayout was reworked
>> and a number of bugs were fixed. If you are using 3.0, please give 3.1 a
>> try and see if this fixes your problem.
>>
>> public static void main (String [] args) {
>> Display display = new Display ();
>> Color green = display.getSystemColor(SWT.COLOR_GREEN);
>> Color red = display.getSystemColor(SWT.COLOR_RED);
>> Color blue = display.getSystemColor(SWT.COLOR_BLUE);
>> Color cyan = display.getSystemColor(SWT.COLOR_CYAN);
>> Shell shell = new Shell (display);
>> shell.setLayout(new FillLayout());
>>
>> Composite parent = new Composite(shell, SWT.NONE);
>> GridLayout myParentGrid = new GridLayout();
>> myParentGrid.numColumns = 2;
>> myParentGrid.horizontalSpacing = 0;
>> myParentGrid.verticalSpacing = 0;
>> myParentGrid.marginHeight = 0;
>> myParentGrid.marginWidth = 0;
>>
>> parent.setLayout(myParentGrid);
>>
>> BorderedComposite myComposite1 = new BorderedComposite(parent, green,
>> 2, 0, 2, 2, GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite2 = new BorderedComposite(parent, green,
>> 2, 0, 0, 2, GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite3 = new BorderedComposite(parent, green,
>> 2, 2, 2, 2, GridData.FILL_BOTH, 2);
>>
>> BorderedComposite myComposite4 = new BorderedComposite(parent, green,
>> 2, 2, 0, 2, GridData.FILL_BOTH, 2);
>>
>> BorderedComposite myComposite5 = new
>> BorderedComposite(myComposite4.getInnerComposite(), blue, 0, 0, 0, 2,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite6 = new
>> BorderedComposite(myComposite4.getInnerComposite(), blue, 0, 0, 0, 0,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite7 = new
>> BorderedComposite(myComposite4.getInnerComposite(), blue, 2, 0, 0, 2,
>> GridData.FILL_BOTH, 2);
>>
>> BorderedComposite myComposite8 = new
>> BorderedComposite(myComposite4.getInnerComposite(), blue, 2, 0, 0, 0,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite9 = new
>> BorderedComposite(myComposite7.getInnerComposite(), red, 0, 0, 0, 2,
>> GridData.FILL_BOTH, 2);
>>
>> BorderedComposite myComposite10 = new
>> BorderedComposite(myComposite7.getInnerComposite(), red, 0, 0, 0, 0,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite11 = new
>> BorderedComposite(myComposite3.getInnerComposite(), cyan, 0, 0, 0, 2,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite12 = new
>> BorderedComposite(myComposite3.getInnerComposite(), cyan, 0, 0, 0, 0,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite15 = new
>> BorderedComposite(myComposite1.getInnerComposite(), blue, 0, 2, 0, 0,
>> GridData.FILL_BOTH, 2);
>>
>> BorderedComposite myComposite16 = new
>> BorderedComposite(myComposite1.getInnerComposite(), blue, 0, 0, 0, 0,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite17 = new
>> BorderedComposite(myComposite15.getInnerComposite(), red, 0, 0, 0, 2,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite18 = new
>> BorderedComposite(myComposite15.getInnerComposite(), red, 0, 0, 0, 0,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite19 = new
>> BorderedComposite(myComposite18.getInnerComposite(), cyan, 0, 2, 0, 0,
>> GridData.FILL_BOTH, 1);
>>
>> BorderedComposite myComposite20 = new
>> BorderedComposite(myComposite18.getInnerComposite(), cyan, 0, 0, 0, 0,
>> GridData.FILL_BOTH, 2);
>>
>> shell.open ();
>> while (!shell.isDisposed ()) {
>> if (!display.readAndDispatch ()) display.sleep ();
>> }
>> display.dispose ();
>> }
>>
Previous Topic:Incomplete fill with polygon clipped 'gc.fillGradientRectangle(...)'
Next Topic:fixing intial size of TitleAreaDialog
Goto Forum:
  


Current Time: Sat Apr 20 02:43:33 GMT 2024

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

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

Back to the top