mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 15:23:04 +00:00
- Part 2, Menu.c, cosmetic fixes. Fixed most of all the drawing issues. One outstanding needed fix is Lazarus. There maybe some tweaking needed, over all menus look nice.
svn path=/trunk/; revision=23304
This commit is contained in:
parent
de6dc70c56
commit
55483dc7f6
1 changed files with 106 additions and 61 deletions
|
@ -117,6 +117,8 @@ static WORD ArrowBitmapWidth = 0, ArrowBitmapHeight = 0;
|
||||||
static HBITMAP StdMnArrow = NULL;
|
static HBITMAP StdMnArrow = NULL;
|
||||||
static HBITMAP BmpSysMenu = NULL;
|
static HBITMAP BmpSysMenu = NULL;
|
||||||
|
|
||||||
|
static SIZE MenuCharSize;
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* MenuGetRosMenuInfo
|
* MenuGetRosMenuInfo
|
||||||
*
|
*
|
||||||
|
@ -768,7 +770,9 @@ MenuDrawMenuItem(HWND Wnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
|
||||||
SelectObject(DcMem, OrigBitmap);
|
SelectObject(DcMem, OrigBitmap);
|
||||||
DeleteDC(DcMem);
|
DeleteDC(DcMem);
|
||||||
}
|
}
|
||||||
Rect.left += CheckBitmapWidth;
|
Rect.left += 4;
|
||||||
|
if( !(MenuInfo->dwStyle & MNS_NOCHECK))
|
||||||
|
Rect.left += CheckBitmapWidth;
|
||||||
Rect.right -= ArrowBitmapWidth;
|
Rect.right -= ArrowBitmapWidth;
|
||||||
}
|
}
|
||||||
else if (Item->hbmpItem) /* Draw the bitmap */
|
else if (Item->hbmpItem) /* Draw the bitmap */
|
||||||
|
@ -785,6 +789,9 @@ MenuDrawMenuItem(HWND Wnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
|
||||||
UINT uFormat = MenuBar ? DT_CENTER | DT_VCENTER | DT_SINGLELINE
|
UINT uFormat = MenuBar ? DT_CENTER | DT_VCENTER | DT_SINGLELINE
|
||||||
: DT_LEFT | DT_VCENTER | DT_SINGLELINE;
|
: DT_LEFT | DT_VCENTER | DT_SINGLELINE;
|
||||||
|
|
||||||
|
if( !(MenuInfo->dwStyle & MNS_CHECKORBMP))
|
||||||
|
Rect.left += MenuInfo->maxBmpSize.cx;
|
||||||
|
|
||||||
if (0 != (Item->fState & MFS_DEFAULT))
|
if (0 != (Item->fState & MFS_DEFAULT))
|
||||||
{
|
{
|
||||||
FontOld = SelectObject(Dc, hMenuFontBold);
|
FontOld = SelectObject(Dc, hMenuFontBold);
|
||||||
|
@ -837,6 +844,7 @@ MenuDrawMenuItem(HWND Wnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Rect.right = Item->XTab;
|
||||||
uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE;
|
uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,7 +1186,7 @@ MenuCalcItemSize(HDC Dc, PROSMENUITEMINFO ItemInfo, PROSMENUINFO MenuInfo, HWND
|
||||||
INT OrgX, INT OrgY, BOOL MenuBar)
|
INT OrgX, INT OrgY, BOOL MenuBar)
|
||||||
{
|
{
|
||||||
PWCHAR p;
|
PWCHAR p;
|
||||||
SIZE MenuCharSize;
|
INT itemheight = 0;
|
||||||
UINT CheckBitmapWidth = GetSystemMetrics(SM_CXMENUCHECK);
|
UINT CheckBitmapWidth = GetSystemMetrics(SM_CXMENUCHECK);
|
||||||
|
|
||||||
DPRINT("dc=%x owner=%x (%d,%d)\n", Dc, WndOwner, OrgX, OrgY);
|
DPRINT("dc=%x owner=%x (%d,%d)\n", Dc, WndOwner, OrgX, OrgY);
|
||||||
|
@ -1231,83 +1239,114 @@ MenuCalcItemSize(HDC Dc, PROSMENUITEMINFO ItemInfo, PROSMENUINFO MenuInfo, HWND
|
||||||
ItemInfo->Rect.right += ArrowBitmapWidth + MenuCharSize.cx;
|
ItemInfo->Rect.right += ArrowBitmapWidth + MenuCharSize.cx;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemInfo->XTab = 0;
|
||||||
|
|
||||||
if (ItemInfo->hbmpItem)
|
if (ItemInfo->hbmpItem)
|
||||||
{
|
{
|
||||||
SIZE Size;
|
SIZE Size;
|
||||||
|
|
||||||
if (!MenuBar)
|
if (!MenuBar) /* hbmpItem */
|
||||||
{
|
{
|
||||||
MenuGetBitmapItemSize(ItemInfo, &Size, WndOwner );
|
MenuGetBitmapItemSize(ItemInfo, &Size, WndOwner );
|
||||||
/* Keep the size of the bitmap in callback mode to be able
|
/* Keep the size of the bitmap in callback mode to be able
|
||||||
* to draw it correctly */
|
* to draw it correctly */
|
||||||
ItemInfo->Rect.right = ItemInfo->Rect.left + Size.cx;
|
ItemInfo->Rect.right = ItemInfo->Rect.left + Size.cx;
|
||||||
if (MenuInfo->maxBmpSize.cx < abs(Size.cx) + MENU_ITEM_HBMP_SPACE ||
|
if (MenuInfo->maxBmpSize.cx < abs(Size.cx) + MENU_ITEM_HBMP_SPACE ||
|
||||||
MenuInfo->maxBmpSize.cy < abs(Size.cy))
|
MenuInfo->maxBmpSize.cy < abs(Size.cy))
|
||||||
{
|
{
|
||||||
MenuInfo->maxBmpSize.cx = abs(Size.cx) + MENU_ITEM_HBMP_SPACE;
|
MenuInfo->maxBmpSize.cx = abs(Size.cx) + MENU_ITEM_HBMP_SPACE;
|
||||||
MenuInfo->maxBmpSize.cy = abs(Size.cy);
|
MenuInfo->maxBmpSize.cy = abs(Size.cy);
|
||||||
}
|
}
|
||||||
MenuSetRosMenuInfo(MenuInfo);
|
MenuSetRosMenuInfo(MenuInfo);
|
||||||
|
ItemInfo->Rect.right += Size.cx + 2;
|
||||||
|
itemheight = Size.cy + 2;
|
||||||
|
|
||||||
ItemInfo->Rect.right += 2 * CheckBitmapWidth;
|
if( !(MenuInfo->dwStyle & MNS_NOCHECK))
|
||||||
if (0 != (ItemInfo->fType & MF_POPUP))
|
ItemInfo->Rect.right += 2 * CheckBitmapWidth;
|
||||||
{
|
ItemInfo->Rect.right += 4 + MenuCharSize.cx;
|
||||||
ItemInfo->Rect.right += ArrowBitmapWidth;
|
ItemInfo->XTab = ItemInfo->Rect.right;
|
||||||
}
|
ItemInfo->Rect.right += ArrowBitmapWidth;
|
||||||
}
|
}
|
||||||
else
|
else /* hbmpItem & MenuBar */
|
||||||
{
|
{
|
||||||
MenuGetBitmapItemSize(ItemInfo, &Size, WndOwner );
|
MenuGetBitmapItemSize(ItemInfo, &Size, WndOwner );
|
||||||
ItemInfo->Rect.right += Size.cx;
|
ItemInfo->Rect.right += Size.cx;
|
||||||
ItemInfo->Rect.bottom += Size.cy;
|
if( ItemInfo->Text) ItemInfo->Rect.right += 2;
|
||||||
|
itemheight = Size.cy;
|
||||||
/* Leave space for the sunken border */
|
|
||||||
ItemInfo->Rect.right += 2;
|
|
||||||
ItemInfo->Rect.bottom += 2;
|
|
||||||
|
|
||||||
/* Special case: Minimize button doesn't have a space behind it. */
|
/* Special case: Minimize button doesn't have a space behind it. */
|
||||||
if (ItemInfo->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE ||
|
if (ItemInfo->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE ||
|
||||||
ItemInfo->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE_D)
|
ItemInfo->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE_D)
|
||||||
ItemInfo->Rect.right -= 1;
|
ItemInfo->Rect.right -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (!MenuBar)
|
||||||
|
{
|
||||||
|
if( !(MenuInfo->dwStyle & MNS_NOCHECK))
|
||||||
|
ItemInfo->Rect.right += CheckBitmapWidth;
|
||||||
|
ItemInfo->Rect.right += 4 + MenuCharSize.cx;
|
||||||
|
ItemInfo->XTab = ItemInfo->Rect.right;
|
||||||
|
ItemInfo->Rect.right += ArrowBitmapWidth;
|
||||||
|
}
|
||||||
|
|
||||||
/* it must be a text item - unless it's the system menu */
|
/* it must be a text item - unless it's the system menu */
|
||||||
if (0 == (ItemInfo->fType & MF_SYSMENU) && ItemInfo->Text)
|
if (0 == (ItemInfo->fType & MF_SYSMENU) && ItemInfo->Text)
|
||||||
{
|
{
|
||||||
SIZE Size;
|
HFONT hfontOld = NULL;
|
||||||
|
RECT rc = ItemInfo->Rect;
|
||||||
|
LONG txtheight, txtwidth;
|
||||||
|
|
||||||
GetTextExtentPoint32W(Dc, (LPWSTR) ItemInfo->dwTypeData,
|
if ( ItemInfo->fState & MFS_DEFAULT )
|
||||||
strlenW((LPWSTR) ItemInfo->dwTypeData), &Size);
|
{
|
||||||
|
hfontOld = SelectObject( Dc, hMenuFontBold );
|
||||||
ItemInfo->Rect.right += Size.cx;
|
}
|
||||||
ItemInfo->Rect.bottom += max(Size.cy, GetSystemMetrics(SM_CYMENU) - 1);
|
if (MenuBar)
|
||||||
ItemInfo->XTab = 0;
|
{
|
||||||
|
txtheight = DrawTextW( Dc, ItemInfo->dwTypeData, -1, &rc,
|
||||||
if (MenuBar)
|
DT_SINGLELINE|DT_CALCRECT);
|
||||||
|
ItemInfo->Rect.right += rc.right - rc.left;
|
||||||
|
itemheight = max( max( itemheight, txtheight),
|
||||||
|
GetSystemMetrics( SM_CYMENU) - 1);
|
||||||
|
ItemInfo->Rect.right += 2 * MenuCharSize.cx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((p = strchrW( ItemInfo->dwTypeData, '\t' )) != NULL)
|
||||||
{
|
{
|
||||||
ItemInfo->Rect.right += MENU_BAR_ITEMS_SPACE;
|
RECT tmprc = rc;
|
||||||
}
|
LONG tmpheight;
|
||||||
else if ((p = wcschr((LPWSTR) ItemInfo->dwTypeData, L'\t' )) != NULL)
|
int n = (int)( p - ItemInfo->dwTypeData);
|
||||||
{
|
/* Item contains a tab (only meaningful in popup menus) */
|
||||||
/* Item contains a tab (only meaningful in popup menus) */
|
/* get text size before the tab */
|
||||||
GetTextExtentPoint32W(Dc, (LPWSTR) ItemInfo->dwTypeData,
|
txtheight = DrawTextW( Dc, ItemInfo->dwTypeData, n, &rc,
|
||||||
(int)(p - (LPWSTR) ItemInfo->dwTypeData), &Size);
|
DT_SINGLELINE|DT_CALCRECT);
|
||||||
ItemInfo->XTab = CheckBitmapWidth + MENU_TAB_SPACE + Size.cx;
|
txtwidth = rc.right - rc.left;
|
||||||
ItemInfo->Rect.right += MENU_TAB_SPACE;
|
p += 1; /* advance past the Tab */
|
||||||
}
|
/* get text size after the tab */
|
||||||
else
|
tmpheight = DrawTextW( Dc, p, -1, &tmprc, DT_SINGLELINE|DT_CALCRECT);
|
||||||
|
ItemInfo->XTab += txtwidth;
|
||||||
|
txtheight = max( txtheight, tmpheight);
|
||||||
|
txtwidth += MenuCharSize.cx + /* space for the tab */
|
||||||
|
tmprc.right - tmprc.left; /* space for the short cut */
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (NULL != wcschr((LPWSTR) ItemInfo->dwTypeData, L'\b'))
|
txtheight = DrawTextW( Dc, ItemInfo->dwTypeData, -1, &rc,
|
||||||
{
|
DT_SINGLELINE|DT_CALCRECT);
|
||||||
ItemInfo->Rect.right += MENU_TAB_SPACE;
|
txtwidth = rc.right - rc.left;
|
||||||
}
|
ItemInfo->XTab += txtwidth;
|
||||||
ItemInfo->XTab = ItemInfo->Rect.right - CheckBitmapWidth
|
|
||||||
- ArrowBitmapWidth;
|
|
||||||
}
|
}
|
||||||
}
|
ItemInfo->Rect.right += 2 + txtwidth;
|
||||||
|
itemheight = max( itemheight, max( txtheight + 2, MenuCharSize.cy + 4));
|
||||||
|
}
|
||||||
|
if (hfontOld) SelectObject (Dc, hfontOld);
|
||||||
|
}
|
||||||
|
else if( MenuBar)
|
||||||
|
{
|
||||||
|
itemheight = max( itemheight, GetSystemMetrics(SM_CYMENU)-1);
|
||||||
|
}
|
||||||
|
ItemInfo->Rect.bottom += itemheight;
|
||||||
DPRINT("(%ld,%ld)-(%ld,%ld)\n", ItemInfo->Rect.left, ItemInfo->Rect.top, ItemInfo->Rect.right, ItemInfo->Rect.bottom);
|
DPRINT("(%ld,%ld)-(%ld,%ld)\n", ItemInfo->Rect.left, ItemInfo->Rect.top, ItemInfo->Rect.right, ItemInfo->Rect.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1337,6 +1376,9 @@ MenuPopupMenuCalcSize(PROSMENUINFO MenuInfo, HWND WndOwner)
|
||||||
Start = 0;
|
Start = 0;
|
||||||
MaxX = 2 + 1;
|
MaxX = 2 + 1;
|
||||||
|
|
||||||
|
MenuInfo->maxBmpSize.cx = 0;
|
||||||
|
MenuInfo->maxBmpSize.cy = 0;
|
||||||
|
|
||||||
MenuInitRosMenuItemInfo(&ItemInfo);
|
MenuInitRosMenuItemInfo(&ItemInfo);
|
||||||
while (Start < MenuInfo->MenuItemCount)
|
while (Start < MenuInfo->MenuItemCount)
|
||||||
{
|
{
|
||||||
|
@ -1441,6 +1483,9 @@ MenuMenuBarCalcSize(HDC Dc, LPRECT Rect, PROSMENUINFO MenuInfo, HWND WndOwner)
|
||||||
Start = 0;
|
Start = 0;
|
||||||
HelpPos = -1;
|
HelpPos = -1;
|
||||||
|
|
||||||
|
MenuInfo->maxBmpSize.cx = 0;
|
||||||
|
MenuInfo->maxBmpSize.cy = 0;
|
||||||
|
|
||||||
MenuInitRosMenuItemInfo(&ItemInfo);
|
MenuInitRosMenuItemInfo(&ItemInfo);
|
||||||
while (Start < MenuInfo->MenuItemCount)
|
while (Start < MenuInfo->MenuItemCount)
|
||||||
{
|
{
|
||||||
|
@ -1467,7 +1512,6 @@ MenuMenuBarCalcSize(HDC Dc, LPRECT Rect, PROSMENUINFO MenuInfo, HWND WndOwner)
|
||||||
|
|
||||||
DPRINT("calling MENU_CalcItemSize org=(%d, %d)\n", OrgX, OrgY);
|
DPRINT("calling MENU_CalcItemSize org=(%d, %d)\n", OrgX, OrgY);
|
||||||
MenuCalcItemSize(Dc, &ItemInfo, MenuInfo, WndOwner, OrgX, OrgY, TRUE);
|
MenuCalcItemSize(Dc, &ItemInfo, MenuInfo, WndOwner, OrgX, OrgY, TRUE);
|
||||||
|
|
||||||
if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo))
|
if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo))
|
||||||
{
|
{
|
||||||
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
||||||
|
@ -1770,7 +1814,7 @@ MenuShowPopup(HWND WndOwner, HMENU Menu, UINT Id,
|
||||||
|
|
||||||
if (GetSystemMetrics(SM_CXSCREEN ) < X + Width)
|
if (GetSystemMetrics(SM_CXSCREEN ) < X + Width)
|
||||||
{
|
{
|
||||||
if (0 != XAnchor)
|
if (0 != XAnchor && X >= Width - XAnchor)
|
||||||
{
|
{
|
||||||
X -= Width - XAnchor;
|
X -= Width - XAnchor;
|
||||||
}
|
}
|
||||||
|
@ -1786,7 +1830,7 @@ MenuShowPopup(HWND WndOwner, HMENU Menu, UINT Id,
|
||||||
|
|
||||||
if (GetSystemMetrics(SM_CYSCREEN) < Y + Height)
|
if (GetSystemMetrics(SM_CYSCREEN) < Y + Height)
|
||||||
{
|
{
|
||||||
if (0 != YAnchor)
|
if (0 != YAnchor && Y >= Height + YAnchor)
|
||||||
{
|
{
|
||||||
Y -= Height + YAnchor;
|
Y -= Height + YAnchor;
|
||||||
}
|
}
|
||||||
|
@ -2201,9 +2245,10 @@ MenuShowSubPopup(HWND WndOwner, PROSMENUINFO MenuInfo, BOOL SelectFirst, UINT Fl
|
||||||
if (0 != (MenuInfo->Flags & MF_POPUP))
|
if (0 != (MenuInfo->Flags & MF_POPUP))
|
||||||
{
|
{
|
||||||
Rect.left += ItemInfo.Rect.right - GetSystemMetrics(SM_CXBORDER);
|
Rect.left += ItemInfo.Rect.right - GetSystemMetrics(SM_CXBORDER);
|
||||||
Rect.top += ItemInfo.Rect.top;
|
Rect.top += ItemInfo.Rect.top - 3;
|
||||||
Rect.right = ItemInfo.Rect.left - ItemInfo.Rect.right + GetSystemMetrics(SM_CXBORDER);
|
Rect.right = ItemInfo.Rect.left - ItemInfo.Rect.right + GetSystemMetrics(SM_CXBORDER);
|
||||||
Rect.bottom = ItemInfo.Rect.top - ItemInfo.Rect.bottom;
|
Rect.bottom = ItemInfo.Rect.top - ItemInfo.Rect.bottom - 3 - 2
|
||||||
|
- GetSystemMetrics(SM_CYBORDER);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue