Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample')
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/AlignableTab.java73
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ButtonTab.java175
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ComboTab.java102
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ControlExample.java94
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/DialogTab.java417
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/Images.java50
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/LabelTab.java152
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ListTab.java71
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ProgressBarTab.java99
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/RangeTab.java154
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/SashTab.java155
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ScrollableTab.java47
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ShellTab.java212
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/SliderTab.java212
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/Tab.java354
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TableTab.java172
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TextTab.java96
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ToolBarTab.java261
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TreeTab.java111
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/folder.gifbin0 -> 906 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/folderOpen.gifbin0 -> 184 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/stop.gifbin0 -> 917 bytes
22 files changed, 3007 insertions, 0 deletions
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/AlignableTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/AlignableTab.java
new file mode 100755
index 0000000000..10a96c039b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/AlignableTab.java
@@ -0,0 +1,73 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+/**
+* <code>AlignableTab</code> is the abstract
+* superclass of example controls that can be
+* aligned.
+*/
+
+abstract class AlignableTab extends Tab {
+
+ /* Allignment Controls */
+ Button leftButton, rightButton, centerButton;
+
+ /* Alignment Group */
+ Group allignmentGroup;
+/**
+* Creates the "Control" group.
+*/
+void createControlGroup () {
+ super.createControlGroup ();
+
+ /* Create the group */
+ allignmentGroup = new Group (controlGroup, SWT.NULL);
+ allignmentGroup.setLayout (new GridLayout ());
+ allignmentGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ allignmentGroup.setText (resControls.getString("Alignment"));
+
+ /* Create the controls */
+ leftButton = new Button (allignmentGroup, SWT.RADIO);
+ leftButton.setText (resControls.getString("Left"));
+ centerButton = new Button (allignmentGroup, SWT.RADIO);
+ centerButton.setText(resControls.getString("Center"));
+ rightButton = new Button (allignmentGroup, SWT.RADIO);
+ rightButton.setText (resControls.getString("Right"));
+
+ /* Add the listeners */
+ SelectionListener selectionListener = new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent event) {
+ if (!((Button) event.widget).getSelection ()) return;
+ setExampleWidgetAlignment ();
+ };
+ };
+ leftButton.addSelectionListener (selectionListener);
+ centerButton.addSelectionListener (selectionListener);
+ rightButton.addSelectionListener (selectionListener);
+}
+/**
+* Sets the alignment of the "Example" widgets.
+*/
+abstract void setExampleWidgetAlignment ();
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ Control [] controls = getExampleWidgets ();
+ if (controls.length != 0) {
+ leftButton.setSelection ((controls [0].getStyle () & SWT.LEFT) != 0);
+ centerButton.setSelection ((controls [0].getStyle () & SWT.CENTER) != 0);
+ rightButton.setSelection ((controls [0].getStyle () & SWT.RIGHT) != 0);
+ }
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ButtonTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ButtonTab.java
new file mode 100755
index 0000000000..0b3697b400
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ButtonTab.java
@@ -0,0 +1,175 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+/**
+* <code>ButtonTab</code> is the class that
+* demonstrates SWT buttons.
+*/
+
+class ButtonTab extends AlignableTab {
+
+ /* Example widgets and groups that contain them */
+ Button button1, button2, button3, button4, button5, button6;
+ Group textButtonGroup, imageButtonGroup;
+
+ /* Allignment widgets added to the "Control" group */
+ Button upButton, downButton;
+
+ /* Style widgets added to the "Style" group */
+ Button pushButton, checkButton, radioButton, toggleButton, arrowButton;
+/**
+* Creates the "Control" group.
+*/
+void createControlGroup () {
+ super.createControlGroup ();
+
+ /* Create the controls */
+ upButton = new Button (allignmentGroup, SWT.RADIO);
+ upButton.setText (resControls.getString("Up"));
+ downButton = new Button (allignmentGroup, SWT.RADIO);
+ downButton.setText (resControls.getString("Down"));
+
+ /* Add the listeners */
+ SelectionListener selectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ if (!((Button) event.widget).getSelection()) return;
+ setExampleWidgetAlignment ();
+ };
+ };
+ upButton.addSelectionListener(selectionListener);
+ downButton.addSelectionListener(selectionListener);
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for text buttons */
+ textButtonGroup = new Group(exampleGroup, SWT.NONE);
+ GridLayout gridLayout = new GridLayout ();
+ textButtonGroup.setLayout(gridLayout);
+ gridLayout.numColumns = 3;
+ textButtonGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ textButtonGroup.setText (resControls.getString("Text_Buttons"));
+
+ /* Create a group for the image buttons */
+ imageButtonGroup = new Group(exampleGroup, SWT.NONE);
+ gridLayout = new GridLayout();
+ imageButtonGroup.setLayout(gridLayout);
+ gridLayout.numColumns = 3;
+ imageButtonGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ imageButtonGroup.setText (resControls.getString("Image_Buttons"));
+
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (pushButton.getSelection()) style |= SWT.PUSH;
+ if (checkButton.getSelection()) style |= SWT.CHECK;
+ if (radioButton.getSelection()) style |= SWT.RADIO;
+ if (toggleButton.getSelection()) style |= SWT.TOGGLE;
+ if (arrowButton.getSelection()) style |= SWT.ARROW;
+ if (borderButton.getSelection()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ button1 = new Button(textButtonGroup, style);
+ button1.setText(resControls.getString("One"));
+ button2 = new Button(textButtonGroup, style);
+ button2.setText(resControls.getString("Two"));
+ button3 = new Button(textButtonGroup, style);
+ button3.setText(resControls.getString("Three"));
+ button4 = new Button(imageButtonGroup, style);
+ button4.setImage(Images.CLOSED_FOLDER_IMAGE);
+ button5 = new Button(imageButtonGroup, style);
+ button5.setImage(Images.OPEN_FOLDER_IMAGE);
+ button6 = new Button(imageButtonGroup, style);
+ button6.setImage(Images.TARGET_IMAGE);
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup() {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ pushButton = new Button (styleGroup, SWT.RADIO);
+ pushButton.setText(resControls.getString("SWT_PUSH"));
+ checkButton = new Button (styleGroup, SWT.RADIO);
+ checkButton.setText (resControls.getString("SWT_CHECK"));
+ radioButton = new Button (styleGroup, SWT.RADIO);
+ radioButton.setText (resControls.getString("SWT_RADIO"));
+ toggleButton = new Button (styleGroup, SWT.RADIO);
+ toggleButton.setText (resControls.getString("SWT_TOGGLE"));
+ arrowButton = new Button (styleGroup, SWT.RADIO);
+ arrowButton.setText (resControls.getString("SWT_ARROW"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {button1, button2, button3, button4, button5, button6};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Button");
+}
+/**
+* Sets the alignment of the "Example" widgets.
+*/
+void setExampleWidgetAlignment () {
+ int allignment = 0;
+ if (leftButton.getSelection ()) allignment = SWT.LEFT;
+ if (centerButton.getSelection ()) allignment = SWT.CENTER;
+ if (rightButton.getSelection ()) allignment = SWT.RIGHT;
+ if (upButton.getSelection ()) allignment = SWT.UP;
+ if (downButton.getSelection ()) allignment = SWT.DOWN;
+ button1.setAlignment (allignment);
+ button2.setAlignment (allignment);
+ button3.setAlignment (allignment);
+ button4.setAlignment (allignment);
+ button5.setAlignment (allignment);
+ button6.setAlignment (allignment);
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ if (arrowButton.getSelection ()) {
+ upButton.setEnabled (true);
+ centerButton.setEnabled (false);
+ downButton.setEnabled (true);
+ } else {
+ upButton.setEnabled (false);
+ centerButton.setEnabled (true);
+ downButton.setEnabled (false);
+ }
+ upButton.setSelection ((button1.getStyle () & SWT.UP) != 0);
+ downButton.setSelection ((button1.getStyle () & SWT.DOWN) != 0);
+ pushButton.setSelection ((button1.getStyle () & SWT.PUSH) != 0);
+ checkButton.setSelection ((button1.getStyle () & SWT.CHECK) != 0);
+ radioButton.setSelection ((button1.getStyle () & SWT.RADIO) != 0);
+ toggleButton.setSelection ((button1.getStyle () & SWT.TOGGLE) != 0);
+ arrowButton.setSelection ((button1.getStyle () & SWT.ARROW) != 0);
+ borderButton.setSelection ((button1.getStyle () & SWT.BORDER) != 0);
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ComboTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ComboTab.java
new file mode 100755
index 0000000000..9b4f5fdade
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ComboTab.java
@@ -0,0 +1,102 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ComboTab extends Tab {
+
+ /* Example widgets and groups that contain them */
+ Combo combo1;
+ Group comboGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button dropDownButton, readOnlyButton, simpleButton;
+
+ static String [] ListData = {resControls.getString("ListData0_0"),
+ resControls.getString("ListData0_1"),
+ resControls.getString("ListData0_2"),
+ resControls.getString("ListData0_3"),
+ resControls.getString("ListData0_4"),
+ resControls.getString("ListData0_5"),
+ resControls.getString("ListData0_6"),
+ resControls.getString("ListData0_7"),
+ resControls.getString("ListData0_8")};
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the combo box */
+ comboGroup = new Group (exampleGroup, SWT.NULL);
+ comboGroup.setLayout (new GridLayout ());
+ comboGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ comboGroup.setText (resControls.getString("Combo"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (dropDownButton.getSelection ()) style |= SWT.DROP_DOWN;
+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY;
+ if (simpleButton.getSelection ()) style |= SWT.SIMPLE;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ combo1 = new Combo (comboGroup, style);
+ combo1.setItems (ListData);
+ if (ListData.length >= 3) {
+ combo1.setText(ListData [2]);
+ }
+
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ dropDownButton = new Button (styleGroup, SWT.RADIO);
+ dropDownButton.setText (resControls.getString("SWT_DROP_DOWN"));
+ simpleButton = new Button (styleGroup, SWT.RADIO);
+ simpleButton.setText(resControls.getString("SWT_SIMPLE"));
+ readOnlyButton = new Button (styleGroup, SWT.CHECK);
+ readOnlyButton.setText (resControls.getString("SWT_READ_ONLY"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {combo1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Combo");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ dropDownButton.setSelection ((combo1.getStyle () & SWT.DROP_DOWN) != 0);
+ simpleButton.setSelection ((combo1.getStyle () & SWT.SIMPLE) != 0);
+ readOnlyButton.setSelection ((combo1.getStyle () & SWT.READ_ONLY) != 0);
+ borderButton.setSelection ((combo1.getStyle () & SWT.BORDER) != 0);
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ControlExample.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ControlExample.java
new file mode 100755
index 0000000000..88e477f0ad
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ControlExample.java
@@ -0,0 +1,94 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import java.util.ResourceBundle;
+
+/**
+* <code>ControlExample</code> is a simple demonstration
+* of the controls defined by SWT. It consists of a shell
+* and tab folder where each tab in the folder allows the
+* user to interact with a control.
+*/
+
+public class ControlExample {
+ Shell shell;
+ TabFolder tabFolder;
+ ResourceBundle resControls = ResourceBundle.getBundle("examples_control");
+/**
+* Create a new example and open it.
+*
+* @param args the command line arguments
+*
+*/
+public static void main (String[] args) {
+ new ControlExample ().open ();
+}
+/**
+* Open the example.
+*/
+void open () {
+
+ /* Load resources */
+ Images.loadImages ();
+
+ /* Create the shell */
+ shell = new Shell ();
+ shell.setText (resControls.getString("Control_Example"));
+ shell.addControlListener (new ControlAdapter () {
+ public void controlResized (ControlEvent e) {
+ tabFolder.setBounds (shell.getClientArea ());
+ }
+ });
+
+ /* Create the tab folder */
+ ShellTab shellTab = new ShellTab ();
+ tabFolder = new TabFolder (shell, SWT.NULL);
+ Tab [] tabs = new Tab [] {
+ new ButtonTab (),
+ new ComboTab (),
+ new DialogTab (),
+ new LabelTab (),
+ new ListTab (),
+ new ProgressBarTab (),
+ new SashTab (),
+ shellTab,
+ new SliderTab (),
+ new TableTab (),
+ new TextTab (),
+ new ToolBarTab (),
+ new TreeTab (),
+ };
+ for (int i=0; i<tabs.length; i++) {
+ TabItem item = new TabItem (tabFolder, SWT.NULL);
+ item.setText (tabs [i].getTabText ());
+ item.setControl (tabs [i].createTabFolderPage (tabFolder));
+ }
+
+ /* Run the event loop */
+ shell.open ();
+ Display display = Display.getDefault ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+
+ /*
+ * Destroy any shells that may have been created
+ * by the Shells tab. When a shell is disposed,
+ * all child shells are also disposed. Therefore
+ * it is necessary to check for disposed shells
+ * in the shells list to avoid disposing a shell
+ * twice.
+ */
+ shellTab.closeAllShells ();
+
+ /* Free resources */
+ Images.freeImages ();
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/DialogTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/DialogTab.java
new file mode 100755
index 0000000000..76a56e521e
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/DialogTab.java
@@ -0,0 +1,417 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class DialogTab extends Tab {
+
+ /* Example widgets and groups that contain them */
+ Group dialogStyleGroup, resultGroup;
+ Text textWidget;
+
+ /* Style widgets added to the "Style" group */
+ Combo dialogCombo;
+ Button okButton, cancelButton;
+ Button yesButton, noButton;
+ Button retryButton;
+ Button abortButton, ignoreButton;
+ Button iconErrorButton, iconInformationButton, iconQuestionButton;
+ Button iconWarningButton, iconWorkingButton;
+ Button modelessButton, primaryModalButton, applicationModalButton, systemModalButton;
+ Button saveButton, openButton;
+
+ static String [] FilterExtensions = {".txt.", ".bat", ".doc"};
+ static String [] FilterNames = {resControls.getString("FilterName_0"),
+ resControls.getString("FilterName_1"),
+ resControls.getString("FilterName_2")};
+
+/**
+* Handle a button style selection event.
+*
+* @param event the selection event
+*/
+void buttonStyleSelected(SelectionEvent event) {
+ /*
+ * Only certain combinations of button styles are
+ * supported for various dialogs. Make sure the
+ * control widget reflects only valid combinations.
+ */
+ okButton.setEnabled (
+ !(yesButton.getSelection () || noButton.getSelection () ||
+ retryButton.getSelection () || abortButton.getSelection () ||
+ ignoreButton.getSelection ()));
+ cancelButton.setEnabled (
+ !(abortButton.getSelection () || ignoreButton.getSelection ()));
+ yesButton.setEnabled (
+ !(okButton.getSelection () || retryButton.getSelection () ||
+ abortButton.getSelection () || ignoreButton.getSelection ()));
+ noButton.setEnabled (
+ !(okButton.getSelection () || retryButton.getSelection () ||
+ abortButton.getSelection () || ignoreButton.getSelection ()));
+ retryButton.setEnabled (
+ !(okButton.getSelection() || yesButton.getSelection() || noButton.getSelection ()));
+ abortButton.setEnabled (
+ !(okButton.getSelection () || cancelButton.getSelection () ||
+ yesButton.getSelection () || noButton.getSelection ()));
+ ignoreButton.setEnabled (
+ !(okButton.getSelection () || cancelButton.getSelection () |
+ yesButton.getSelection () || noButton.getSelection ()));
+}
+/**
+ * Handle the create button selection event.
+ *
+ * @param event org.eclipse.swt.events.SelectionEvent
+ */
+void createButtonSelected(SelectionEvent event) {
+
+ /* Compute the appropriate dialog style */
+ int style = SWT.NULL;
+ if (okButton.getEnabled () && okButton.getSelection ()) style |= SWT.OK;
+ if (cancelButton.getEnabled () && cancelButton.getSelection ()) style |= SWT.CANCEL;
+ if (yesButton.getEnabled () && yesButton.getSelection ()) style |= SWT.YES;
+ if (noButton.getEnabled () && noButton.getSelection ()) style |= SWT.NO;
+ if (retryButton.getEnabled () && retryButton.getSelection ()) style |= SWT.RETRY;
+ if (abortButton.getEnabled () && abortButton.getSelection ()) style |= SWT.ABORT;
+ if (ignoreButton.getEnabled () && ignoreButton.getSelection ()) style |= SWT.IGNORE;
+ if (iconErrorButton.getEnabled () && iconErrorButton.getSelection ()) style |= SWT.ICON_ERROR;
+ if (iconInformationButton.getEnabled () && iconInformationButton.getSelection ()) style |= SWT.ICON_INFORMATION;
+ if (iconQuestionButton.getEnabled () && iconQuestionButton.getSelection ()) style |= SWT.ICON_QUESTION;
+ if (iconWarningButton.getEnabled () && iconWarningButton.getSelection ()) style |= SWT.ICON_WARNING;
+ if (iconWorkingButton.getEnabled () && iconWorkingButton.getSelection ()) style |= SWT.ICON_WORKING;
+ if (primaryModalButton.getEnabled () && primaryModalButton.getSelection ()) style |= SWT.PRIMARY_MODAL;
+ if (applicationModalButton.getEnabled () && applicationModalButton.getSelection ()) style |= SWT.APPLICATION_MODAL;
+ if (systemModalButton.getEnabled () && systemModalButton.getSelection ()) style |= SWT.SYSTEM_MODAL;
+ if (saveButton.getEnabled () && saveButton.getSelection ()) style |= SWT.SAVE;
+ if (openButton.getEnabled () && openButton.getSelection ()) style |= SWT.OPEN;
+
+ /* Open the appropriate dialog type */
+ String name = dialogCombo.getText ();
+ Shell shell = tabFolderPage.getShell ();
+
+ if (name.equals (resControls.getString("ColorDialog"))) {
+ ColorDialog dialog = new ColorDialog (shell ,style);
+ dialog.setRGB (new RGB (100, 100, 100));
+ dialog.setText (resControls.getString("Title"));
+ RGB result = dialog.open ();
+ textWidget.append (resControls.getString("ColorDialog") + Text.DELIMITER);
+ textWidget.append (resControls.getString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (resControls.getString("DirectoryDialog"))) {
+ DirectoryDialog dialog = new DirectoryDialog (shell, style);
+ dialog.setMessage (resControls.getString("Example_string"));
+ dialog.setText (resControls.getString("Title"));
+ String result = dialog.open ();
+ textWidget.append (resControls.getString("DirectoryDialog") + Text.DELIMITER);
+ textWidget.append (resControls.getString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (resControls.getString("FileDialog"))) {
+ FileDialog dialog = new FileDialog (shell, style);
+ dialog.setFileName (resControls.getString("readme_txt"));
+ dialog.setFilterNames (FilterNames);
+ dialog.setFilterExtensions (FilterExtensions);
+ dialog.setText (resControls.getString("Title"));
+ String result = dialog.open();
+ textWidget.append (resControls.getString("FileDialog") + Text.DELIMITER);
+ textWidget.append (resControls.getString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (resControls.getString("FontDialog"))) {
+ FontDialog dialog = new FontDialog (shell, style);
+ dialog.setText (resControls.getString("Title"));
+ FontData result = dialog.open ();
+ textWidget.append (resControls.getString("FontDialog") + Text.DELIMITER);
+ textWidget.append (resControls.getString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals(resControls.getString("MessageBox"))) {
+ MessageBox dialog = new MessageBox (shell, style);
+ dialog.setMessage (resControls.getString("Example_string"));
+ dialog.setText (resControls.getString("Title"));
+ int result = dialog.open ();
+ textWidget.append (resControls.getString("MessageBox") + Text.DELIMITER);
+ /*
+ * The resulting integer depends on the original
+ * dialog style. Decode the result and display it.
+ */
+ switch (result) {
+ case SWT.OK:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_OK"));
+ break;
+ case SWT.YES:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_YES"));
+ break;
+ case SWT.NO:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_NO"));
+ break;
+ case SWT.CANCEL:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_CANCEL"));
+ break;
+ case SWT.ABORT:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_ABORT"));
+ break;
+ case SWT.RETRY:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_RETRY"));
+ break;
+ case SWT.IGNORE:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_IGNORE"));
+ break;
+ default:
+ textWidget.append(resControls.getString("Result") + result);
+ break;
+ }
+ textWidget.append (Text.DELIMITER + Text.DELIMITER);
+ }
+}
+/**
+* Creates the "Control" group.
+*/
+void createControlGroup () {
+ /*
+ * Create the "Control" group. This is the group on the
+ * left half of each example tab. It consists of the
+ * style group, the display group and the size group.
+ */
+ controlGroup = new Group (tabFolderPage, SWT.NULL);
+ GridLayout gridLayout= new GridLayout ();
+ controlGroup.setLayout(gridLayout);
+ gridLayout.numColumns = 2;
+ gridLayout.makeColumnsEqualWidth = true;
+ controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ controlGroup.setText (resControls.getString("Parameters"));
+
+ /*
+ * Create a group to hold the dialog style combo box and
+ * create dialog button.
+ */
+ dialogStyleGroup = new Group (controlGroup, SWT.NULL);
+ dialogStyleGroup.setLayout (new GridLayout ());
+ GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER);
+ gridData.horizontalSpan = 2;
+ dialogStyleGroup.setLayoutData (gridData);
+ dialogStyleGroup.setText (resControls.getString("Dialog_Type"));
+}
+/**
+* Creates the "Control" widget children.
+*/
+void createControlWidgets () {
+
+ /* Create the combo */
+ String [] strings = {
+ resControls.getString("ColorDialog"),
+ resControls.getString("DirectoryDialog"),
+ resControls.getString("FileDialog"),
+ resControls.getString("FontDialog"),
+ resControls.getString("MessageBox"),
+ };
+ dialogCombo = new Combo (dialogStyleGroup, SWT.READ_ONLY);
+ dialogCombo.setItems (strings);
+ dialogCombo.setText (strings [0]);
+
+ /* Create the create dialog button */
+ Button createButton = new Button(dialogStyleGroup, SWT.NULL);
+ createButton.setText (resControls.getString("Create_Dialog"));
+ createButton.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
+
+ /* Create a group for the various dialog button style controls */
+ Group buttonStyleGroup = new Group (controlGroup, SWT.NULL);
+ buttonStyleGroup.setLayout (new GridLayout ());
+ buttonStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ buttonStyleGroup.setText (resControls.getString("Button_Styles"));
+
+ /* Create the button style buttons */
+ okButton = new Button (buttonStyleGroup, SWT.CHECK);
+ okButton.setText (resControls.getString("SWT_OK"));
+ cancelButton = new Button (buttonStyleGroup, SWT.CHECK);
+ cancelButton.setText (resControls.getString("SWT_CANCEL"));
+ yesButton = new Button (buttonStyleGroup, SWT.CHECK);
+ yesButton.setText (resControls.getString("SWT_YES"));
+ noButton = new Button (buttonStyleGroup, SWT.CHECK);
+ noButton.setText (resControls.getString("SWT_NO"));
+ retryButton = new Button (buttonStyleGroup, SWT.CHECK);
+ retryButton.setText (resControls.getString("SWT_RETRY"));
+ abortButton = new Button (buttonStyleGroup, SWT.CHECK);
+ abortButton.setText (resControls.getString("SWT_ABORT"));
+ ignoreButton = new Button (buttonStyleGroup, SWT.CHECK);
+ ignoreButton.setText (resControls.getString("SWT_IGNORE"));
+
+ /* Create a group for the icon style controls */
+ Group iconStyleGroup = new Group (controlGroup, SWT.NULL);
+ iconStyleGroup.setLayout (new GridLayout ());
+ iconStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ iconStyleGroup.setText (resControls.getString("Icon_Styles"));
+
+ /* Create the icon style buttons */
+ iconErrorButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconErrorButton.setText (resControls.getString("SWT_ICON_ERROR"));
+ iconInformationButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconInformationButton.setText (resControls.getString("SWT_ICON_INFORMATION"));
+ iconQuestionButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconQuestionButton.setText (resControls.getString("SWT_ICON_QUESTION"));
+ iconWarningButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconWarningButton.setText (resControls.getString("SWT_ICON_WARNING"));
+ iconWorkingButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconWorkingButton.setText (resControls.getString("SWT_ICON_WORKING"));
+
+ /* Create a group for the modal style controls */
+ Group modalStyleGroup = new Group (controlGroup, SWT.NULL);
+ modalStyleGroup.setLayout (new GridLayout ());
+ modalStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ modalStyleGroup.setText (resControls.getString("Modal_Styles"));
+
+ /* Create the modal style buttons */
+ modelessButton = new Button (modalStyleGroup, SWT.RADIO);
+ modelessButton.setText (resControls.getString("SWT_MODELESS"));
+ primaryModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ primaryModalButton.setText (resControls.getString("SWT_PRIMARY_MODAL"));
+ applicationModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ applicationModalButton.setText (resControls.getString("SWT_APPLICATION_MODAL"));
+ systemModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ systemModalButton.setText (resControls.getString("SWT_SYSTEM_MODAL"));
+
+ /* Create a group for the file dialog style controls */
+ Group fileDialogStyleGroup = new Group (controlGroup, SWT.NULL);
+ fileDialogStyleGroup.setLayout (new GridLayout ());
+ fileDialogStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ fileDialogStyleGroup.setText (resControls.getString("File_Dialog_Styles"));
+
+ /* Create the file dialog style buttons */
+ saveButton = new Button (fileDialogStyleGroup, SWT.RADIO);
+ saveButton.setText (resControls.getString("SWT_SAVE"));
+ openButton = new Button(fileDialogStyleGroup, SWT.RADIO);
+ openButton.setText(resControls.getString("SWT_OPEN"));
+
+ /* Add the listeners */
+ dialogCombo.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ dialogSelected (event);
+ };
+ });
+ createButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ createButtonSelected (event);
+ };
+ });
+ SelectionListener buttonStyleListener = new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ buttonStyleSelected (event);
+ };
+ };
+ okButton.addSelectionListener (buttonStyleListener);
+ cancelButton.addSelectionListener (buttonStyleListener);
+ yesButton.addSelectionListener (buttonStyleListener);
+ noButton.addSelectionListener (buttonStyleListener);
+ retryButton.addSelectionListener (buttonStyleListener);
+ abortButton.addSelectionListener (buttonStyleListener);
+ ignoreButton.addSelectionListener (buttonStyleListener);
+
+ /* Set default values for style buttons */
+ okButton.setEnabled (false);
+ cancelButton.setEnabled (false);
+ yesButton.setEnabled (false);
+ noButton.setEnabled (false);
+ retryButton.setEnabled (false);
+ abortButton.setEnabled (false);
+ ignoreButton.setEnabled (false);
+ iconErrorButton.setEnabled (false);
+ iconInformationButton.setEnabled (false);
+ iconQuestionButton.setEnabled (false);
+ iconWarningButton.setEnabled (false);
+ iconWorkingButton.setEnabled (false);
+ saveButton.setEnabled (false);
+ openButton.setEnabled (false);
+ openButton.setSelection (true);
+ iconInformationButton.setSelection (true);
+ modelessButton.setSelection (true);
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /*
+ * Create a group for the text widget to display
+ * the results returned by the example dialogs.
+ */
+ resultGroup = new Group (exampleGroup, SWT.NULL);
+ resultGroup.setLayout (new GridLayout ());
+ resultGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ resultGroup.setText (resControls.getString("Dialog_Result"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+ /*
+ * Create a multi lined, scrolled text widget for output.
+ */
+ textWidget = new Text(resultGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ GridData gridData = new GridData ();
+ gridData.widthHint = 300;
+ gridData.heightHint = 400;
+ textWidget.setLayoutData (gridData);
+}
+/**
+* Handle a dialog type combo selection event.
+*
+* @param event the selection event
+*/
+void dialogSelected (SelectionEvent event) {
+
+ /* Enable/Disable the buttons */
+ String name = dialogCombo.getText ();
+ boolean isMessageBox = name.equals (resControls.getString("MessageBox"));
+ boolean isFileDialog = name.equals (resControls.getString("FileDialog"));
+ okButton.setEnabled (isMessageBox);
+ cancelButton.setEnabled (isMessageBox);
+ yesButton.setEnabled (isMessageBox);
+ noButton.setEnabled (isMessageBox);
+ retryButton.setEnabled (isMessageBox);
+ abortButton.setEnabled (isMessageBox);
+ ignoreButton.setEnabled (isMessageBox);
+ iconErrorButton.setEnabled (isMessageBox);
+ iconInformationButton.setEnabled (isMessageBox);
+ iconQuestionButton.setEnabled (isMessageBox);
+ iconWarningButton.setEnabled (isMessageBox);
+ iconWorkingButton.setEnabled (isMessageBox);
+ saveButton.setEnabled (isFileDialog);
+ openButton.setEnabled (isFileDialog);
+
+ /* Unselect the buttons */
+ if (!isMessageBox) {
+ okButton.setSelection (false);
+ cancelButton.setSelection (false);
+ yesButton.setSelection (false);
+ noButton.setSelection (false);
+ retryButton.setSelection (false);
+ abortButton.setSelection (false);
+ ignoreButton.setSelection (false);
+ }
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [0];
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Dialog");
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/Images.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/Images.java
new file mode 100755
index 0000000000..5c536330d4
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/Images.java
@@ -0,0 +1,50 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.ResourceBundle;
+
+/**
+* <code>Images</code> contains every image
+* that is used by the example.
+*/
+class Images {
+ static Image CLOSED_FOLDER_IMAGE;
+ static Image OPEN_FOLDER_IMAGE;
+ static Image TARGET_IMAGE;
+ private static ResourceBundle resControl = ResourceBundle.getBundle("examples_control");
+/**
+* Free the images.
+*/
+public static void freeImages () {
+ CLOSED_FOLDER_IMAGE.dispose ();
+ OPEN_FOLDER_IMAGE.dispose ();
+ TARGET_IMAGE.dispose ();
+}
+/**
+ * Load the images.
+ */
+public static void loadImages () {
+ Class clazz = Images.class;
+ try {
+ ImageData source = new ImageData(clazz.getResourceAsStream ("folder.gif"));
+ ImageData mask = source.getTransparencyMask();
+ CLOSED_FOLDER_IMAGE = new Image (null, source, mask);
+
+ source = new ImageData(clazz.getResourceAsStream ("folderOpen.gif"));
+ mask = source.getTransparencyMask();
+ OPEN_FOLDER_IMAGE = new Image (null, source, mask);
+
+ source = new ImageData(clazz.getResourceAsStream ("stop.gif"));
+ mask = source.getTransparencyMask();
+ TARGET_IMAGE = new Image (null, source, mask);
+ } catch (Throwable ex) {
+ System.out.println (resControl.getString("Images_failed"));
+ }
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/LabelTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/LabelTab.java
new file mode 100755
index 0000000000..3a79520f65
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/LabelTab.java
@@ -0,0 +1,152 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class LabelTab extends AlignableTab {
+
+ /* Example widgets and groups that contain them */
+ Label label1, label2, label3, label4, label5, label6;
+ Group textLabelGroup, imageLabelGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button separatorButton, horizontalButton, verticalButton, shadowInButton, shadowOutButton;
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the text labels */
+ textLabelGroup = new Group(exampleGroup, SWT.NULL);
+ GridLayout gridLayout = new GridLayout ();
+ textLabelGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 3;
+ textLabelGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ textLabelGroup.setText (resControls.getString("Text_Labels"));
+
+ /* Create a group for the image labels */
+ imageLabelGroup = new Group (exampleGroup, SWT.SHADOW_NONE);
+ gridLayout = new GridLayout ();
+ imageLabelGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 3;
+ imageLabelGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ imageLabelGroup.setText (resControls.getString("Image_Labels"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (separatorButton.getSelection ()) style |= SWT.SEPARATOR;
+ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL;
+ if (verticalButton.getSelection ()) style |= SWT.VERTICAL;
+ if (shadowInButton.getSelection ()) style |= SWT.SHADOW_IN;
+ if (shadowOutButton.getSelection ()) style |= SWT.SHADOW_OUT;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ label1 = new Label (textLabelGroup, style);
+ label1.setText(resControls.getString("One"));
+ label2 = new Label (textLabelGroup, style);
+ label2.setText(resControls.getString("Two"));
+ label3 = new Label (textLabelGroup, style);
+ label3.setText (resControls.getString("Three"));
+ label4 = new Label (imageLabelGroup, style);
+ label4.setImage (Images.CLOSED_FOLDER_IMAGE);
+ label5 = new Label (imageLabelGroup, style);
+ label5.setImage (Images.OPEN_FOLDER_IMAGE);
+ label6 = new Label(imageLabelGroup, style);
+ label6.setImage (Images.TARGET_IMAGE);
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup() {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ separatorButton = new Button (styleGroup, SWT.CHECK);
+ separatorButton.setText (resControls.getString("SWT_SEPARATOR"));
+ horizontalButton = new Button (styleGroup, SWT.RADIO);
+ horizontalButton.setText (resControls.getString("SWT_HORIZONTAL"));
+ verticalButton = new Button (styleGroup, SWT.RADIO);
+ verticalButton.setText (resControls.getString("SWT_VERTICAL"));
+ Group styleSubGroup = new Group (styleGroup, SWT.NULL);
+ styleSubGroup.setLayout (new GridLayout ());
+ shadowInButton = new Button (styleSubGroup, SWT.RADIO);
+ shadowInButton.setText (resControls.getString("SWT_SHADOW_IN"));
+ shadowOutButton = new Button (styleSubGroup, SWT.RADIO);
+ shadowOutButton.setText (resControls.getString("SWT_SHADOW_OUT"));
+ borderButton = new Button(styleGroup, SWT.CHECK);
+ borderButton.setText(resControls.getString("SWT_BORDER"));
+
+ /* Add the listeners */
+ SelectionListener selectionListener = new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent event) {
+ if ((event.widget.getStyle() & SWT.RADIO) != 0) {
+ if (!((Button) event.widget).getSelection ()) return;
+ }
+ recreateExampleWidgets ();
+ };
+ };
+ shadowInButton.addSelectionListener (selectionListener);
+ shadowOutButton.addSelectionListener (selectionListener);
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {label1, label2, label3, label4, label5, label6};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Label");
+}
+/**
+* Sets the alignment of the "Example" widgets.
+*/
+void setExampleWidgetAlignment () {
+ int allignment = 0;
+ if (leftButton.getSelection ()) allignment = SWT.LEFT;
+ if (centerButton.getSelection ()) allignment = SWT.CENTER;
+ if (rightButton.getSelection ()) allignment = SWT.RIGHT;
+ label1.setAlignment (allignment);
+ label2.setAlignment (allignment);
+ label3.setAlignment (allignment);
+ label4.setAlignment (allignment);
+ label5.setAlignment (allignment);
+ label6.setAlignment (allignment);
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ boolean isSeparator = (label1.getStyle () & SWT.SEPARATOR) != 0;
+ leftButton.setSelection (!isSeparator && (label1.getStyle () & SWT.LEFT) != 0);
+ centerButton.setSelection (!isSeparator && (label1.getStyle () & SWT.CENTER) != 0);
+ rightButton.setSelection (!isSeparator && (label1.getStyle () & SWT.RIGHT) != 0);
+ shadowInButton.setSelection (isSeparator && (label1.getStyle () & SWT.SHADOW_IN) != 0);
+ shadowOutButton.setSelection (isSeparator && (label1.getStyle () & SWT.SHADOW_OUT) != 0);
+ leftButton.setEnabled (!isSeparator);
+ centerButton.setEnabled (!isSeparator);
+ rightButton.setEnabled (!isSeparator);
+ shadowInButton.setEnabled (isSeparator);
+ shadowOutButton.setEnabled (isSeparator);
+ horizontalButton.setEnabled (isSeparator);
+ verticalButton.setEnabled (isSeparator);
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ListTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ListTab.java
new file mode 100755
index 0000000000..a9f53e1e45
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ListTab.java
@@ -0,0 +1,71 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ListTab extends ScrollableTab {
+
+ /* Example widgets and groups that contain them */
+ List list1;
+ Group listGroup;
+
+ static String [] ListData1 = {resControls.getString("ListData1_0"),
+ resControls.getString("ListData1_1"),
+ resControls.getString("ListData1_2"),
+ resControls.getString("ListData1_3"),
+ resControls.getString("ListData1_4"),
+ resControls.getString("ListData1_5"),
+ resControls.getString("ListData1_6"),
+ resControls.getString("ListData1_7"),
+ resControls.getString("ListData1_8")};
+
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the list */
+ listGroup = new Group (exampleGroup, SWT.NULL);
+ listGroup.setLayout (new GridLayout ());
+ listGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ listGroup.setText (resControls.getString("List"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (singleButton.getSelection ()) style |= SWT.SINGLE;
+ if (multiButton.getSelection ()) style |= SWT.MULTI;
+ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL;
+ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ list1 = new List (listGroup, style);
+ list1.setItems (ListData1);
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {list1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("List");
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ProgressBarTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ProgressBarTab.java
new file mode 100755
index 0000000000..e73b035805
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ProgressBarTab.java
@@ -0,0 +1,99 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ProgressBarTab extends RangeTab {
+
+ /* Example widgets and groups that contain them */
+ ProgressBar progressBar1;
+ Group progressBarGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button smoothButton;
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup() {
+ super.createExampleGroup ();
+
+ /* Create a group for the progress bar */
+ progressBarGroup = new Group (exampleGroup, SWT.NULL);
+ progressBarGroup.setLayout (new GridLayout ());
+ progressBarGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ progressBarGroup.setText (resControls.getString("ProgressBar"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL;
+ if (verticalButton.getSelection ()) style |= SWT.VERTICAL;
+ if (smoothButton.getSelection ()) style |= SWT.SMOOTH;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ progressBar1 = new ProgressBar (progressBarGroup, style);
+ progressBar1.setMaximum (100);
+ progressBar1.setSelection (50);
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ smoothButton = new Button (styleGroup, SWT.CHECK);
+ smoothButton.setText (resControls.getString("SWT_SMOOTH"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {progressBar1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("ProgressBar");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ maximumScale.setMaximum (progressBar1.getMaximum ());
+ smoothButton.setSelection ((progressBar1.getStyle () & SWT.SMOOTH) != 0);
+}
+/**
+* Sets the maximum of the "Example" widgets.
+*/
+void setWidgetMaximum () {
+ progressBar1.setMaximum (maximumScale.getSelection ());
+}
+/**
+* Sets the minimim of the "Example" widgets.
+*/
+void setWidgetMinimum () {
+ progressBar1.setMinimum (minimumScale.getSelection ());
+}
+/**
+* Sets the selection of the "Example" widgets.
+*/
+void setWidgetSelection () {
+ progressBar1.setSelection (selectionScale.getSelection ());
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/RangeTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/RangeTab.java
new file mode 100755
index 0000000000..4645a9f8b8
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/RangeTab.java
@@ -0,0 +1,154 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+abstract class RangeTab extends Tab {
+
+ /* Style widgets added to the "Style" group */
+ Button horizontalButton, verticalButton;
+
+ /* Scale widgets added to the "Control" group */
+ Scale minimumScale, selectionScale, maximumScale;
+
+/**
+* Creates the "Control" widget children.
+*/
+void createControlWidgets () {
+
+ /* Leave an empty cell */
+ new Composite (controlGroup, SWT.NULL);
+
+ /* Create controls specific to this example */
+ createMinimumGroup ();
+ createMaximumGroup ();
+ createSelectionGroup ();
+}
+/**
+* Create a group of widgets to control the maximum
+* attribute of the example widget.
+*/
+void createMaximumGroup() {
+
+ /* Create the group */
+ Group maximumGroup = new Group (controlGroup, SWT.NULL);
+ maximumGroup.setLayout (new GridLayout ());
+ maximumGroup.setText (resControls.getString("Maximum"));
+
+ /* Create a scale widget */
+ maximumScale = new Scale (maximumGroup, SWT.NULL);
+ maximumScale.setMaximum (100);
+ maximumScale.setSelection (100);
+ maximumScale.setPageIncrement (10);
+ maximumScale.setIncrement (5);
+
+ /* Add the listeners */
+ maximumScale.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetMaximum ();
+ };
+ });
+}
+/**
+* Create a group of widgets to control the minimum
+* attribute of the example widget.
+*/
+void createMinimumGroup() {
+
+ /* Create the group */
+ Group minimumGroup = new Group (controlGroup, SWT.NULL);
+ minimumGroup.setLayout (new GridLayout ());
+ minimumGroup.setText (resControls.getString("Minimum"));
+
+ /* Create a scale widget */
+ minimumScale = new Scale (minimumGroup, SWT.NULL);
+ minimumScale.setMaximum (100);
+ minimumScale.setPageIncrement (10);
+ minimumScale.setIncrement (5);
+
+ /* Add the listeners */
+ minimumScale.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetMinimum ();
+ };
+ });
+
+}
+/**
+* Create a group of widgets to control the selection
+* attribute of the example widget.
+*/
+void createSelectionGroup() {
+
+ /* Create the group */
+ Group selectionGroup = new Group(controlGroup, SWT.NULL);
+ selectionGroup.setLayout(new GridLayout());
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ gridData.horizontalSpan = 2;
+ selectionGroup.setLayoutData(gridData);
+ selectionGroup.setText(resControls.getString("Selection"));
+
+ /* Create a scale widget */
+ selectionScale = new Scale (selectionGroup, SWT.NULL);
+ selectionScale.setMaximum (100);
+ selectionScale.setSelection (50);
+ selectionScale.setPageIncrement (10);
+ selectionScale.setIncrement (5);
+
+ /* Add the listeners */
+ selectionScale.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ setWidgetSelection ();
+ };
+ });
+
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ horizontalButton = new Button (styleGroup, SWT.RADIO);
+ horizontalButton.setText (resControls.getString("SWT_HORIZONTAL"));
+ verticalButton = new Button (styleGroup, SWT.RADIO);
+ verticalButton.setText (resControls.getString("SWT_VERTICAL"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ setWidgetMinimum ();
+ setWidgetMaximum ();
+ setWidgetSelection ();
+ Control [] controls = getExampleWidgets ();
+ if (controls.length != 0){
+ horizontalButton.setSelection ((controls [0].getStyle () & SWT.HORIZONTAL) != 0);
+ verticalButton.setSelection ((controls [0].getStyle () & SWT.VERTICAL) != 0);
+ borderButton.setSelection ((controls [0].getStyle () & SWT.BORDER) != 0);
+ }
+}
+/**
+* Sets the maximum of the "Example" widgets.
+*/
+abstract void setWidgetMaximum ();
+/**
+* Sets the minimim of the "Example" widgets.
+*/
+abstract void setWidgetMinimum ();
+/**
+* Sets the selection of the "Example" widgets.
+*/
+abstract void setWidgetSelection ();
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/SashTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/SashTab.java
new file mode 100755
index 0000000000..0827db8c07
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/SashTab.java
@@ -0,0 +1,155 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class SashTab extends Tab {
+
+ /* Example widgets and groups that contain them */
+ Sash hSash, vSash;
+ List list1, list2, list3;
+ Text text;
+
+ static String [] ListData0 = {resControls.getString("ListData0_0"),
+ resControls.getString("ListData0_1"),
+ resControls.getString("ListData0_2"),
+ resControls.getString("ListData0_3"),
+ resControls.getString("ListData0_4"),
+ resControls.getString("ListData0_5"),
+ resControls.getString("ListData0_6"),
+ resControls.getString("ListData0_7"),
+ resControls.getString("ListData0_8")};
+
+ static String [] ListData1 = {resControls.getString("ListData1_0"),
+ resControls.getString("ListData1_1"),
+ resControls.getString("ListData1_2"),
+ resControls.getString("ListData1_3"),
+ resControls.getString("ListData1_4"),
+ resControls.getString("ListData1_5"),
+ resControls.getString("ListData1_6"),
+ resControls.getString("ListData1_7"),
+ resControls.getString("ListData1_8")};
+
+ /* Constants */
+ static final int SASH_WIDTH = 3;
+/**
+* Creates the tab folder page.
+*/
+Composite createTabFolderPage (TabFolder tabFolder) {
+ /*
+ * Create the page. This example does not use layouts.
+ */
+ tabFolderPage = new Composite(tabFolder, SWT.BORDER);
+
+ /* Create the list and text widgets */
+ list1 = new List (tabFolderPage, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
+ list1.setItems (ListData0);
+ list2 = new List (tabFolderPage, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
+ list2.setItems (ListData1);
+ text = new Text (tabFolderPage, SWT.MULTI | SWT.BORDER);
+ text.setText (resControls.getString("Multi_line"));
+
+ /* Create the sashes */
+ vSash = new Sash (tabFolderPage, SWT.VERTICAL);
+ hSash = new Sash (tabFolderPage, SWT.HORIZONTAL);
+
+ /* Add the listeners */
+ hSash.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ if (event.detail != SWT.DRAG) {
+ hSash.setBounds (event.x, event.y, event.width, event.height);
+ layout ();
+ }
+ }
+ });
+ vSash.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ if (event.detail != SWT.DRAG) {
+ vSash.setBounds(event.x, event.y, event.width, event.height);
+ layout ();
+ }
+ }
+ });
+ tabFolderPage.addControlListener (new ControlAdapter () {
+ public void controlResized (ControlEvent event) {
+ shellResized ();
+ }
+ });
+
+ /*
+ * Do not set the bounds of the lists, text and sashes here
+ * because this method is run before the widget is opened
+ * so we do not know how big the tabComposite is going to be.
+ * When the widget is opened a resize event will occur
+ * and the contained widgets can be sized accordingly.
+ */
+ return tabFolderPage;
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Sash");
+}
+/**
+* Layout the list and text widgets according to the new
+* positions of the sashes..events.SelectionEvent
+*/
+void layout () {
+
+ Rectangle tabCompositeBounds = tabFolderPage.getClientArea ();
+ Rectangle hSashBounds = hSash.getBounds ();
+ Rectangle vSashBounds = vSash.getBounds ();
+
+ list1.setBounds (0, 0, vSashBounds.x, hSashBounds.y);
+ list2.setBounds (vSashBounds.x + vSashBounds.width, 0, tabCompositeBounds.width - (vSashBounds.x + vSashBounds.width), hSashBounds.y);
+ text.setBounds (0, hSashBounds.y + hSashBounds.height, tabCompositeBounds.width, tabCompositeBounds.height - (hSashBounds.y + hSashBounds.height));
+
+ /**
+ * If the horizontal sash has been moved then the vertical
+ * sash is either too long or too short and its size must
+ * be adjusted.
+ */
+ vSashBounds.height = hSashBounds.y;
+ vSash.setBounds (vSashBounds);
+}
+/**
+* Handle the shell resized event.
+*/
+void shellResized () {
+
+ /* Get the client area for the shell */
+ Rectangle tabFolderPageBounds = tabFolderPage.getClientArea ();
+
+ /*
+ * Make list 1 half the width and half the height of the tab leaving room for the sash.
+ * Place list 1 in the top left quadrant of the tab.
+ */
+ Rectangle list1Bounds = new Rectangle (0, 0, (tabFolderPageBounds.width - SASH_WIDTH) / 2, (tabFolderPageBounds.height - SASH_WIDTH) / 2);
+ list1.setBounds (list1Bounds);
+
+ /*
+ * Make list 2 half the width and half the height of the tab leaving room for the sash.
+ * Place list 2 in the top right quadrant of the tab.
+ */
+ list2.setBounds (list1Bounds.width + SASH_WIDTH, 0, tabFolderPageBounds.width - (list1Bounds.width + SASH_WIDTH), list1Bounds.height);
+
+ /*
+ * Make the text area the full width and half the height of the tab leaving room for the sash.
+ * Place the text area in the bottom half of the tab.
+ */
+ text.setBounds (0, list1Bounds.height + SASH_WIDTH, tabFolderPageBounds.width, tabFolderPageBounds.height - (list1Bounds.height + SASH_WIDTH));
+
+ /* Position the sashes */
+ vSash.setBounds (list1Bounds.width, 0, SASH_WIDTH, list1Bounds.height);
+ hSash.setBounds (0, list1Bounds.height, tabFolderPageBounds.width, SASH_WIDTH);
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ScrollableTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ScrollableTab.java
new file mode 100755
index 0000000000..9a90516272
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ScrollableTab.java
@@ -0,0 +1,47 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+abstract class ScrollableTab extends Tab {
+
+ /* Style widgets added to the "Style" group */
+ Button singleButton, multiButton, horizontalButton, verticalButton, borderButton;
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ singleButton = new Button (styleGroup, SWT.RADIO);
+ singleButton.setText (resControls.getString("SWT_SINGLE"));
+ multiButton = new Button (styleGroup, SWT.RADIO);
+ multiButton.setText (resControls.getString("SWT_MULTI"));
+ horizontalButton = new Button (styleGroup, SWT.CHECK);
+ horizontalButton.setText (resControls.getString("SWT_H_SCROLL"));
+ verticalButton = new Button (styleGroup, SWT.CHECK);
+ verticalButton.setText (resControls.getString("SWT_V_SCROLL"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ Control [] controls = getExampleWidgets ();
+ if (controls.length != 0){
+ singleButton.setSelection ((controls [0].getStyle () & SWT.SINGLE) != 0);
+ multiButton.setSelection ((controls [0].getStyle () & SWT.MULTI) != 0);
+ horizontalButton.setSelection ((controls [0].getStyle () & SWT.H_SCROLL) != 0);
+ verticalButton.setSelection ((controls [0].getStyle () & SWT.V_SCROLL) != 0);
+ borderButton.setSelection ((controls [0].getStyle () & SWT.BORDER) != 0);
+ }
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ShellTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ShellTab.java
new file mode 100755
index 0000000000..9fd63330db
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ShellTab.java
@@ -0,0 +1,212 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ShellTab extends Tab {
+
+ /* Style widgets added to the "Style" group */
+ Button noParentButton, parentButton;
+ Button noTrimButton, closeButton, titleButton, minButton, maxButton, borderButton, resizeButton;
+ Button createButton, closeAllButton;
+ Group parentStyleGroup;
+
+ /* Variables used to track the open shells */
+ int shellCount = 0;
+ Shell [] shells = new Shell [4];
+/**
+* Close all the example shells.
+*/
+void closeAllShells() {
+ for (int i = 0; i<shellCount; i++) {
+ if (shells[i] != null & !shells [i].isDisposed ()) {
+ shells [i].dispose();
+ }
+ }
+ shellCount = 0;
+}
+/**
+* Handle the Create button selection event.
+*
+* @param event org.eclipse.swt.events.SelectionEvent
+*/
+public void createButtonSelected(SelectionEvent event) {
+
+ /*
+ * Remember the example shells so they
+ * can be disposed by the user.
+ */
+ if (shellCount >= shells.length) {
+ Shell [] newShells = new Shell [shells.length + 4];
+ System.arraycopy (shells, 0, newShells, 0, shells.length);
+ shells = newShells;
+ }
+
+ /* Compute the shell style */
+ int style = SWT.NONE;
+ if (noTrimButton.getSelection()) style |= SWT.NO_TRIM;
+ if (closeButton.getSelection()) style |= SWT.CLOSE;
+ if (titleButton.getSelection()) style |= SWT.TITLE;
+ if (minButton.getSelection()) style |= SWT.MIN;
+ if (maxButton.getSelection()) style |= SWT.MAX;
+ if (borderButton.getSelection()) style |= SWT.BORDER;
+ if (resizeButton.getSelection()) style |= SWT.RESIZE;
+
+ /* Create the shell with or without a parent */
+ if (noParentButton.getSelection ()) {
+ shells [shellCount] = new Shell (style);
+ } else {
+ Shell shell = tabFolderPage.getShell ();
+ shells [shellCount] = new Shell (shell, style);
+ }
+
+ /* Set the size, title and open the shell */
+ shells [shellCount].setSize (300, 100);
+ shells [shellCount].setText (resControls.getString("Title") + shellCount);
+ shells [shellCount++].open ();
+}
+/**
+* Creates the "Control" group.
+*/
+void createControlGroup () {
+ /*
+ * Create the "Control" group. This is the group on the
+ * left half of each example tab. It consists of the
+ * style group, the display group and the size group.
+ */
+ controlGroup = new Group (tabFolderPage, SWT.NULL);
+ GridLayout gridLayout= new GridLayout ();
+ controlGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 1;
+ gridLayout.makeColumnsEqualWidth = true;
+ controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ controlGroup.setText (resControls.getString("Parameters"));
+
+ /* Create individual groups inside the "Control" group */
+ styleGroup = new Group (controlGroup, SWT.NULL);
+ gridLayout = new GridLayout ();
+ styleGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 2;
+ styleGroup.setLayoutData (new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ styleGroup.setText (resControls.getString("Styles"));
+
+ /* Create a group for the parent sytle controls */
+ parentStyleGroup = new Group (styleGroup, SWT.NULL);
+ parentStyleGroup.setLayout (new GridLayout ());
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ gridData.horizontalSpan = 2;
+ parentStyleGroup.setLayoutData (gridData);
+ parentStyleGroup.setText (resControls.getString("Parent"));
+}
+/**
+* Creates the "Control" widget children.
+*/
+void createControlWidgets () {
+
+ /* Create the parent style buttons */
+ noParentButton = new Button (parentStyleGroup, SWT.RADIO);
+ noParentButton.setText (resControls.getString("No_Parent"));
+ parentButton = new Button (parentStyleGroup, SWT.RADIO);
+ parentButton.setText (resControls.getString("Parent"));
+
+ /* Create a group for the decoration style controls */
+ Group decorationStyleGroup = new Group(styleGroup, SWT.NULL);
+ decorationStyleGroup.setLayout (new GridLayout ());
+ GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER);
+ gridData.horizontalSpan = 2;
+ decorationStyleGroup.setLayoutData (gridData);
+ decorationStyleGroup.setText (resControls.getString("Decoration_Styles"));
+
+ /* Create the decoration style buttons */
+ noTrimButton = new Button (decorationStyleGroup, SWT.CHECK);
+ noTrimButton.setText (resControls.getString("SWT_NO_TRIM"));
+ closeButton = new Button (decorationStyleGroup, SWT.CHECK);
+ closeButton.setText (resControls.getString("SWT_CLOSE"));
+ titleButton = new Button (decorationStyleGroup, SWT.CHECK);
+ titleButton.setText (resControls.getString("SWT_TITLE"));
+ minButton = new Button (decorationStyleGroup, SWT.CHECK);
+ minButton.setText (resControls.getString("SWT_MIN"));
+ maxButton = new Button (decorationStyleGroup, SWT.CHECK);
+ maxButton.setText (resControls.getString("SWT_MAX"));
+ borderButton = new Button (decorationStyleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+ resizeButton = new Button (decorationStyleGroup, SWT.CHECK);
+ resizeButton.setText (resControls.getString("SWT_RESIZE"));
+
+ /* Create the "create" and "closeAll" buttons */
+ createButton = new Button (styleGroup, SWT.NULL);
+ gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER);
+ createButton.setLayoutData (gridData);
+ createButton.setText (resControls.getString("Create_Shell"));
+ closeAllButton = new Button (styleGroup, SWT.NULL);
+ closeAllButton.setText (resControls.getString("Close_All_Shells"));
+ closeAllButton.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_CENTER));
+
+ /* Add the listeners */
+ createButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ createButtonSelected(e);
+ };
+ });
+ closeAllButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ closeAllShells ();
+ };
+ });
+ SelectionListener decorationButtonListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ decorationButtonSelected(event);
+ };
+ };
+ noTrimButton.addSelectionListener (decorationButtonListener);
+ closeButton.addSelectionListener (decorationButtonListener);
+ titleButton.addSelectionListener (decorationButtonListener);
+ minButton.addSelectionListener (decorationButtonListener);
+ maxButton.addSelectionListener (decorationButtonListener);
+ borderButton.addSelectionListener (decorationButtonListener);
+ resizeButton.addSelectionListener (decorationButtonListener);
+
+ /* Set the default state */
+ noParentButton.setSelection (true);
+}
+/**
+* Handle a decoration button selection event.
+*
+* @param event org.eclipse.swt.events.SelectionEvent
+*/
+public void decorationButtonSelected(SelectionEvent event) {
+
+ /*
+ * Make sure if the No Trim button is selected then
+ * all other decoration buttons are deselected.
+ */
+ Button widget = (Button) event.widget;
+ if (widget.getSelection() && widget != noTrimButton) {
+ noTrimButton.setSelection (false);
+ return;
+ }
+ if (widget.getSelection() && widget == noTrimButton) {
+ closeButton.setSelection (false);
+ titleButton.setSelection (false);
+ minButton.setSelection (false);
+ maxButton.setSelection (false);
+ borderButton.setSelection (false);
+ resizeButton.setSelection (false);
+ return;
+ }
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Shell");
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/SliderTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/SliderTab.java
new file mode 100755
index 0000000000..6aac6dc087
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/SliderTab.java
@@ -0,0 +1,212 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class SliderTab extends RangeTab {
+
+ /* Example widgets and groups that contain them */
+ Scale scale1;
+ Slider slider1;
+ Group sliderGroup, scaleGroup;
+
+ /* Scale widgets added to the "Control" group */
+ Scale incrementScale, pageIncrementScale, thumbScale;
+/**
+* Creates the "Control" widget children.
+*/
+void createControlWidgets () {
+ super.createControlWidgets ();
+ createThumbGroup ();
+ createIncrementGroup ();
+ createPageIncrementGroup ();
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the slider */
+ sliderGroup = new Group (exampleGroup, SWT.NULL);
+ sliderGroup.setLayout (new GridLayout ());
+ sliderGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ sliderGroup.setText (resControls.getString("Slider"));
+
+ /* Create a group for the scale */
+ scaleGroup = new Group (exampleGroup, SWT.NULL);
+ scaleGroup.setLayout (new GridLayout ());
+ scaleGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ scaleGroup.setText (resControls.getString("Scale"));
+
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL;
+ if (verticalButton.getSelection ()) style |= SWT.VERTICAL;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ scale1 = new Scale (scaleGroup, style);
+ scale1.setMaximum (100);
+ scale1.setSelection (50);
+ scale1.setIncrement (5);
+ scale1.setPageIncrement (10);
+ slider1 = new Slider(sliderGroup, style);
+ slider1.setMaximum (100);
+ slider1.setSelection (50);
+ slider1.setIncrement(5);
+ slider1.setPageIncrement (10);
+ slider1.setThumb (10);
+}
+/**
+* Create a group of widgets to control the increment
+* attribute of the example widget.
+*/
+void createIncrementGroup() {
+
+ /* Create the group */
+ Group incrementGroup = new Group (controlGroup, SWT.NULL);
+ incrementGroup.setLayout (new GridLayout ());
+ incrementGroup.setText (resControls.getString("Increment"));
+
+ /* Create the scale widget */
+ incrementScale = new Scale (incrementGroup, SWT.NULL);
+ incrementScale.setMaximum (100);
+ incrementScale.setSelection (5);
+ incrementScale.setPageIncrement (10);
+ incrementScale.setIncrement (5);
+
+ /* Add the listeners */
+ incrementScale.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ setWidgetIncrement ();
+ };
+ });
+}
+/**
+* Create a group of widgets to control the page increment
+* attribute of the example widget.
+*/
+void createPageIncrementGroup() {
+
+ /* Create the group */
+ Group pageIncrementGroup = new Group (controlGroup, SWT.NULL);
+ pageIncrementGroup.setLayout (new GridLayout ());
+ pageIncrementGroup.setText (resControls.getString("Page_Increment"));
+
+ /* Create the scale widget */
+ pageIncrementScale = new Scale (pageIncrementGroup, SWT.NULL);
+ pageIncrementScale.setMaximum (100);
+ pageIncrementScale.setSelection (10);
+ pageIncrementScale.setPageIncrement (10);
+ pageIncrementScale.setIncrement (5);
+
+ /* Add the listeners */
+ pageIncrementScale.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetIncrement ();
+ }
+ });
+}
+/**
+* Create a group of widgets to control the thumb
+* attribute of the example widget.
+*/
+void createThumbGroup() {
+
+ /* Create the group */
+ Group thumbGroup = new Group (controlGroup, SWT.NULL);
+ thumbGroup.setLayout (new GridLayout ());
+ thumbGroup.setText (resControls.getString("Thumb"));
+
+ /* Create the scale widget */
+ thumbScale = new Scale (thumbGroup, SWT.NULL);
+ thumbScale.setMaximum (100);
+ thumbScale.setSelection (10);
+ thumbScale.setPageIncrement (10);
+ thumbScale.setIncrement (5);
+
+ /* Add the listeners */
+ thumbScale.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetThumb ();
+ };
+ });
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {scale1, slider1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Slider_and_Scale");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ setWidgetIncrement ();
+ setWidgetPageIncrement ();
+ setWidgetThumb ();
+}
+/**
+* Sets the increment of the "Example" widgets.
+*/
+void setWidgetIncrement () {
+ slider1.setIncrement (incrementScale.getSelection ());
+ scale1.setIncrement (incrementScale.getSelection ());
+}
+/**
+* Sets the minimim of the "Example" widgets.
+*/
+void setWidgetMaximum () {
+ slider1.setMaximum (maximumScale.getSelection ());
+ scale1.setMaximum (maximumScale.getSelection ());
+}
+/**
+* Sets the minimim of the "Example" widgets.
+*/
+void setWidgetMinimum () {
+ slider1.setMinimum (minimumScale.getSelection ());
+ scale1.setMinimum (minimumScale.getSelection ());
+}
+/**
+* Sets the page increment of the "Example" widgets.
+*/
+void setWidgetPageIncrement () {
+ slider1.setPageIncrement (pageIncrementScale.getSelection ());
+ scale1.setPageIncrement (pageIncrementScale.getSelection ());
+}
+/**
+* Sets the selection of the "Example" widgets.
+*/
+void setWidgetSelection () {
+ slider1.setSelection (selectionScale.getSelection ());
+ scale1.setSelection (selectionScale.getSelection ());
+}
+/**
+* Sets the thumb of the "Example" widgets.
+*/
+void setWidgetThumb () {
+ slider1.setThumb (thumbScale.getSelection ());
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/Tab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/Tab.java
new file mode 100755
index 0000000000..432e492a16
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/Tab.java
@@ -0,0 +1,354 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+import java.util.ResourceBundle;
+
+/**
+* <code>Tab</code> is the abstract superclass of every page
+* in the example's tab folder. Each page in the tab folder
+* describes a control.
+*
+* A Tab itself is not a control but instead provides a
+* hierarchy with which to share code that is common to
+* every page in the folder.
+*
+* A typical page in a Tab contains a two column composite.
+* The left column contains the "Example" group. The right
+* column contains "Control" group. The "Control" group
+* contains controls that allow the user to interact with
+* the example control. The "Control" group typically
+* contains a "Style", "Display" and "Size" group. Subclasses
+* can override these defaults to augment a group or stop
+* a group from being created.
+*/
+
+abstract class Tab {
+
+ protected static ResourceBundle resControls = ResourceBundle.getBundle("examples_control");
+
+ /* Common control buttons */
+ Button borderButton, enabledButton, visibleButton;
+ Button preferredButton, tooSmallButton, smallButton, largeButton;
+
+ /* Common groups and composites */
+ Composite tabFolderPage;
+ Group exampleGroup, controlGroup, displayGroup, sizeGroup, styleGroup;
+
+ /* Sizing constants for the "Size" group */
+ static final int TOO_SMALL_SIZE = 10;
+ static final int SMALL_SIZE = 50;
+ static final int LARGE_SIZE = 100;
+/**
+* Creates the "Control" group. The "Control" group
+* is typically the right hand column in the tab.
+*/
+void createControlGroup () {
+
+ /*
+ * Create the "Control" group. This is the group on the
+ * left half of each example tab. It consists of the
+ * style group, the display group and the size group.
+ */
+ controlGroup = new Group (tabFolderPage, SWT.NONE);
+ GridLayout gridLayout= new GridLayout ();
+ controlGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 2;
+ gridLayout.makeColumnsEqualWidth = true;
+ controlGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ controlGroup.setText (resControls.getString("Parameters"));
+
+ /* Create individual groups inside the "Control" group */
+ createStyleGroup ();
+ createDisplayGroup ();
+ createSizeGroup ();
+
+ /*
+ * For each Button child in the style group, add a selection
+ * listener that will recreate the example controls. If the
+ * style group button is a RADIO button, ensure that the radio
+ * button is selected before recreating the example controls.
+ * When the user selects a RADIO button, the curreont RADIO
+ * button in the group is deselected and the new RADIO button
+ * is selected automatically. The listeners are notified for
+ * both these operations but typically only do work when a RADIO
+ * button is selected.
+ */
+ SelectionListener selectionListener = new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ if ((event.widget.getStyle () & SWT.RADIO) != 0) {
+ if (!((Button) event.widget).getSelection ()) return;
+ }
+ recreateExampleWidgets ();
+ };
+ };
+ Control [] children = styleGroup.getChildren ();
+ for (int i=0; i<children.length; i++) {
+ if (children [i] instanceof Button) {
+ Button button = (Button) children [i];
+ button.addSelectionListener (selectionListener);
+ }
+ }
+}
+/**
+* Creates the "Control" widget children.
+* Subclasses override this method to augment
+* the standard controls created in the "Style",
+* "Display" and "Size" groups.
+*/
+void createControlWidgets () {
+}
+/**
+* Creates the "Display" group. This is typically
+* a child of the "Control" group.
+*/
+void createDisplayGroup () {
+
+ /* Create the group */
+ displayGroup = new Group (controlGroup, SWT.NONE);
+ displayGroup.setLayout (new GridLayout ());
+ displayGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ displayGroup.setText (resControls.getString("State"));
+
+ /* Create the controls */
+ enabledButton = new Button(displayGroup, SWT.CHECK);
+ enabledButton.setText(resControls.getString("Enabled"));
+ visibleButton = new Button(displayGroup, SWT.CHECK);
+ visibleButton.setText(resControls.getString("Visible"));
+
+ /* Add the listeners */
+ enabledButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setExampleWidgetEnabled ();
+ }
+ });
+ visibleButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setExampleWidgetVisibility ();
+ }
+ });
+
+ /* Set the default state */
+ enabledButton.setSelection(true);
+ visibleButton.setSelection(true);
+}
+/**
+* Creates the "Example" group. The "Example" group
+* is typically the left hand column in the tab.
+*/
+void createExampleGroup () {
+ /*
+ * Create the example group. This is the
+ * group on the right half of each example
+ * tab.
+ */
+ exampleGroup = new Group (tabFolderPage, SWT.NONE);
+ GridLayout gridLayout = new GridLayout ();
+ exampleGroup.setLayout (gridLayout);
+ exampleGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+}
+/**
+* Creates the "Example" widget children of the "Example" group.
+* Subclasses override this method to create the particular
+* example control.
+*/
+void createExampleWidgets () {
+ /* Do nothing */
+}
+/**
+* Creates the "Size" group. The "Size" group contains
+* controls that allow the user to change the size of
+* the example widgets.
+*/
+void createSizeGroup () {
+
+ /* Create the group */
+ sizeGroup = new Group (controlGroup, SWT.NONE);
+ sizeGroup.setLayout (new GridLayout());
+ sizeGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ sizeGroup.setText (resControls.getString("Size"));
+
+ /* Create the controls */
+
+ /*
+ * The preferred size of a widget is the size returned
+ * by widget.computeSize (SWT.DEFAULT, SWT.DEFAULT).
+ * This size is defined on a widget by widget basis.
+ * Many widgets will attempt to display their contents.
+ */
+ preferredButton = new Button (sizeGroup, SWT.RADIO);
+ preferredButton.setText (resControls.getString("Preferred"));
+ tooSmallButton = new Button (sizeGroup, SWT.RADIO);
+ tooSmallButton.setText (TOO_SMALL_SIZE + " X " + TOO_SMALL_SIZE);
+ smallButton = new Button(sizeGroup, SWT.RADIO);
+ smallButton.setText (SMALL_SIZE + " X " + SMALL_SIZE);
+ largeButton = new Button (sizeGroup, SWT.RADIO);
+ largeButton.setText (LARGE_SIZE + " X " + LARGE_SIZE);
+
+ /* Add the listeners */
+ SelectionAdapter selectionListener = new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ if (!((Button) event.widget).getSelection ()) return;
+ setExampleWidgetSize ();
+ };
+ };
+ preferredButton.addSelectionListener(selectionListener);
+ tooSmallButton.addSelectionListener(selectionListener);
+ smallButton.addSelectionListener(selectionListener);
+ largeButton.addSelectionListener(selectionListener);
+
+ /* Set the default state */
+ preferredButton.setSelection (true);
+}
+/**
+* Creates the "Style" group. The "Style" group contains
+* controls that allow the user to change the style of
+* the example widgets. Changing a widget "Style" causes
+* the widget to be destroyed and recreated.
+*/
+void createStyleGroup () {
+ styleGroup = new Group (controlGroup, SWT.NONE);
+ styleGroup.setLayout (new GridLayout ());
+ styleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ styleGroup.setText (resControls.getString("Styles"));
+}
+/**
+* Creates the tab folder page.
+*
+* @param tabFolder org.eclipse.swt.widgets.TabFolder
+* @return the new page for the tab folder
+*/
+Composite createTabFolderPage (TabFolder tabFolder) {
+ /*
+ * Create a two column page.
+ */
+ tabFolderPage = new Composite (tabFolder, SWT.NULL);
+ GridLayout gridLayout = new GridLayout ();
+ tabFolderPage.setLayout (gridLayout);
+ gridLayout.numColumns = 2;
+
+ /* Create the "Example" and "Control" columns */
+ createExampleGroup ();
+ createControlGroup ();
+
+ /* Create the widgets in the two columns */
+ createExampleWidgets ();
+ createControlWidgets ();
+ setExampleWidgetState ();
+
+ return tabFolderPage;
+}
+/**
+* Disposes the "Example" widgets.
+*/
+void disposeExampleWidgets () {
+ Control [] controls = getExampleWidgets ();
+ for (int i=0; i<controls.length; i++) {
+ controls [i].dispose ();
+ }
+}
+/**
+* Gets the "Example" widget children.
+*
+* @return an array of example widget children
+*/
+Control [] getExampleWidgets () {
+ return new Control [0];
+}
+/**
+* Gets the text for the tab folder item.
+*
+* @return the text for the tab item
+*/
+String getTabText () {
+ return "";
+}
+/**
+* Recreates the "Example" widgets.
+*/
+void recreateExampleWidgets () {
+ disposeExampleWidgets ();
+ createExampleWidgets ();
+ setExampleWidgetState ();
+}
+/**
+* Sets the enabled state of the "Example" widgets.
+*/
+void setExampleWidgetEnabled () {
+ Control [] controls = getExampleWidgets ();
+ for (int i=0; i<controls.length; i++) {
+ controls [i].setEnabled (enabledButton.getSelection ());
+ }
+}
+/**
+* Sets the size of the "Example" widgets.
+*/
+void setExampleWidgetSize () {
+ int size = SWT.DEFAULT;
+ if (preferredButton == null) return;
+ if (preferredButton.getSelection()) size = SWT.DEFAULT;
+ if (tooSmallButton.getSelection()) size = TOO_SMALL_SIZE;
+ if (smallButton.getSelection()) size = SMALL_SIZE;
+ if (largeButton.getSelection()) size = LARGE_SIZE;
+ Control [] controls = getExampleWidgets ();
+ for (int i=0; i<controls.length; i++) {
+ GridData gridData = new GridData ();
+ gridData.widthHint = size;
+ gridData.heightHint = size;
+ controls [i].setLayoutData (gridData);
+ }
+ /*
+ * Force the entire widget tree to layout,
+ * even when the child sizes nay not have
+ * changed.
+ */
+ int seenCount = 0;
+ Composite [] seen = new Composite [4];
+ for (int i=0; i<controls.length; i++) {
+ Control control = controls [i];
+ while (control != exampleGroup) {
+ Composite parent = control.getParent ();
+ int index = 0;
+ while (index < seenCount) {
+ if (seen [index] == parent) break;
+ index++;
+ }
+ if (index == seenCount) parent.layout ();
+ if (seenCount == seen.length) {
+ Composite [] newSeen = new Composite [seen.length + 4];
+ System.arraycopy (seen, 0, newSeen, 0, seen.length);
+ seen = newSeen;
+ }
+ seen [seenCount++] = parent;
+ control = control.getParent ();
+ }
+ }
+}
+/**
+* Sets the state of the "Example" widgets. Subclasses
+* reimplement this method to set "Example" widget state
+* that is specific to the widget.
+*/
+void setExampleWidgetState () {
+ setExampleWidgetEnabled ();
+ setExampleWidgetVisibility ();
+ setExampleWidgetSize ();
+}
+/**
+* Sets the visibility of the "Example" widgets.
+*/
+void setExampleWidgetVisibility () {
+ Control [] controls = getExampleWidgets ();
+ for (int i=0; i<controls.length; i++) {
+ controls [i].setVisible (visibleButton.getSelection ());
+ }
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TableTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TableTab.java
new file mode 100755
index 0000000000..ab6305dac4
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TableTab.java
@@ -0,0 +1,172 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class TableTab extends ScrollableTab {
+
+ /* Example widgets and groups that contain them */
+ Table table1;
+ Group tableGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button fullSelectionButton;
+
+ /* Display widgets added to the "Display" group */
+ Button headerVisibleButton, linesVisibleButton;
+
+ static String [] columnTitles = {resControls.getString("TableTitle_0"),
+ resControls.getString("TableTitle_1"),
+ resControls.getString("TableTitle_2"),
+ resControls.getString("TableTitle_3")};
+
+ static String [] stringLine0 = {resControls.getString("TableLine0_0"),
+ resControls.getString("TableLine0_1"),
+ resControls.getString("TableLine0_2"),
+ resControls.getString("TableLine0_3")};
+
+ static String [] stringLine1 = {resControls.getString("TableLine1_0"),
+ resControls.getString("TableLine1_1"),
+ resControls.getString("TableLine1_2"),
+ resControls.getString("TableLine1_3")};
+
+ static String [] stringLine2 = {resControls.getString("TableLine2_0"),
+ resControls.getString("TableLine2_1"),
+ resControls.getString("TableLine2_2"),
+ resControls.getString("TableLine2_3")};
+
+/**
+* Creates the "Display" group.
+*/
+void createDisplayGroup () {
+ super.createDisplayGroup ();
+
+ /* Create display controls specific to this example */
+ headerVisibleButton = new Button (displayGroup, SWT.CHECK);
+ headerVisibleButton.setText (resControls.getString("Header_Visible"));
+ linesVisibleButton = new Button (displayGroup, SWT.CHECK);
+ linesVisibleButton.setText (resControls.getString("Lines_Visible"));
+
+ /* Add the listeners */
+ headerVisibleButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetHeaderVisible ();
+ }
+ });
+ linesVisibleButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetLinesVisible ();
+ };
+ });
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the table */
+ tableGroup = new Group (exampleGroup, SWT.NULL);
+ tableGroup.setLayout (new GridLayout ());
+ tableGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ tableGroup.setText (resControls.getString("Table"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (singleButton.getSelection ()) style |= SWT.SINGLE;
+ if (multiButton.getSelection ()) style |= SWT.MULTI;
+ if (fullSelectionButton.getSelection ()) style |= SWT.FULL_SELECTION;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the table widget */
+ table1 = new Table (tableGroup, style);
+
+ /* Fill the table with data */
+ Image [] images = new Image [] {
+ Images.CLOSED_FOLDER_IMAGE,
+ Images.OPEN_FOLDER_IMAGE,
+ Images.TARGET_IMAGE,
+ };
+ int[] columnWidths = {150, 60, 75, 150};
+ for (int i = 0; i < columnTitles.length; i++) {
+ TableColumn tableColumn = new TableColumn(table1, SWT.NULL);
+ tableColumn.setWidth(columnWidths[i]);
+ tableColumn.setText(columnTitles[i]);
+ }
+ for (int i=0; i<16; i++) {
+ TableItem item = new TableItem (table1, SWT.NULL);
+ item.setImage (images [i % 3]);
+ switch (i % 3) {
+ case 0:
+ stringLine0 [0] = resControls.getString("Index") + i;
+ item.setText(stringLine0);
+ break;
+ case 1:
+ stringLine1 [0] = resControls.getString("Index") + i;
+ item.setText(stringLine1);
+ break;
+ case 2:
+ stringLine2 [0] = resControls.getString("Index") + i;
+ item.setText(stringLine2);
+ break;
+ }
+ }
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ fullSelectionButton = new Button (styleGroup, SWT.CHECK);
+ fullSelectionButton.setText (resControls.getString("SWT_FULL_SELECTION"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {table1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Table");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ setWidgetHeaderVisible ();
+ setWidgetLinesVisible ();
+ fullSelectionButton.setSelection ((table1.getStyle () & SWT.FULL_SELECTION) != 0);
+}
+
+/**
+* Sets the header visible state of the "Example" widgets.
+*/
+void setWidgetHeaderVisible () {
+ table1.setHeaderVisible (headerVisibleButton.getSelection ());
+}
+/**
+* Sets the lines visible state of the "Example" widgets.
+*/
+void setWidgetLinesVisible () {
+ table1.setLinesVisible (linesVisibleButton.getSelection ());
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TextTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TextTab.java
new file mode 100755
index 0000000000..b14d60c03f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TextTab.java
@@ -0,0 +1,96 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.custom.*;
+
+class TextTab extends ScrollableTab {
+
+ /* Example widgets and groups that contain them */
+ Text text;
+ StyledText richText;
+ Group textGroup, richTextGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button readOnlyButton;
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the text widget */
+ textGroup = new Group (exampleGroup, SWT.NULL);
+ textGroup.setLayout (new GridLayout ());
+ textGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ textGroup.setText (resControls.getString("Text"));
+
+ /* Create a group for the rich text widget */
+ richTextGroup = new Group (exampleGroup, SWT.NULL);
+ richTextGroup.setLayout (new GridLayout ());
+ richTextGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ richTextGroup.setText (resControls.getString("RichText"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (singleButton.getSelection ()) style |= SWT.SINGLE;
+ if (multiButton.getSelection ()) style |= SWT.MULTI;
+ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL;
+ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL;
+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ text = new Text (textGroup, style);
+ text.setText (resControls.getString("Example_string"));
+ text.append (text.DELIMITER);
+ text.append (resControls.getString("One_Two_Three"));
+ richText = new StyledText (richTextGroup, style);
+ richText.setText (resControls.getString("Example_string"));
+ richText.append ("\n");
+ richText.append (resControls.getString("One_Two_Three"));
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup() {
+ super.createStyleGroup();
+
+ /* Create the extra widgets */
+ readOnlyButton = new Button (styleGroup, SWT.CHECK);
+ readOnlyButton.setText (resControls.getString("SWT_READ_ONLY"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {text, richText};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Text");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ readOnlyButton.setSelection ((text.getStyle () & SWT.READ_ONLY) != 0);
+}
+
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ToolBarTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ToolBarTab.java
new file mode 100755
index 0000000000..9d69aae0e5
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/ToolBarTab.java
@@ -0,0 +1,261 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ToolBarTab extends Tab {
+
+ /* Example widgets and groups that contain them */
+ ToolBar imageToolBar, textToolBar;
+ Shell dropDownShell;
+ List dropDownList;
+ Group imageToolBarGroup, textToolBarGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button flatButton, wrapButton;
+
+ static String [] ListData0 = {resControls.getString("ListData0_0"),
+ resControls.getString("ListData0_1"),
+ resControls.getString("ListData0_2"),
+ resControls.getString("ListData0_3"),
+ resControls.getString("ListData0_4"),
+ resControls.getString("ListData0_5"),
+ resControls.getString("ListData0_6"),
+ resControls.getString("ListData0_7"),
+ resControls.getString("ListData0_8")};
+
+/**
+* Create the drop down list widget used by the
+* drop down style tool bar item.
+*/
+void createDropDownList() {
+
+ /* Don't create more than one list */
+ if (dropDownList != null) return;
+
+ /* Create the list */
+ Shell shell = tabFolderPage.getShell ();
+ dropDownShell = new Shell (shell, SWT.NO_TRIM);
+ dropDownList = new List(dropDownShell, SWT.VERTICAL);
+ dropDownShell.setLayout (new FillLayout ());
+ dropDownList.setItems (ListData0);
+
+ /*
+ * Add a list selection listener so that the list is hidden
+ * when the user selects an item from the drop down list.
+ */
+ dropDownList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ disposeDropDownList ();
+ }
+ });
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the image tool bar */
+ imageToolBarGroup = new Group (exampleGroup, SWT.NULL);
+ imageToolBarGroup.setLayout (new GridLayout ());
+ imageToolBarGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ imageToolBarGroup.setText (resControls.getString("Image_ToolBar"));
+
+ /* Create a group for the text tool bar */
+ textToolBarGroup = new Group (exampleGroup, SWT.NULL);
+ textToolBarGroup.setLayout (new GridLayout ());
+ textToolBarGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ textToolBarGroup.setText (resControls.getString("Text_ToolBar"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (flatButton.getSelection()) style |= SWT.FLAT;
+ if (wrapButton.getSelection()) style |= SWT.WRAP;
+ if (borderButton.getSelection()) style |= SWT.BORDER;
+
+ /*
+ * Create the example widgets.
+ *
+ * A tool bar must consist of all image tool
+ * items or all text tool items but not both.
+ */
+
+ /* Create the image tool bar */
+ imageToolBar = new ToolBar (imageToolBarGroup, style);
+ ToolItem item = new ToolItem (imageToolBar, SWT.PUSH);
+ item.setImage (Images.CLOSED_FOLDER_IMAGE);
+ item.setToolTipText(resControls.getString("SWT_PUSH"));
+ item = new ToolItem (imageToolBar, SWT.PUSH);
+ item.setImage (Images.CLOSED_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_PUSH"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (Images.OPEN_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (Images.OPEN_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.CHECK);
+ item.setImage (Images.TARGET_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_CHECK"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (Images.CLOSED_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (Images.CLOSED_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.SEPARATOR);
+ item.setToolTipText(resControls.getString("SWT_SEPARATOR"));
+ item = new ToolItem (imageToolBar, SWT.DROP_DOWN);
+ item.setImage (Images.TARGET_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_DROP_DOWN"));
+
+ /*
+ * Add a selection listener to the drop down tool item
+ * so that we can show the list when the drop down area
+ * is pressed.
+ */
+ item.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ dropDownToolItemSelected (event);
+ }
+ });
+
+ /* Create the text tool bar */
+ textToolBar = new ToolBar (textToolBarGroup, style);
+ item = new ToolItem (textToolBar, SWT.PUSH);
+ item.setText (resControls.getString("Push"));
+ item.setToolTipText(resControls.getString("SWT_PUSH"));
+ item = new ToolItem (textToolBar, SWT.PUSH);
+ item.setText (resControls.getString("Push"));
+ item.setToolTipText(resControls.getString("SWT_PUSH"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (resControls.getString("Radio"));
+ item.setToolTipText(resControls.getString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (resControls.getString("Radio"));
+ item.setToolTipText(resControls.getString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.CHECK);
+ item.setText (resControls.getString("Check"));
+ item.setToolTipText(resControls.getString("SWT_CHECK"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (resControls.getString("Radio"));
+ item.setToolTipText(resControls.getString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (resControls.getString("Radio"));
+ item.setToolTipText(resControls.getString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.SEPARATOR);
+ item.setToolTipText(resControls.getString("SWT_SEPARATOR"));
+ item = new ToolItem (textToolBar, SWT.DROP_DOWN);
+ item.setText (resControls.getString("Drop_Down"));
+ item.setToolTipText(resControls.getString("SWT_DROP_DOWN"));
+
+ /*
+ * Do not add the selection event for this drop down
+ * tool item. Without hooking the event, the drop down
+ * widget does nothing special when the drop down area
+ * is selected.
+ */
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup() {
+ super.createStyleGroup();
+
+ /* Create the extra widgets */
+ flatButton = new Button (styleGroup, SWT.CHECK);
+ flatButton.setText (resControls.getString("SWT_FLAT"));
+ wrapButton = new Button (styleGroup, SWT.CHECK);
+ wrapButton.setText (resControls.getString("SWT_WRAP"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+void disposeDropDownList () {
+ if (dropDownShell != null) dropDownShell.dispose ();
+ dropDownShell = null; dropDownList = null;
+}
+void disposeExampleWidgets () {
+ super.disposeExampleWidgets ();
+ disposeDropDownList ();
+}
+/**
+* Handle the drop down tool item selection event.
+*
+* @param event the selection event
+*/
+void dropDownToolItemSelected (SelectionEvent event) {
+
+ /*
+ * If list was already dropped down then close it.
+ * We would do this regardless of where the tool
+ * item was selected.
+ */
+ createDropDownList ();
+ if (dropDownShell.getVisible ()) {
+ disposeDropDownList ();
+ return;
+ }
+
+ /**
+ * A selection event will be fired when a drop down tool
+ * item is selected in the main area and in the drop
+ * down arrow. Examine the event detail to determine
+ * where the widget was selected.
+ */
+ if (event.detail == SWT.ARROW) {
+ /*
+ * The drop down arrow was selected.
+ * Position the list below and vertically
+ * alligned with the the drop down tool button.
+ */
+ ToolItem item = (ToolItem) event.widget;
+ Rectangle toolItemBounds = item.getBounds ();
+ Point point1 = imageToolBar.toDisplay (new Point (toolItemBounds.x, toolItemBounds.y));
+ dropDownShell.setBounds (point1.x, point1.y + toolItemBounds.height, 100, 100);
+ dropDownShell.setVisible (true);
+ } else {
+ /*
+ * Main area of drop down tool item selected.
+ * An application would invoke the code was
+ * required to perform the action for the tool
+ * item.
+ */
+ }
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {imageToolBar, textToolBar};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("ToolBar");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ flatButton.setSelection ((imageToolBar.getStyle () & SWT.FLAT) != 0);
+ wrapButton.setSelection ((imageToolBar.getStyle () & SWT.WRAP) != 0);
+ borderButton.setSelection ((imageToolBar.getStyle () & SWT.BORDER) != 0);
+}
+
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TreeTab.java b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TreeTab.java
new file mode 100755
index 0000000000..ef17d660c3
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/TreeTab.java
@@ -0,0 +1,111 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class TreeTab extends ScrollableTab {
+
+ /* Example widgets and groups that contain them */
+ Tree tree1, tree2;
+ Group treeGroup, imageTreeGroup;
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the text tree */
+ treeGroup = new Group (exampleGroup, SWT.NULL);
+ treeGroup.setLayout (new GridLayout ());
+ treeGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ treeGroup.setText (resControls.getString("Tree"));
+
+ /* Create a group for the image tree */
+ imageTreeGroup = new Group (exampleGroup, SWT.NULL);
+ imageTreeGroup.setLayout (new GridLayout ());
+ imageTreeGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ imageTreeGroup.setText (resControls.getString("Tree_With_Images"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (singleButton.getSelection()) style |= SWT.SINGLE;
+ if (multiButton.getSelection()) style |= SWT.MULTI;
+ if (borderButton.getSelection()) style |= SWT.BORDER;
+
+ /* Create the text tree */
+ tree1 = new Tree (treeGroup, style);
+ TreeItem node1 = new TreeItem (tree1, SWT.NULL);
+ node1.setText (resControls.getString("Node_1"));
+ TreeItem node2 = new TreeItem (tree1, SWT.NULL);
+ node2.setText (resControls.getString("Node_2"));
+ TreeItem node3 = new TreeItem (tree1, SWT.NULL);
+ node3.setText (resControls.getString("Node_3"));
+ TreeItem node4 = new TreeItem (tree1, SWT.NULL);
+ node4.setText (resControls.getString("Node_4"));
+ TreeItem node1_1 = new TreeItem (node1, SWT.NULL);
+ node1_1.setText (resControls.getString("Node_1_1"));
+ TreeItem node2_1 = new TreeItem (node2, SWT.NULL);
+ node2_1.setText (resControls.getString("Node_2_1"));
+ TreeItem node3_1 = new TreeItem (node3, SWT.NULL);
+ node3_1.setText (resControls.getString("Node_3_1"));
+ TreeItem node2_2 = new TreeItem (node2, SWT.NULL);
+ node2_2.setText (resControls.getString("Node_2_2"));
+ TreeItem node2_2_1 = new TreeItem (node2_2, SWT.NULL);
+ node2_2_1.setText (resControls.getString("Node_2_2_1"));
+
+ /* Create the image tree */
+ tree2 = new Tree (imageTreeGroup, style);
+ node1 = new TreeItem (tree2, SWT.NULL);
+ node1.setText (resControls.getString("Node_1"));
+ node1.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node2 = new TreeItem (tree2, SWT.NULL);
+ node2.setText (resControls.getString("Node_2"));
+ node2.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node3 = new TreeItem (tree2, SWT.NULL);
+ node3.setText (resControls.getString("Node_3"));
+ node3.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node4 = new TreeItem (tree2, SWT.NULL);
+ node4.setText (resControls.getString("Node_4"));
+ node4.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node1_1 = new TreeItem (node1, SWT.NULL);
+ node1_1.setText (resControls.getString("Node_1_1"));
+ node1_1.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node2_1 = new TreeItem (node2, SWT.NULL);
+ node2_1.setText (resControls.getString("Node_2_1"));
+ node2_1.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node3_1 = new TreeItem (node3, SWT.NULL);
+ node3_1.setText (resControls.getString("Node_3_1"));
+ node3_1.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node2_2 = new TreeItem(node2, SWT.NULL);
+ node2_2.setText (resControls.getString("Node_2_2"));
+ node2_2.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node2_2_1 = new TreeItem (node2_2, SWT.NULL);
+ node2_2_1.setText (resControls.getString("Node_2_2_1"));
+ node2_2_1.setImage (Images.CLOSED_FOLDER_IMAGE);
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {tree1, tree2};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Tree");
+}
+}
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/folder.gif b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/folder.gif
new file mode 100755
index 0000000000..6660d0b11a
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/folder.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/folderOpen.gif b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/folderOpen.gif
new file mode 100755
index 0000000000..fc9943f111
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/folderOpen.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/stop.gif b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/stop.gif
new file mode 100755
index 0000000000..9807ae648d
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/org/eclipse/swt/examples/controlexample/stop.gif
Binary files differ

Back to the top