mirror of
https://github.com/reactos/reactos.git
synced 2024-07-21 11:48:04 +00:00
added support for right-aligned menus
svn path=/trunk/; revision=7975
This commit is contained in:
parent
dc7e97f014
commit
af5a3793e1
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: menu.c,v 1.45 2004/01/26 23:22:48 weiden Exp $
|
/* $Id: menu.c,v 1.46 2004/02/01 20:45:02 weiden Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS user32.dll
|
* PROJECT: ReactOS user32.dll
|
||||||
* FILE: lib/user32/windows/menu.c
|
* FILE: lib/user32/windows/menu.c
|
||||||
|
@ -353,8 +353,9 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
|
||||||
HMENU mnu;
|
HMENU mnu;
|
||||||
HANDLE hHeap;
|
HANDLE hHeap;
|
||||||
PVOID Buf, hBuf;
|
PVOID Buf, hBuf;
|
||||||
DWORD BufSize, Items, Items2;
|
DWORD BufSize, Items, Items2, hItems;
|
||||||
MENUITEMINFOW *mii;
|
MENUITEMINFOW *mii;
|
||||||
|
PVOID milist, *mih;
|
||||||
SETMENUITEMRECT smir;
|
SETMENUITEMRECT smir;
|
||||||
RECT *omir, *mir = NULL;
|
RECT *omir, *mir = NULL;
|
||||||
LPWSTR str;
|
LPWSTR str;
|
||||||
|
@ -374,65 +375,113 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
|
||||||
|
|
||||||
if(!Draw)
|
if(!Draw)
|
||||||
{
|
{
|
||||||
bottom = line = Rect->top;
|
bottom = line = Rect->top;
|
||||||
smir.fByPosition = TRUE;
|
smir.fByPosition = TRUE;
|
||||||
smir.uItem = 0;
|
smir.uItem = 0;
|
||||||
/* calculate menu item rectangles */
|
/* calculate menu item rectangles */
|
||||||
while(Items > 0)
|
milist = NULL;
|
||||||
{
|
hItems = 0;
|
||||||
omir = mir;
|
while(Items > 0)
|
||||||
mii = (LPMENUITEMINFOW)Buf;
|
|
||||||
Buf += sizeof(MENUITEMINFOW);
|
|
||||||
mir = (LPRECT)Buf;
|
|
||||||
Buf += sizeof(RECT);
|
|
||||||
if(mii->cch)
|
|
||||||
{
|
{
|
||||||
str = (LPWSTR)Buf;
|
omir = mir;
|
||||||
Buf += (mii->cch + 1) * sizeof(WCHAR);
|
mii = (LPMENUITEMINFOW)Buf;
|
||||||
}
|
Buf += sizeof(MENUITEMINFOW);
|
||||||
else
|
mir = (LPRECT)Buf;
|
||||||
str = NULL;
|
Buf += sizeof(RECT);
|
||||||
if(omir)
|
if(mii->cch)
|
||||||
{
|
{
|
||||||
mir->left = omir->right + 1;
|
str = (LPWSTR)Buf;
|
||||||
mir->top = omir->top;
|
Buf += (mii->cch + 1) * sizeof(WCHAR);
|
||||||
mir->right += mir->left;
|
}
|
||||||
mir->bottom += mir->top;
|
else
|
||||||
}
|
str = NULL;
|
||||||
else
|
if(omir)
|
||||||
{
|
{
|
||||||
mir->left = Rect->left;
|
mir->left = omir->right + 1;
|
||||||
mir->top = Rect->top;
|
mir->top = omir->top;
|
||||||
}
|
mir->right += mir->left;
|
||||||
MeasureMenuItem(hWnd, mnu, hDC, mii, mir, str);
|
mir->bottom += mir->top;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mir->left = Rect->left;
|
||||||
|
mir->top = Rect->top;
|
||||||
|
}
|
||||||
|
if((mii->fType & MFT_RIGHTJUSTIFY) && !milist)
|
||||||
|
{
|
||||||
|
milist = mih = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Items * sizeof(MENUITEMINFOW*));
|
||||||
|
hItems = Items;
|
||||||
|
}
|
||||||
|
|
||||||
if(mir->right > Rect->right)
|
MeasureMenuItem(hWnd, mnu, hDC, mii, mir, str);
|
||||||
|
|
||||||
|
if((mir->right > Rect->right) || (mii->fType & (MFT_MENUBREAK | MFT_MENUBARBREAK)))
|
||||||
|
{
|
||||||
|
mir->right -= (mir->left - Rect->left);
|
||||||
|
mir->left = Rect->left;
|
||||||
|
mir->top += line;
|
||||||
|
mir->bottom += line;
|
||||||
|
line = mir->bottom - mir->top;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!milist)
|
||||||
|
{
|
||||||
|
smir.rcRect = *mir;
|
||||||
|
NtUserSetMenuItemRect(mnu, &smir);
|
||||||
|
smir.uItem++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*(mih++) = mii;
|
||||||
|
}
|
||||||
|
|
||||||
|
bottom = max(bottom, mir->bottom);
|
||||||
|
line = max(line, mir->bottom - mir->top);
|
||||||
|
Items--;
|
||||||
|
}
|
||||||
|
/* align help menus to the right */
|
||||||
|
if(milist)
|
||||||
{
|
{
|
||||||
mir->right -= (mir->left - Rect->left);
|
LONG x;
|
||||||
mir->left = Rect->left;
|
x = Rect->right;
|
||||||
mir->top += line;
|
mii = NULL;
|
||||||
mir->bottom += line;
|
smir.uItem = Items2 - 1;
|
||||||
line = mir->bottom - mir->top;
|
while(hItems > 0)
|
||||||
|
{
|
||||||
|
LONG wd;
|
||||||
|
MENUITEMINFOW *omii;
|
||||||
|
|
||||||
|
omii = mii;
|
||||||
|
mii = (MENUITEMINFOW*)(*(--mih));
|
||||||
|
mir = (LPRECT)(mii + 1);
|
||||||
|
|
||||||
|
if(omii && ((mir->right >= x) || (omii->fType & (MFT_MENUBREAK | MFT_MENUBARBREAK))))
|
||||||
|
{
|
||||||
|
x = Rect->right;
|
||||||
|
}
|
||||||
|
|
||||||
|
wd = (mir->right - mir->left);
|
||||||
|
mir->right = x - 1;
|
||||||
|
mir->left = mir->right - wd;
|
||||||
|
x = mir->left;
|
||||||
|
|
||||||
|
smir.rcRect = *mir;
|
||||||
|
|
||||||
|
NtUserSetMenuItemRect(mnu, &smir);
|
||||||
|
smir.uItem--;
|
||||||
|
hItems--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
smir.rcRect = *mir;
|
if(milist)
|
||||||
NtUserSetMenuItemRect(mnu, &smir);
|
HeapFree(GetProcessHeap(), 0, milist);
|
||||||
|
|
||||||
bottom = max(bottom, mir->bottom);
|
bottom = max(bottom, Rect->top + GetSystemMetrics(SM_CYMENU));
|
||||||
line = max(line, mir->bottom - mir->top);
|
if(bottom - Rect->top > 0)
|
||||||
/* DbgPrint("Measure menu item %ws: (%d, %d, %d, %d)\n", str, mir->left, mir->top, mir->right, mir->bottom); */
|
|
||||||
Items--;
|
|
||||||
smir.uItem++;
|
|
||||||
}
|
|
||||||
bottom = max(bottom, Rect->top + GetSystemMetrics(SM_CYMENU));
|
|
||||||
if(bottom - Rect->top > 0)
|
|
||||||
{
|
|
||||||
if(NtUserSetMenuBarHeight(mnu, bottom - Rect->top) && Draw)
|
|
||||||
{
|
{
|
||||||
/* FIXME - update frame */
|
NtUserSetMenuBarHeight(mnu, bottom - Rect->top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bottom = Rect->bottom;
|
bottom = Rect->bottom;
|
||||||
|
@ -896,8 +945,9 @@ InsertMenuA(
|
||||||
{
|
{
|
||||||
MENUITEMINFOA mii;
|
MENUITEMINFOA mii;
|
||||||
mii.cbSize = sizeof(MENUITEMINFOA);
|
mii.cbSize = sizeof(MENUITEMINFOA);
|
||||||
mii.fMask = MIIM_FTYPE | MIIM_STRING;
|
mii.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE;
|
||||||
mii.fType = 0;
|
mii.fType = 0;
|
||||||
|
mii.fState = MFS_ENABLED;
|
||||||
|
|
||||||
if(uFlags & MF_BITMAP)
|
if(uFlags & MF_BITMAP)
|
||||||
{
|
{
|
||||||
|
@ -907,6 +957,28 @@ InsertMenuA(
|
||||||
{
|
{
|
||||||
mii.fType |= MFT_OWNERDRAW;
|
mii.fType |= MFT_OWNERDRAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(uFlags & MF_RIGHTJUSTIFY)
|
||||||
|
{
|
||||||
|
mii.fType |= MFT_RIGHTJUSTIFY;
|
||||||
|
}
|
||||||
|
if(uFlags & MF_MENUBREAK)
|
||||||
|
{
|
||||||
|
mii.fType |= MFT_MENUBREAK;
|
||||||
|
}
|
||||||
|
if(uFlags & MF_MENUBARBREAK)
|
||||||
|
{
|
||||||
|
mii.fType |= MFT_MENUBARBREAK;
|
||||||
|
}
|
||||||
|
if(uFlags & MF_DISABLED)
|
||||||
|
{
|
||||||
|
mii.fState |= MFS_DISABLED;
|
||||||
|
}
|
||||||
|
if(uFlags & MF_GRAYED)
|
||||||
|
{
|
||||||
|
mii.fState |= MFS_GRAYED;
|
||||||
|
}
|
||||||
|
|
||||||
mii.dwTypeData = (LPSTR)lpNewItem;
|
mii.dwTypeData = (LPSTR)lpNewItem;
|
||||||
if(uFlags & MF_POPUP)
|
if(uFlags & MF_POPUP)
|
||||||
{
|
{
|
||||||
|
@ -1033,8 +1105,9 @@ InsertMenuW(
|
||||||
{
|
{
|
||||||
MENUITEMINFOW mii;
|
MENUITEMINFOW mii;
|
||||||
mii.cbSize = sizeof(MENUITEMINFOW);
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
||||||
mii.fMask = MIIM_FTYPE | MIIM_STRING;
|
mii.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE;
|
||||||
mii.fType = 0;
|
mii.fType = 0;
|
||||||
|
mii.fState = MFS_ENABLED;
|
||||||
|
|
||||||
if(uFlags & MF_BITMAP)
|
if(uFlags & MF_BITMAP)
|
||||||
{
|
{
|
||||||
|
@ -1044,6 +1117,28 @@ InsertMenuW(
|
||||||
{
|
{
|
||||||
mii.fType |= MFT_OWNERDRAW;
|
mii.fType |= MFT_OWNERDRAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(uFlags & MF_RIGHTJUSTIFY)
|
||||||
|
{
|
||||||
|
mii.fType |= MFT_RIGHTJUSTIFY;
|
||||||
|
}
|
||||||
|
if(uFlags & MF_MENUBREAK)
|
||||||
|
{
|
||||||
|
mii.fType |= MFT_MENUBREAK;
|
||||||
|
}
|
||||||
|
if(uFlags & MF_MENUBARBREAK)
|
||||||
|
{
|
||||||
|
mii.fType |= MFT_MENUBARBREAK;
|
||||||
|
}
|
||||||
|
if(uFlags & MF_DISABLED)
|
||||||
|
{
|
||||||
|
mii.fState |= MFS_DISABLED;
|
||||||
|
}
|
||||||
|
if(uFlags & MF_GRAYED)
|
||||||
|
{
|
||||||
|
mii.fState |= MFS_GRAYED;
|
||||||
|
}
|
||||||
|
|
||||||
mii.dwTypeData = (LPWSTR)lpNewItem;
|
mii.dwTypeData = (LPWSTR)lpNewItem;
|
||||||
if(uFlags & MF_POPUP)
|
if(uFlags & MF_POPUP)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue