Changeset 165 for trunk/src/plugins/org.eclipse.swt
- Timestamp:
- Jul 10, 2009, 11:37:08 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/TabFolder.java
r106 r165 44 44 public class TabFolder extends Composite { 45 45 TabItem [] items; 46 int[] itemsID; 47 int iLongestMajText = 0; 46 48 // ImageList imageList; 47 49 static final int TabFolderProc; … … 165 167 //public Point computeSize (int wHint, int hHint, boolean changed) { 166 168 // checkWidget (); 169 // RECTL rcl = new RECTL (); 170 // RECTL insetRect = new RECTL (); 171 // WinQueryWindowPos(hwndDialog, &swpDialog); 172 // OS.WinQueryWindowPos(handle, rcl); 173 // insetRect.yBottom=insetRect.xLeft=0; 174 // insetRect.xRight=rcl.cx; 175 // insetRect.yTop=rcl.cy; 176 // Return size of notebook page in pixel for given notebook window size (with tab text size set) 177 178 // OS.WinSendMsg(hwndNotebook, BKM_CALCPAGERECT, insetRect, true); 179 // Calculate notebook size so that notebook dialog page fits into the notebook page 180 181 // swpNB.cx-=(rectlNB.xRight-rectlNB.xLeft)-ptlNB.x; 182 // swpNB.cy-=(rectlNB.yTop-rectlNB.yBottom)-ptlNB.y; 183 // 184 167 185 // RECT insetRect = new RECT (), itemRect = new RECT (); 186 // OS.WinSendMsg (handle, OS.BKM_CALCPAGERECT, rcl, false); 168 187 // OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, insetRect); 169 188 // int width = insetRect.left - insetRect.right, height = 0; … … 208 227 if (count == items.length) { 209 228 TabItem [] newItems = new TabItem [items.length + 4]; 229 int[] newIDs = new int[itemsID.length + 4]; 210 230 System.arraycopy (items, 0, newItems, 0, items.length); 231 System.arraycopy (itemsID, 0, newIDs, 0, itemsID.length); 211 232 items = newItems; 233 itemsID = newIDs; 212 234 } 213 235 // PSZ tabText = new PSZ("Hello"); 214 int pageID = OS.WinSendMsg (handle, OS.BKM_INSERTPAGE, 0, OS.MPFROM2SHORT((short)(OS.BKA_AUTOPAGESIZE | OS.BKA_MAJOR | OS.BKA_STATUSTEXTON),(short)OS.BKA_FIRST)); 236 int pageID = OS.WinSendMsg (handle, OS.BKM_INSERTPAGE, 0, OS.MPFROM2SHORT((short)(OS.BKA_AUTOPAGESIZE | OS.BKA_MAJOR | OS.BKA_STATUSTEXTON),(short)OS.BKA_LAST)); 237 //@@INFO(lpino): All tabs are gray to keep a consistent look with the rests of the platforms 238 OS.WinSendMsg (handle, OS.BKM_SETTABCOLOR, pageID , 0x00C0C0C0); 215 239 // OS.WinSendMsg (handle, OS.BKM_SETTABTEXT, pageID, tabText); 216 // if (pageID == 0) {217 //error (SWT.ERROR_ITEM_NOT_ADDED);218 //}240 if (pageID == OS.NULLHANDLE) { 241 error (SWT.ERROR_ITEM_NOT_ADDED); 242 } 219 243 System.arraycopy (items, index, items, index + 1, count - index); 244 System.arraycopy (itemsID, index, itemsID, index + 1, count - index); 245 itemsID[index] = pageID; 220 246 items [index] = item; 221 247 … … 236 262 super.createHandle (); 237 263 state &= ~CANVAS; 238 239 // /*240 // * Feature in Windows. Despite the fact that the241 // * tool tip text contains \r\n, the tooltip will242 // * not honour the new line unless TTM_SETMAXTIPWIDTH243 // * is set. The fix is to set TTM_SETMAXTIPWIDTH to244 // * a large value.245 // */246 // int hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);247 // OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);248 //249 // /*250 // * Feature in Windows. When the tool tip control is251 // * created, the parent of the tool tip is the shell.252 // * If SetParent () is used to reparent the tab folder253 // * into a new shell, the tool tip is not reparented254 // * and pops up underneath the new shell. The fix is255 // * to make sure the tool tip is a topmost window.256 // */257 // /*258 // * Bug in Windows 98 and NT. Setting the tool tip to be the259 // * top most window using HWND_TOPMOST can result in a parent260 // * dialog shell being moved behind its parent if the dialog261 // * has a sibling that is currently on top. The fix is to lock262 // * the z-order of the active window.263 // */264 // Display display = getDisplay ();265 // int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOSIZE;266 // display.lockActiveWindow = true;267 // OS.SetWindowPos (hwndToolTip, OS.HWND_TOPMOST, 0, 0, 0, 0, flags);268 // display.lockActiveWindow = false;269 264 } 270 265 … … 272 267 super.createWidget (); 273 268 items = new TabItem [4]; 269 itemsID = new int[4]; 274 270 } 275 271 … … 282 278 } 283 279 if (index == count) return; 284 int selectionIndex = OS.WinSendMsg (handle, OS.BKM_QUERYPAGEID, 0, OS.MPFROM2SHORT((short)OS.BKA_TOP,(short)OS.BKA_MAJOR));280 int selectionIndex = itemsID[index]; 285 281 if (OS.WinSendMsg (handle, OS.BKM_DELETEPAGE, selectionIndex, (short)OS.BKA_TAB) == 0) { 286 282 error (SWT.ERROR_ITEM_NOT_REMOVED); 287 283 } 288 284 System.arraycopy (items, index + 1, items, index, --count - index); 285 System.arraycopy (itemsID, index + 1, itemsID, index, --count - index); 289 286 items [count] = null; 287 itemsID[count] = 0; 290 288 if (count == 0) { 291 289 // if (imageList != null) { … … 296 294 // imageList = null; 297 295 items = new TabItem [4]; 296 itemsID = new int[4]; 298 297 } 299 298 if (count > 0 && index == selectionIndex) { … … 507 506 } 508 507 items = null; 508 itemsID = null; 509 509 // if (imageList != null) { 510 510 // OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0); … … 593 593 } 594 594 } 595 OS.WinSendMsg (handle, OS.BKM_TURNTOPAGE, getPageID(index), 0);595 OS.WinSendMsg (handle, OS.BKM_TURNTOPAGE, itemsID[index], 0); 596 596 int newIndex = getSelectionIndex(); 597 597 if (newIndex != -1) { … … 610 610 } 611 611 int getTabIndex(int pageID){ 612 int total = OS.WinSendMsg (handle, OS.BKM_QUERYPAGECOUNT, 0, OS.BKA_MAJOR); 613 int diff = OS.WinSendMsg (handle, OS.BKM_QUERYPAGECOUNT, pageID, OS.BKA_END); 614 return total-diff; 612 for(int i=0;i<itemsID.length;i++){ 613 if(itemsID[i] == pageID) 614 return i; 615 } 616 return -1; 615 617 } 616 618 … … 657 659 658 660 int widgetStyle () { 659 /*660 * Bug in Windows. Under certain circumstances,661 * when TCM_SETITEM is used to change the text662 * in a tab item, the tab folder draws on top663 * of the client area. The fix is ensure that664 * this cannot happen by setting WS_CLIPCHILDREN.665 */666 661 int bits = super.widgetStyle () | OS.WS_VISIBLE | OS.WS_CLIPCHILDREN | OS.BKS_TABBEDDIALOG | OS.BKS_MAJORTABTOP | OS.WS_CLIPSIBLINGS; 667 662 return bits; … … 675 670 return TabFolderProc; 676 671 } 672 673 boolean setTabDimensions( PSZ tabText ){ 674 int iSize = 0; 675 int hps = this.hps; 676 if (hps == 0) hps = OS.WinGetPS (handle); 677 FONTMETRICS fm = new FONTMETRICS(); 678 if(OS.GpiQueryFontMetrics (hps, FONTMETRICS.sizeof, fm)) 679 fm.lMaxBaselineExt<<=1; 680 else 681 fm.lMaxBaselineExt = 30; 682 683 iSize = getStringSize( hps, tabText ); 684 685 if( iSize > iLongestMajText ) 686 iLongestMajText = iSize; 687 688 if (this.hps == 0) OS.WinReleasePS (hps); 689 690 OS.WinSendMsg(handle, OS.BKM_SETDIMENSIONS, 691 OS.MPFROM2SHORT((short)(iLongestMajText+5), (short)((float)fm.lMaxBaselineExt * 0.8)), 692 (short)OS.BKA_MAJORTAB); 693 694 OS.WinSendMsg(handle, OS.BKM_SETDIMENSIONS, 695 OS.MPFROM2SHORT((short)0, (short)0), 696 (short)OS.BKA_MINORTAB); 697 return true; 698 } 699 700 int getStringSize( int hps, PSZ szString ) 701 { 702 int[] pnts = new int [OS.TXTBOX_COUNT * 2]; 703 OS.GpiQueryTextBox( hps, szString.getBytes().length, szString.getBytes(), OS.TXTBOX_COUNT, pnts); 704 return pnts[8]; 705 } 706 677 707 678 708 //LRESULT WM_GETDLGCODE (int wParam, int lParam) { … … 704 734 // int hittest = OS.DefWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); 705 735 // return new LRESULT (hittest); 706 //}707 //708 //LRESULT WM_NOTIFY (int wParam, int lParam) {709 // /*710 // * Feature in Windows. When the tab folder window711 // * proc processes WM_NOTIFY, it forwards this712 // * message to its parent. This is done so that713 // * children of this control that send this message714 // * type to their parent will notify not only715 // * this control but also the parent of this control,716 // * which is typically the application window and717 // * the window that is looking for the message.718 // * If the control did not forward the message,719 // * applications would have to subclass the control720 // * window to see the message. Because the control721 // * window is subclassed by SWT, the message722 // * is delivered twice, once by SWT and once when723 // * the message is forwarded by the window proc.724 // * The fix is to avoid calling the window proc725 // * for this control.726 // */727 // LRESULT result = super.WM_NOTIFY (wParam, lParam);728 // if (result != null) return result;729 // return LRESULT.ZERO;730 736 //} 731 737 // … … 818 824 postEvent (SWT.Selection, event); 819 825 } 826 case OS.BKN_NEWPAGESIZE: 827 // if (isDisposed ()) return result; 828 // int index = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0); 829 // if (index != -1) { 830 // TabItem item = items [index]; 831 // Control control = item.control; 832 // if (control != null && !control.isDisposed ()) { 833 // control.setBounds (getClientArea ()); 834 // } 835 // } 836 820 837 } 821 838 return super.wmControlChild (mp1, mp2); 822 839 } 823 //LRESULT wmNotifyChild (int wParam, int lParam) { 824 // NMHDR hdr = new NMHDR (); 825 // OS.MoveMemory (hdr, lParam, NMHDR.sizeof); 826 // int code = hdr.code; 827 // switch (code) { 828 // case OS.TCN_SELCHANGE: 829 // case OS.TCN_SELCHANGING: 830 // TabItem item = null; 831 // int index = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0); 832 // if (index != -1) item = items [index]; 833 // if (item != null) { 834 // Control control = item.control; 835 // if (control != null && !control.isDisposed ()) { 836 // if (code == OS.TCN_SELCHANGE) { 837 // control.setBounds (getClientArea ()); 838 // } 839 // control.setVisible (code == OS.TCN_SELCHANGE); 840 // } 841 // } 842 // if (code == OS.TCN_SELCHANGE) { 843 // Event event = new Event (); 844 // event.item = item; 845 // postEvent (SWT.Selection, event); 846 // } 847 // } 848 // return super.wmNotifyChild (wParam, lParam); 849 //} 850 } 840 }
Note:
See TracChangeset
for help on using the changeset viewer.