[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [ptp-dev] Minimum expected display size for Eclipse user?
|
Interesting!!!!
I took the example from the documentation:
http://help.eclipse.org/help32/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/ScrolledComposite.html
and added it to the
org.eclipse.ptp.orte.ui.rmLaunchConfiguration.ORTERMLaunchConfigurationDynamicTab.java
code as shown below.
If N_ADDED_CHILDREN is zero then one button from each color
field appears. Pressing the "add children" button a number of
times will cause scrollbars to appear. Everything seems to be
acting normally.
If N_ADDED_CHILDREN is set to ten, then ten buttons from each
color field appear, but **NO** scrollbars!!!
If you hit the "add children" button a couple of times, then
the scrollbars **DO** appear and work as expected.
There is something about default/initial sizes that I don't understand.
Any suggestions? I'm going to continue playing with this.
public void createControl(Composite parent, IResourceManager rm,
IPQueue queue) throws CoreException {
Display display = parent.getDisplay();
Color red = display.getSystemColor(SWT.COLOR_RED);
Color blue = display.getSystemColor(SWT.COLOR_BLUE);
// Shell shell = new Shell (display);
// shell.setLayout(new FillLayout());
Composite shell = parent;
numProcsText = new Text(shell, SWT.NONE);
// set the size of the scrolled content - method 1
final ScrolledComposite sc1 = new ScrolledComposite(shell,
SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite c1 = new Composite(sc1, SWT.NONE);
sc1.setContent(c1);
c1.setBackground(red);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
c1.setLayout(layout);
Button b1 = new Button (c1, SWT.PUSH);
b1.setText("first button");
c1.setSize(timesX(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT),2));
// set the minimum width and height of the scrolled content - method 2
final ScrolledComposite sc2 = new ScrolledComposite(shell,
SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
sc2.setExpandHorizontal(true);
sc2.setExpandVertical(true);
final Composite c2 = new Composite(sc2, SWT.NONE);
sc2.setContent(c2);
c2.setBackground(blue);
layout = new GridLayout();
layout.numColumns = 4;
c2.setLayout(layout);
Button b2 = new Button (c2, SWT.PUSH);
b2.setText("first button");
sc2.setMinSize(timesX(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT),2));
Button add = new Button (shell, SWT.PUSH);
add.setText("add children");
final int[] index = new int[]{0};
add.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
addChildren(c1, sc2, c2, index);
}
});
for (int i=0; i < N_ADDED_CHILDREN; ++i) {
addChildren(c1, sc2, c2, index);
}
}
private Point timesX(Point computeSize, int d) {
return new Point(computeSize.x*d, computeSize.y*d);
}
/**
* @param c1
* @param sc2
* @param c2
* @param index
*/
private void addChildren(final Composite c1, final ScrolledComposite
sc2,
final Composite c2, final int[] index) {
index[0]++;
Button button = new Button(c1, SWT.PUSH);
button.setText("button "+index[0]);
// reset size of content so children can be seen - method 1
c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
c1.layout();
button = new Button(c2, SWT.PUSH);
button.setText("button "+index[0]);
// reset the minimum width and height so children can be seen - method
2
sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
c2.layout();
}