1 11 package org.eclipse.swt.custom; 12 13 import org.eclipse.swt.*; 14 import org.eclipse.swt.graphics.*; 15 import org.eclipse.swt.widgets.*; 16 17 22 class CTabFolderLayout extends Layout { 23 protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { 24 CTabFolder folder = (CTabFolder)composite; 25 CTabItem[] items = folder.items; 26 int tabW = 0; 28 GC gc = new GC(folder); 29 for (int i = 0; i < items.length; i++) { 30 if (folder.single) { 31 tabW = Math.max(tabW, items[i].preferredWidth(gc, true, false)); 32 } else { 33 tabW += items[i].preferredWidth(gc, i == folder.selectedIndex, false); 34 } 35 } 36 gc.dispose(); 37 tabW += 3; 38 if (folder.showMax) tabW += CTabFolder.BUTTON_SIZE; 39 if (folder.showMin) tabW += CTabFolder.BUTTON_SIZE; 40 if (folder.single) tabW += 3*CTabFolder.BUTTON_SIZE/2; if (folder.topRight != null) { 42 Point pt = folder.topRight.computeSize(SWT.DEFAULT, folder.tabHeight, flushCache); 43 tabW += 3 + pt.x; 44 } 45 if (!folder.single && !folder.simple) tabW += folder.curveWidth - 2*folder.curveIndent; 46 47 int controlW = 0; 48 int controlH = 0; 49 for (int i = 0; i < items.length; i++) { 51 Control control = items[i].getControl(); 52 if (control != null && !control.isDisposed()){ 53 Point size = control.computeSize (wHint, hHint, flushCache); 54 controlW = Math.max (controlW, size.x); 55 controlH = Math.max (controlH, size.y); 56 } 57 } 58 59 int minWidth = Math.max(tabW, controlW); 60 int minHeight = (folder.minimized) ? 0 : controlH; 61 if (minWidth == 0) minWidth = CTabFolder.DEFAULT_WIDTH; 62 if (minHeight == 0) minHeight = CTabFolder.DEFAULT_HEIGHT; 63 64 if (wHint != SWT.DEFAULT) minWidth = wHint; 65 if (hHint != SWT.DEFAULT) minHeight = hHint; 66 67 return new Point (minWidth, minHeight); 68 } 69 protected boolean flushCache(Control control) { 70 return true; 71 } 72 protected void layout(Composite composite, boolean flushCache) { 73 CTabFolder folder = (CTabFolder)composite; 74 if (folder.selectedIndex != -1) { 76 Control control = folder.items[folder.selectedIndex].getControl(); 77 if (control != null && !control.isDisposed()) { 78 control.setBounds(folder.getClientArea()); 79 } 80 } 81 } 82 } 83 | Popular Tags |