Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 55156 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/ColorSchemeService.java (-3 / +4 lines)
Lines 126-134 Link Here
126
        c[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
126
        c[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
127
        c[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
127
        c[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
128
128
129
        percent[0] = theme.getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT);
129
		percent[0] = presentation.getGradientPercentage();
130
        vertical = theme.getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL);
130
        vertical = false;
131
        
131
132
        // Note: This is currently being overridden in PartTabFolderPresentation
132
        control.setBackground(c, percent, vertical);		
133
        control.setBackground(c, percent, vertical);		
133
134
134
        if (presentation.isActive()) {                
135
        if (presentation.isActive()) {                
(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchThemeConstants.java (-4 / +1 lines)
Lines 30-37 Link Here
30
    public static final String INACTIVE_TAB_BG_END = "org.eclipse.ui.workbench.INACTIVE_TAB_BG_END"; //$NON-NLS-1$
30
    public static final String INACTIVE_TAB_BG_END = "org.eclipse.ui.workbench.INACTIVE_TAB_BG_END"; //$NON-NLS-1$
31
31
32
    public static final String ACTIVE_TAB_PERCENT = "org.eclipse.ui.workbench.ACTIVE_TAB_PERCENT"; //$NON-NLS-1$
32
    public static final String ACTIVE_TAB_PERCENT = "org.eclipse.ui.workbench.ACTIVE_TAB_PERCENT"; //$NON-NLS-1$
33
    public static final String INACTIVE_TAB_PERCENT = "org.eclipse.ui.workbench.INACTIVE_TAB_PERCENT"; //$NON-NLS-1$
33
    public static final String ACTIVE_TAB_VERTICAL = "org.eclipse.ui.workbench.ACTIVE_TAB_VERTICAL"; //$NON-NLS-1$    
34
35
    public static final String ACTIVE_TAB_VERTICAL = "org.eclipse.ui.workbench.ACTIVE_TAB_VERTICAL"; //$NON-NLS-1$
36
    public static final String INACTIVE_TAB_VERTICAL = "org.eclipse.ui.workbench.INACTIVE_TAB_VERTICAL"; //$NON-NLS-1$    
37
}
34
}
(-)Eclipse UI/org/eclipse/ui/internal/PartTabFolder.java (-14 / +10 lines)
Lines 40-45 Link Here
40
import org.eclipse.ui.presentations.StackDropResult;
40
import org.eclipse.ui.presentations.StackDropResult;
41
import org.eclipse.ui.presentations.StackPresentation;
41
import org.eclipse.ui.presentations.StackPresentation;
42
42
43
/**
44
 * Manages a set of ViewPanes that are docked into the workbench window. The container for a PartTabFolder
45
 * is always a PartSashContainer (or null), and its children are always either PartPlaceholders or PartPanes.
46
 * 
47
 * TODO: write a common base class for EditorWorkbook and PartTabFolder.
48
 * TODO: remove the LayoutPart superclass. All code can either refer to PartPane, 
49
 * PartPlaceholder, PartSashContainer, or the common base class for EditorWorkbook and PartTabFolder.
50
 * The frequent downcasting is due to the fact that much of the code tries to use LayoutPart 
51
 * or ILayoutContainer references for many different purposes.
52
 */
43
public class PartTabFolder extends LayoutPart implements ILayoutContainer {
53
public class PartTabFolder extends LayoutPart implements ILayoutContainer {
44
54
45
    private boolean active = false;
55
    private boolean active = false;
Lines 537-556 Link Here
537
        DragUtil
547
        DragUtil
538
                .performDrag(part, DragUtil.getDisplayBounds(part.getControl()));
548
                .performDrag(part, DragUtil.getDisplayBounds(part.getControl()));
539
    }
549
    }
540
541
    /**
542
     * Returns the current presentable part, or null if there is no current
543
     * selection
544
     * 
545
     * @return the current presentable part, or null if there is no current
546
     *         selection
547
     */
548
    /*
549
     * not used private IPresentablePart getCurrentPresentablePart() { if
550
     * (current != null) { return current.getPresentablePart(); }
551
     * 
552
     * return null; }
553
     */
554
550
555
    private void presentationSelectionChanged(IPresentablePart newSelection) {
551
    private void presentationSelectionChanged(IPresentablePart newSelection) {
556
        setSelection(getLayoutPart(newSelection));
552
        setSelection(getLayoutPart(newSelection));
(-)Eclipse UI/org/eclipse/ui/internal/PresentableEditorPart.java (+8 lines)
Lines 15-20 Link Here
15
15
16
import org.eclipse.swt.graphics.Image;
16
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.swt.graphics.Rectangle;
17
import org.eclipse.swt.graphics.Rectangle;
18
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.ui.IEditorReference;
19
import org.eclipse.ui.IEditorReference;
19
import org.eclipse.ui.IPropertyListener;
20
import org.eclipse.ui.IPropertyListener;
20
import org.eclipse.ui.presentations.IPresentablePart;
21
import org.eclipse.ui.presentations.IPresentablePart;
Lines 97-101 Link Here
97
	public boolean isBusy() {
98
	public boolean isBusy() {
98
		// editors do not support busy currently
99
		// editors do not support busy currently
99
		return false;
100
		return false;
101
	}
102
103
	/* (non-Javadoc)
104
	 * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
105
	 */
106
	public Control getToolBar() {
107
		return null;
100
	}
108
	}
101
}
109
}
(-)Eclipse UI/org/eclipse/ui/internal/PresentableViewPart.java (-1 / +8 lines)
Lines 17-22 Link Here
17
import org.eclipse.jface.util.PropertyChangeEvent;
17
import org.eclipse.jface.util.PropertyChangeEvent;
18
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Rectangle;
19
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.ui.IPropertyListener;
21
import org.eclipse.ui.IPropertyListener;
21
import org.eclipse.ui.IViewReference;
22
import org.eclipse.ui.IViewReference;
22
import org.eclipse.ui.IWorkbenchPartSite;
23
import org.eclipse.ui.IWorkbenchPartSite;
Lines 27-33 Link Here
27
28
28
    private final List listeners = new ArrayList();
29
    private final List listeners = new ArrayList();
29
 
30
 
30
31
    private ViewPane pane;
31
    private ViewPane pane;
32
    
32
    
33
    private boolean busy = false;
33
    private boolean busy = false;
Lines 121-126 Link Here
121
	 */
121
	 */
122
	public boolean isBusy() {
122
	public boolean isBusy() {
123
		return busy;
123
		return busy;
124
	}
125
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
128
	 */
129
	public Control getToolBar() {
130
		return pane.getToolBarManager().getControl();
124
	}
131
	}
125
	
132
	
126
	
133
	
(-)Eclipse UI/org/eclipse/ui/internal/ViewPane.java (-11 / +68 lines)
Lines 289-296 Link Here
289
		// All actions on the System toolbar should be accessible on the pane menu.
289
		// All actions on the System toolbar should be accessible on the pane menu.
290
		if (control.getContent() == null) {
290
		if (control.getContent() == null) {
291
			// content can be null if view creation failed
291
			// content can be null if view creation failed
292
			if (locked)
292
//			if (locked)
293
				control.setTabList(new Control[] { isvToolBar , viewToolBar });
293
//				control.setTabList(new Control[] { isvToolBar , viewToolBar });
294
		} else {
294
		} else {
295
			if (locked)
295
			if (locked)
296
				control.setTabList(new Control[] { viewToolBar, control.getContent()});
296
				control.setTabList(new Control[] { viewToolBar, control.getContent()});
Lines 440-450 Link Here
440
	
440
	
441
	private void toolBarResized(ToolBar toolBar, int newSize) {
441
	private void toolBarResized(ToolBar toolBar, int newSize) {
442
		if (locked) {
442
		if (locked) {
443
			if (toolBar == viewToolBar) {
443
			//if (toolBar == viewToolBar) {
444
				((ViewForm)control).setTopRight(newSize == 0 ? null :viewToolBar);
444
			//	((ViewForm)control).setTopRight(newSize == 0 ? null :viewToolBar);
445
			} else if (toolBar == isvToolBar) {
445
			//} 
446
				((ViewForm)control).setTopCenter(newSize == 0 ? null : isvToolBar);
446
//			else if (toolBar == isvToolBar) {
447
			}
447
				//((ViewForm)control).setTopCenter(newSize == 0 ? null : isvToolBar);
448
			//}
448
		}
449
		}
449
	}
450
	}
450
	
451
	
Lines 490-496 Link Here
490
		
491
		
491
		// ISV toolbar.
492
		// ISV toolbar.
492
		//			// 1GD0ISU: ITPUI:ALL - Dbl click on view tool cause zoom
493
		//			// 1GD0ISU: ITPUI:ALL - Dbl click on view tool cause zoom
493
		isvToolBar = new ToolBar(parentControl, barStyle);
494
		isvToolBar = new ToolBar(parentControl.getParent(), barStyle);
494
		
495
		
495
		
496
		
496
		
497
		
Lines 503-509 Link Here
503
				}
504
				}
504
			});
505
			});
505
		} else {
506
		} else {
506
			isvToolBar.setLayoutData(new GridData(GridData.FILL_BOTH));
507
			//isvToolBar.setLayoutData(new GridData(GridData.FILL_BOTH));
507
		}
508
		}
508
		IContributionItem[] isvItems = null;
509
		IContributionItem[] isvItems = null;
509
		if (isvToolBarMgr != null) {
510
		if (isvToolBarMgr != null) {
Lines 521-528 Link Here
521
		// whenever updating the tab colors
522
		// whenever updating the tab colors
522
		if (viewToolBar != null)
523
		if (viewToolBar != null)
523
		    ColorSchemeService.setViewColors(viewToolBar);
524
		    ColorSchemeService.setViewColors(viewToolBar);
524
		ColorSchemeService.setViewColors(isvToolBar);
525
		//ColorSchemeService.setViewColors(isvToolBar);
525
		ColorSchemeService.setViewColors(isvToolBar.getParent());
526
		//ColorSchemeService.setViewColors(isvToolBar.getParent());
526
	}
527
	}
527
	
528
	
528
	/**
529
	/**
Lines 1081-1084 Link Here
1081
	public IPresentablePart getPresentablePart() {
1082
	public IPresentablePart getPresentablePart() {
1082
		return presentableAdapter;
1083
		return presentableAdapter;
1083
	}
1084
	}
1085
	
1086
	/* (non-Javadoc)
1087
	 * @see org.eclipse.ui.internal.LayoutPart#reparent(org.eclipse.swt.widgets.Composite)
1088
	 */
1089
	public void reparent(Composite newParent) {
1090
		super.reparent(newParent);
1091
		
1092
		if (isvToolBar != null) {
1093
			isvToolBar.setParent(newParent);
1094
		}
1095
	}
1096
	
1097
	/* (non-Javadoc)
1098
	 * @see org.eclipse.ui.internal.LayoutPart#moveAbove(org.eclipse.swt.widgets.Control)
1099
	 */
1100
	public void moveAbove(Control refControl) {
1101
		super.moveAbove(refControl);
1102
		
1103
		isvToolBar.moveAbove(control);
1104
	}
1105
	
1106
	/* (non-Javadoc)
1107
	 * @see org.eclipse.ui.internal.LayoutPart#setVisible(boolean)
1108
	 */
1109
	public void setVisible(boolean makeVisible) {
1110
		super.setVisible(makeVisible);
1111
		
1112
		if (isvToolBar != null) {
1113
			isvToolBar.setVisible(makeVisible);
1114
		}
1115
	}
1116
1117
	/**
1118
	 * @param bounds
1119
	 */
1120
	public void setToolbarBounds(Rectangle bounds) {
1121
		if (isvToolBar != null) {
1122
			isvToolBar.update();
1123
			isvToolBar.setBounds(bounds);
1124
		}
1125
	}
1126
1127
	/**
1128
	 * @param hint
1129
	 * @param hint2
1130
	 * @return
1131
	 */
1132
	public Point computePreferredToolbarSize(int hint, int hint2) {
1133
		if (isvToolBar != null) {
1134
			isvToolBar.update();
1135
			return isvToolBar.computeSize(hint, hint2);
1136
		}
1137
		
1138
		return new Point(0,0);
1139
	}
1140
	
1084
}
1141
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/BasicStackPresentation.java (-16 / +62 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
11
package org.eclipse.ui.internal.presentations;
12
12
13
import java.util.ArrayList;
14
import java.util.List;
15
13
import org.eclipse.jface.action.IMenuManager;
16
import org.eclipse.jface.action.IMenuManager;
14
import org.eclipse.jface.action.MenuManager;
17
import org.eclipse.jface.action.MenuManager;
15
import org.eclipse.jface.resource.FontRegistry;
18
import org.eclipse.jface.resource.FontRegistry;
Lines 28-33 Link Here
28
import org.eclipse.swt.graphics.Point;
31
import org.eclipse.swt.graphics.Point;
29
import org.eclipse.swt.graphics.Rectangle;
32
import org.eclipse.swt.graphics.Rectangle;
30
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.swt.widgets.Display;
31
import org.eclipse.swt.widgets.Event;
35
import org.eclipse.swt.widgets.Event;
32
import org.eclipse.swt.widgets.Listener;
36
import org.eclipse.swt.widgets.Listener;
33
import org.eclipse.swt.widgets.Menu;
37
import org.eclipse.swt.widgets.Menu;
Lines 52-57 Link Here
52
	private boolean activeState = false;
56
	private boolean activeState = false;
53
	private int tabPosition;
57
	private int tabPosition;
54
	private MenuManager systemMenuManager = new MenuManager();
58
	private MenuManager systemMenuManager = new MenuManager();
59
	private TabFolderLayout layout;
60
	
61
	// Controls which will be inserted into the title bar if there is room, or above the client pane
62
	// if not
63
	private List topControls = new ArrayList();
64
	
65
	// Stand-in for the top controls
66
	//private Composite toolbarProxy;
55
	
67
	
56
	private int mousedownState = -1;
68
	private int mousedownState = -1;
57
	
69
	
Lines 128-133 Link Here
128
		}
140
		}
129
	};
141
	};
130
	
142
	
143
	public int getTopTrimStart() {
144
		return layout.getTrimStart();
145
	}
146
	
131
	private Listener resizeListener = new Listener() {
147
	private Listener resizeListener = new Listener() {
132
		public void handleEvent(Event e) {
148
		public void handleEvent(Event e) {
133
			setControlSize();
149
			setControlSize();
Lines 170-175 Link Here
170
	public BasicStackPresentation(CTabFolder control, IStackPresentationSite stackSite) {
186
	public BasicStackPresentation(CTabFolder control, IStackPresentationSite stackSite) {
171
	    super(stackSite);
187
	    super(stackSite);
172
		tabFolder = control;
188
		tabFolder = control;
189
		layout = new TabFolderLayout(tabFolder);
173
		
190
		
174
		// listener to switch between visible tabItems
191
		// listener to switch between visible tabItems
175
		tabFolder.addListener(SWT.Selection, selectionListener);
192
		tabFolder.addListener(SWT.Selection, selectionListener);
Lines 204-210 Link Here
204
				}
221
				}
205
			}
222
			}
206
		});
223
		});
207
						
224
		
225
		// Insert a bogus composite into the top-right of the tab folder. We do this to keep
226
		// track of where to draw the toolbars.
227
		//toolbarProxy = new Composite(tabFolder, SWT.NONE);
228
		
229
		//tabFolder.setTopRight(toolbarProxy);
208
	}
230
	}
