From: <kr_...@us...> - 2003-11-15 10:31:53
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv1334/src/cbits/Win32 Modified Files: Frame.c Internals.h Menu.c MenuHandlesMap.c MenuHandlesMap.h StatusBar.c Log Message: Extended StatusBar API. Added support for tooltips for menu items Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Frame.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Frame.c 14 Nov 2003 22:35:20 -0000 1.18 --- Frame.c 15 Nov 2003 10:31:49 -0000 1.19 *************** *** 3,6 **** --- 3,7 ---- #include "Menu.h" #include "DockBar.h" + #include "StatusBar.h" #include "MenuHandlesMap.h" #include "Canvas.h" *************** *** 40,43 **** --- 41,52 ---- free(pData->lpszAppVersion); deleteMenuHandlesMap(pData->pMenuHandlesMap); + + while (pData->statusContexts) + { + StatusContext context = pData->statusContexts; + pData->statusContexts = context->next; + free(context); + } + free(pData); PostQuitMessage(0); *************** *** 109,112 **** --- 118,122 ---- (HANDLE) ghModule, NULL); + pData->statusContexts = NULL; SetWindowLong(hWnd,GWL_USERDATA,(LONG) pData); *************** *** 348,351 **** --- 358,377 ---- } break; + case WM_MENUSELECT: + if ((HIWORD(wParam) & MF_POPUP) == 0) + { + handle = getMenuHandle(pData->pMenuHandlesMap, (UINT) LOWORD(wParam)); + if (handle) + { + SetWindowText(pData->hStatusBar, handle->tip ? handle->tip : ""); + } + } + break; + case WM_ENTERMENULOOP: + osPushStatusBarContext(); + break; + case WM_EXITMENULOOP: + osPopStatusBarContext(); + break; } Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Internals.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Internals.h 14 Nov 2003 22:35:20 -0000 1.13 --- Internals.h 15 Nov 2003 10:31:49 -0000 1.14 *************** *** 61,64 **** --- 61,70 ---- extern void SetupLogBrush(LOGBRUSH *plb, BOOL bSetSolid, int hatchStyle, BitmapHandle patBmp); + typedef struct StatusContext + { + struct StatusContext *next; + char tip[0]; + } *StatusContext; + typedef struct { *************** *** 71,74 **** --- 77,81 ---- HWND hLeftBar, hTopBar, hRightBar, hBottomBar; HWND hStatusBar; + StatusContext statusContexts; } FrameData; Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Menu.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Menu.c 14 Nov 2003 22:35:20 -0000 1.18 --- Menu.c 15 Nov 2003 10:31:49 -0000 1.19 *************** *** 462,465 **** --- 462,481 ---- } + char *osGetMenuTip(MenuHandle handle) + { + CHECK_MENU_TYPE(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM, NULL); + return handle->tip; + } + + void osSetMenuTip(MenuHandle handle, char *tip) + { + CHECK_MENU_TYPE_V(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM); + + if (handle->tip) + free(handle->tip); + + handle->tip = strdup(tip); + } + void osSetMenuItemAccel(MenuHandle handle, int key, unsigned int mods) { Index: MenuHandlesMap.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/MenuHandlesMap.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MenuHandlesMap.c 17 Aug 2003 16:45:07 -0000 1.3 --- MenuHandlesMap.c 15 Nov 2003 10:31:49 -0000 1.4 *************** *** 86,89 **** --- 86,90 ---- handle->nextInGroup = handle; handle->sibling = NULL; + handle->tip = NULL; if (type != MENU_POPUP) Index: MenuHandlesMap.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/MenuHandlesMap.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MenuHandlesMap.h 17 Aug 2003 16:45:07 -0000 1.4 --- MenuHandlesMap.h 15 Nov 2003 10:31:49 -0000 1.5 *************** *** 31,34 **** --- 31,35 ---- BitmapHandle bitmap; MENU_TYPE type; + char *tip; }; Index: StatusBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/StatusBar.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StatusBar.c 14 Nov 2003 22:35:20 -0000 1.1 --- StatusBar.c 15 Nov 2003 10:31:49 -0000 1.2 *************** *** 15,16 **** --- 15,60 ---- return (GetWindowLong(pData->hStatusBar, GWL_STYLE) & WS_VISIBLE) != 0; } + + void osPushStatusBarContext() + { + int nLen; + StatusContext context; + FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + + nLen = GetWindowTextLength(pData->hStatusBar); + context = (StatusContext) rmalloc(sizeof(struct StatusContext) + nLen+1); + GetWindowText(pData->hStatusBar, context->tip, nLen+1); + context->next = pData->statusContexts; + pData->statusContexts = context; + } + + void osPopStatusBarContext() + { + StatusContext context; + FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + + context = pData->statusContexts; + if (!context) + return; + + pData->statusContexts = context->next; + + SetWindowText(pData->hStatusBar, context->tip); + + free(context); + } + + char *osGetStatusBarTitle() + { + FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + int nLen = GetWindowTextLength(pData->hStatusBar); + char *buffer = (char *) rmalloc(nLen+1); + GetWindowText(pData->hStatusBar, buffer, nLen+1); + return buffer; + }; + + void osSetStatusBarTitle(char *title) + { + FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + SetWindowText(pData->hStatusBar, title); + }; |