summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java47
1 files changed, 38 insertions, 9 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java
index a9fbf021ba..49505b3884 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java
@@ -38,15 +38,44 @@ protected Point computeSize(Composite composite, int wHint, int hHint, boolean f
tabW += renderer.computeSize(i, state, gc, SWT.DEFAULT, SWT.DEFAULT).x;
}
}
- tabW += 3;
- if (folder.showMax) tabW += renderer.computeSize(CTabFolderRenderer.PART_MAX_BUTTON, SWT.NONE, gc, SWT.DEFAULT, SWT.DEFAULT).x;
- if (folder.showMin) tabW += renderer.computeSize(CTabFolderRenderer.PART_MIN_BUTTON, SWT.NONE, gc, SWT.DEFAULT, SWT.DEFAULT).x;
- if (folder.single) tabW += renderer.computeSize(CTabFolderRenderer.PART_CHEVRON_BUTTON, SWT.NONE, gc, SWT.DEFAULT, SWT.DEFAULT).x;
- if (folder.topRight != null) {
- Point pt = folder.topRight.computeSize(SWT.DEFAULT, folder.tabHeight, flushCache);
- tabW += 3 + pt.x;
+ int width = 0, wrapHeight = 0;
+ boolean leftControl = false, rightControl = false;
+ if (wHint == SWT.DEFAULT) {
+ for (int i = 0; i < folder.controls.length; i++) {
+ Control control = folder.controls[i];
+ if (control.getVisible()) {
+ if ((folder.controlAlignments[i] & SWT.LEAD) != 0) {
+ leftControl = true;
+ } else {
+ rightControl = true;
+ }
+ width += control.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+ }
+ }
+ } else {
+ Point size = new Point (wHint, hHint);
+ boolean[][] positions = new boolean[1][];
+ Rectangle[] rects = folder.computeControlBounds(size, positions);
+ int minY = Integer.MAX_VALUE, maxY = 0;
+ for (int i = 0; i < rects.length; i++) {
+ if (positions[0][i]) {
+ minY = Math.min(minY, rects[i].y);
+ maxY = Math.max(maxY, rects[i].y + rects[i].height);
+ wrapHeight = maxY - minY;
+ } else {
+ if ((folder.controlAlignments[i] & SWT.LEAD) != 0) {
+ leftControl = true;
+ } else {
+ rightControl = true;
+ }
+ width += rects[i].width;
+ }
+ }
}
+ if (leftControl) width += CTabFolder.SPACING * 2;
+ if (rightControl) width += CTabFolder.SPACING * 2;
+ tabW += width;
gc.dispose();
@@ -62,8 +91,8 @@ protected Point computeSize(Composite composite, int wHint, int hHint, boolean f
}
}
- int minWidth = Math.max(tabW, controlW);
- int minHeight = (folder.minimized) ? 0 : controlH;
+ int minWidth = Math.max(tabW, controlW + folder.marginWidth);
+ int minHeight = (folder.minimized) ? 0 : controlH + wrapHeight;
if (minWidth == 0) minWidth = CTabFolder.DEFAULT_WIDTH;
if (minHeight == 0) minHeight = CTabFolder.DEFAULT_HEIGHT;