209
231
210
	/**
232
	/**
Lines 306-311 Link Here
306
	}
328
	}
307
	
329
	
308
	public void drawGradient(Color fgColor, Color [] bgColors, int [] percentages, boolean vertical) {
330
	public void drawGradient(Color fgColor, Color [] bgColors, int [] percentages, boolean vertical) {
331
		Display display = tabFolder.getDisplay();
332
		Color c = display.getSystemColor(SWT.COLOR_BLUE);
333
334
		//fgColor = c;
335
//		tabFolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
336
//				 		                           display.getSystemColor(SWT.COLOR_BLUE),
337
//				 		                           display.getSystemColor(SWT.COLOR_WHITE), 
338
//				 		                           display.getSystemColor(SWT.COLOR_WHITE)},
339
//				 		               new int[] {25, 50, 100});
340
		
341
		//tabFolder.setBackground(display.getSystemColor(SWT.COLOR_DARK_BLUE));
342
		
309
		tabFolder.setSelectionForeground(fgColor);
343
		tabFolder.setSelectionForeground(fgColor);
310
		tabFolder.setSelectionBackground(bgColors, percentages, vertical);			    
344
		tabFolder.setSelectionBackground(bgColors, percentages, vertical);			    
311
	}
345
	}
Lines 317-323 Link Here
317
	/**
351
	/**
318
	 * Set the size of a page in the folder.
352
	 * Set the size of a page in the folder.
319
	 */
353
	 */
320
	private void setControlSize() {
354
	protected void setControlSize() {
321
		if (current == null || tabFolder == null)
355
		if (current == null || tabFolder == null)
322
			return;
356
			return;
323
//		Rectangle bounds;
357
//		Rectangle bounds;
Lines 327-348 Link Here
327
//			bounds = calculatePageBounds(tabFolder);
361
//			bounds = calculatePageBounds(tabFolder);
328
//		else
362
//		else
329
//			bounds = tabFolder.getBounds();
363
//			bounds = tabFolder.getBounds();
330
		current.setBounds(calculatePageBounds(tabFolder));
364
		layout.layout();
365
		current.setBounds(layout.getClientBounds());
366
				
331
		//current.moveAbove(tabFolder);
367
		//current.moveAbove(tabFolder);
332
	}
368
	}
333
	
369
	
334
	public static Rectangle calculatePageBounds(CTabFolder folder) {
335
		if (folder == null)
336
			return new Rectangle(0, 0, 0, 0);
337
		Rectangle bounds = folder.getBounds();
338
		Rectangle offset = folder.getClientArea();
339
		bounds.x += offset.x;
340
		bounds.y += offset.y;
341
		bounds.width = offset.width;
342
		bounds.height = offset.height;
343
		return bounds;
344
	}	
345
	
346
	/* (non-Javadoc)
370
	/* (non-Javadoc)
347
	 * @see org.eclipse.ui.internal.skins.Presentation#dispose()
371
	 * @see org.eclipse.ui.internal.skins.Presentation#dispose()
348
	 */
372
	 */
Lines 443-448 Link Here
443
		}
467
		}
444
	}
468
	}
445
	
469
	
470
	public IPresentablePart getCurrentPart() {
471
		return current;
472
	}
473
	
474
	protected void setTopRight(Control[] topRight) {
475
		layout.setTopRight(topRight);
476
		setControlSize();
477
	}
478
	
446
	/* (non-Javadoc)
479
	/* (non-Javadoc)
447
	 * @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle)
480
	 * @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle)
448
	 */
481
	 */
Lines 505-511 Link Here
505
	 * @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point)
538
	 * @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point)
506
	 */
539
	 */
507
	public StackDropResult dragOver(Control currentControl, Point location) {
540
	public StackDropResult dragOver(Control currentControl, Point location) {
508
		
509
		// Determine which tab we're currently dragging over
541
		// Determine which tab we're currently dragging over
510
		Point localPos = tabFolder.toControl(location);
542
		Point localPos = tabFolder.toControl(location);
511
		final CTabItem tabUnderPointer = tabFolder.getItem(localPos);
543
		final CTabItem tabUnderPointer = tabFolder.getItem(localPos);
Lines 519-522 Link Here
519
		return new StackDropResult(Geometry.toDisplay(tabFolder, tabUnderPointer.getBounds()),
551
		return new StackDropResult(Geometry.toDisplay(tabFolder, tabUnderPointer.getBounds()),
520
			tabFolder.indexOf(tabUnderPointer));
552
			tabFolder.indexOf(tabUnderPointer));
521
	}
553
	}
554
	
555
	public int getGradientPercentage() {
556
		Rectangle clientBounds = getTabFolder().getBounds();
557
		
558
		int percentage = clientBounds.width == 0 ? 100 : Math.min(100, 
559
				100 * getTopTrimStart() / clientBounds.width);
560
		
561
		if (percentage < 0) {
562
			percentage = 0;
563
		}
564
		
565
		return percentage;	    
566
	}
567
	
522
}
568
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/EditorPresentation.java (-2 / +2 lines)
Lines 264-271 Link Here
264
            		.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR);           
264
            		.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR);           
265
            bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
265
            bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
266
            bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
266
            bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
267
            percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT);
267
            percent[0] = getGradientPercentage();
268
            vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL);            
268
            vertical = false;            
269
        }
269
        }
270
270
271
        getTabFolder()
271
        getTabFolder()
