Bug 396780 - CTabRendering doesn't draw bottom tabs correctly
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
index 5b70128..bec1880 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -167,10 +167,10 @@
Menu showMenu;
ToolBar chevronTb;
ToolItem chevronItem;
- Image chevronImage;
int chevronCount;
boolean chevronVisible = true;
+ Image chevronImage;
Control topRight;
int topRightAlignment = SWT.RIGHT;
boolean ignoreResize;
@@ -562,7 +562,7 @@
int bodyLeft = -bodyTrim.x;
int bodyWidth = size.x - bodyLeft - bodyRight;
x = size.x - bodyRight;
- int y = -bodyTrim.y;
+ int y = onBottom ? this.getSize().y - getTabHeight() + 2*bodyTrim.y : -bodyTrim.y;
availableWidth = bodyWidth;
int maxHeight = 0;
for (int i = 0; i < controls.length; i++) {
@@ -571,7 +571,7 @@
if (availableWidth > ctrlSize.x) {
x -= ctrlSize.x;
rects[i].width = ctrlSize.x;
- rects[i].y = y;
+ rects[i].y = onBottom ? y - ctrlSize.y : y;
rects[i].height = ctrlSize.y;
rects[i].x = x;
availableWidth -= ctrlSize.x;
@@ -587,7 +587,7 @@
} else {
ctrlSize = controls[i].isDisposed() ? new Point(0,0) : controls[i].computeSize(bodyWidth, SWT.DEFAULT);
rects[i].width = bodyWidth;
- rects[i].y = y;
+ rects[i].y = onBottom ? y - ctrlSize.y : y;
rects[i].height = ctrlSize.y;
rects[i].x = size.x - ctrlSize.x - bodyRight;
y += ctrlSize.y;
@@ -3331,7 +3331,7 @@
int getControlY(Point size, Rectangle[] rects, int borderBottom, int borderTop, int i) {
int center = fixedTabHeight != SWT.DEFAULT ? 0 : (tabHeight - rects[i].height)/2;
- return onBottom ? size.y - 1 - borderBottom - tabHeight + center : 1 + borderTop + center;
+ return onBottom ? size.y - borderBottom - tabHeight + center : 1 + borderTop + center;
}
/**
@@ -3726,14 +3726,26 @@
if (control instanceof Composite) ((Composite) control).setBackgroundMode(SWT.INHERIT_DEFAULT);
Rectangle bounds = control.getBounds();
int tabHeight = getTabHeight();
- boolean wrapped = onBottom ? bounds.y > this.getSize().y - tabHeight : bounds.y > tabHeight;
+ int height = this.getSize().y;
+ boolean wrapped = onBottom ? bounds.y + bounds.height < height - tabHeight : bounds.y > tabHeight;
if (wrapped || gradientColors == null) {
control.setBackgroundImage(null);
control.setBackground(getBackground());
} else {
bounds.width = 10;
- bounds.y = -bounds.y;
- bounds.height -= 2*bounds.y - 1;
+ if (!onBottom) {
+ bounds.y = -bounds.y;
+ bounds.height -= 2*bounds.y - 1;
+ } else {
+ Rectangle trim = renderer.computeTrim(CTabFolderRenderer.PART_BORDER, SWT.NONE, 0, 0, 0, 0);
+ int borderRight = trim.width + trim.x;
+ int borderLeft = -trim.x;
+ int borderBottom = trim.height + trim.y;
+ int borderTop = -trim.y;
+ int origY = bounds.y + bounds.height;
+ bounds.height += height - (bounds.y + bounds.height);
+ bounds.y = -1;
+ }
bounds.x = 0;
if (controlBkImages[i] != null) controlBkImages[i].dispose();
controlBkImages[i] = new Image(control.getDisplay(), bounds);