Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layout problem using CTabFolder in a form
Layout problem using CTabFolder in a form [message #447950] Wed, 22 December 2004 07:34 Go to next message
Eclipse UserFriend
Originally posted by: tschlat.gmx.de

Hi,

i have a FormPage to display in a FormEditor. The FormPage itself contains
a CTabFolder. I would like the folder to span the whole width of the
editor. Therefore I set a layout data for the tabFolder. The problem is:
If I set the layout the width spans the editor width but the tab content
is not shown anymore (the tabs are there, only the content is missing). If
I do not set layoutData, the width of the TabFolder is "as wide as
necessary" and the content is shown.

Help would be appreciated

ciao, Thorsten

The following code creates the page content:

protected void createFormContent(IManagedForm managedForm) {
ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
form.setText("Form with subpages");
form.setBackgroundImage(ClientPlugin.getDefault().
getImage(ICrmClientConstants.FORM_BANNER));
GridLayout layout = new GridLayout();
layout.marginWidth = 10;
form.getBody().setLayout(layout);

tabFolder = new CTabFolder(form.getBody(), SWT.FLAT|SWT.TOP);
toolkit.adapt(tabFolder, true, true);

// Set a layoutdata to fill horizontally
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 0;
tabFolder.setLayoutData(gd);


Color selectedColor = toolkit.getColors().getColor(FormColors.SEPARATOR);
tabFolder.setSelectionBackground(new Color[] {selectedColor,
toolkit.getColors().getBackground()}, new int[] {50});
tabFolder.setCursor(FormsResources.getHandCursor());

toolkit.paintBordersFor(tabFolder);
createOverviewTab(toolkit, null);
createRatingTab(toolkit, null);
tabFolder.setSelection(0);
}

private void createOverviewTab(FormToolkit toolkit, Composite parent) {
CTabItem item = new CTabItem(tabFolder, SWT.NULL);
item.setText(ClientPlugin.getDefault().
getResourceString("overviewPage.label"));

Text text = toolkit.createText(tabFolder, "Overview", SWT.SINGLE);
text.setText("Overview");
item.setControl(text);
}

private void createRatingTab(FormToolkit toolkit, Composite parent) {
CTabItem item = new CTabItem(tabFolder, SWT.NULL);
item.setText(ClientPlugin.getDefault().
getResourceString("ratingIndustryPage.

Text text = toolkit.createText(tabFolder, "Rating", SWT.SINGLE);
text.setText("Rating / Industry");
item.setControl(text);

}
Re: Layout problem using CTabFolder in a form [message #447992 is a reply to message #447950] Wed, 22 December 2004 19:17 Go to previous message
Eclipse UserFriend
Originally posted by: tschlat.gmx.de

Finally I found out what the problem is. If I use
GridData gd = new GridData(GridData.FILL_BOTH);
for the tabFolder it works fine.

tschlat wrote:

> Hi,

> i have a FormPage to display in a FormEditor. The FormPage itself contains
> a CTabFolder. I would like the folder to span the whole width of the
> editor. Therefore I set a layout data for the tabFolder. The problem is:
> If I set the layout the width spans the editor width but the tab content
> is not shown anymore (the tabs are there, only the content is missing). If
> I do not set layoutData, the width of the TabFolder is "as wide as
> necessary" and the content is shown.

> Help would be appreciated

> ciao, Thorsten

> The following code creates the page content:

> protected void createFormContent(IManagedForm managedForm) {
> ScrolledForm form = managedForm.getForm();
> FormToolkit toolkit = managedForm.getToolkit();
> form.setText("Form with subpages");
> form.setBackgroundImage(ClientPlugin.getDefault().
> getImage(ICrmClientConstants.FORM_BANNER));
> GridLayout layout = new GridLayout();
> layout.marginWidth = 10;
> form.getBody().setLayout(layout);

> tabFolder = new CTabFolder(form.getBody(), SWT.FLAT|SWT.TOP);
> toolkit.adapt(tabFolder, true, true);

> // Set a layoutdata to fill horizontally
> GridData gd = new GridData(GridData.FILL_HORIZONTAL);
> gd.heightHint = 0;
> tabFolder.setLayoutData(gd);


> Color selectedColor = toolkit.getColors().getColor(FormColors.SEPARATOR);
> tabFolder.setSelectionBackground(new Color[] {selectedColor,
> toolkit.getColors().getBackground()}, new int[] {50});
> tabFolder.setCursor(FormsResources.getHandCursor());

> toolkit.paintBordersFor(tabFolder);
> createOverviewTab(toolkit, null);
> createRatingTab(toolkit, null);
> tabFolder.setSelection(0);
> }

> private void createOverviewTab(FormToolkit toolkit, Composite parent) {
> CTabItem item = new CTabItem(tabFolder, SWT.NULL);
> item.setText(ClientPlugin.getDefault().
> getResourceString("overviewPage.label"));

> Text text = toolkit.createText(tabFolder, "Overview", SWT.SINGLE);
> text.setText("Overview");
> item.setControl(text);
> }

> private void createRatingTab(FormToolkit toolkit, Composite parent) {
> CTabItem item = new CTabItem(tabFolder, SWT.NULL);
> item.setText(ClientPlugin.getDefault().
> getResourceString("ratingIndustryPage.

> Text text = toolkit.createText(tabFolder, "Rating", SWT.SINGLE);
> text.setText("Rating / Industry");
> item.setControl(text);

> }
Previous Topic:ScrolledPageBook example
Next Topic:A question about Menu
Goto Forum:
  


Current Time: Wed Oct 21 02:41:07 GMT 2020

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

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

Back to the top