(-)Eclipse UI/org/eclipse/ui/internal/presentations/PartTabFolderPresentation.java (-4 / +70 lines)
Lines 21-31 Link Here
21
import org.eclipse.swt.graphics.Color;
21
import org.eclipse.swt.graphics.Color;
22
import org.eclipse.swt.graphics.Font;
22
import org.eclipse.swt.graphics.Font;
23
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.ui.internal.ColorSchemeService;
26
import org.eclipse.ui.internal.ColorSchemeService;
26
import org.eclipse.ui.internal.IPreferenceConstants;
27
import org.eclipse.ui.internal.IPreferenceConstants;
27
import org.eclipse.ui.internal.IWorkbenchThemeConstants;
28
import org.eclipse.ui.internal.IWorkbenchThemeConstants;
28
import org.eclipse.ui.internal.WorkbenchPlugin;
29
import org.eclipse.ui.internal.WorkbenchPlugin;
30
import org.eclipse.ui.presentations.IPresentablePart;
29
import org.eclipse.ui.presentations.IStackPresentationSite;
31
import org.eclipse.ui.presentations.IStackPresentationSite;
30
import org.eclipse.ui.themes.ITheme;
32
import org.eclipse.ui.themes.ITheme;
31
33
Lines 36-43 Link Here
36
 */
38
 */
37
public class PartTabFolderPresentation extends BasicStackPresentation {
39
public class PartTabFolderPresentation extends BasicStackPresentation {
38
	
40
	
39
	private IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore();
41
	private IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore();	
40
		
42
41
	private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
43
	private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
42
		public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
44
		public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
43
			if (IPreferenceConstants.VIEW_TAB_POSITION.equals(propertyChangeEvent.getProperty()) && !isDisposed()) {
45
			if (IPreferenceConstants.VIEW_TAB_POSITION.equals(propertyChangeEvent.getProperty()) && !isDisposed()) {
Lines 53-58 Link Here
53
	public PartTabFolderPresentation(Composite parent, IStackPresentationSite newSite, int flags) {
55
	public PartTabFolderPresentation(Composite parent, IStackPresentationSite newSite, int flags) {
54
		
56
		
55
		super(new CTabFolder(parent, SWT.BORDER), newSite);
57
		super(new CTabFolder(parent, SWT.BORDER), newSite);
58
		
56
		CTabFolder tabFolder = getTabFolder();
59
		CTabFolder tabFolder = getTabFolder();
57
		
60
		
58
		preferenceStore.addPropertyChangeListener(propertyChangeListener);
61
		preferenceStore.addPropertyChangeListener(propertyChangeListener);
Lines 117-125 Link Here
117
	        fgColor = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR);
120
	        fgColor = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR);
118
            bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
121
            bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
119
            bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
122
            bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
120
            percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT);
123
            percent[0] = getGradientPercentage();
121
            vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL);
124
            vertical = false;
122
		}	
125
		}	
126
        
123
		drawGradient(fgColor, bgColors, percent, vertical);	
127
		drawGradient(fgColor, bgColors, percent, vertical);	
124
	}
128
	}
125
	
129
	
Lines 138-141 Link Here
138
		preferenceStore.removePropertyChangeListener(propertyChangeListener);
142
		preferenceStore.removePropertyChangeListener(propertyChangeListener);
139
		super.dispose();
143
		super.dispose();
140
	}
144
	}
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.ui.internal.presentations.BasicStackPresentation#setControlSize()
147
	 */
148
	protected void setControlSize() {		
149
		super.setControlSize();
150
		
151
		updateTitleGradient();
152
	}
153
	
154
	protected Control getCurrentToolbar() {
155
		IPresentablePart part = getCurrentPart();		
156
		if (part == null) {
157
			return null;
158
		}
159
160
		return part.getToolBar();
161
	}
162
	
163
	/* (non-Javadoc)
164
	 * @see org.eclipse.ui.presentations.StackPresentation#selectPart(org.eclipse.ui.presentations.IPresentablePart)
165
	 */
166
	public void selectPart(IPresentablePart toSelect) {
167
		super.selectPart(toSelect);
168
		
169
		Control toolbar = getCurrentToolbar();
170
		
171
		if (toolbar == null) {
172
			setTopRight(new Control[0]);
173
		} else {
174
		    ColorSchemeService.setViewColors(toolbar);
175
			setTopRight(new Control[] {toolbar});
176
177
			ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();	    
178
			ColorRegistry colorRegistry = currentTheme.getColorRegistry();
179
				
180
		    Color c = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
181
182
			toolbar.setBackground(c);
183
		}
184
		
185
		//getTabFolder().redraw();
186
		//updateToolbar();
187
		updateTitleGradient();
188
	}
189
	
190
	/**
191
	 * Updates the title's gradient based on the current size and position of 
192
	 * the toolbar. 
193
	 */
194
	protected void updateTitleGradient() {
195
		ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();	    
196
		ColorRegistry colorRegistry = currentTheme.getColorRegistry();
197
		
198
		Color [] c = new Color[2];
199
		c[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
200
		c[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
201
202
		int[] percents = new int[] {getGradientPercentage()};				
203
       
204
		getTabFolder().setBackground(c, percents, false);
205
	}
206
141
}
207
}
(-)Eclipse UI/org/eclipse/ui/internal/themes/WorkbenchPreview.java (-1 / +1 lines)
Lines 148-154 Link Here
148
        Color [] colors = new Color[2];
148
        Color [] colors = new Color[2];
149
        colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
149
        colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
150
        colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
150
        colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
151
        folder.setBackground(colors, new int [] {theme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT)}, theme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL));
151
        folder.setBackground(colors, new int [] {100}, false);
152
        toolBar.setBackground(colors[1]);
152
        toolBar.setBackground(colors[1]);
153
        viewMessage.setBackground(colors[1]);
153
        viewMessage.setBackground(colors[1]);
154
        viewForm.setBackground(colors[1]);
154
        viewForm.setBackground(colors[1]);
