View | Details | Raw Unified | Return to bug 377113 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java (-43 / +75 lines)
Lines 152-158 Link Here
152
	boolean minimized = false;
152
	boolean minimized = false;
153
	boolean showMax = false;
153
	boolean showMax = false;
154
	boolean maximized = false;
154
	boolean maximized = false;
155
	ToolBar minMaxTb;
155
	ToolBar minTb;
156
	ToolBar maxTb;
156
	ToolItem maxItem;
157
	ToolItem maxItem;
157
	ToolItem minItem;
158
	ToolItem minItem;
158
	Image maxImage;
159
	Image maxImage;
Lines 440-448 Link Here
440
	for (int i = 0; i < rects.length; i++) {
441
	for (int i = 0; i < rects.length; i++) {
441
		rects[i] = new Rectangle(0, 0, 0, 0);
442
		rects[i] = new Rectangle(0, 0, 0, 0);
442
	}
443
	}
444
	Rectangle headerTrim = renderer.computeTrim(CTabFolderRenderer.PART_HEADER, SWT.NONE, 0, 0, 0, 0);
443
	Rectangle trim = renderer.computeTrim(CTabFolderRenderer.PART_BORDER, SWT.NONE, 0, 0, 0, 0);
445
	Rectangle trim = renderer.computeTrim(CTabFolderRenderer.PART_BORDER, SWT.NONE, 0, 0, 0, 0);
444
	int borderRight = trim.width + trim.x;
446
	int borderRight = trim.width + trim.x + headerTrim.x + headerTrim.width;
445
	int borderLeft = -trim.x;
447
	int borderLeft = -trim.x - headerTrim.x;
446
	int borderBottom = trim.height + trim.y;
448
	int borderBottom = trim.height + trim.y;
447
	int borderTop = -trim.y;
449
	int borderTop = -trim.y;
448
450
Lines 644-650 Link Here
644
	Point size = renderer.computeSize(button, SWT.NONE, tempGC, SWT.DEFAULT, SWT.DEFAULT);
646
	Point size = renderer.computeSize(button, SWT.NONE, tempGC, SWT.DEFAULT, SWT.DEFAULT);
645
	tempGC.dispose();
647
	tempGC.dispose();
646
	Rectangle trim = renderer.computeTrim(button, SWT.NONE, 0, 0, 0, 0);
648
	Rectangle trim = renderer.computeTrim(button, SWT.NONE, 0, 0, 0, 0);
647
	Image image = new Image (display, size.x - trim.width, size.y - trim.height);
649
	int width = size.x - trim.width;
650
	if (button == CTabFolderRenderer.PART_MAX_BUTTON
651
			|| button == CTabFolderRenderer.PART_MIN_BUTTON && !showMax) {
652
		Rectangle headerTrim = renderer.computeTrim(CTabFolderRenderer.PART_HEADER, SWT.NONE, 0, 0, 0, 0);
653
		width = width - headerTrim.width + headerTrim.x; //Make rightmost button narrower so that its bounds don't intersect with the topRight rounded corner
654
	}
655
	Image image = new Image (display, width, size.y - trim.height);
648
	GC gc = new GC (image);
656
	GC gc = new GC (image);
649
	RGB transparent;
657
	RGB transparent;
650
	if (button == CTabFolderRenderer.PART_CHEVRON_BUTTON) {
658
	if (button == CTabFolderRenderer.PART_CHEVRON_BUTTON) {
Lines 1460-1472 Link Here
1460
		}
1468
		}
1461
	});
1469
	});
