ERR("MenuInit(): CreateFontIndirectW(hMenuFont) failed!\n");
return FALSE;
}
- ncm.lfMenuFont.lfWeight = max(ncm.lfMenuFont.lfWeight + 300, 1000);
+ ncm.lfMenuFont.lfWeight = min(ncm.lfMenuFont.lfWeight + (FW_BOLD - FW_NORMAL), FW_HEAVY);
ghMenuFontBold = GreCreateFontIndirectW(&ncm.lfMenuFont);
if (ghMenuFontBold == NULL)
{
drawItem.itemData = lpitem->dwItemData;
/* some applications make this assumption on the DC's origin */
GreSetViewportOrgEx( hdc, lpitem->xItem, lpitem->yItem, &origorg);
- RECTL_vOffsetRect( &drawItem.rcItem, - lpitem->xItem, - lpitem->yItem);
+ RECTL_vOffsetRect(&drawItem.rcItem, -(LONG)lpitem->xItem, -(LONG)lpitem->yItem);
co_IntSendMessage( UserHMGetHandle(WndOwner), WM_DRAWITEM, 0, (LPARAM)&drawItem);
GreSetViewportOrgEx( hdc, origorg.x, origorg.y, NULL);
return;
* Display a popup menu.
*/
static BOOL FASTCALL MENU_ShowPopup(PWND pwndOwner, PMENU menu, UINT id, UINT flags,
- INT x, INT y, INT xanchor, INT yanchor )
+ INT x, INT y)
{
UINT width, height;
POINT pt;
PMONITOR monitor;
PWND pWnd;
USER_REFERENCE_ENTRY Ref;
+ BOOL bIsPopup = (flags & TPM_POPUPMENU) != 0;
- TRACE("owner=%p menu=%p id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n",
- pwndOwner, menu, id, x, y, xanchor, yanchor);
+ TRACE("owner=%p menu=%p id=0x%04x x=0x%04x y=0x%04x\n",
+ pwndOwner, menu, id, x, y);
if (menu->iItem != NO_SELECTED_ITEM)
{
pt.y = y;
monitor = UserMonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST );
- if (flags & TPM_LAYOUTRTL)
+ if (flags & TPM_LAYOUTRTL)
flags ^= TPM_RIGHTALIGN;
if( flags & TPM_RIGHTALIGN ) x -= width;
if( x + width > monitor->rcMonitor.right)
{
- if( xanchor && x >= width - xanchor )
- x -= width - xanchor;
-
if( x + width > monitor->rcMonitor.right)
- x = monitor->rcMonitor.right - width;
+ {
+ /* If we would flip around our origin, would we go off screen on the other side?
+ Or is our origin itself too far to the right already? */
+ if (!bIsPopup || x - width < monitor->rcMonitor.left || x > monitor->rcMonitor.right)
+ x = monitor->rcMonitor.right - width;
+ else
+ x -= width;
+ }
+ }
+ if( x < monitor->rcMonitor.left )
+ {
+ /* If we would flip around our origin, would we go off screen on the other side? */
+ if (!bIsPopup || x + width > monitor->rcMonitor.right)
+ x = monitor->rcMonitor.left;
+ else
+ x += width;
}
- if( x < monitor->rcMonitor.left ) x = monitor->rcMonitor.left;
if( y + height > monitor->rcMonitor.bottom)
{
- if( yanchor && y >= height + yanchor )
- y -= height + yanchor;
-
if( y + height > monitor->rcMonitor.bottom)
- y = monitor->rcMonitor.bottom - height;
+ {
+ /* If we would flip around our origin, would we go off screen on the other side?
+ Or is our origin itself too far to the bottom already? */
+ if (!bIsPopup || y - height < monitor->rcMonitor.top || y > monitor->rcMonitor.bottom)
+ y = monitor->rcMonitor.bottom - height;
+ else
+ y -= height;
+ }
+ }
+ if( y < monitor->rcMonitor.top )
+ {
+ /* If we would flip around our origin, would we go off screen on the other side? */
+ if (!bIsPopup || y + height > monitor->rcMonitor.bottom)
+ y = monitor->rcMonitor.top;
+ else
+ y += height;
}
- if( y < monitor->rcMonitor.top ) y = monitor->rcMonitor.top;
pWnd = ValidateHwndNoErr( menu->hWnd );
MENU_InitPopup( WndOwner, Item->spSubMenu, Flags );
MENU_ShowPopup( WndOwner, Item->spSubMenu, Menu->iItem, Flags,
- Rect.left, Rect.top, Rect.right, Rect.bottom );
+ Rect.left, Rect.top);
if (SelectFirst)
{
MENU_MoveSelection(WndOwner, Item->spSubMenu, ITEM_NEXT);
if (menu->fFlags & MNF_SYSMENU)
MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
- if (MENU_ShowPopup(pWnd, menu, 0, wFlags, x, y, 0, 0 ))
+ if (MENU_ShowPopup(pWnd, menu, 0, wFlags | TPM_POPUPMENU, x, y))
ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd,
lpTpm ? &lpTpm->rcExclude : NULL);
else
{
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
pPopupMenu->spmenu = UserGetMenuObject(cs->lpCreateParams);
+ if (pPopupMenu->spmenu)
+ {
+ UserReferenceObject(pPopupMenu->spmenu);
+ }
break;
}
case WM_NCDESTROY:
{
+ if (pPopupMenu->spmenu)
+ {
+ IntReleaseMenuObject(pPopupMenu->spmenu);
+ }
DesktopHeapFree(Wnd->head.rpdesk, pPopupMenu );
((PMENUWND)Wnd)->ppopupmenu = 0;
Wnd->fnid = FNID_DESTROY;
ERR("Bad Menu Handle\n");
break;
}
+ UserReferenceObject(pmenu);
+ if (pPopupMenu->spmenu)
+ {
+ IntReleaseMenuObject(pPopupMenu->spmenu);
+ }
pPopupMenu->spmenu = pmenu;
break;
}