Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

oslibmenu.cpp

Go to the documentation of this file.
00001 /* $Id: oslibmenu.cpp,v 1.12 2000/03/13 13:10:46 sandervl Exp $ */
00002 /*
00003  * Window Menu wrapper functions for OS/2
00004  *
00005  *
00006  * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
00007  *
00008  *
00009  * Project Odin Software License can be found in LICENSE.TXT
00010  *
00011  */
00012 #define  INCL_WIN
00013 #define  INCL_PM
00014 #include <os2wrap.h>
00015 #include <stdlib.h>
00016 #include <string.h>
00017 
00018 #include <misc.h>
00019 #include <winconst.h>
00020 #include "oslibwin.h"
00021 #include "oslibutil.h"
00022 #include "oslibmenu.h"
00023 
00024 #define DBG_LOCALLOG    DBG_oslibmenu
00025 #include "dbglocal.h"
00026 
00027 //******************************************************************************
00028 //******************************************************************************
00029 HWND OSLibWinSetMenu(HWND hwndParent, HMENU hMenu)
00030 {
00031    // Remove current menu from window
00032    HWND currMenu = WinWindowFromID( (HWND)hwndParent, FID_MENU );
00033    if (currMenu)
00034    {
00035       dprintf(("OSLibWinSetMenu: old menu %x, new menu %x", currMenu, hMenu));
00036       WinSetOwner (currMenu, HWND_OBJECT);
00037       WinSetParent(currMenu, HWND_OBJECT, FALSE);
00038    }
00039 
00040    if (hMenu)
00041    {
00042         if(WinIsWindow(GetThreadHAB(), hMenu) == TRUE) 
00043         {
00044                 WinSetOwner (hMenu, hwndParent);
00045                 WinSetParent(hMenu, hwndParent, FALSE );
00046                 WinSetWindowUShort(hMenu, QWS_ID, FID_MENU);
00047                 WinSendMsg(hwndParent, WM_UPDATEFRAME, (MPARAM)FCF_MENU, 0);
00048                 return hMenu;
00049         }
00050         else {
00051                 dprintf(("OSLibWinSetMenu: %x = invalid menu handle", hMenu));
00052         }
00053    }
00054    return 0;
00055 }
00056 //******************************************************************************
00057 //******************************************************************************
00058 int OSLibGetMenuItemCount(HWND hMenu)
00059 {
00060    return (int)SHORT1FROMMR(WinSendMsg(hMenu, MM_QUERYITEMCOUNT, NULL, NULL));
00061 }
00062 //******************************************************************************
00063 //******************************************************************************
00064 HMENU OSLibWinCreateMenu(PVOID menutemplate)
00065 {
00066     return (HMENU)WinCreateMenu(HWND_OBJECT, menutemplate);
00067 }
00068 //******************************************************************************
00069 //******************************************************************************
00070 HMENU OSLibWinCreateEmptyMenu()
00071 {
00072    return WinCreateWindow(HWND_OBJECT, WC_MENU, NULL, MS_ACTIONBAR | 0x0008 | WS_SAVEBITS,
00073                           0, 0, 0, 0, HWND_OBJECT, HWND_TOP, 0, NULL, NULL);
00074 }
00075 //******************************************************************************
00076 //******************************************************************************
00077 HMENU OSLibWinCreateEmptyPopupMenu()
00078 {
00079    return WinCreateWindow(HWND_OBJECT, WC_MENU, NULL, WS_CLIPSIBLINGS | WS_SAVEBITS,
00080                           0, 0, 0, 0, HWND_OBJECT, HWND_TOP, 0, NULL, NULL);
00081 }
00082 //******************************************************************************
00083 //Returns menu item rectange in screen coordinates
00084 //******************************************************************************
00085 BOOL OSLibGetMenuItemRect(HWND hMenu, int index, LPRECT pRect)
00086 {
00087   RECTL rectl;
00088   BOOL  rc;
00089   ULONG id;
00090 
00091    //First get id from menu index
00092    id = (ULONG)WinSendMsg(hMenu, MM_ITEMIDFROMPOSITION, MPARAM(index), 0);
00093 
00094    rc = (BOOL)WinSendMsg(hMenu, MM_QUERYITEMRECT, MPARAM(id), (MPARAM)&rectl);
00095    if(rc == FALSE) {
00096         dprintf(("OSLibGetMenuItemRect %x %d %d failed!", hMenu, index, id));
00097         return FALSE;
00098    }
00099    WinMapWindowPoints(hMenu, HWND_DESKTOP, (PPOINTL)&rectl, 2);
00100    pRect->left  = rectl.xLeft;
00101    pRect->right = rectl.xRight;
00102    pRect->top   = OSLibQueryScreenHeight() - rectl.yTop;
00103    pRect->bottom= OSLibQueryScreenHeight() - rectl.yBottom;
00104    return TRUE;
00105 }
00106 //******************************************************************************
00107 //******************************************************************************
00108 

Generated on Wed Jan 23 23:17:38 2002 for ODIN-user32 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001