Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 108691 Details for
Bug 242163
[SWT Examples - SWT Controls] top-level tab folder requires wide screen on OS X
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
preview of a possible solution
242163-preview.patch (text/plain), 9.34 KB, created by
Volker Wegert
on 2008-07-29 15:40:13 EDT
(
hide
)
Description:
preview of a possible solution
Filename:
MIME Type:
Creator:
Volker Wegert
Created:
2008-07-29 15:40:13 EDT
Size:
9.34 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.swt.examples >Index: src/org/eclipse/swt/examples/controlexample/ControlExample.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ControlExample.java,v >retrieving revision 1.50 >diff -u -r1.50 ControlExample.java >--- src/org/eclipse/swt/examples/controlexample/ControlExample.java 29 Nov 2007 22:39:09 -0000 1.50 >+++ src/org/eclipse/swt/examples/controlexample/ControlExample.java 29 Jul 2008 19:33:47 -0000 >@@ -12,6 +12,9 @@ > > > import org.eclipse.swt.*; >+import org.eclipse.swt.custom.StackLayout; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.graphics.*; > import org.eclipse.swt.layout.*; > import org.eclipse.swt.widgets.*; >@@ -24,8 +27,11 @@ > private static ResourceBundle resourceBundle = > ResourceBundle.getBundle("examples_control"); //$NON-NLS-1$ > private ShellTab shellTab; >- private TabFolder tabFolder; >+ private Combo tabCombo; >+ private Composite tabArea; >+ private StackLayout tabLayout; > private Tab [] tabs; >+ private Composite[] tabPages; > Image images[]; > > static final int ciClosedFolder = 0, ciOpenFolder = 1, ciTarget = 2, ciBackground = 3, ciParentBackground = 4; >@@ -52,14 +58,42 @@ > */ > public ControlExample(Composite parent) { > initResources(); >- tabFolder = new TabFolder (parent, SWT.NONE); > tabs = createTabs(); >- for (int i=0; i<tabs.length; i++) { >- TabItem item = new TabItem (tabFolder, SWT.NONE); >- item.setText (tabs [i].getTabText ()); >- item.setControl (tabs [i].createTabFolderPage (tabFolder)); >- item.setData (tabs [i]); >+ >+ String comboEntries[] = new String[tabs.length]; >+ for (int i = 0; i < tabs.length; i++) { >+ comboEntries[i] = tabs[i].getTabText(); > } >+ >+ Composite top = new Composite(parent, SWT.NONE); >+ top.setLayout(new GridLayout(2, false)); >+ >+ Label tabLabel = new Label(top, SWT.NONE); >+ tabLabel.setText("Control"); >+ tabLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); >+ >+ tabCombo = new Combo(top, SWT.READ_ONLY); >+ tabCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); >+ tabCombo.setItems(comboEntries); >+ tabCombo.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ selectTab(tabCombo.getSelectionIndex()); >+ } >+ }); >+ >+ tabLayout = new StackLayout(); >+ tabArea = new Composite(top, SWT.NONE); >+ tabArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); >+ tabArea.setLayout(tabLayout); >+ tabPages = new Composite[tabs.length]; >+ for (int i = 0; i < tabs.length; i++) { >+ tabPages[i] = tabs[i].createPageComposite(tabArea); >+ } >+ >+ tabCombo.select(0); >+ tabLayout.topControl = tabPages[0]; >+ tabArea.layout(); >+ > startup = false; > } > >@@ -69,28 +103,28 @@ > Tab[] createTabs() { > return new Tab [] { > new ButtonTab (this), >- new CanvasTab (this), >- new ComboTab (this), >+// new CanvasTab (this), TODO >+// new ComboTab (this), TODO > new CoolBarTab (this), > new DateTimeTab (this), >- new DialogTab (this), >+// new DialogTab (this), TODO > new ExpandBarTab (this), > new GroupTab (this), > new LabelTab (this), > new LinkTab (this), > new ListTab (this), >- new MenuTab (this), >+// new MenuTab (this), TODO > new ProgressBarTab (this), > new SashTab (this), > new ScaleTab (this), >- shellTab = new ShellTab(this), >+// shellTab = new ShellTab(this), TODO > new SliderTab (this), >- new SpinnerTab (this), >+// new SpinnerTab (this), TODO > new TabFolderTab (this), > new TableTab (this), >- new TextTab (this), >+// new TextTab (this), TODO > new ToolBarTab (this), >- new ToolTipTab (this), >+// new ToolTipTab (this), TODO > new TreeTab (this), > new BrowserTab (this), > }; >@@ -111,7 +145,8 @@ > */ > if (shellTab != null) shellTab.closeAllShells (); > shellTab = null; >- tabFolder = null; >+ tabArea = null; >+ tabCombo = null; > freeResources(); > } > >@@ -214,10 +249,19 @@ > } > > /** >+ * Changes the tab displayed in the group. >+ * @param index the index of the tab in tabs[] >+ */ >+ void selectTab(int index) { >+ tabLayout.topControl = tabPages[index]; >+ tabArea.layout(); >+ } >+ >+ /** > * Grabs input focus. > */ > public void setFocus() { >- tabFolder.setFocus(); >+ tabCombo.setFocus(); > } > > /** >@@ -231,14 +275,14 @@ > /* Workaround: if the tab folder is wider than the screen, > * carbon clips instead of somehow scrolling the tab items. > * We try to recover some width by using shorter tab names. */ >- if (size.x > monitorArea.width && SWT.getPlatform().equals("carbon")) { >- TabItem [] tabItems = instance.tabFolder.getItems(); >- for (int i=0; i<tabItems.length; i++) { >- tabItems[i].setText (instance.tabs [i].getShortTabText ()); >- } >- size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); >- } >- shell.setSize(Math.min(size.x, monitorArea.width), Math.min(size.y, monitorArea.height)); >+// if (size.x > monitorArea.width && SWT.getPlatform().equals("carbon")) { >+// TabItem [] tabItems = instance.tabFolder.getItems(); >+// for (int i=0; i<tabItems.length; i++) { >+// tabItems[i].setText (instance.tabs [i].getShortTabText ()); >+// } >+// size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+// } >+// shell.setSize(Math.min(size.x, monitorArea.width), Math.min(size.y, monitorArea.height)); > } > } > >Index: src/org/eclipse/swt/examples/controlexample/Tab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java,v >retrieving revision 1.79 >diff -u -r1.79 Tab.java >--- src/org/eclipse/swt/examples/controlexample/Tab.java 29 May 2008 18:46:47 -0000 1.79 >+++ src/org/eclipse/swt/examples/controlexample/Tab.java 29 Jul 2008 19:33:47 -0000 >@@ -44,7 +44,7 @@ > Button preferredButton, tooSmallButton, smallButton, largeButton, fillHButton, fillVButton; > > /* Common groups and composites */ >- Composite tabFolderPage; >+ Composite pageComposite; > Group exampleGroup, controlGroup, listenersGroup, otherGroup, sizeGroup, styleGroup, colorGroup, backgroundModeGroup; > > /* Controlling instance */ >@@ -231,7 +231,7 @@ > * right half of each example tab. It consists of the > * "Style" group, the "Other" group and the "Size" group. > */ >- controlGroup = new Group (tabFolderPage, SWT.NONE); >+ controlGroup = new Group (pageComposite, SWT.NONE); > controlGroup.setLayout (new GridLayout (2, true)); > controlGroup.setLayoutData (new GridData(SWT.FILL, SWT.FILL, false, false)); > controlGroup.setText (ControlExample.getResourceString("Parameters")); >@@ -762,7 +762,7 @@ > * is typically the left hand column in the tab. > */ > void createExampleGroup () { >- exampleGroup = new Group (tabFolderPage, SWT.NONE); >+ exampleGroup = new Group (pageComposite, SWT.NONE); > exampleGroup.setLayout (new GridLayout ()); > exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); > } >@@ -901,7 +901,7 @@ > * goes below the "Example" and "Control" groups. > */ > void createListenersGroup () { >- listenersGroup = new Group (tabFolderPage, SWT.NONE); >+ listenersGroup = new Group (pageComposite, SWT.NONE); > listenersGroup.setLayout (new GridLayout (3, false)); > listenersGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true, 2, 1)); > listenersGroup.setText (ControlExample.getResourceString ("Listeners")); >@@ -1238,30 +1238,32 @@ > * @param tabFolder org.eclipse.swt.widgets.TabFolder > * @return the new page for the tab folder > */ >- Composite createTabFolderPage (TabFolder tabFolder) { >- /* Cache the shell and display. */ >- shell = tabFolder.getShell (); >- display = shell.getDisplay (); >- >- /* Create a two column page. */ >- tabFolderPage = new Composite (tabFolder, SWT.NONE); >- tabFolderPage.setLayout (new GridLayout (2, false)); >- >- /* Create the "Example" and "Control" groups. */ >- createExampleGroup (); >- createControlGroup (); >- >- /* Create the "Listeners" group under the "Control" group. */ >- createListenersGroup (); >- >- /* Create and initialize the example and control widgets. */ >- createExampleWidgets (); >- hookExampleWidgetListeners (); >- createControlWidgets (); >- createBackgroundModeGroup (); >- setExampleWidgetState (); >+ Composite createPageComposite(Composite parent) { >+ if (pageComposite == null) { >+ /* Cache the shell and display. */ >+ shell = parent.getShell (); >+ display = shell.getDisplay (); >+ >+ /* Create a two column page. */ >+ pageComposite = new Composite (parent, SWT.NONE); >+ pageComposite.setLayout (new GridLayout (2, false)); >+ >+ /* Create the "Example" and "Control" groups. */ >+ createExampleGroup (); >+ createControlGroup (); >+ >+ /* Create the "Listeners" group under the "Control" group. */ >+ createListenersGroup (); >+ >+ /* Create and initialize the example and control widgets. */ >+ createExampleWidgets (); >+ hookExampleWidgetListeners (); >+ createControlWidgets (); >+ createBackgroundModeGroup (); >+ setExampleWidgetState (); >+ } > >- return tabFolderPage; >+ return pageComposite; > } > > void setExampleWidgetPopupMenu() { >@@ -1734,7 +1736,7 @@ > gridData.verticalAlignment = fillVButton.getSelection() ? SWT.FILL : SWT.TOP; > controls [i].setLayoutData (gridData); > } >- tabFolderPage.layout (controls); >+ pageComposite.layout (controls); > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 242163
:
108494
|
108691
|
112243
|
151643