- Timestamp:
- May 23, 2008, 6:30:07 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Menu.java
r66 r76 221 221 void createHandle () { 222 222 if ((style & SWT.BAR) != 0) { 223 handle = OS.WinCreateWindow (OS.HWND_DESKTOP, /* parent window */ 223 System.out.println("Menu:createHandle: Menu Bar"); 224 handle = OS.WinCreateWindow (parent.frameHandle, /* parent window */ 224 225 PSZ.getAtom (OS.WC_MENU), /* class name */ 225 n ew PSZ(""), /* window text */226 null, /* window text */ 226 227 OS.MS_ACTIONBAR, /* window style */ 227 228 0, 0, 0, 0, /* size and position */ 228 OS.HWND_DESKTOP, /* owner window */229 parent.frameHandle, /* owner window */ 229 230 OS.HWND_TOP, /* sibling window */ 230 231 OS.FID_MENU, /* ID */ … … 232 233 0 /* presentation parameters */ 233 234 ); 234 } else { 235 //System.out.println ( 236 // "Menu.createHandle(): FID_MENU window has been created:\n" + 237 // " hwnd = " + Integer.toHexString (handle) + "\n" + 238 // " hwnd.parent = hwnd.owner = " + Integer.toHexString (handle) + "\n" + 239 // " class = WC_MENU\n" + 240 // " style = MS_ACTIONBAR" 241 //); 242 } else if ((style & SWT.POP_UP) != 0) { 235 243 short flOptions = OS.PU_MOUSEBUTTON1DOWN | OS.PU_KEYBOARD | OS.PU_MOUSEBUTTON1; 236 244 handle = OS.WinCreateWindow (OS.HWND_DESKTOP, /* parent window */ 237 245 PSZ.getAtom (OS.WC_MENU), /* class name */ 238 n ew PSZ(""), /* window text */246 null, /* window text */ 239 247 0, /* window style */ 240 248 0, 0, 0, 0, /* size and position */ … … 246 254 ); 247 255 boolean rc = OS.WinPopupMenu(OS.HWND_DESKTOP, OS.HWND_DESKTOP, handle, 0, 0, 0, flOptions); 256 System.out.println ( 257 "Menu.createHandle(): FID_MENU window has been created:\n" + 258 " hwnd = " + Integer.toHexString (handle) + "\n" + 259 " hwnd.parent = hwnd.owner = " + Integer.toHexString (handle) + "\n" + 260 " class = WC_MENU\n" + 261 " style = MS_ACTIONBAR" 262 ); 248 263 264 } else if ((style & SWT.DROP_DOWN) != 0) { 265 System.out.println("Menu:createHandle: Menu DropDown"); 266 handle = OS.WinCreateWindow (OS.HWND_DESKTOP, /* parent window */ 267 PSZ.getAtom (OS.WC_MENU), /* class name */ 268 null, /* window text */ 269 0, /* window style */ 270 0, 0, 0, 0, /* size and position */ 271 OS.HWND_DESKTOP, /* owner window */ 272 OS.HWND_TOP, /* sibling window */ 273 OS.FID_MENU, /* ID */ 274 OS.NULLHANDLE, /* control data */ 275 0 /* presentation parameters */ 276 ); 277 //System.out.println ( 278 // "Menu.createHandle(): A menu has been created:\n" + 279 // " hwnd = " + Integer.toHexString (handle) + "\n" + 280 // " hwnd.parent = hwnd.owner = " + Integer.toHexString (handle) + "\n" + 281 // " class = WC_MENU\n" + 282 // " style = 0" 283 //); 249 284 } 250 285 if (handle == 0) error (SWT.ERROR_NO_HANDLES); … … 257 292 boolean success = false; 258 293 259 260 294 MENUITEM info = new MENUITEM(); 261 295 info.iPosition = OS.MIT_END; … … 263 297 info.afAttribute = 0; 264 298 info.id = (short)item.id; 299 System.out.println("Menu:createItem ID = " + info.id); 265 300 info.hwndSubMenu = OS.NULLHANDLE; 266 301 info.hItem = 0; 267 268 int rc = OS.WinSendMsg (handle, OS.MM_INSERTITEM, info, new PSZ("")); 302 int rc = OS.WinSendMsg (handle, OS.MM_INSERTITEM, info, new PSZ(" ")); 269 303 if(rc != OS.MIT_MEMERROR && rc != OS.MIT_ERROR) 270 304 success = true; … … 273 307 error (SWT.ERROR_ITEM_NOT_ADDED); 274 308 } 275 //redraw ();309 redraw (); 276 310 } 277 311 … … 295 329 } 296 330 297 //void destroyAcceleratorTable () {298 //parent.destroyAcceleratorTable ();299 //}331 void destroyAcceleratorTable () { 332 parent.destroyAcceleratorTable (); 333 } 300 334 301 335 void destroyItem (MenuItem item) { 302 336 int count = GetMenuItemCount (handle); 337 System.out.println("ITEMS antes de destroy = " + count); 303 338 int rc = OS.WinSendMsg (handle, OS.MM_DELETEITEM, OS.MPFROM2SHORT ((short)item.id, (short)OS.TRUE), 0); 304 339 if (rc == count) { 305 340 error (SWT.ERROR_ITEM_NOT_REMOVED); 306 341 } 307 //redraw ();342 redraw (); 308 343 } 309 344 … … 333 368 return parent.findMenuItem (info.id); 334 369 335 // info.cbSize = MENUITEMINFO.sizeof;336 // info.fMask = OS.MIIM_ID;337 // if (OS.GetMenuItemInfo (handle, id, false, info)) {338 // return parent.findMenuItem (info.wID);339 // }340 370 return null; 341 371 } … … 384 414 public MenuItem getItem (int index) { 385 415 checkWidget (); 386 // MENUITEMINFO info = new MENUITEMINFO ();387 // info.cbSize = MENUITEMINFO.sizeof;388 // info.fMask = OS.MIIM_DATA;389 416 MENUITEM info = new MENUITEM(); 390 417 int id = OS.WinSendMsg (handle, OS.MM_ITEMIDFROMPOSITION, (short)index, 0); … … 433 460 MenuItem [] items = new MenuItem [length]; 434 461 MENUITEM info = new MENUITEM(); 435 // info.cbSize = MENUITEMINFO.sizeof;436 // info.fMask = OS.MIIM_DATA;437 462 int idItem = 0; 438 463 // Revisa si esto es redundante o no … … 588 613 MENUITEM info = new MENUITEM(); 589 614 int idItem = 0; 590 // MENUITEMINFO info = new MENUITEMINFO ();591 // info.cbSize = MENUITEMINFO.sizeof;592 // info.fMask = OS.MIIM_DATA;593 615 while ((idItem=OS.WinSendMsg (handle, OS.MM_ITEMIDFROMPOSITION, index, 0)) != OS.MIT_ERROR) { 594 616 //@@TODO(lpino) Check if the next call is necesary or we could use the idItem directly … … 641 663 } 642 664 643 //void redraw () { 644 // if (OS.IsPPC) return; 645 // if (OS.IsHPC) { 646 // /* 647 // * Each time a menu has been modified, we need 648 // * to redraw the command bar. 649 // */ 650 // OS.CommandBar_DrawMenuBar (parent.hwndCB, 0); 651 // return; 652 // } 653 // if ((style & SWT.BAR) != 0) { 665 void redraw () { 666 if ((style & SWT.BAR) != 0) { 667 // OS.WinSendMsg (frameHandle, OS.WM_UPDATEFRAME, OS.FCF_MENU, 0); 654 668 // OS.DrawMenuBar (parent.handle); 655 // return; 656 // } 657 // if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) { 658 // return; 659 // } 660 // boolean hasCheck = false, hasImage = false; 669 return; 670 } 671 672 // boolean hasCheck = false, hasImage = false; 661 673 // MenuItem [] items = getItems (); 662 674 // for (int i=0; i<items.length; i++) { … … 679 691 // } 680 692 // OS.SetMenuInfo (handle, lpcmi); 681 //}682 683 //void releaseChild () {684 //super.releaseChild ();685 //if (cascade != null) cascade.setMenu (null);686 //if ((style & SWT.BAR) != 0 && this == parent.menuBar) {687 //parent.setMenuBar (null);688 //}689 //}693 } 694 695 void releaseChild () { 696 super.releaseChild (); 697 if (cascade != null) cascade.setMenu (null); 698 if ((style & SWT.BAR) != 0 && this == parent.menuBar) { 699 parent.setMenuBar (null); 700 } 701 } 690 702 691 703 void releaseHandle () { … … 776 788 } 777 789 OS.WinSendMsg (handle, OS.MM_SETDEFAULTITEMID, command, 0); 778 //redraw ();790 redraw (); 779 791 } 780 792 … … 838 850 * </ul> 839 851 */ 840 //public void setVisible (boolean visible) {841 //checkWidget ();842 //if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;843 //int hwndParent = parent.handle;852 public void setVisible (boolean visible) { 853 checkWidget (); 854 if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return; 855 int hwndParent = parent.handle; 844 856 // if (!visible) { 845 857 // OS.SendMessage (hwndParent, OS.WM_CANCELMODE, 0, 0); … … 853 865 // nY = (short) (pos >> 16); 854 866 // } 855 ///*856 //* Feature in Windows. It is legal use TrackPopupMenu ()857 //* to display an empty menu as long as menu items are added858 //* inside of WM_INITPOPUPMENU. If no items are added, then859 //* TrackPopupMenu () fails and does not send an indication860 //* that the menu has been closed. This is not strictly a861 //* bug but leads to unwanted behavior when application code862 //* assumes that every WM_INITPOPUPMENU will eventually result863 //* in a WM_MENUSELECT, wParam=0xFFFF0000, lParam=0 to indicate864 //* that the menu has been closed. The fix is to detect the865 //* case when TrackPopupMenu fails and the number of items in866 //* the menu is zero and issue a fake WM_MENUSELECT.867 //*/867 /* 868 * Feature in Windows. It is legal use TrackPopupMenu () 869 * to display an empty menu as long as menu items are added 870 * inside of WM_INITPOPUPMENU. If no items are added, then 871 * TrackPopupMenu () fails and does not send an indication 872 * that the menu has been closed. This is not strictly a 873 * bug but leads to unwanted behavior when application code 874 * assumes that every WM_INITPOPUPMENU will eventually result 875 * in a WM_MENUSELECT, wParam=0xFFFF0000, lParam=0 to indicate 876 * that the menu has been closed. The fix is to detect the 877 * case when TrackPopupMenu fails and the number of items in 878 * the menu is zero and issue a fake WM_MENUSELECT. 879 */ 868 880 // boolean success = OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null); 869 881 // if (!success && GetMenuItemCount (handle) == 0) { 870 882 // OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0); 871 883 // } 872 //}873 874 } 884 } 885 886 }
Note:
See TracChangeset
for help on using the changeset viewer.