Changeset 2852 for trunk/src/user32/menu.cpp
- Timestamp:
- Feb 21, 2000, 6:25:33 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/menu.cpp
r2804 r2852 1 /* $Id: menu.cpp,v 1.1 7 2000-02-16 14:34:22 sandervlExp $*/1 /* $Id: menu.cpp,v 1.18 2000-02-21 17:25:28 cbratschi Exp $*/ 2 2 /* 3 3 * Menu functions … … 9 9 * Copyright 1999 Christoph Bratschi 10 10 * 11 * Corel version: 20000212 11 12 * WINE version: 20000130 12 13 * … … 30 31 #include "menu.h" 31 32 32 #define DBG_LOCALLOG 33 #define DBG_LOCALLOG DBG_menu 33 34 #include "dbglocal.h" 34 35 35 36 //DEFAULT_DEBUG_CHANNEL(menu) 37 //DECLARE_DEBUG_CHANNEL(winhelp) 36 38 37 39 … … 129 131 130 132 #define IS_STRING_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_STRING) 133 #define IS_SEPARATOR_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_SEPARATOR) 131 134 #define IS_BITMAP_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_BITMAP) 132 135 … … 175 178 static BOOL fEndMenu = FALSE; 176 179 180 /* 181 The following variables and defines are used to keep track of which 182 menu item the mouse is currently over. (Used to implement a pause before 183 popup menus are displayed. ) 184 185 See: MENU_MouseMove() 186 MENU_TrackMenu() 187 */ 188 #define SUBMENU_POPUP_TIMERID 100 189 #define POPUP_MENU_DELAY 500 190 static UINT mouseOverMenuID = -1; 191 static BOOL isTimerSet = FALSE; 177 192 178 193 /*********************************************************************** … … 1084 1099 rect = lpitem->rect; 1085 1100 1101 //CB: todo: does Win98 use DrawEdge for menubars? 1102 1086 1103 if ((lpitem->fState & MF_HILITE) && !(IS_BITMAP_ITEM(lpitem->fType))) 1087 1104 FillRect( hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT) ); … … 1123 1140 if (lpitem->fState & MF_GRAYED) 1124 1141 SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) ); 1142 #if 1 //CB: WINE's Win98 menubar -> to check 1143 1125 1144 else 1126 1145 SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) ); 1146 #else 1147 else 1148 { 1149 if (menuBar) 1150 SetTextColor(hdc,GetSysColor(COLOR_MENUTEXT)); 1151 else 1152 SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) ); 1153 } 1154 #endif 1127 1155 SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) ); 1128 1156 } … … 1761 1789 { 1762 1790 POPUPMENU *menu = MENU_GetMenu((UINT)id); 1763 if ( menu) menu->wFlags |= MF_POPUP;1791 if (IS_A_MENU(menu)) menu->wFlags |= MF_POPUP; 1764 1792 else 1765 1793 { … … 2102 2130 2103 2131 GetWindowRect(menu->hWnd,&rectWindow); 2104 rect.left = rectWindow.left + item->rect.right -arrow_bitmap_width;2132 rect.left = rectWindow.left + item->rect.right; 2105 2133 rect.top = rectWindow.top + item->rect.top; 2106 rect.right = item->rect.left - item->rect.right + 2*arrow_bitmap_width;2134 rect.right = item->rect.left - item->rect.right; 2107 2135 rect.bottom = item->rect.top - item->rect.bottom; 2108 2136 } … … 2339 2367 else if( ptmenu->FocusedItem != id ) 2340 2368 { 2341 MENU_SwitchTracking( pmt, hPtMenu, id ); 2342 pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags,&pmt->pt); 2369 POPUPMENU *menu; 2370 MENUITEM *item; 2371 2372 MENU_SwitchTracking( pmt, hPtMenu, id ); 2373 2374 2375 /* 2376 Test to see if we are trying to popup a submenu or not. 2377 If we aren't, don't change the current menu pointer 2378 and return. 2379 */ 2380 if (!(menu = (POPUPMENU *)MENU_GetMenu( hPtMenu ))) 2381 { 2382 pmt->hCurrentMenu = hPtMenu; 2383 return TRUE; 2384 } 2385 2386 if (!IsWindow( menu->hWnd ) || 2387 (menu->FocusedItem == NO_SELECTED_ITEM)) 2388 { 2389 pmt->hCurrentMenu = hPtMenu; 2390 return TRUE; 2391 } 2392 2393 item = &menu->items[menu->FocusedItem]; 2394 if (!(item->fType & MF_POPUP) || 2395 (item->fState & (MF_GRAYED | MF_DISABLED))) 2396 { 2397 pmt->hCurrentMenu = hPtMenu; 2398 return TRUE; 2399 } 2400 2401 2402 /* 2403 If we made it this far, we want to pop up a submenu. Before we pop it up, 2404 we want a slight delay. This is implemented by remembering the ID of the menu 2405 where the mouse is currently positioned, and setting up a timer. When the 2406 timer fires (handled in MENU_TrackMenu() ), if the mouse is over the same 2407 submenu item, we popup it up. Otherwise, we do nothing. 2408 */ 2409 KillTimer (pmt->hOwnerWnd, SUBMENU_POPUP_TIMERID); /* Just in case another timer was set up and not fired yet... */ 2410 if ( (SetTimer (pmt->hOwnerWnd, SUBMENU_POPUP_TIMERID, POPUP_MENU_DELAY, NULL)) != SUBMENU_POPUP_TIMERID) 2411 { 2412 /* 2413 For some reason the timer wasn't set up properly... Revert to old 2414 functionality. 2415 */ 2416 2417 pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags,&pmt->pt); 2418 return TRUE; 2419 } 2420 2421 mouseOverMenuID = id; 2422 isTimerSet = TRUE; 2343 2423 } 2344 2424 return TRUE; … … 2711 2791 } /* switch(msg.message) - mouse */ 2712 2792 } 2793 else if (msg.message == WM_TIMER) 2794 { 2795 UINT id = -1; 2796 POPUPMENU *ptmenu = NULL; 2797 2798 if (isTimerSet) 2799 { 2800 /* 2801 If we get here, an attempt was made to pop up a submenu. 2802 (See MENU_MouseMove() ) 2803 */ 2804 2805 /* Get the ID of the menu item the mouse is over now. */ 2806 if( hmenu ) 2807 { 2808 ptmenu = (POPUPMENU *)MENU_GetMenu( hmenu ); 2809 if( IS_SYSTEM_MENU(ptmenu) ) 2810 id = 0; 2811 else 2812 MENU_FindItemByCoords( ptmenu, mt.pt, &id ); 2813 } 2814 2815 /* If it is over the same item that set up the timer 2816 originally .... */ 2817 if (mouseOverMenuID == id) 2818 { 2819 /* .... Pop up the menu */ 2820 mt.hCurrentMenu = MENU_ShowSubPopup(mt.hOwnerWnd, hmenu, FALSE, wFlags,&mt.pt); 2821 } 2822 2823 /* Reset the timer so it doesn't fire again. (So we are ready for the next 2824 attempt to popup a submenu... ) */ 2825 KillTimer (mt.hOwnerWnd, 100); 2826 isTimerSet = FALSE; 2827 } 2828 } 2713 2829 else if ((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST)) 2714 2830 { … … 2750 2866 break; 2751 2867 2868 case VK_F1: 2869 { 2870 HELPINFO hi; 2871 hi.cbSize = sizeof(HELPINFO); 2872 hi.iContextType = HELPINFO_MENUITEM; 2873 if (menu->FocusedItem == NO_SELECTED_ITEM) 2874 hi.iCtrlId = 0; 2875 else 2876 hi.iCtrlId = menu->items[menu->FocusedItem].wID; 2877 hi.hItemHandle = hmenu; 2878 hi.dwContextId = menu->dwContextHelpID; 2879 hi.MousePos = msg.pt; 2880 //TRACE_(winhelp)("Sending HELPINFO_MENUITEM to 0x%08x\n", hwnd); 2881 SendMessageA(hwnd, WM_HELP, 0, (LPARAM)&hi); 2882 break; 2883 } 2884 2752 2885 default: 2753 2886 break; … … 2889 3022 } 2890 3023 3024 MENUITEM *MENU_HighlightedItem=NULL; 3025 UINT MENU_HighlightedItemID=NO_SELECTED_ITEM; 3026 POPUPMENU *MENU_HighlightedMenu=NULL; 3027 3028 void MENU_TrackMouseMenuBar_MouseMove(HWND hwnd,POINT pt,BOOL OnMenu) 3029 { 3030 HMENU hMenu = getMenu(hwnd); 3031 MENUITEM *item = NULL; 3032 RECT rect; 3033 HDC hdc; 3034 BOOL UnHighlight = (OnMenu==TRUE)?FALSE:TRUE; 3035 POPUPMENU *ptmenu = NULL; 3036 UINT id = NO_SELECTED_ITEM; 3037 3038 if (OnMenu == TRUE && IsMenu(hMenu)) { 3039 3040 ptmenu=(POPUPMENU *)MENU_GetMenu( hMenu ); 3041 3042 item=MENU_FindItemByCoords( ptmenu, pt, &id ); 3043 3044 if(!item) { 3045 /* No item selected, perhaps we are on the blank spot? */ 3046 UnHighlight = TRUE; 3047 /* Paranoid setting */ 3048 item=NULL; 3049 } else if(id == MENU_HighlightedItemID) { 3050 /* If it's already highlighted, don't do it again */ 3051 return; 3052 } else if(item->fState & MF_MOUSESELECT) { 3053 /* If it's dropped, we let the DrawMenuItem draw the sunken border */ 3054 return; 3055 } else if(item->fType & MF_BITMAP) { 3056 UnHighlight = TRUE; 3057 /* (Required) Paranoid setting */ 3058 item=NULL; 3059 } else { 3060 hdc = GetDCEx( ptmenu->hWnd, 0, DCX_CACHE | DCX_WINDOW); 3061 rect = item->rect; 3062 DrawEdge(hdc, &rect, BDR_RAISEDINNER, BF_RECT); 3063 ReleaseDC( ptmenu->hWnd, hdc ); 3064 3065 UnHighlight = TRUE; 3066 } 3067 } 3068 3069 if(UnHighlight == TRUE) { 3070 if(MENU_HighlightedItem) { 3071 if(!(MENU_HighlightedItem->fState & MF_MOUSESELECT)) { 3072 hdc = GetDCEx( MENU_HighlightedMenu->hWnd, 0, DCX_CACHE | DCX_WINDOW); 3073 rect = MENU_HighlightedItem->rect; 3074 3075 FrameRect(hdc, &rect, GetSysColorBrush(COLOR_MENU)); 3076 ReleaseDC( MENU_HighlightedMenu->hWnd, hdc ); 3077 } 3078 } 3079 3080 /* Sets to NULL, NO_SELECTED_ITEM, NULL, unless it found a new 3081 item, then it will be filled in with the proper values */ 3082 MENU_HighlightedItem = item; 3083 MENU_HighlightedItemID = id; 3084 MENU_HighlightedMenu= ptmenu; 3085 } 3086 } 2891 3087 2892 3088 /*********************************************************************** … … 3333 3529 dprintf(("USER32: GetMenuItemCount")); 3334 3530 3335 if (! menu) return -1;3531 if (!IS_A_MENU(menu)) return -1; 3336 3532 //TRACE("(%04x) returning %d\n", 3337 3533 // hMenu, menu->nItems ); … … 3348 3544 dprintf(("USER32: GetMenuItemID")); 3349 3545 3350 if (!(lpmi = MENU_FindItem(&hMenu,(UINT*)&nPos,MF_BYPOSITION))) return 0 ;3351 if (lpmi->fType & MF_POPUP) return -1;3546 if (!(lpmi = MENU_FindItem(&hMenu,(UINT*)&nPos,MF_BYPOSITION))) return 0xFFFFFFFF; 3547 if (lpmi->fType & MF_POPUP) return 0xFFFFFFFF; 3352 3548 return lpmi->wID; 3353 3549 … … 3544 3740 3545 3741 if (!(hmenu = CreateMenu())) return 0; 3546 menu = (POPUPMENU*)hmenu;3742 menu = MENU_GetMenu(hmenu); 3547 3743 menu->wFlags |= MF_POPUP; 3548 3744 menu->bTimeToHide = FALSE; … … 3633 3829 SetWindowLongA(pTPWnd,0,0); 3634 3830 3635 if (!IS_A_MENU(lppop)) lppop = NULL; 3636 if (lppop) 3831 if (IS_A_MENU(lppop)) 3637 3832 { 3638 3833 lppop->wMagic = 0; /* Mark it as destroyed */ … … 3945 4140 BOOL WINAPI IsMenu(HMENU hmenu) 3946 4141 { 3947 LPPOPUPMENU menu = (LPPOPUPMENU)hmenu;4142 LPPOPUPMENU menu = MENU_GetMenu(hmenu); 3948 4143 3949 4144 dprintf(("USER32: IsMenu")); … … 4112 4307 if (menu->hSubMenu) { 4113 4308 POPUPMENU *subMenu = MENU_GetMenu((UINT)menu->hSubMenu); 4114 if ( subMenu) {4309 if (IS_A_MENU(subMenu)) { 4115 4310 subMenu->wFlags |= MF_POPUP; 4116 4311 menu->fType |= MF_POPUP; … … 4465 4660 4466 4661 dprintf(("USER32: GetMenuContextHelpId")); 4467 //TRACE("(0x%04x)\n", hMenu);4468 4662 4469 4663 menu = MENU_GetMenu(hMenu); … … 4481 4675 { 4482 4676 dprintf(("USER32: MenuItemFromPoint not implemented!")); 4483 //FIXME("(0x%04x,0x%04x,(%ld,%ld)):stub\n", 4484 // hWnd, hMenu, ptScreen.x, ptScreen.y); 4677 4485 4678 return 0; 4679 } 4680 4681 /********************************************************************** 4682 * IsMenuActive (Internal) 4683 */ 4684 BOOL IsMenuActive() 4685 { 4686 return pTopPopupWnd && (GetWindowLongA(pTopPopupWnd,GWL_STYLE) & WS_VISIBLE); 4486 4687 } 4487 4688
Note:
See TracChangeset
for help on using the changeset viewer.