How to realize a proper WizardPage with ScrolledComposite? [message #448289] |
Thu, 20 April 2006 15:25 |
Daniel Krügler Messages: 853 Registered: July 2009 |
Senior Member |
|
|
Hello,
I would like to here any comments, whether the following
code is well-formed for implementing a WizardPage implementation
with a ScrolledComposite, because the page uses a dynamical
created widget list. The main questions are:
1) Do I properly integrate ScrolledComposite as one should do?
2) As you see, I do assume, that the parent provided by the
createControl method has layout data of type GridData. Is that something
I can trust in general? If not: Does there exist a proper method to
get the effect, that the wizard will be opened with its default
size and that the ScrolledComposite just shows scrolls bars if these
are needed?
Thank you very much for any hint,
Daniel Krügler
public void createControl(Composite parent) {
... // Init data
initializeDialogUnits(parent);
Control composite = doCreateControl(parent);
setControl(composite);
Dialog.applyDialogFont(composite);
}
private Control doCreateControl(Composite parent) {
Point initialSize = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
final ScrolledComposite scrolled = new ScrolledComposite(parent,
SWT.V_SCROLL | SWT.H_SCROLL);
scrolled.setFont(parent.getFont());
final Composite ctrl = new Composite(scrolled, SWT.NONE);
scrolled.setContent(ctrl);
scrolled.setExpandVertical(true);
scrolled.setExpandHorizontal(true);
ctrl.setFont(scrolled.getFont());
// makeSectionLayout is a helper method to generate
// a GridLayout for 2 columns (v.i.)
ctrl.setLayout(makeSectionLayout(2));
// Data model, which shall be presented here:
AnalytepropertyValueBean[] values = fValuesModel.getPropertyValues();
final int count = values.length;
.. // Prepare data binding stuff (ommitted here)
fCombos = new Combo[count];
fLabels = new Label[count];
for (int i = 0; i < count; ++i) {
// This method generates a pair of controls
// (a Label and a Combo) for each datum:
makeControls(fValuesModel, values, i, ctrl);
}
//!! Here follows the critical code: The reason for it
// is to get the effect that the wizard is shown in its
// default size (assuming no special widgets are
// provided to grow in height or width):
GridData parLayoutData = (GridData) parent.getLayoutData();
GridData controlData = new GridData(parLayoutData.horizontalAlignment,
parLayoutData.verticalAlignment,
parLayoutData.grabExcessHorizontalSpace,
parLayoutData.grabExcessVerticalSpace,
parLayoutData.horizontalSpan, parLayoutData.verticalSpan);
controlData.widthHint = initialSize.x;
controlData.heightHint = initialSize.y;
parent.setLayoutData(controlData);
scrolled.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
return scrolled;
}
public static GridLayout makeSectionLayout(int columns) {
final GridLayout sectionLayout = new GridLayout();
sectionLayout.numColumns = columns;
sectionLayout.verticalSpacing = ..;
sectionLayout.marginWidth = ..;
sectionLayout.marginHeight = ..;
return sectionLayout;
}
|
|
|
Re: How to realize a proper WizardPage with ScrolledComposite? [message #448342 is a reply to message #448289] |
Fri, 21 April 2006 07:24 |
Daniel Krügler Messages: 853 Registered: July 2009 |
Senior Member |
|
|
I would like to add that I really don't like the current
"solution", because of at least two reasons:
1) This is a single WizardPage from possible many but it
resets its **parents** layout data, thus this change influences
every other page.
2) It seems extremely insecure to rely on a special GridData
type of the parent.
The only reason for doing this is, that
- It has the effect I want to have, that is, the wizard
opens with its initial siez, that is with the size it has, if no
single widget has been attached to any wizard page
- I don't know to realize a corresponding solution without
modification of the *parent* layout data :-((. I made
several attempts to introduce a wrapper composite between
parent and the ScrolledComposite, but wasn't successful.
Any ideas are welcome!
Thanks in advance,
Daniel Krügler
|
|
|
Powered by
FUDForum. Page generated in 0.02935 seconds