diff options
author | Carolyn MacLeod <Carolyn_MacLeod@ca.ibm.com> | 2012-06-18 13:58:09 -0400 |
---|---|---|
committer | Carolyn MacLeod <Carolyn_MacLeod@ca.ibm.com> | 2012-06-18 13:58:09 -0400 |
commit | 43782d41bf6e68d6d0f0c17b2b5cc18389b23a24 (patch) | |
tree | 6e27a547cb644a824af382faaa105f47e74c242d /examples | |
parent | 0f3c1bcc03658eaff93340278a73ca8a2bca2a39 (diff) | |
download | eclipse.platform.swt-43782d41bf6e68d6d0f0c17b2b5cc18389b23a24.tar.gz eclipse.platform.swt-43782d41bf6e68d6d0f0c17b2b5cc18389b23a24.tar.xz eclipse.platform.swt-43782d41bf6e68d6d0f0c17b2b5cc18389b23a24.zip |
Bug 382887 - CustomControlExample CTabFolder should have setTopRight
Diffstat (limited to 'examples')
-rw-r--r-- | examples/org.eclipse.swt.examples/src/examples_control.properties | 1 | ||||
-rw-r--r-- | examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java | 53 |
2 files changed, 53 insertions, 1 deletions
diff --git a/examples/org.eclipse.swt.examples/src/examples_control.properties b/examples/org.eclipse.swt.examples/src/examples_control.properties index 32514e6ba0..b3c93b7a90 100644 --- a/examples/org.eclipse.swt.examples/src/examples_control.properties +++ b/examples/org.eclipse.swt.examples/src/examples_control.properties @@ -228,6 +228,7 @@ Set_Unselected_Image_Visible = Image on Unselected Tabs Selection_Foreground_Color = Selection Foreground Color Selection_Background_Color = Selection Background Color Set_Image = Set Image +Set_Top_Right = Set Top Right TableTree_column = Column MenuItem_Cut = Cu&t Ctrl+X MenuItem_Copy = &Copy Ctrl+C diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java index 15daa91d1c..432a16c10f 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java @@ -27,6 +27,7 @@ class CTabFolderTab extends Tab { /* Style widgets added to the "Style" group */ Button topButton, bottomButton, flatButton, closeButton; + Button rightButton, fillButton, wrapButton; static String [] CTabItems1 = {ControlExample.getResourceString("CTabItem1_0"), ControlExample.getResourceString("CTabItem1_1"), @@ -40,7 +41,10 @@ class CTabFolderTab extends Tab { Font itemFont; /* Other widgets added to the "Other" group */ - Button simpleTabButton, singleTabButton, imageButton, showMinButton, showMaxButton, unselectedCloseButton, unselectedImageButton; + Button simpleTabButton, singleTabButton, imageButton, showMinButton, showMaxButton, + topRightButton, unselectedCloseButton, unselectedImageButton; + + ToolBar topRightControl; /** * Creates the Tab within a given instance of ControlExample. @@ -161,6 +165,15 @@ class CTabFolderTab extends Tab { } }); + topRightButton = new Button (otherGroup, SWT.CHECK); + topRightButton.setText (ControlExample.getResourceString("Set_Top_Right")); + topRightButton.setSelection(false); + topRightButton.addSelectionListener (new SelectionAdapter () { + public void widgetSelected (SelectionEvent event) { + setTopRight(); + } + }); + imageButton = new Button (otherGroup, SWT.CHECK); imageButton.setText (ControlExample.getResourceString("Set_Image")); imageButton.addSelectionListener (new SelectionAdapter () { @@ -227,7 +240,10 @@ class CTabFolderTab extends Tab { lastSelectedTab = tabFolder1.getSelectionIndex(); } }); + + /* If we have saved state, restore it */ tabFolder1.setSelection(lastSelectedTab); + setTopRight (); } /** @@ -248,6 +264,18 @@ class CTabFolderTab extends Tab { flatButton.setText ("SWT.FLAT"); closeButton = new Button (styleGroup, SWT.CHECK); closeButton.setText ("SWT.CLOSE"); + + Group topRightGroup = new Group(styleGroup, SWT.NONE); + topRightGroup.setLayout (new GridLayout ()); + topRightGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); + topRightGroup.setText (ControlExample.getResourceString("Top_Right_Styles")); + rightButton = new Button (topRightGroup, SWT.RADIO); + rightButton.setText ("SWT.RIGHT"); + rightButton.setSelection(true); + fillButton = new Button (topRightGroup, SWT.RADIO); + fillButton.setText ("SWT.FILL"); + wrapButton = new Button (topRightGroup, SWT.RADIO); + wrapButton.setText ("SWT.RIGHT | SWT.WRAP"); } /** @@ -380,6 +408,29 @@ class CTabFolderTab extends Tab { setExampleWidgetSize(); } /** + * Sets the top right control to a toolbar + */ + void setTopRight () { + if (topRightButton.getSelection ()) { + topRightControl = new ToolBar(tabFolder1, SWT.FLAT); + ToolItem item = new ToolItem(topRightControl, SWT.PUSH); + item.setImage(instance.images[ControlExample.ciClosedFolder]); + item = new ToolItem(topRightControl, SWT.PUSH); + item.setImage(instance.images[ControlExample.ciOpenFolder]); + int topRightStyle = 0; + if (rightButton.getSelection ()) topRightStyle |= SWT.RIGHT; + if (fillButton.getSelection ()) topRightStyle |= SWT.FILL; + if (wrapButton.getSelection ()) topRightStyle |= SWT.RIGHT | SWT.WRAP; + tabFolder1.setTopRight(topRightControl, topRightStyle); + } else { + if (topRightControl != null) { + tabFolder1.setTopRight(null); + topRightControl.dispose(); + } + } + setExampleWidgetSize(); + } + /** * Sets the visibility of the close button on unselected tabs */ void setUnselectedCloseVisible () { |