(-)Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java (+10 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.swt.graphics.Image;
13
import org.eclipse.swt.graphics.Image;
14
import org.eclipse.swt.graphics.Rectangle;
14
import org.eclipse.swt.graphics.Rectangle;
15
import org.eclipse.swt.widgets.Control;
15
import org.eclipse.ui.IPropertyListener;
16
import org.eclipse.ui.IPropertyListener;
16
17
17
/**
18
/**
Lines 61-66 Link Here
61
	 *   <li><code>IWorkbenchPart.PROP_TITLE</code> </li>
62
	 *   <li><code>IWorkbenchPart.PROP_TITLE</code> </li>
62
	 *   <li><code>IEditorPart.PROP_INPUT</code> </li>
63
	 *   <li><code>IEditorPart.PROP_INPUT</code> </li>
63
	 *   <li><code>IEditorPart.PROP_DIRTY</code> </li>
64
	 *   <li><code>IEditorPart.PROP_DIRTY</code> </li>
65
	 *   <li><code>IWorkbenchPart.PROP_TOOLBAR</code> </li>
64
	 * </ul>
66
	 * </ul>
65
	 * </p>
67
	 * </p>
66
	 *
68
	 *
Lines 138-142 Link Here
138
	 * @return boolean true if busy
140
	 * @return boolean true if busy
139
	 */
141
	 */
140
	public boolean isBusy();
142
	public boolean isBusy();
143
144
	/**
145
	 * Returns the local toolbar for this part, or null if this part does not
146
	 * have a local toolbar. Callers must not dispose or downcast the return value.
147
	 * 
148
	 * @return the local toolbar for the part, or null if none
149
	 */
150
	public Control getToolBar();
141
	
151
	
142
}
152
}
(-)Eclipse (+90 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.graphics.Point;
15
import org.eclipse.swt.graphics.Rectangle;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.swt.widgets.Event;
19
import org.eclipse.swt.widgets.Layout;
20
import org.eclipse.swt.widgets.Listener;
21
22
/**
23
 * This class creates an invisible SWT control that can be inserted as a placeholder into
24
 * a layout. This object can be subclassed in order to track sizing events.
25
 * 
26
 * @since 3.0
27
 */
28
public class ProxyControl {
29
	
30
	private Composite proxy;
31
	
32
	/**
33
	 * Creates a proxy control in the given parent.
34
	 *  
35
	 * @param parent the parent of the invisible proxy
36
	 * @param beingDragged a control whose size and position will always match that of the
37
	 * invisible proxy.
38
	 */
39
	public ProxyControl(Composite parent) {
40
		proxy = new Composite(parent, SWT.NONE);
41
		
42
		proxy.setLayout(new Layout() {
43
			protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
44
				return ProxyControl.this.computeSize(wHint, hHint, flushCache);
45
			}
46
47
			protected void layout(Composite composite, boolean flushCache) {
48
				setBounds(composite.getBounds());
49
			}
50
		});
51
		
52
		Listener boundsListener = new Listener() {
53
			public void handleEvent(Event e) {
54
				setBounds(proxy.getBounds());
55
			}
56
		};
57
		
58
		proxy.addListener(SWT.Resize, boundsListener);
59
		proxy.addListener(SWT.Move, boundsListener);
60
	}
61
	
62
	public void dispose() {
63
		proxy.dispose();
64
	}
65
	
66
	public Control getControl() {
67
		return proxy;
68
	}
69
	
70
	/**
71
	 * Subclasses can override to return the preferred size of the proxy
72
	 * 
73
	 * @param composite
74
	 * @param wHint
75
	 * @param hHint
76
	 * @param flushCache
77
	 * @return
78
	 */
79
	public Point computeSize(int wHint, int hHint, boolean flushCache) {
80
		return new Point(0,0);
81
	}
82
83
	/**
84
	 * Subclasses can override to capture resize events.
85
	 * 
86
	 * @param bounds
87
	 */
88
	public void setBounds(Rectangle bounds) {
89
	}
90
}
(-)Eclipse (+56 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import org.eclipse.swt.graphics.Point;
14
import org.eclipse.swt.widgets.Control;
15
16
/**
17
 * Caches the preferred sizes of an array of controls
18
 * 
19
 * @since 3.0
20
 */
21
public class LayoutCache {
22
	private SizeCache[] caches;
23
	
24
	/**
25
	 * Creates a cache for the given array of controls
26
	 * 
27
	 * @param controls
28
	 */
29
	public LayoutCache(Control[] controls) {
30
		caches = new SizeCache[controls.length];
31
		for (int idx = 0; idx < controls.length; idx++) {
32
			caches[idx] = new SizeCache(controls[idx]);
33
		}
34
	}
35
	
36
	/**
37
	 * Computes the preferred size of the nth control
38
	 * 
39
	 * @param controlIndex index of the control whose size will be computed
40
	 * @param widthHint width of the control (or SWT.DEFAULT if unknown)
41
	 * @param heightHint height of the control (or SWT.DEFAULT if unknown)
42
	 * @return the preferred size of the control
43
	 */
44
	public Point computeSize(int controlIndex, int widthHint, int heightHint) {
45
		return caches[controlIndex].computeSize(widthHint, heightHint);
46
	}
47
	
48
	/**
49
	 * Flushes the cache
50
	 */
51
	public void flush() {
52
		for (int idx = 0; idx < caches.length; idx++) {
53
			caches[idx].flush();
54
		}
55
	}
56
}
(-)Eclipse (+119 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.graphics.Point;
15
import org.eclipse.swt.widgets.Control;
16
17
/**
18
 * Caches the preferred size of an SWT control
19
 * 
20
 * @since 3.0
21
 */
22
public class SizeCache {
23
	private Control control;
24
	
25
	private Point preferredSize;	
26
	private Point cachedWidth;
27
	private Point cachedHeight;
28
29
	/**
30
	 * Creates a cache for size computations on the given control
31
	 * 
32
	 * @param control the control for which 
33
	 */
34
	public SizeCache(Control control) {
35
		this.control = control;		
36
	}
37
	
38
	/**
39
	 * Flush the cache (should be called if the control's contents may have changed since the
40
	 * last query)
41
	 */
42
	public void flush() {
43
		preferredSize = null;
44
		cachedWidth = null;
45
		cachedHeight = null;
46
	}
47
	
48
	/**
49
	 * Computes the preferred size of the control.
50
	 *  
51
	 * @param widthHint the known width of the control (pixels) or SWT.DEFAULT if unknown
52
	 * @param heightHint the known height of the control (pixels) or SWT.DEFAULT if unknown
53
	 * @return the preferred size of the control
54
	 */
55
	public Point computeSize(int widthHint, int heightHint) {
56
		// No hints given -- find the preferred size
57
		if (widthHint == SWT.DEFAULT && heightHint == SWT.DEFAULT) {
58
			if (preferredSize == null) {
59
				preferredSize = computeSize(control, widthHint, heightHint);
60
			}
61
			
62
			return preferredSize;
63
		}
64
		
65
		// Computing a width
66
		if (widthHint == SWT.DEFAULT) {
67
			if (preferredSize != null && heightHint == preferredSize.y) {
68
				return preferredSize;
69
			}
70
71
			if (cachedWidth == null || cachedWidth.y != heightHint) {
72
				cachedWidth = computeSize(control, widthHint, heightHint);
73
			}
74
			
75
			return cachedWidth;
76
		}
77
		
78
		// Computing a height
79
		if (heightHint == SWT.DEFAULT) {
80
			// Check if we're asking about the preferred width
81
			if (preferredSize != null && widthHint == preferredSize.x) {
82
				return preferredSize;
83
			}
84
			
85
			if (cachedHeight == null || cachedHeight.x != widthHint) {
86
				cachedHeight = computeSize(control, widthHint, heightHint);
87
			}
88
			
89
			return cachedHeight;
90
		}
91
		
92
		return computeSize(control, widthHint, heightHint);
93
	}
94
	
95
	/**
96
	 * Compute the control's size, and ensure that non-default hints are returned verbatim
97
	 * (this tries to compensate for SWT's hints, which aren't really the outer width of the
98
	 * control).
99
	 * 
100
	 * @param control
101
	 * @param widthHint
102
	 * @param heightHint
103
	 * @return
104
	 */
105
	private static Point computeSize(Control control, int widthHint, int heightHint) {
106
		Point result = control.computeSize(widthHint, heightHint);
107
		
108
		if (widthHint != SWT.DEFAULT) {
109
			result.x = widthHint;
110
		}
111
		
112
		if (heightHint != SWT.DEFAULT) {
113
			result.y = heightHint;
114
		}
115
		
116
		return result;
117
	}
118
	
119
}
(-)Eclipse (+232 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import org.eclipse.jface.util.Geometry;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CTabFolder;
16
import org.eclipse.swt.custom.CTabItem;
17
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.graphics.Rectangle;
19
import org.eclipse.swt.widgets.Control;
20
21
/**
22
 * Arranges the contents of a CTabFolder
23
 * 
24
 * @since 3.0
25
 */
26
public class TabFolderLayout {
27
	private CTabFolder tabFolder;
28
	private Control[] topControls;
29
	//private Control upperRightProxy;
30
	private LayoutCache cache;
31
	private Rectangle centerArea = new Rectangle(0,0,0,0);
32
	private int trimStart;
33
	
34
	public TabFolderLayout(CTabFolder folder) {
35
		this.tabFolder = folder;
36
		
37
//		Composite cmp = new Composite(folder, SWT.DEFAULT);
38
//		upperRightProxy = cmp;
39
//		upperRightProxy.setVisible(false);
40
//		
41
//		cmp.setLayout(new Layout() {
42
//
43
//			protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
44
//				return new Point(10,10);
45
//			}
46
//
47
//			protected void layout(Composite composite, boolean flushCache) {
48
//				
49
//			}
50
//		});
51
52
		//tabFolder.setTopRight(upperRightProxy);
53
		setTopRight(new Control[0]);
54
	}
55
	
56
	public void dispose() {
57
		//tabFolder.setTopRight(null);
58
		//upperRightProxy.dispose();
59
	}
60
	
61
	public Rectangle getClientBounds() {
62
		return centerArea;
63
	}
64
	
65
	public int getTrimStart() {
66
		return trimStart;
67
	}
68
	
69
	/**
70
	 * Sets the list of controls to be placed at the top-right of the CTabFolder
71
	 * 
72
	 * @param topRight a list of Control
73
	 */
74
	public void setTopRight(Control[] upperRight) {
75
		topControls = upperRight;
76
		
77
		cache = new LayoutCache(upperRight);
78
		layout();
79
	}
80
	
81
	/**
82
	 * Arranges all the controls in this layout
83
	 */
84
	public void layout() {
85
		cache.flush();		
86
87
		if (topControls.length == 0) {
88
			tabFolder.setTopRight(null);
89
		}
90
		
91
//			DragUtil.getDisplayBounds(tabFolder);
92
//		
93
//		displayBounds.height = tabFolder.getTabHeight();
94
//		displayBounds.x = displayBounds.x + displayBounds.width - 30;
95
//		displayBounds.width = 30;
96
		
97
		int trimWidth = computeTrimWidth();
98
		int available = getAvailableSpace(tabFolder);
99
	
100
		Rectangle clientBounds = calculatePageBounds(tabFolder);
101
		
102
		Rectangle bounds = tabFolder.getBounds();
103
		trimStart = bounds.x + bounds.width;
104
		
105
		// Check if we have room for all our topRight controls on the top border
106
		if (available >= trimWidth) {
107
			//upperRightProxy.setSize(0, 0);
108
			//tabFolder.setTopRight(upperRightProxy);
109
			
110
			Rectangle displayBounds = //DragUtil.getDisplayBounds(upperRightProxy);
111
				Geometry.toDisplay(tabFolder, tabFolder.getMinimizeBounds());
112
			
113
			//displayBounds.height = tabFolder.getTabHeight();
114
			displayBounds.width = 0;
115
			displayBounds.y --;
116
			displayBounds.height += 2;
117
			Rectangle targetBounds = Geometry.toControl(tabFolder.getParent(), displayBounds);
118
			
119
			targetBounds.x = targetBounds.x + targetBounds.width - trimWidth;
120
			
121
			Rectangle currentRectangle = new Rectangle(targetBounds.x, targetBounds.y, 0, targetBounds.height);
122
123
			trimStart = targetBounds.x; 
124
				
125
			for (int idx = 0; idx < topControls.length; idx++) {
126
				Point nextSize = cache.computeSize(idx, SWT.DEFAULT, SWT.DEFAULT);				
127
				
128
				currentRectangle.width = nextSize.x;
129
				//currentRectangle.height = nextSize.y;
130
				
131
				//topControls[idx].moveAbove(null);
132
				topControls[idx].setBounds(currentRectangle);
133
				
134
				currentRectangle.x += currentRectangle.width;				
135
			}
136
	
137
			centerArea = Geometry.copy(clientBounds);
138
			
139
			return;
140
		}
141
		
142
		//tabFolder.setTopRight(null);
143
		
144
		// Else we need to place the controls below the title
145
		int y = clientBounds.y;
146
		int x = clientBounds.x + clientBounds.width;
147
		
148
		int rowHeight = 0;
149
		for (int idx = 0; idx < topControls.length; idx++) {
150
			Point nextSize = cache.computeSize(idx, SWT.DEFAULT, SWT.DEFAULT);
151
			
152
			if (nextSize.x < clientBounds.width) {
153
				topControls[idx].setBounds(x - nextSize.x, y, nextSize.x, nextSize.y);
154
				rowHeight = Math.max(rowHeight, nextSize.y);
155
				x -= nextSize.x;
156
			} else {
157
				y += rowHeight;
158
				x = clientBounds.x;
159
				rowHeight = 0;
160
				
161
				nextSize = cache.computeSize(idx, clientBounds.width, SWT.DEFAULT);
162
				topControls[idx].setBounds(x, y, nextSize.x, nextSize.y);
163
				
164
				y += nextSize.y;
165
			}
166
		}
167
		
168
		y += rowHeight;
169
170
		centerArea = new Rectangle(clientBounds.x, y, clientBounds.width, 
171
					clientBounds.height + clientBounds.y - y);
172
	}
173
	
174
	/**
175
	 * Computes the maximium size available for the trim controls without causing
176
	 * tabs to disappear.
177
	 * 
178
	 * @param folder
179
	 * @return the amount of empty space to the right of the tabs
180
	 */
181
	protected static int getAvailableSpace(CTabFolder folder) {
182
		int available = folder.getBounds().width;
183
		
184
		available -= 2 * folder.getBorderWidth();
185
		available -= folder.getChevronBounds().width;
186
		available -= folder.getMaximizeBounds().width;
187
		available -= folder.getMinimizeBounds().width;
188
		
189
		// Add a safety margin to avoid stomping on the curve
190
		available -= 10;
191
		
192
		CTabItem[] tabs = folder.getItems();
193
		for (int idx = 0; idx < tabs.length; idx++) {
194
			CTabItem item = tabs[idx];
195
			
196
			if (!item.isShowing()) {
197
				return 0;
198
			}
199
			
200
			available -= item.getBounds().width;
201
		}
202
		
203
		return Math.max(0, available);
204
	}
205
		
206
	/**
207
	 * Returns the total preferred width of the top controls
208
	 * 
209
	 * @return the total preferred width of the top controls
210
	 */
211
	protected int computeTrimWidth() {
212
		int width = 0;
213
		for (int idx = 0; idx < topControls.length; idx++) {
214
			width += cache.computeSize(idx, SWT.DEFAULT, SWT.DEFAULT).x;
215
		}
216
		
217
		return width;
218
	}
219
	
220
	private static Rectangle calculatePageBounds(CTabFolder folder) {
221
		if (folder == null)
222
			return new Rectangle(0, 0, 0, 0);
223
		Rectangle bounds = folder.getBounds();
224
		Rectangle offset = folder.getClientArea();
225
		bounds.x += offset.x;
226
		bounds.y += offset.y;
227
		bounds.width = offset.width;
228
		bounds.height = offset.height;
229
		return bounds;
230
	}	
231
232
}

Return to bug 55156