1462
}
1470
}
1463
void initAccessibleMinMaxTb() {
1471
void initAccessibleMinTb() {
1464
	minMaxTb.getAccessible().addAccessibleListener(new AccessibleAdapter() {
1472
	minTb.getAccessible().addAccessibleListener(new AccessibleAdapter() {
1465
		public void getName(AccessibleEvent e) {
1473
		public void getName(AccessibleEvent e) {
1466
			if (e.childID != ACC.CHILDID_SELF) {
1474
			if (e.childID != ACC.CHILDID_SELF) {
1467
				if (minItem != null && e.childID == minMaxTb.indexOf(minItem)) {
1475
				if (minItem != null && e.childID == minTb.indexOf(minItem)) {
1468
					e.result = minItem.getToolTipText();
1476
					e.result = minItem.getToolTipText();
1469
				} else if (maxItem != null && e.childID == minMaxTb.indexOf(maxItem)) {
1477
				}
1478
			}
1479
		}
1480
	});
1481
}
1482
void initAccessibleMaxTb() {
1483
	maxTb.getAccessible().addAccessibleListener(new AccessibleAdapter() {
1484
		public void getName(AccessibleEvent e) {
1485
			if (e.childID != ACC.CHILDID_SELF) {
1486
				if (maxItem != null && e.childID == maxTb.indexOf(maxItem)) {
1470
					e.result = maxItem.getToolTipText();
1487
					e.result = maxItem.getToolTipText();
1471
				}
1488
				}
1472
			}
1489
			}
Lines 1594-1600 Link Here
1594
1611
1595
	minItem = null;
1612
	minItem = null;
1596
	maxItem = null;
1613
	maxItem = null;
1597
	minMaxTb = null;
1614
	minTb = null;
1615
	maxTb = null;
1598
	
1616
	
1599
	chevronItem = null;
1617
	chevronItem = null;
1600
	chevronTb = null;
1618
	chevronTb = null;
Lines 2362-2400 Link Here
2362
}
2380
}
2363
void setButtonBounds(GC gc) {
2381
void setButtonBounds(GC gc) {
2364
	Point size = getSize();
2382
	Point size = getSize();
2365
	// max button
2366
	Display display = getDisplay();
2383
	Display display = getDisplay();
2367
	if (showMax) {
2368
		if (minMaxTb == null) {
2369
			minMaxTb = new ToolBar(this, SWT.FLAT);
2370
			initAccessibleMinMaxTb();
2371
			addTabControl(minMaxTb, SWT.TRAIL, 0, false);
2372
		}
2373
		if (maxItem == null) {
2374
			maxItem = new ToolItem(minMaxTb, SWT.PUSH);
2375
			if (maxImage == null) {
2376
				maxImage = createButtonImage(display, CTabFolderRenderer.PART_MAX_BUTTON);
2377
			}
2378
			maxItem.setImage(maxImage);
2379
			maxItem.setToolTipText(maximized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Maximize")); //$NON-NLS-1$ //$NON-NLS-2$
2380
			maxItem.addListener(SWT.Selection, listener);
2381
		}
2382
	} else {
2383
		//might need to remove it if already there
2384
		if (maxItem != null) {
2385
			maxItem.dispose();
2386
			maxItem = null;
2387
		}
2388
	}
2389
	// min button
2384
	// min button
2390
	if (showMin) {
2385
	if (showMin) {
2391
		if (minMaxTb == null) {
2386
		if (minTb == null) {
2392
			minMaxTb = new ToolBar(this, SWT.FLAT);
2387
			minTb = new ToolBar(this, SWT.FLAT);
2393
			initAccessibleMinMaxTb();
2388
			initAccessibleMinTb();
2394
			addTabControl(minMaxTb, SWT.TRAIL, 0, false);
2389
			addTabControl(minTb, SWT.TRAIL, maxItem != null ? 1 : 0, false);
2390
		}
2391
		if (minItem != null && (showMax || maxItem != null)) {
2392
			// need to recreate as normal/narrow version 
2393
			minItem.dispose();
2394
			minItem = null;
2395
		}
2395
		}
2396
		if (minItem == null) {
2396
		if (minItem == null) {
2397
			minItem = new ToolItem(minMaxTb, SWT.PUSH, 0);
2397
			minItem = new ToolItem(minTb, SWT.PUSH, 0);
2398
			if (minImage != null && (showMax || maxItem != null)) {
2399
				minImage.dispose();
2400
				minImage = null;
2401
			}
2398
			if (minImage == null) {
2402
			if (minImage == null) {
2399
				minImage = createButtonImage(display, CTabFolderRenderer.PART_MIN_BUTTON);
2403
				minImage = createButtonImage(display, CTabFolderRenderer.PART_MIN_BUTTON);
2400
			}
2404
			}
Lines 2408-2418 Link Here
2408
			minItem.dispose();
2412
			minItem.dispose();
2409
			minItem = null;
2413
			minItem = null;
2410
		}
2414
		}
2415
		if (minTb != null) {
2416
			removeTabControl(minTb, false);
2417
			minTb.dispose();
2418
			minTb = null;
2419
		}
2411
	}
2420
	}
2412
	if (minMaxTb != null && minMaxTb.getItemCount() == 0) {
2421
	// max button
2413
		removeTabControl(minMaxTb, false);
2422
	if (showMax) {
2414
		minMaxTb.dispose();
2423
		if (maxTb == null) {
2415
		minMaxTb = null;
2424
			maxTb = new ToolBar(this, SWT.FLAT);
2425
			initAccessibleMaxTb();
2426
			addTabControl(maxTb, SWT.TRAIL, 0, false);
2427
		}
2428
		if (maxItem == null) {
2429
			maxItem = new ToolItem(maxTb, SWT.PUSH);
2430
			if (maxImage == null) {
2431
				maxImage = createButtonImage(display, CTabFolderRenderer.PART_MAX_BUTTON);
2432
			}
2433
			maxItem.setImage(maxImage);
2434
			maxItem.setToolTipText(maximized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Maximize")); //$NON-NLS-1$ //$NON-NLS-2$
2435
			maxItem.addListener(SWT.Selection, listener);
2436
		}
2437
	} else {
2438
		//might need to remove it if already there
2439
		if (maxItem != null) {
2440
			maxItem.dispose();
2441
			maxItem = null;
2442
		}
2443
		if (maxTb != null) {
2444
			removeTabControl(maxTb, false);
2445
			maxTb.dispose();
2446
			maxTb = null;
2447
		}
2416
	}
2448
	}
2417
	if (showChevron) {
2449
	if (showChevron) {
2418
		int itemCount = items.length;
2450
		int itemCount = items.length;
Lines 2806-2812 Link Here
2806
	if (this.maximized == maximize) return;
2838
	if (this.maximized == maximize) return;
2807
	if (maximize && this.minimized) setMinimized(false);
2839
	if (maximize && this.minimized) setMinimized(false);
2808
	this.maximized = maximize;
2840
	this.maximized = maximize;
2809
	if (minMaxTb != null && maxItem != null) {
2841
	if (maxTb != null && maxItem != null) {
2810
		if (maxImage != null) maxImage.dispose();
2842
		if (maxImage != null) maxImage.dispose();
2811
		maxImage = createButtonImage(getDisplay(), CTabFolderRenderer.PART_MAX_BUTTON);
2843
		maxImage = createButtonImage(getDisplay(), CTabFolderRenderer.PART_MAX_BUTTON);
2812
		maxItem.setImage(maxImage);
2844
		maxItem.setImage(maxImage);
Lines 2850-2856 Link Here
2850
	if (this.minimized == minimize) return;
2882
	if (this.minimized == minimize) return;
2851
	if (minimize && this.maximized) setMaximized(false);
2883
	if (minimize && this.maximized) setMaximized(false);
2852
	this.minimized = minimize;
2884
	this.minimized = minimize;
2853
	if (minMaxTb != null && minItem != null) {
2885
	if (minTb != null && minItem != null) {
2854
		if (minImage != null) minImage.dispose();
2886
		if (minImage != null) minImage.dispose();
2855
		minImage = createButtonImage(getDisplay(), CTabFolderRenderer.PART_MIN_BUTTON);
2887
		minImage = createButtonImage(getDisplay(), CTabFolderRenderer.PART_MIN_BUTTON);
2856
		minItem.setImage(minImage);
2888
		minItem.setImage(minImage);
(-)Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java (-1 / +4 lines)
Lines 349-355 Link Here
349
				}
349
				}
350
				break;
350
				break;
351
			case PART_HEADER:
351
			case PART_HEADER:
352
				//no trim 
352
				if (parent.borderVisible) {
353
					// leave space for corner radius
354
					width = width + (5 - CTabFolder.SPACING);
355
				}
353
				break;
356
				break;
354
			case PART_MAX_BUTTON:
357
			case PART_MAX_BUTTON:
355
			case PART_MIN_BUTTON:
358
			case PART_MIN_BUTTON:

Return to bug 377113