Commit 05b29423 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move WM_NCCALCSIZE implementation from user32.

parent 81d04f93
......@@ -114,8 +114,6 @@ extern BOOL update_wallpaper( const WCHAR *wallpaper, const WCHAR *pattern ) DEC
/* menu controls */
extern HWND MENU_IsMenuActive(void) DECLSPEC_HIDDEN;
extern UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth,
INT orgX, INT orgY ) DECLSPEC_HIDDEN;
extern void MENU_TrackMouseMenuBar( HWND hwnd, INT ht, POINT pt ) DECLSPEC_HIDDEN;
extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar ) DECLSPEC_HIDDEN;
extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd ) DECLSPEC_HIDDEN;
......@@ -123,7 +121,6 @@ extern void MENU_EndMenu(HWND) DECLSPEC_HIDDEN;
extern HMENU MENU_GetSysMenu( HWND hWnd, HMENU hPopupMenu ) DECLSPEC_HIDDEN;
/* nonclient area */
extern void NC_HandleNCCalcSize( HWND hwnd, WPARAM wParam, RECT *winRect ) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleNCHitTest( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleNCMouseMove( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
......
......@@ -173,10 +173,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
return NC_HandleNCHitTest( hwnd, pt );
}
case WM_NCCALCSIZE:
NC_HandleNCCalcSize( hwnd, wParam, (RECT *)lParam );
break;
case WM_WINDOWPOSCHANGED:
DEFWND_HandleWindowPosChanged( hwnd, (const WINDOWPOS *)lParam );
break;
......
......@@ -3506,31 +3506,6 @@ LRESULT WINAPI PopupMenuWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM
}
/***********************************************************************
* MENU_GetMenuBarHeight
*
* Compute the size of the menu bar height. Used by NC_HandleNCCalcSize().
*/
UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth,
INT orgX, INT orgY )
{
HDC hdc;
RECT rectBar;
LPPOPUPMENU lppop;
TRACE("HWND %p, width %d, at (%d, %d).\n", hwnd, menubarWidth, orgX, orgY );
if (!(lppop = MENU_GetMenu( GetMenu(hwnd) ))) return 0;
hdc = NtUserGetDCEx( hwnd, 0, DCX_CACHE | DCX_WINDOW );
SelectObject( hdc, get_menu_font(FALSE));
SetRect(&rectBar, orgX, orgY, orgX+menubarWidth, orgY+GetSystemMetrics(SM_CYMENU));
MENU_MenuBarCalcSize( hdc, &rectBar, lppop, hwnd );
NtUserReleaseDC( hwnd, hdc );
return lppop->Height;
}
/*******************************************************************
* ChangeMenuA (USER32.@)
*/
......
......@@ -342,76 +342,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRectExForDpi( LPRECT rect, DWORD style
/***********************************************************************
* NC_HandleNCCalcSize
*
* Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
*/
void NC_HandleNCCalcSize( HWND hwnd, WPARAM wparam, RECT *winRect )
{
RECT tmpRect = { 0, 0, 0, 0 };
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
LONG exStyle = GetWindowLongW( hwnd, GWL_EXSTYLE );
if (winRect == NULL)
return;
if (!(style & WS_MINIMIZE))
{
AdjustWindowRectEx( &tmpRect, style, FALSE, exStyle & ~WS_EX_CLIENTEDGE);
winRect->left -= tmpRect.left;
winRect->top -= tmpRect.top;
winRect->right -= tmpRect.right;
winRect->bottom -= tmpRect.bottom;
if (((style & (WS_CHILD | WS_POPUP)) != WS_CHILD) && GetMenu(hwnd))
{
TRACE("Calling GetMenuBarHeight with hwnd %p, width %ld, at (%ld, %ld).\n",
hwnd, winRect->right - winRect->left, -tmpRect.left, -tmpRect.top );
winRect->top +=
MENU_GetMenuBarHeight( hwnd,
winRect->right - winRect->left,
-tmpRect.left, -tmpRect.top );
}
if( exStyle & WS_EX_CLIENTEDGE)
if( winRect->right - winRect->left > 2 * GetSystemMetrics(SM_CXEDGE) &&
winRect->bottom - winRect->top > 2 * GetSystemMetrics(SM_CYEDGE))
InflateRect( winRect, - GetSystemMetrics(SM_CXEDGE),
- GetSystemMetrics(SM_CYEDGE));
if (style & WS_VSCROLL)
if (winRect->right - winRect->left >= GetSystemMetrics(SM_CXVSCROLL))
{
/* rectangle is in screen coords when wparam is false */
if (!wparam && (exStyle & WS_EX_LAYOUTRTL)) exStyle ^= WS_EX_LEFTSCROLLBAR;
if((exStyle & WS_EX_LEFTSCROLLBAR) != 0)
winRect->left += GetSystemMetrics(SM_CXVSCROLL);
else
winRect->right -= GetSystemMetrics(SM_CXVSCROLL);
}
if (style & WS_HSCROLL)
if( winRect->bottom - winRect->top > GetSystemMetrics(SM_CYHSCROLL))
winRect->bottom -= GetSystemMetrics(SM_CYHSCROLL);
if (winRect->top > winRect->bottom)
winRect->bottom = winRect->top;
if (winRect->left > winRect->right)
winRect->right = winRect->left;
}
else
{
winRect->right = winRect->left;
winRect->bottom = winRect->top;
}
}
/***********************************************************************
* NC_GetInsideRect
*
* Get the 'inside' rectangle of a window, i.e. the whole window rectangle
......
......@@ -1487,6 +1487,66 @@ static LRESULT handle_nc_activate( HWND hwnd, WPARAM wparam, LPARAM lparam )
return TRUE;
}
static void handle_nc_calc_size( HWND hwnd, WPARAM wparam, RECT *win_rect )
{
RECT rect = { 0, 0, 0, 0 };
LONG style = get_window_long( hwnd, GWL_STYLE );
LONG ex_style = get_window_long( hwnd, GWL_EXSTYLE );
if (!win_rect) return;
if (!(style & WS_MINIMIZE))
{
AdjustWindowRectEx( &rect, style, FALSE, ex_style & ~WS_EX_CLIENTEDGE );
win_rect->left -= rect.left;
win_rect->top -= rect.top;
win_rect->right -= rect.right;
win_rect->bottom -= rect.bottom;
if (((style & (WS_CHILD | WS_POPUP)) != WS_CHILD) && get_menu( hwnd ))
{
TRACE( "getting menu bar height with hwnd %p, width %d, at (%d, %d)\n",
hwnd, win_rect->right - win_rect->left, -rect.left, -rect.top );
win_rect->top += get_menu_bar_height( hwnd, win_rect->right - win_rect->left,
-rect.left, -rect.top );
}
if (ex_style & WS_EX_CLIENTEDGE)
if (win_rect->right - win_rect->left > 2 * get_system_metrics( SM_CXEDGE ) &&
win_rect->bottom - win_rect->top > 2 * get_system_metrics( SM_CYEDGE ))
InflateRect( win_rect, -get_system_metrics( SM_CXEDGE ),
-get_system_metrics( SM_CYEDGE ));
if ((style & WS_VSCROLL) &&
win_rect->right - win_rect->left >= get_system_metrics( SM_CXVSCROLL ))
{
/* rectangle is in screen coords when wparam is false */
if (!wparam && (ex_style & WS_EX_LAYOUTRTL)) ex_style ^= WS_EX_LEFTSCROLLBAR;
if (ex_style & WS_EX_LEFTSCROLLBAR)
win_rect->left += get_system_metrics( SM_CXVSCROLL );
else
win_rect->right -= get_system_metrics( SM_CXVSCROLL );
}
if ((style & WS_HSCROLL) &&
win_rect->bottom - win_rect->top > get_system_metrics( SM_CYHSCROLL ))
{
win_rect->bottom -= get_system_metrics( SM_CYHSCROLL );
}
if (win_rect->top > win_rect->bottom) win_rect->bottom = win_rect->top;
if (win_rect->left > win_rect->right) win_rect->right = win_rect->left;
}
else
{
win_rect->right = win_rect->left;
win_rect->bottom = win_rect->top;
}
}
LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi )
{
LRESULT result = 0;
......@@ -1514,6 +1574,10 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
break;
}
case WM_NCCALCSIZE:
handle_nc_calc_size( hwnd, wparam, (RECT *)lparam );
break;
case WM_NCPAINT:
return handle_nc_paint( hwnd, (HRGN)wparam );
......
......@@ -2724,7 +2724,7 @@ static void get_real_fontname( LOGFONTW *lf, WCHAR fullname[LF_FACESIZE] )
lstrcpyW( fullname, lf->lfFaceName );
}
static LONG get_char_dimensions( HDC hdc, TEXTMETRICW *metric, LONG *height )
LONG get_char_dimensions( HDC hdc, TEXTMETRICW *metric, LONG *height )
{
SIZE sz;
static const WCHAR abcdW[] =
......@@ -2763,7 +2763,7 @@ static void get_text_metr_size( HDC hdc, LOGFONTW *lf, TEXTMETRICW *metric, UINT
NtGdiDeleteObjectApp( hfont );
}
static DWORD get_dialog_base_units(void)
DWORD get_dialog_base_units(void)
{
static LONG cx, cy;
......
......@@ -392,6 +392,7 @@ extern void update_mouse_tracking_info( HWND hwnd ) DECLSPEC_HIDDEN;
extern HMENU create_menu( BOOL is_popup ) DECLSPEC_HIDDEN;
extern BOOL draw_menu_bar( HWND hwnd ) DECLSPEC_HIDDEN;
extern HMENU get_menu( HWND hwnd ) DECLSPEC_HIDDEN;
extern UINT get_menu_bar_height( HWND hwnd, UINT width, INT org_x, INT org_y ) DECLSPEC_HIDDEN;
extern BOOL get_menu_info( HMENU handle, MENUINFO *info ) DECLSPEC_HIDDEN;
extern INT get_menu_item_count( HMENU handle ) DECLSPEC_HIDDEN;
extern UINT get_menu_state( HMENU handle, UINT item_id, UINT flags ) DECLSPEC_HIDDEN;
......@@ -413,6 +414,8 @@ extern LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM
/* sysparams.c */
extern BOOL enable_thunk_lock DECLSPEC_HIDDEN;
extern HBRUSH get_55aa_brush(void) DECLSPEC_HIDDEN;
extern DWORD get_dialog_base_units(void) DECLSPEC_HIDDEN;
extern LONG get_char_dimensions( HDC hdc, TEXTMETRICW *metric, LONG *height ) DECLSPEC_HIDDEN;
extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN;
extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN;
extern BOOL get_monitor_info( HMONITOR handle, MONITORINFO *info ) DECLSPEC_HIDDEN;
......
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