Commit af00521e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move NtUserDrawMenuBarTemp implementation from user32.

parent 05b29423
......@@ -119,8 +119,6 @@ static HMENU top_popup_hmenu;
/* Flag set by EndMenu() to force an exit from menu tracking */
static BOOL fEndMenu = FALSE;
DWORD WINAPI DrawMenuBarTemp(HWND hwnd, HDC hDC, LPRECT lprect, HMENU hMenu, HFONT hFont);
static BOOL is_win_menu_disallowed(HWND hwnd)
{
return (GetWindowLongW(hwnd, GWL_STYLE) & (WS_CHILD | WS_POPUP)) == WS_CHILD;
......@@ -1198,81 +1196,6 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, UINT max_height )
}
/***********************************************************************
* MENU_MenuBarCalcSize
*
* FIXME: Word 6 implements its own MDI and its own 'close window' bitmap
* height is off by 1 pixel which causes lengthy window relocations when
* active document window is maximized/restored.
*
* Calculate the size of the menu bar.
*/
static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect,
LPPOPUPMENU lppop, HWND hwndOwner )
{
MENUITEM *lpitem;
UINT start, i, helpPos;
int orgX, orgY;
if ((lprect == NULL) || (lppop == NULL)) return;
if (lppop->nItems == 0) return;
TRACE("lprect %p %s\n", lprect, wine_dbgstr_rect( lprect));
/* Start with a 1 pixel top border.
This corresponds to the difference between SM_CYMENU and SM_CYMENUSIZE. */
SetRect(&lppop->items_rect, 0, 0, lprect->right - lprect->left, 1);
start = 0;
helpPos = ~0U;
lppop->textOffset = 0;
while (start < lppop->nItems)
{
lpitem = &lppop->items[start];
orgX = lppop->items_rect.left;
orgY = lppop->items_rect.bottom;
/* Parse items until line break or end of menu */
for (i = start; i < lppop->nItems; i++, lpitem++)
{
if ((helpPos == ~0U) && (lpitem->fType & MF_RIGHTJUSTIFY)) helpPos = i;
if ((i != start) &&
(lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
TRACE("calling MENU_CalcItemSize org=(%d, %d)\n", orgX, orgY );
debug_print_menuitem (" item: ", lpitem, "");
MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, TRUE, lppop );
if (lpitem->rect.right > lppop->items_rect.right)
{
if (i != start) break;
else lpitem->rect.right = lppop->items_rect.right;
}
lppop->items_rect.bottom = max( lppop->items_rect.bottom, lpitem->rect.bottom );
orgX = lpitem->rect.right;
}
/* Finish the line (set all items to the largest height found) */
while (start < i) lppop->items[start++].rect.bottom = lppop->items_rect.bottom;
}
OffsetRect(&lppop->items_rect, lprect->left, lprect->top);
lppop->Width = lppop->items_rect.right - lppop->items_rect.left;
lppop->Height = lppop->items_rect.bottom - lppop->items_rect.top;
lprect->bottom = lppop->items_rect.bottom;
/* Flush right all items between the MF_RIGHTJUSTIFY and */
/* the last item (if several lines, only move the last line) */
if (helpPos == ~0U) return;
lpitem = &lppop->items[lppop->nItems-1];
orgY = lpitem->rect.top;
orgX = lprect->right - lprect->left;
for (i = lppop->nItems - 1; i >= helpPos; i--, lpitem--) {
if (lpitem->rect.top != orgY) break; /* Other line */
if (lpitem->rect.right >= orgX) break; /* Too far right already */
lpitem->rect.left += orgX - lpitem->rect.right;
lpitem->rect.right = orgX;
orgX = lpitem->rect.left;
}
}
static void draw_scroll_arrow(HDC hdc, int x, int top, int height, BOOL up, BOOL enabled)
{
RECT rect, light_rect;
......@@ -1787,7 +1710,7 @@ UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd )
return GetSystemMetrics(SM_CYMENU);
}
return DrawMenuBarTemp(hwnd, hDC, lprect, hMenu, NULL);
return NtUserDrawMenuBarTemp( hwnd, hDC, lprect, hMenu, NULL );
}
......@@ -4028,67 +3951,6 @@ BOOL WINAPI DrawMenuBar( HWND hwnd )
return NtUserDrawMenuBar( hwnd );
}
/***********************************************************************
* DrawMenuBarTemp (USER32.@)
*
* UNDOCUMENTED !!
*
* called by W98SE desk.cpl Control Panel Applet
*
* Not 100% sure about the param names, but close.
*/
DWORD WINAPI DrawMenuBarTemp(HWND hwnd, HDC hDC, LPRECT lprect, HMENU hMenu, HFONT hFont)
{
LPPOPUPMENU lppop;
UINT i,retvalue;
HFONT hfontOld = 0;
BOOL flat_menu = FALSE;
SystemParametersInfoW (SPI_GETFLATMENU, 0, &flat_menu, 0);
if (!hMenu)
hMenu = GetMenu(hwnd);
if (!hFont)
hFont = get_menu_font(FALSE);
lppop = MENU_GetMenu( hMenu );
if (lppop == NULL || lprect == NULL)
{
retvalue = GetSystemMetrics(SM_CYMENU);
goto END;
}
TRACE("(%p, %p, %p, %p, %p)\n", hwnd, hDC, lprect, hMenu, hFont);
hfontOld = SelectObject( hDC, hFont);
if (lppop->Height == 0)
MENU_MenuBarCalcSize(hDC, lprect, lppop, hwnd);
lprect->bottom = lprect->top + lppop->Height;
FillRect(hDC, lprect, GetSysColorBrush(flat_menu ? COLOR_MENUBAR : COLOR_MENU) );
SelectObject( hDC, SYSCOLOR_GetPen(COLOR_3DFACE));
MoveToEx( hDC, lprect->left, lprect->bottom, NULL );
LineTo( hDC, lprect->right, lprect->bottom );
if (lppop->nItems == 0)
{
retvalue = GetSystemMetrics(SM_CYMENU);
goto END;
}
for (i = 0; i < lppop->nItems; i++)
MENU_DrawMenuItem( hwnd, lppop, hwnd, hDC, &lppop->items[i], TRUE, ODA_DRAWENTIRE );
retvalue = lppop->Height;
END:
if (hfontOld) SelectObject (hDC, hfontOld);
return retvalue;
}
/***********************************************************************
* EndMenu (USER.187)
......
......@@ -194,7 +194,7 @@
@ stdcall DrawIcon(long long long long)
@ stdcall DrawIconEx(long long long long long long long long long) NtUserDrawIconEx
@ stdcall DrawMenuBar(long)
@ stdcall DrawMenuBarTemp(long long ptr long long)
@ stdcall DrawMenuBarTemp(long long ptr long long) NtUserDrawMenuBarTemp
@ stdcall DrawStateA(long long ptr long long long long long long long)
@ stdcall DrawStateW(long long ptr long long long long long long long)
@ stdcall DrawTextA(long str long ptr long)
......
......@@ -1103,6 +1103,19 @@ BOOL WINAPI NtGdiSetBrushOrg( HDC hdc, INT x, INT y, POINT *oldorg )
}
BOOL set_viewport_org( HDC hdc, INT x, INT y, POINT *point )
{
DC *dc;
if (!(dc = get_dc_ptr( hdc ))) return FALSE;
if (point) *point = dc->attr->vport_org;
dc->attr->vport_org.x = x;
dc->attr->vport_org.y = y;
release_dc_ptr( dc );
return NtGdiComputeXformCoefficients( hdc );
}
/***********************************************************************
* NtGdiGetTransform (win32u.@)
*
......
......@@ -138,7 +138,7 @@ static const signed char ltrb_inner_mono[] = {
-1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
};
static BOOL draw_rect_edge( HDC hdc, RECT *rc, UINT type, UINT flags, UINT width )
BOOL draw_rect_edge( HDC hdc, RECT *rc, UINT type, UINT flags, UINT width )
{
int lbi_offset = 0, lti_offset = 0, rti_offset = 0, rbi_offset = 0;
signed char lt_inner, lt_outer, rb_inner, rb_outer;
......@@ -1016,7 +1016,7 @@ static void draw_caption_bar( HDC hdc, const RECT *rect, DWORD style, BOOL activ
}
/* Draw the system icon */
static BOOL draw_nc_sys_button( HWND hwnd, HDC hdc, BOOL down )
BOOL draw_nc_sys_button( HWND hwnd, HDC hdc, BOOL down )
{
HICON icon = get_nc_icon_for_window( hwnd );
......@@ -1122,7 +1122,7 @@ static BOOL draw_push_button( HDC dc, RECT *r, UINT flags )
return TRUE;
}
static BOOL draw_frame_caption( HDC dc, RECT *r, UINT flags )
BOOL draw_frame_caption( HDC dc, RECT *r, UINT flags )
{
RECT rect;
int small_diam = make_square_rect( r, &rect ) - 2;
......@@ -1181,6 +1181,77 @@ static BOOL draw_frame_caption( HDC dc, RECT *r, UINT flags )
return TRUE;
}
BOOL draw_frame_menu( HDC dc, RECT *r, UINT flags )
{
RECT rect;
int dmall_diam = make_square_rect( r, &rect );
HBRUSH prev_brush;
HPEN prev_pen;
POINT points[6];
int xe, ye;
int xc, yc;
BOOL retval = TRUE;
ULONG count;
int i;
fill_rect( dc, r, GetStockObject( WHITE_BRUSH ));
prev_brush = NtGdiSelectBrush( dc, GetStockObject( BLACK_BRUSH ));
prev_pen = NtGdiSelectPen( dc, GetStockObject( BLACK_PEN ));
switch (flags & 0xff)
{
case DFCS_MENUARROW:
i = 187 * dmall_diam / 750;
points[2].x = rect.left + 468 * dmall_diam/ 750;
points[2].y = rect.top + 352 * dmall_diam/ 750 + 1;
points[0].y = points[2].y - i;
points[1].y = points[2].y + i;
points[0].x = points[1].x = points[2].x - i;
count = 3;
NtGdiPolyPolyDraw( dc, points, &count, 1, NtGdiPolyPolygon );
break;
case DFCS_MENUBULLET:
xe = rect.left;
ye = rect.top + dmall_diam - dmall_diam / 2;
xc = rect.left + dmall_diam - dmall_diam / 2;
yc = rect.top + dmall_diam - dmall_diam / 2;
i = 234 * dmall_diam / 750;
i = i < 1 ? 1 : i;
SetRect( &rect, xc - i + i / 2, yc - i + i / 2, xc + i / 2, yc + i / 2 );
NtGdiArcInternal( NtGdiPie, dc, rect.left, rect.top, rect.right, rect.bottom,
xe, ye, xe, ye );
break;
case DFCS_MENUCHECK:
points[0].x = rect.left + 253 * dmall_diam / 1000;
points[0].y = rect.top + 445 * dmall_diam / 1000;
points[1].x = rect.left + 409 * dmall_diam / 1000;
points[1].y = points[0].y + (points[1].x - points[0].x);
points[2].x = rect.left + 690 * dmall_diam / 1000;
points[2].y = points[1].y - (points[2].x - points[1].x);
points[3].x = points[2].x;
points[3].y = points[2].y + 3 * dmall_diam / 16;
points[4].x = points[1].x;
points[4].y = points[1].y + 3 * dmall_diam / 16;
points[5].x = points[0].x;
points[5].y = points[0].y + 3 * dmall_diam / 16;
count = 6;
NtGdiPolyPolyDraw( dc, points, &count, 1, NtGdiPolyPolygon );
break;
default:
WARN( "Invalid menu; flags=0x%04x\n", flags );
retval = FALSE;
break;
}
NtGdiSelectPen( dc, prev_pen );
NtGdiSelectBrush( dc, prev_brush );
return retval;
}
static void draw_close_button( HWND hwnd, HDC hdc, BOOL down, BOOL grayed )
{
RECT rect;
......
......@@ -1160,6 +1160,7 @@ static struct unix_funcs unix_funcs =
NtUserDispatchMessage,
NtUserDragDetect,
NtUserDrawIconEx,
NtUserDrawMenuBarTemp,
NtUserEmptyClipboard,
NtUserEnableMenuItem,
NtUserEndDeferWindowPosEx,
......
......@@ -181,6 +181,7 @@ extern struct dce *get_dc_dce( HDC hdc ) DECLSPEC_HIDDEN;
extern void set_dc_dce( HDC hdc, struct dce *dce ) DECLSPEC_HIDDEN;
extern WORD set_dce_flags( HDC hdc, WORD flags ) DECLSPEC_HIDDEN;
extern DWORD set_stretch_blt_mode( HDC hdc, DWORD mode ) DECLSPEC_HIDDEN;
extern BOOL set_viewport_org( HDC hdc, INT x, INT y, POINT *point ) DECLSPEC_HIDDEN;
extern void DC_InitDC( DC * dc ) DECLSPEC_HIDDEN;
extern void DC_UpdateXforms( DC * dc ) DECLSPEC_HIDDEN;
......
......@@ -851,7 +851,7 @@
@ stub NtUserDrawCaption
@ stub NtUserDrawCaptionTemp
@ stdcall NtUserDrawIconEx(long long long long long long long long long)
@ stub NtUserDrawMenuBarTemp
@ stdcall NtUserDrawMenuBarTemp(long long ptr long long)
@ stub NtUserDwmGetRemoteSessionOcclusionEvent
@ stub NtUserDwmGetRemoteSessionOcclusionState
@ stub NtUserDwmKernelShutdown
......
......@@ -217,6 +217,7 @@ struct unix_funcs
BOOL (WINAPI *pNtUserDragDetect)( HWND hwnd, int x, int y );
BOOL (WINAPI *pNtUserDrawIconEx)( HDC hdc, INT x0, INT y0, HICON icon, INT width,
INT height, UINT istep, HBRUSH hbr, UINT flags );
DWORD (WINAPI *pNtUserDrawMenuBarTemp)( HWND hwnd, HDC hdc, RECT *rect, HMENU handle, HFONT font );
BOOL (WINAPI *pNtUserEmptyClipboard)(void);
BOOL (WINAPI *pNtUserEnableMenuItem)( HMENU handle, UINT id, UINT flags );
BOOL (WINAPI *pNtUserEndDeferWindowPosEx)( HDWP hdwp, BOOL async );
......@@ -365,6 +366,10 @@ extern void register_window_surface( struct window_surface *old,
extern LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
BOOL ansi ) DECLSPEC_HIDDEN;
extern LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
extern BOOL draw_frame_caption( HDC dc, LPRECT r, UINT uFlags ) DECLSPEC_HIDDEN;
extern BOOL draw_frame_menu( HDC dc, RECT *r, UINT flags ) DECLSPEC_HIDDEN;
extern BOOL draw_nc_sys_button( HWND hwnd, HDC hdc, BOOL down ) DECLSPEC_HIDDEN;
extern BOOL draw_rect_edge( HDC hdc, RECT *rc, UINT uType, UINT uFlags, UINT width ) DECLSPEC_HIDDEN;
extern void fill_rect( HDC dc, const RECT *rect, HBRUSH hbrush ) DECLSPEC_HIDDEN;
/* hook.c */
......
......@@ -868,6 +868,12 @@ BOOL WINAPI NtUserDrawIconEx( HDC hdc, INT x0, INT y0, HICON icon, INT width,
return unix_funcs->pNtUserDrawIconEx( hdc, x0, y0, icon, width, height, istep, hbr, flags );
}
DWORD WINAPI NtUserDrawMenuBarTemp( HWND hwnd, HDC hdc, RECT *rect, HMENU handle, HFONT font )
{
if (!unix_funcs) return 0;
return unix_funcs->pNtUserDrawMenuBarTemp( hwnd, hdc, rect, handle, font );
}
BOOL WINAPI NtUserEnableMenuItem( HMENU handle, UINT id, UINT flags )
{
if (!unix_funcs) return FALSE;
......
......@@ -539,6 +539,7 @@ LRESULT WINAPI NtUserDispatchMessage( const MSG *msg );
BOOL WINAPI NtUserDragDetect( HWND hwnd, int x, int y );
BOOL WINAPI NtUserDrawIconEx( HDC hdc, INT x0, INT y0, HICON icon, INT width,
INT height, UINT istep, HBRUSH hbr, UINT flags );
DWORD WINAPI NtUserDrawMenuBarTemp( HWND hwnd, HDC hdc, RECT *rect, HMENU handle, HFONT font );
BOOL WINAPI NtUserEmptyClipboard(void);
BOOL WINAPI NtUserEnableMenuItem( HMENU handle, UINT id, UINT flags );
BOOL WINAPI NtUserEndDeferWindowPosEx( HDWP hdwp, BOOL async );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment