From: <kr_...@us...> - 2003-04-01 23:54:24
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv606/port/src/cbits/Win32 Modified Files: Frame.c Menu.c Log Message: Implementation for SDI/MDI menu Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Frame.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Frame.c 30 Mar 2003 22:50:00 -0000 1.5 --- Frame.c 1 Apr 2003 23:54:20 -0000 1.6 *************** *** 83,86 **** --- 83,90 ---- } break; + case WM_COMMAND: + if (lParam == 0) + handleMenuCommand((MenuHandle) (UINT) LOWORD(wParam)); + break; } *************** *** 132,135 **** --- 136,141 ---- if (!pData->hClientWnd) return -1; + + DrawMenuBar(hWnd); } break; *************** *** 167,170 **** --- 173,179 ---- switch (uMsg) { + case WM_CREATE: + SetMenu(hWnd, CreateMenu()); + break; case WM_ACTIVATE: if (pFrameData->hClientWnd) Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Menu.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Menu.c 26 Mar 2003 12:59:24 -0000 1.4 --- Menu.c 1 Apr 2003 23:54:20 -0000 1.5 *************** *** 2,5 **** --- 2,6 ---- #include "Window.h" #include "Internals.h" + #include "Handlers_stub.h" static UINT gMenuItemID = 0; *************** *** 81,98 **** } ! MenuHandle osCreateMenuBar(WindowHandle window) { ! HMENU hMenu = CreateMenu(); ! HMENU hPrev = GetMenu(window); ! SetMenu(window, hMenu); ! if (hPrev != NULL) DestroyMenu(hPrev); ! return hMenu; ! }; ! MenuHandle osAddSubMenu(MenuHandle parent, char *title) { ! MenuHandle menu = CreateMenu(); ! InsertMenu(parent,-1,MF_BYPOSITION | MF_POPUP,(UINT)menu,title); ! return menu; }; --- 82,123 ---- } ! static HMENU getHMENU(HMENU hMenu) { ! return (hMenu) ? hMenu : GetMenu(ghWndFrame); ! } ! static void updateMenuBar(MenuHandle parent) { ! if (!parent) ! { ! RECT rc; ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! GetClientRect(ghWndFrame, &rc); ! SetWindowPos(pFrameData->hClientWnd,NULL,rc.left,rc.top,rc.right,rc.bottom,SWP_NOZORDER); ! DrawMenuBar(ghWndFrame); ! ! if (pFrameData->DocumentInterface == 1) ! { ! handleWindowResize(pFrameData->hClientWnd,rc.right-rc.left,rc.bottom-rc.top); ! handleWindowReLayout(pFrameData->hClientWnd); ! } ! } ! } ! ! MenuHandle osAddMenu(MenuHandle parent, char *title) ! { ! HMENU hMenu, hParent; ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! hMenu = CreateMenu(); ! hParent = getHMENU(parent); ! if (pFrameData->DocumentInterface == 1) ! InsertMenu(hParent,-1,MF_BYPOSITION | MF_POPUP,(UINT)hMenu,title); ! else ! InsertMenu(hParent,GetMenuItemCount(hParent)-1,MF_BYPOSITION | MF_POPUP,(UINT)hMenu,title); ! updateMenuBar(parent); ! ! return hMenu; }; *************** *** 103,108 **** strcpy(temp, title); AddAccelString(key, mods, temp); ! InsertMenu(parent,-1,MF_BYPOSITION | MF_STRING,nMenuItemID,temp); free(temp); return (MenuHandle) nMenuItemID; }; --- 128,134 ---- strcpy(temp, title); AddAccelString(key, mods, temp); ! InsertMenu(getHMENU(parent),-1,MF_BYPOSITION | MF_STRING,nMenuItemID,temp); free(temp); + updateMenuBar(parent); return (MenuHandle) nMenuItemID; }; *************** *** 114,119 **** strcpy(temp, title); AddAccelString(key, mods, temp); ! InsertMenu(parent,-1,MF_BYPOSITION | MF_STRING,nMenuItemID,title); free(temp); return (MenuHandle) nMenuItemID; }; --- 140,146 ---- strcpy(temp, title); AddAccelString(key, mods, temp); ! InsertMenu(getHMENU(parent),-1,MF_BYPOSITION | MF_STRING,nMenuItemID,title); free(temp); + updateMenuBar(parent); return (MenuHandle) nMenuItemID; }; *************** *** 121,130 **** void osAddMenuSeparatorItem(MenuHandle parent) { ! InsertMenu(parent,-1,MF_BYPOSITION | MF_SEPARATOR,0,NULL); } void osSetMenuItemEnabled(MenuHandle parent, MenuHandle item, BOOL bState) { ! EnableMenuItem(parent, (UINT) item, (bState ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND); }; --- 148,158 ---- void osAddMenuSeparatorItem(MenuHandle parent) { ! InsertMenu(getHMENU(parent),-1,MF_BYPOSITION | MF_SEPARATOR,0,NULL); ! updateMenuBar(parent); } void osSetMenuItemEnabled(MenuHandle parent, MenuHandle item, BOOL bState) { ! EnableMenuItem(getHMENU(parent), (UINT) item, (bState ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND); }; *************** *** 134,138 **** mii.cbSize = sizeof(mii); mii.fMask = MIIM_STATE; ! GetMenuItemInfo(parent, item, FALSE, &mii); return (mii.fState & MFS_ENABLED) != 0; }; --- 162,166 ---- mii.cbSize = sizeof(mii); mii.fMask = MIIM_STATE; ! GetMenuItemInfo(getHMENU(parent), (UINT) item, FALSE, &mii); return (mii.fState & MFS_ENABLED) != 0; }; *************** *** 140,144 **** void osSetMenuItemChecked(MenuHandle parent, MenuHandle item, BOOL bState) { ! CheckMenuItem(parent, (UINT) item, (bState ? MF_CHECKED : MF_UNCHECKED) | MF_BYCOMMAND); }; --- 168,172 ---- void osSetMenuItemChecked(MenuHandle parent, MenuHandle item, BOOL bState) { ! CheckMenuItem(getHMENU(parent), (UINT) item, (bState ? MF_CHECKED : MF_UNCHECKED) | MF_BYCOMMAND); }; *************** *** 148,152 **** mii.cbSize = sizeof(mii); mii.fMask = MIIM_STATE; ! GetMenuItemInfo(parent, item, FALSE, &mii); return (mii.fState & MFS_CHECKED) != 0; } --- 176,180 ---- mii.cbSize = sizeof(mii); mii.fMask = MIIM_STATE; ! GetMenuItemInfo(getHMENU(parent), (UINT) item, FALSE, &mii); return (mii.fState & MFS_CHECKED) != 0; } *************** *** 165,169 **** menuItemInfo.dwTypeData = temp; menuItemInfo.cch = strlen(temp); ! SetMenuItemInfo(parent, (UINT) item, FALSE, &menuItemInfo); free(temp); } --- 193,197 ---- menuItemInfo.dwTypeData = temp; menuItemInfo.cch = strlen(temp); ! SetMenuItemInfo(getHMENU(parent), (UINT) item, FALSE, &menuItemInfo); free(temp); } |