Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333384

Summary: [Forms] Eclipse FormHeading Padding
Product: [Eclipse Project] Platform Reporter: abhijit <abhijit_x_pert>
Component: User AssistanceAssignee: platform-ua-inbox <platform-ua-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: cgold, remy.suen
Version: 3.4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
FormHeadin sample picture none

Description abhijit CLA 2011-01-02 07:17:09 EST
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
Comment 1 Remy Suen CLA 2011-01-02 12:49:41 EST
Does the problem persist on Eclipse 3.6.x?
Comment 2 abhijit CLA 2011-01-03 12:02:11 EST
(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.
Comment 3 Chris Goldthorpe CLA 2011-01-05 12:32:57 EST
Can you attach a screen shot and indicate where you are seeing unwanted padding?
Comment 4 abhijit CLA 2011-01-06 11:52:55 EST
Created attachment 186196 [details]
FormHeadin sample picture
Comment 5 Chris Goldthorpe CLA 2011-01-07 18:29:02 EST
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.
Comment 6 Chris Goldthorpe CLA 2011-04-18 19:14:40 EDT
There is no plan to add API to change the margin - closing.