From 10e4a8636f840265f9d8a55a03f1f6b85117b9df Mon Sep 17 00:00:00 2001 From: Veronika Irvine Date: Wed, 12 Sep 2001 12:49:14 +0000 Subject: *** empty log message *** --- .../org/eclipse/swt/custom/ScrolledComposite.java | 75 ++++++++++++++++++++-- 1 file changed, 69 insertions(+), 6 deletions(-) (limited to 'bundles') diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java index daadb8facb..164ba0468c 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java @@ -9,17 +9,80 @@ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; -/* +/** * A ScrolledComposite provides scrollbars and will scroll its content when the user * uses the scrollbars. * - *

If the ScrolledComposite can be configured to stretch the content to be as big as the - * ScrolledComposite when the composite is resized to a size larger than the minimum width - * or minimum height and to provide scrolls when the ScrolledComposite is smaller than the - * minimum width and minimum height. Refer to the methods setExpandHorizontal, - * setExpandVertical, setMinWidth and setMinHeight. * + *

There are two ways to use the ScrolledComposite: + * *

+ * 1) Set the size of the control that is being scrolled and the ScrolledComposite + * will show scrollbars when the contained control can not be fully seen. + * + *

+ * public static void main (String [] args) {
+ *         Display display = new Display ();
+ *         Color red = display.getSystemColor(SWT.COLOR_RED);
+ *         Shell shell = new Shell (display);
+ *         shell.setLayout(new FillLayout());
+ *         ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
+ *         Composite c = new Composite(sc, SWT.NONE);
+ *         c.setBackground(red);
+ *         sc.setContent(c);
+ *         GridLayout layout = new GridLayout();
+ *         layout.numColumns = 5;
+ *         c.setLayout(layout);
+ *         for (int i = 0; i < 10; i++) {
+ *                 Button b1 = new Button(c, SWT.PUSH);
+ *                 b1.setText("button "+i);
+ *         }
+ *         Point pt = c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ *         c.setSize(pt);
+ *         shell.open ();
+ *         while (!shell.isDisposed ()) {
+ *             if (!display.readAndDispatch ()) display.sleep ();
+ *         }
+ *         display.dispose ();
+ * }
+ * 
+ * + * 2) The second way imitates the way a browser would work. Set the minimum size of + * the control and the ScrolledComposite will show scroll bars if the visible area is + * less than the minimum size of the control and it will expand the size of the control + * if the visible area is greater than the minimum size. This requires invoking + * both setMinWidth(), setMinHeight() and setExpandHorizontal(), setExpandVertical(). + * + *
+ * public static void main (String [] args) {
+ *         Display display = new Display ();
+ *         Color red = display.getSystemColor(SWT.COLOR_RED);
+ *         Shell shell = new Shell (display);
+ *         shell.setLayout(new FillLayout());
+ *         ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
+ *         Composite c = new Composite(sc, SWT.NONE);
+ *         c.setBackground(red);
+ *         sc.setContent(c);
+ *         GridLayout layout = new GridLayout();
+ *         layout.numColumns = 5;
+ *         c.setLayout(layout);
+ *         for (int i = 0; i < 10; i++) {
+ *                 Button b1 = new Button(c, SWT.PUSH);
+ *                 b1.setText("button "+i);
+ *         }
+ *         Point pt = c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ *         sc.setExpandHorizontal(true);
+ *         sc.setExpandVertical(true);
+ *         sc.setMinWidth(pt.x);
+ *         sc.setMinHeight(pt.y);
+ *         shell.open ();
+ *         while (!shell.isDisposed ()) {
+ *             if (!display.readAndDispatch ()) display.sleep ();
+ *         }
+ *         display.dispose ();
+ * }
+ * 
+ * *
*
Styles:
H_SCROLL, V_SCROLL *
-- cgit v1.2.3