Community
Participate
Working Groups
Build Identifier: eclipse 3.4.2 Form used by org.eclipse.ui.forms while developing a UI.If some control or composite is created inside the FormHead portion.Then a padding comes beside that composite. Can anybody tell me If it can be removed or not. Below is the simple code . import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; public class FormHeadingExample { /** * @param args */ public static void main(String[] args) { createControl(); } private static void createControl() { Display display = new Display(); Shell shell = new Shell(display, SWT.TOP); shell.setLayout(new GridLayout()); Composite cmp = new Composite(shell, SWT.BORDER); cmp.setLayout(new GridLayout(1, true)); GridData gd = new GridData(GridData.FILL_BOTH); cmp.setLayoutData(gd); FormToolkit toolkit=new FormToolkit(display); final ScrolledForm form = toolkit.createScrolledForm(cmp); form.setLayoutData(gd); Composite head = form.getForm().getHead(); GridLayout gridLayout = new GridLayout(1,true); // Even though form heading as margins as 0 the padding remains gridLayout.marginHeight = 0; gridLayout.marginLeft = 0; gridLayout.marginLeft = 0; gridLayout.marginRight = 0; head.setLayout(gridLayout); Composite headCmp = toolkit.createComposite(head,SWT.BORDER); headCmp.setLayout(new FillLayout()); Text txt = toolkit.createText(headCmp, "Form Heading"); headCmp.setBackground(new Color(null,0,0,255)); form.getForm().setHeadClient(headCmp); form.getForm().setSeparatorVisible(true); form.getBody().setBackground(new Color(null,140,0,255)); // shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // display.dispose(); } } Reproducible: Always Steps to Reproduce: 1.Just Run the code and u will see the padding beside Form Heading text Composite
Does the problem persist on Eclipse 3.6.x?
(In reply to comment #1) > Does the problem persist on Eclipse 3.6.x? Haven't tried in Eclipse 3.6.x but tried in eclipse 3.5.2 galileo .Problem exists .Not sure if the version of eclipse going to matter .If you can try let me know.
Can you attach a screen shot and indicate where you are seeing unwanted padding?
Created attachment 186196 [details] FormHeadin sample picture
I have found out where the padding is coming from: Class FormHeading contains this constant private static final int HMARGIN = 6; Which is used as the size of the horizontal margin in the layout() method. I can't think of an easy way that a client of the Form class could suppress the creation of the margin since any call to layout() would recreate the margin.
There is no plan to add API to change the margin - closing.