Changeset 105 for trunk/src


Ignore:
Timestamp:
Jun 20, 2008, 12:57:17 AM (17 years ago)
Author:
lpino
Message:

More fixes on popup menus, now they are working

Location:
trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Control.java

    r103 r105  
    472472
    473473//@@TODO (dmik): debug code, remove when no more necessary
    474 System.out.println (
    475     "Control.createHandle(): Window has been created:\n" +
    476     "    hwnd = " + Integer.toHexString (handle) + "\n" +
    477     "    hwnd.parent = hwnd.owner = " + Integer.toHexString (parent.handle) + "\n" +
    478     "    class = " + windowClass() + "\n" +
    479     "    style = " + Integer.toHexString (widgetStyle())
    480 );
     474//System.out.println (
     475//    "Control.createHandle(): Window has been created:\n" +
     476//    "    hwnd = " + Integer.toHexString (handle) + "\n" +
     477//    "    hwnd.parent = hwnd.owner = " + Integer.toHexString (parent.handle) + "\n" +
     478//    "    class = " + windowClass() + "\n" +
     479//    "    style = " + Integer.toHexString (widgetStyle())
     480//);
    481481
    482482//@@TODO(dmik): DBCS handling?
     
    30413041    boolean keyUp = (OS.SHORT1FROMMP (mp1) & OS.KC_KEYUP) != 0;
    30423042//@@TODO (dmik): debug, remove   
    3043 System.out.println("WM_CHAR ("+this+"): vk="+OS.SHORT2FROMMP (mp2)+" keyup="+keyUp);
     3043//System.out.println("WM_CHAR ("+this+"): vk="+OS.SHORT2FROMMP (mp2)+" keyup="+keyUp);
    30443044    sendKeyEvent (keyUp ? SWT.KeyUp : SWT.KeyDown, OS.WM_CHAR, mp1, mp2);
    30453045    return null;
     
    30583058    switch (OS.SHORT1FROMMP (mp2)) {
    30593059        case OS.CMDSRC_MENU:
     3060//            System.out.println("Control:WM_COMMAND - CMDSRC_MENU");
    30603061            Decorations shell = menuShell ();
    30613062            if (shell.isEnabled ()) {
     
    30723073            break;
    30733074        case OS.CMDSRC_PUSHBUTTON:
     3075            System.out.println("Control:WM_COMMAND - CMDSRC_PUSHBUTTON");
     3076            break;
    30743077        //@@TODO(lpino)
    30753078        case OS.CMDSRC_FONTDLG:
     3079            System.out.println("Control:WM_COMMAND - CMDSRC_FONTDLG");
     3080            break;
    30763081        case OS.CMDSRC_FILEDLG:
    3077         case OS.CMDSRC_COLORDLG:
     3082            System.out.println("Control:WM_COMMAND - CMDSRC_FILEDLG");
     3083            break;
     3084        case OS.CMDSRC_OTHER:
     3085            System.out.println("Control:WM_COMMAND - CMDSRC_OTHER");
     3086            break;
    30783087        //case OS.CMDSRC_PRINTDLG:
    30793088    }
     
    30923101      * have been destroyed but not removed from the control.
    30933102      */
     3103    //@@TODO(lpino) First check if this validation applies to OS/2 implementation and then validate using the coordinates of the mouse
    30943104//      if (mp2 != handle) return null;
    3095       int parentHandle = OS.WinQueryWindow(menu.handle, OS.QW_PARENT);
    3096       int hab = parent.getDisplay ().hab;
    3097     //@@TODO(lpino) Remove debug msg
    3098 //      System.out.println("Control:WM_CONTEXTMENU - PARENT HANDLE = " + Integer.toHexString (parentHandle));
    3099 //      System.out.println("Control:WM_CONTEXTMENU - MENU HANDLE = " + Integer.toHexString (menu.handle));
     3105//      int parentHandle = OS.WinQueryWindow(menu.handle, OS.QW_PARENT);
     3106//      System.out.println("Control:WM_CONTEXTMENU - PARENTHANDLE = " + Integer.toHexString(parentHandle));
     3107//      System.out.println("Control:WM_CONTEXTMENU - PARENTHANDLE = " + Integer.toHexString(handle));
    31003108      short flOptions = OS.PU_HCONSTRAIN | OS.PU_VCONSTRAIN | OS.PU_KEYBOARD | OS.PU_MOUSEBUTTON1;
    3101       boolean rc = OS.WinPopupMenu(parentHandle, parentHandle, menu.handle, 0, OS.SHORT1FROMMP(mp1), OS.SHORT2FROMMP(mp1), flOptions);
     3109      boolean rc = OS.WinPopupMenu(handle, handle, menu.handle, 0, OS.SHORT1FROMMP(mp1), OS.SHORT2FROMMP(mp1), flOptions);
    31023110//      if (menu != null && !menu.isDisposed ()) {
    31033111//              menu.setVisible (true);
     
    32343242
    32353243      /* Ignore WM_INITMENU for an accelerator */
    3236       System.out.println("Control:WM_INITMENU -  MENU HANDLE = " + Integer.toHexString (mp2));
    32373244      Display display = getDisplay ();
    32383245      if (display.accelKeyHit) return null;
    3239 //      /*
    3240 //      * If the high order word of LPARAM is non-zero,
    3241 //      * the menu is the system menu and we can ignore
    3242 //      * WPARAM.  Otherwise, use WPARAM to find the menu.
    3243 //      */
    32443246      Shell shell = getShell ();
    32453247      Menu oldMenu = shell.activeMenu;
    32463248      Menu newMenu = null;
    3247 //      if ((lParam >> 16) == 0) {
    3248               newMenu = menuShell ().findMenu (mp2);
    3249 //      }
     3249      newMenu = menuShell ().findMenu (mp2);
    32503250      Menu menu = newMenu;
    32513251      while (menu != null && menu != oldMenu) {
     
    32533253      }
    32543254      if (menu == null) {
    3255              menu = shell.activeMenu;
     3255              menu = shell.activeMenu;
    32563256              while (menu != null) {
    32573257                      /*
     
    32723272              }
    32733273      }
    3274       if(menu == null)
    3275         System.out.println("Control:WM_INITMENU " + menu);
    3276       else
    3277         System.out.println("Control:WM_INITMENU " + Integer.toHexString (menu.handle));   
    3278 //
    3279 //      /*
    3280 //      * The shell and the new menu may be disposed because of
    3281 //      * sending the hide event to the ancestor menus but setting
    3282 //      * a field to null in a disposed shell is not harmful.
    3283 //      */
     3274
     3275      /*
     3276      * The shell and the new menu may be disposed because of
     3277      * sending the hide event to the ancestor menus but setting
     3278      * a field to null in a disposed shell is not harmful.
     3279      */
    32843280      if (newMenu != null && newMenu.isDisposed ())
    32853281          newMenu = null;
    32863282      shell.activeMenu = newMenu;
    3287 //
    3288 //      /*
    3289 //      * Send the show event
    3290 //      */
     3283
     3284      /*
     3285      * Send the show event
     3286      */
    32913287      if (newMenu != null && newMenu != oldMenu) {
    32923288              /*
     
    34723468//
    34733469MRESULT WM_MENUSELECT (int mp1, int mp2) {
    3474     System.out.println("Control:WM_MENUSELECT - MP1 SHORT 1= " + OS.SHORT1FROMMP(mp1));
    3475     System.out.println("Control:WM_MENUSELECT - MP1 SHORT 2= " + OS.SHORT2FROMMP(mp1));
     3470//    System.out.println("Control:WM_MENUSELECT - MP1 SHORT 1= " + OS.SHORT1FROMMP(mp1));
    34763471    if(OS.SHORT2FROMMP(mp1) == 0) return MRESULT.FALSE;
    34773472//      int code = wParam >> 16;
     
    35003495//      }
    35013496//      if ((code & OS.MF_SYSMENU) != 0) return null;
    3502 //      if ((code & OS.MF_HILITE) != 0) {
    3503 //              MenuItem item = null;
    3504 //              Decorations menuShell = menuShell ();
    3505 //              if ((code & OS.MF_POPUP) != 0) {
     3497      int sState = OS.WinSendMsg(mp2, OS.MM_QUERYITEMATTR, OS.MPFROM2SHORT(OS.SHORT1FROMMP(mp1), (short)OS.TRUE), OS.MIA_HILITED);
     3498      if ((sState & OS.MIA_HILITED) != 0) {
     3499              MenuItem item = null;
     3500              Decorations menuShell = menuShell ();
     3501              MENUITEM info = new MENUITEM ();
     3502              OS.WinSendMsg (mp2, OS.MM_QUERYITEM,  OS.MPFROM2SHORT (OS.SHORT1FROMMP(mp1), (short)OS.TRUE), info);
     3503              if ((info.afStyle & OS.MIS_SUBMENU) != 0) {
    35063504//                      int index = wParam & 0xFFFF;
    35073505//                      MENUITEMINFO info = new MENUITEMINFO ();
     
    35093507//                      info.fMask = OS.MIIM_SUBMENU;
    35103508//                      if (OS.GetMenuItemInfo (lParam, index, true, info)) {
    3511 //                              Menu newMenu = menuShell.findMenu (info.hSubMenu);
    3512 //                              if (newMenu != null) item = newMenu.cascade;
     3509                              Menu newMenu = menuShell.findMenu (info.hwndSubMenu);
     3510                              if (newMenu != null) item = newMenu.cascade;
    35133511//                      }
    3514 //              } else {
    3515 //                      Menu newMenu = menuShell.findMenu (lParam);
    3516 //                      if (newMenu != null) {
    3517 //                              int id = wParam & 0xFFFF;
    3518 //                              item = menuShell.findMenuItem (id);
    3519 //                      }
    3520 //                      Menu oldMenu = shell.activeMenu;
    3521 //                      if (oldMenu != null) {
    3522 //                              Menu ancestor = oldMenu;
    3523 //                              while (ancestor != null && ancestor != newMenu) {
    3524 //                                      ancestor = ancestor.getParentMenu ();
    3525 //                              }
    3526 //                              if (ancestor == newMenu) {
    3527 //                                      ancestor = oldMenu;
    3528 //                                      while (ancestor != newMenu) {
    3529 //                                              /*
    3530 //                                              * It is possible (but unlikely), that application
    3531 //                                              * code could have disposed the widget in the hide
    3532 //                                              * event or the item about to be armed.  If this
    3533 //                                              * happens, stop searching up the ancestor list
    3534 //                                              * because there is no longer a link to follow.
    3535 //                                              */
    3536 //                                              ancestor.sendEvent (SWT.Hide);
    3537 //                                              if (ancestor.isDisposed ()) break;
    3538 //                                              ancestor = ancestor.getParentMenu ();
    3539 //                                      }
    3540 //                                      /*
    3541 //                                      * The shell and/or the item could be disposed when
    3542 //                                      * processing hide events from above.  If this happens,
    3543 //                                      * ensure that the shell is not accessed and that no
    3544 //                                      * arm event is sent to the item.
    3545 //                                      */
    3546 //                                      if (!shell.isDisposed ()) {
    3547 //                                              if (newMenu != null && newMenu.isDisposed ()) {
    3548 //                                                      newMenu = null;
    3549 //                                              }
    3550 //                                              shell.activeMenu = newMenu;
    3551 //                                      }
    3552 //                                      if (item != null && item.isDisposed ()) item = null;
    3553 //                              }
    3554 //                      }
    3555 //              }
    3556 //              if (item != null) item.sendEvent (SWT.Arm);
    3557 //      }
    3558 //      int parentHandle = OS.WinQueryWindow(menu.handle, OS.QW_PARENT);
    3559 //      boolean bIsWaiting = true;
    3560 //      int hab = 0;
    3561 //      if(parent == null)
    3562 //          hab = getDisplay().hab;
    3563 //      else
    3564 //          hab = parent.getDisplay ().hab;
    3565 //       while(bIsWaiting){       
    3566 //            QMSG qmsg = new QMSG ();
    3567 //
    3568 //            OS.WinGetMsg(hab,qmsg, 0, 0, 0);
    3569 //            if (qmsg.msg == OS.WM_COMMAND || qmsg.msg == OS.WM_MENUSELECT)
    3570 //                bIsWaiting = false;
    3571 //            OS.WinDispatchMsg(hab, qmsg);
    3572 //          System.out.println("Control:WM_CONTEXTMENU");
    3573 //        }
     3512              } else {
     3513                      Menu newMenu = menuShell.findMenu (mp2);
     3514                      if (newMenu != null) {
     3515                              int id = OS.SHORT1FROMMP(mp1);
     3516                              item = menuShell.findMenuItem (id);
     3517                      }
     3518                      Menu oldMenu = shell.activeMenu;
     3519                      if (oldMenu != null) {
     3520                              Menu ancestor = oldMenu;
     3521                              while (ancestor != null && ancestor != newMenu) {
     3522                                      ancestor = ancestor.getParentMenu ();
     3523                              }
     3524                              if (ancestor == newMenu) {
     3525                                      ancestor = oldMenu;
     3526                                      while (ancestor != newMenu) {
     3527                                              /*
     3528                                              * It is possible (but unlikely), that application
     3529                                              * code could have disposed the widget in the hide
     3530                                              * event or the item about to be armed.  If this
     3531                                              * happens, stop searching up the ancestor list
     3532                                              * because there is no longer a link to follow.
     3533                                              */
     3534                                              ancestor.sendEvent (SWT.Hide);
     3535                                              if (ancestor.isDisposed ()) break;
     3536                                              ancestor = ancestor.getParentMenu ();
     3537                                      }
     3538                                      /*
     3539                                      * The shell and/or the item could be disposed when
     3540                                      * processing hide events from above.  If this happens,
     3541                                      * ensure that the shell is not accessed and that no
     3542                                      * arm event is sent to the item.
     3543                                      */
     3544                                      if (!shell.isDisposed ()) {
     3545                                              if (newMenu != null && newMenu.isDisposed ()) {
     3546                                                      newMenu = null;
     3547                                              }
     3548                                              shell.activeMenu = newMenu;
     3549                                      }
     3550                                      if (item != null && item.isDisposed ()) item = null;
     3551                              }
     3552                      }
     3553              }
     3554              if (item != null) item.sendEvent (SWT.Arm);
     3555      }
    35743556      return MRESULT.TRUE;
    35753557}
     
    38303812
    38313813MRESULT WM_MENUEND (int mp1, int mp2) {
    3832     System.out.println("Control:WM_MENUEND - HANDLE = " + Integer.toHexString (mp2));
    38333814      return null;
    38343815}
     
    40404021}
    40414022MRESULT WM_FOCUSCHANGE (int mp1, int mp2) {
    4042     System.out.println("Control:WM_FOCUSCHANGE - HANDLE = " + Integer.toHexString (mp1));
    40434023    callWindowProc (OS.WM_FOCUSCHANGE, mp1, mp2);
    40444024    return MRESULT.ZERO;
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Decorations.java

    r98 r105  
    393393    if (frameHandle == 0) error (SWT.ERROR_NO_HANDLES);
    394394//@@TODO (dmik): debug code, remove when no more necessary
    395 System.out.println (
    396     "Decorations.createHandle(): WC_FRAME has been created:\n" +
    397     "    hwnd = " + Integer.toHexString (frameHandle) + "\n" +
    398     "    hwnd.parent = " + Integer.toHexString (hwndParent) + "\n" +
    399     "    hwnd.owner = " + Integer.toHexString (hwndOwner) + "\n" +
    400     "    class = " + windowFrameClass() + "\n" +
    401     "    style = " + Integer.toHexString (widgetFrameStyle())
    402 );
     395//System.out.println (
     396//    "Decorations.createHandle(): WC_FRAME has been created:\n" +
     397//    "    hwnd = " + Integer.toHexString (frameHandle) + "\n" +
     398//    "    hwnd.parent = " + Integer.toHexString (hwndParent) + "\n" +
     399//    "    hwnd.owner = " + Integer.toHexString (hwndOwner) + "\n" +
     400//    "    class = " + windowFrameClass() + "\n" +
     401//    "    style = " + Integer.toHexString (widgetFrameStyle())
     402//);
    403403    FRAMECDATA fcdata = new FRAMECDATA ();
    404404    fcdata.flCreateFlags = widgetFrameFlags ();
     
    423423    state |= CANVAS;
    424424//@@TODO (dmik): debug code, remove when no more necessary
    425 System.out.println (
    426     "Decorations.createHandle(): FID_CLIENT window has been created:\n" +
    427     "    hwnd = " + Integer.toHexString (handle) + "\n" +
    428     "    hwnd.parent = hwnd.owner = " + Integer.toHexString (frameHandle) + "\n" +
    429     "    class = " + windowClass() + "\n" +
    430     "    style = " + Integer.toHexString (widgetStyle())
    431 );
     425//System.out.println (
     426//    "Decorations.createHandle(): FID_CLIENT window has been created:\n" +
     427//    "    hwnd = " + Integer.toHexString (handle) + "\n" +
     428//    "    hwnd.parent = hwnd.owner = " + Integer.toHexString (frameHandle) + "\n" +
     429//    "    class = " + windowClass() + "\n" +
     430//    "    style = " + Integer.toHexString (widgetStyle())
     431//);
    432432//@@TODO(dmik): do something for MDI windows if needed   
    433433//    if (parent == null) return;
     
    466466        for (int i=0; i<menus.length; i++) {
    467467                Menu menu = menus [i];
     468                if ((menu != null))
    468469                if ((menu != null) && (hMenu == menu.handle)) return menu;
    469470        }
     
    10711072//        OS.SetMenu (handle, hMenu);
    10721073        OS.WinSendMsg (frameHandle, OS.WM_UPDATEFRAME, OS.FCF_MENU, 0);
    1073         System.out.println("Decorations:setMenuBar");
    10741074        destroyAcceleratorTable ();
    10751075}
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Menu.java

    r103 r105  
    233233                                                        0               /* presentation parameters */
    234234                                                        );
    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 );
     235//@@TODO (lpino): debug code, remove when no more necessary
     236//System.out.println (
     237//    "Menu.createHandle(): FID_MENU window has been created:\n" +
     238//    "    hwnd = " + Integer.toHexString (handle) + "\n" +
     239//    "    hwnd.parent = hwnd.owner = " + Integer.toHexString (handle) + "\n" +
     240//    "    class = WC_MENU\n" +
     241//    "    style = MS_ACTIONBAR"
     242//);
    242243        } else  if ((style & SWT.POP_UP) != 0) {
    243244            handle = OS.WinCreateWindow (parent.handle,                     /* parent window */
     
    252253                                                        0                                                   /* presentation parameters */
    253254                                                        );
    254 System.out.println (
    255     "Menu.createHandle(): POPUP menu window has been created:\n" +
    256     "    hwnd = " + Integer.toHexString (handle) + "\n" +
    257     "    hwnd.parent = hwnd.owner = " + Integer.toHexString (parent.handle) + "\n" +
    258     "    class = WC_MENU\n" +
    259     "    style = 0"
    260 );
     255//@@TODO (lpino): debug code, remove when no more necessary
     256//System.out.println (
     257//    "Menu.createHandle(): POPUP menu window has been created:\n" +
     258//    "    hwnd = " + Integer.toHexString (handle) + "\n" +
     259//    "    hwnd.parent = hwnd.owner = " + Integer.toHexString (parent.handle) + "\n" +
     260//    "    class = WC_MENU\n" +
     261//    "    style = 0"
     262//);
    261263             
    262264        } else if ((style & SWT.DROP_DOWN) != 0) {
     
    273275                                                        0               /* presentation parameters */
    274276                                                        );
     277//@@TODO (lpino): debug code, remove when no more necessary
    275278//System.out.println (
    276279//    "Menu.createHandle(): A menu has been created:\n" +
     
    875878        * the menu is zero and issue a fake WM_MENUSELECT.
    876879        */
    877          System.out.println("Menu:setVisible - HANDLE = " + Integer.toHexString (handle));
    878          short flOptions = OS.PU_MOUSEBUTTON1DOWN | OS.PU_KEYBOARD | OS.PU_MOUSEBUTTON1;
    879          boolean success = OS.WinPopupMenu(OS.HWND_DESKTOP, parent.handle, handle, 0, 0, 0, flOptions);
    880880//      boolean success = OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null);
    881881//      if (!success && GetMenuItemCount (handle) == 0) {
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/MenuItem.java

    r103 r105  
    22/*
    33 * OS/2 version.
    4  * Copyright (c) 2002, 2007 EclipseOS2 Team.
     4 * Copyright (c) 2002, 2008 EclipseOS2 Team.
    55 */
    66
Note: See TracChangeset for help on using the changeset viewer.