Width of compound widget [message #447744] |
Thu, 16 December 2004 20:57 |
Thorsten Messages: 5 Registered: July 2009 |
Junior Member |
|
|
Hi,
I have created a compound widget which consists of a Combo and a Button. I
would like to layout this compound together with other Combos (vertically)
unfortunately neither the left edge of the Combo fits the left edge of the
Combo above nor the right edge of the Button fits the right edge of the
Combo above. It looks like this:
--------------------
Label | combo |
--------------------
------------- ----
Label | combo | |BT|
------------- ----
Here is the code that creates the compound widget:
Initialisation of compound widget (CountrySelector):
private void init(Composite parent) {
GridLayout layout= new GridLayout(2, false);
this.setLayout(layout);
GridData gd= new GridData(GridData.FILL_HORIZONTAL |
GridData.GRAB_HORIZONTAL);
countryName = new Combo(this, SWT.SINGLE | SWT.BORDER);
countryName.setLayoutData(gd);
gd= new GridData();
gd.heightHint = countryName.computeSize(SWT.DEFAULT, SWT.DEFAULT,
false).y;
searchButton = new Button(this, SWT.PUSH);
searchButton.setText("...");
searchButton.setLayoutData(gd);
}
Here is the code that creates the control in a SearchPage:
public void createControl(Composite parent) {
initializeDialogUnits(parent);
GridData gd;
Composite result= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout(2, false);
result.setLayout(layout);
Label label= new Label(result, SWT.LEFT);
label.setText(SearchMessages.getString("SearchPage.containingText.text "));
gd= new GridData(GridData.BEGINNING);
gd.horizontalSpan= 1;
label.setLayoutData(gd);
Combo combo = new Combo(result, SWT.SINGLE | SWT.BORDER);;
gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan= 1;
combo.setLayoutData(gd);
label= new Label(result, SWT.LEFT);
label.setText(SearchMessages.getString("SearchPage.containingText.text "));
gd= new GridData(GridData.BEGINNING);
gd.horizontalSpan= 1;
label.setLayoutData(gd);
CountrySelector countrySelector = new CountrySelector(result, SWT.NONE);;
gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan= 1;
countrySelector.setLayoutData(gd);
setControl(result);
Dialog.applyDialogFont(result);
}
I have no experience with SWT since I am usually programming Swing but it
seems to me that the Composite that makes up the compound also uses a
border or trim or whatever. I have studied the article "Creating Your Own
Widgets using SWT" but I don't really see how to solve this problem. Help
would be appreciated.
Thanx in advance
Thorsten
|
|
|
Powered by
FUDForum. Page generated in 0.04299 seconds