mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-15 20:39:29 +00:00
win32u: Move GetDialogBaseUnits implementation from user32.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
parent
817dca1099
commit
d65f2492ed
|
@ -1519,22 +1519,7 @@ BOOL WINAPI CheckRadioButton( HWND hwndDlg, int firstID,
|
|||
*/
|
||||
DWORD WINAPI GetDialogBaseUnits(void)
|
||||
{
|
||||
static LONG cx, cy;
|
||||
|
||||
if (!cx)
|
||||
{
|
||||
HDC hdc;
|
||||
|
||||
if ((hdc = GetDC(0)))
|
||||
{
|
||||
cx = GdiGetCharDimensions( hdc, NULL, &cy );
|
||||
NtUserReleaseDC( 0, hdc );
|
||||
}
|
||||
TRACE( "base units = %ld,%ld\n", cx, cy );
|
||||
}
|
||||
|
||||
return MAKELONG( MulDiv( cx, GetDpiForSystem(), USER_DEFAULT_SCREEN_DPI ),
|
||||
MulDiv( cy, GetDpiForSystem(), USER_DEFAULT_SCREEN_DPI ));
|
||||
return NtUserGetDialogBaseUnits();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2724,38 +2724,66 @@ static void get_real_fontname( LOGFONTW *lf, WCHAR fullname[LF_FACESIZE] )
|
|||
lstrcpyW( fullname, lf->lfFaceName );
|
||||
}
|
||||
|
||||
/* get text metrics and/or "average" char width of the specified logfont
|
||||
* for the specified dc */
|
||||
static void get_text_metr_size( HDC hdc, LOGFONTW *plf, TEXTMETRICW * ptm, UINT *psz)
|
||||
static LONG get_char_dimensions( HDC hdc, TEXTMETRICW *metric, LONG *height )
|
||||
{
|
||||
ENUMLOGFONTEXDVW exdv = { .elfEnumLogfontEx.elfLogFont = *plf };
|
||||
HFONT hfont, hfontsav;
|
||||
TEXTMETRICW tm;
|
||||
if (!ptm) ptm = &tm;
|
||||
hfont = NtGdiHfontCreate( &exdv, sizeof(exdv), 0, 0, NULL );
|
||||
if (!hfont || !(hfontsav = NtGdiSelectFont( hdc, hfont )))
|
||||
{
|
||||
ptm->tmHeight = -1;
|
||||
if (psz) *psz = 10;
|
||||
if (hfont) NtGdiDeleteObjectApp( hfont );
|
||||
return;
|
||||
}
|
||||
NtGdiGetTextMetricsW( hdc, ptm, 0 );
|
||||
if (psz)
|
||||
{
|
||||
SIZE sz;
|
||||
static const WCHAR abcdW[] =
|
||||
{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
|
||||
'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
|
||||
'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
|
||||
if (NtGdiGetTextExtentExW( hdc, abcdW, ARRAYSIZE(abcdW), 0, NULL, NULL, &sz, 0 ))
|
||||
*psz = (sz.cx / 26 + 1) / 2;
|
||||
else *psz = 10;
|
||||
|
||||
if (metric && !NtGdiGetTextMetricsW( hdc, metric, 0 )) return 0;
|
||||
|
||||
if (!NtGdiGetTextExtentExW( hdc, abcdW, ARRAYSIZE(abcdW), 0, NULL, NULL, &sz, 0 ))
|
||||
return 0;
|
||||
|
||||
if (height) *height = sz.cy;
|
||||
return (sz.cx / 26 + 1) / 2;
|
||||
}
|
||||
|
||||
/* get text metrics and/or "average" char width of the specified logfont
|
||||
* for the specified dc */
|
||||
static void get_text_metr_size( HDC hdc, LOGFONTW *plf, TEXTMETRICW *metric, UINT *psz)
|
||||
{
|
||||
ENUMLOGFONTEXDVW exdv = { .elfEnumLogfontEx.elfLogFont = *plf };
|
||||
HFONT hfont, hfontsav;
|
||||
TEXTMETRICW tm;
|
||||
UINT ret;
|
||||
if (!metric) metric = &tm;
|
||||
hfont = NtGdiHfontCreate( &exdv, sizeof(exdv), 0, 0, NULL );
|
||||
if (!hfont || !(hfontsav = NtGdiSelectFont( hdc, hfont )))
|
||||
{
|
||||
metric->tmHeight = -1;
|
||||
if (psz) *psz = 10;
|
||||
if (hfont) NtGdiDeleteObjectApp( hfont );
|
||||
return;
|
||||
}
|
||||
ret = get_char_dimensions( hdc, metric, NULL );
|
||||
if (psz) *psz = ret ? ret : 10;
|
||||
NtGdiSelectFont( hdc, hfontsav );
|
||||
NtGdiDeleteObjectApp( hfont );
|
||||
}
|
||||
|
||||
static DWORD get_dialog_base_units(void)
|
||||
{
|
||||
static LONG cx, cy;
|
||||
|
||||
if (!cx)
|
||||
{
|
||||
HDC hdc;
|
||||
|
||||
if ((hdc = NtUserGetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW )))
|
||||
{
|
||||
cx = get_char_dimensions( hdc, NULL, &cy );
|
||||
NtUserReleaseDC( 0, hdc );
|
||||
}
|
||||
TRACE( "base units = %d,%d\n", cx, cy );
|
||||
}
|
||||
|
||||
return MAKELONG( muldiv( cx, get_system_dpi(), USER_DEFAULT_SCREEN_DPI ),
|
||||
muldiv( cy, get_system_dpi(), USER_DEFAULT_SCREEN_DPI ));
|
||||
}
|
||||
|
||||
/* adjust some of the raw values found in the registry */
|
||||
static void normalize_nonclientmetrics( NONCLIENTMETRICSW *pncm)
|
||||
{
|
||||
|
@ -4681,6 +4709,9 @@ ULONG_PTR WINAPI NtUserCallNoParam( ULONG code )
|
|||
case NtUserCallNoParam_GetDesktopWindow:
|
||||
return HandleToUlong( get_desktop_window() );
|
||||
|
||||
case NtUserCallNoParam_GetDialogBaseUnits:
|
||||
return get_dialog_base_units();
|
||||
|
||||
case NtUserCallNoParam_GetInputState:
|
||||
return get_input_state();
|
||||
|
||||
|
|
|
@ -718,6 +718,7 @@ enum
|
|||
{
|
||||
NtUserCallNoParam_DestroyCaret,
|
||||
NtUserCallNoParam_GetDesktopWindow,
|
||||
NtUserCallNoParam_GetDialogBaseUnits,
|
||||
NtUserCallNoParam_GetInputState,
|
||||
NtUserCallNoParam_ReleaseCapture,
|
||||
/* temporary exports */
|
||||
|
@ -735,6 +736,11 @@ static inline HWND NtUserGetDesktopWindow(void)
|
|||
return UlongToHandle( NtUserCallNoParam( NtUserCallNoParam_GetDesktopWindow ));
|
||||
}
|
||||
|
||||
static inline DWORD NtUserGetDialogBaseUnits(void)
|
||||
{
|
||||
return NtUserCallNoParam( NtUserCallNoParam_GetDialogBaseUnits );
|
||||
};
|
||||
|
||||
static inline BOOL NtUserGetInputState(void)
|
||||
{
|
||||
return NtUserCallNoParam( NtUserCallNoParam_GetInputState );
|
||||
|
|
Loading…
Reference in a new issue