Commit 3582a175 authored by Justin Chevrier's avatar Justin Chevrier Committed by Alexandre Julliard

- Implemented SPI_SETICONMETRICS.

- Fixed SPI_GETICONTITLELOGFONT to only return values retrieved from win.ini on first call and return a cached version in subsequent calls. - Created unit test for SPI_{GET,SET}ICONMETRICS.
parent 5007de8b
......@@ -72,8 +72,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(system);
#define SPI_SETMOUSEHOVERTIME_IDX 28
#define SPI_SETMOUSESCROLLLINES_IDX 29
#define SPI_SETMENUSHOWDELAY_IDX 30
#define SPI_SETICONTITLELOGFONT_IDX 31
#define SPI_WINE_IDX SPI_SETMENUSHOWDELAY_IDX
#define SPI_WINE_IDX SPI_SETICONTITLELOGFONT_IDX
/**
* Names of the registry subkeys of HKEY_CURRENT_USER key and value names
......@@ -236,6 +237,7 @@ static BOOL keyboard_cues = FALSE;
static BOOL gradient_captions = FALSE;
static BOOL listbox_smoothscrolling = FALSE;
static BOOL hot_tracking = FALSE;
static LOGFONTW log_font = { -11,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH };
/***********************************************************************
* GetTimerResolution (USER.14)
......@@ -1295,33 +1297,39 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
case SPI_GETICONTITLELOGFONT: /* 31 */
{
LPLOGFONTW lpLogFont = (LPLOGFONTW)pvParam;
LOGFONTW lfDefault;
if (!pvParam) return FALSE;
/*
* The 'default GDI fonts' seems to be returned.
* If a returned font is not a correct font in your environment,
* please try to fix objects/gdiobj.c at first.
*/
GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(LOGFONTW), &lfDefault );
GetProfileStringW( Desktop, IconTitleFaceName,
lfDefault.lfFaceName,
lpLogFont->lfFaceName, LF_FACESIZE );
lpLogFont->lfHeight = -GetProfileIntW( Desktop, IconTitleSize, 11 );
lpLogFont->lfWidth = 0;
lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
lpLogFont->lfWeight = FW_NORMAL;
lpLogFont->lfItalic = FALSE;
lpLogFont->lfStrikeOut = FALSE;
lpLogFont->lfUnderline = FALSE;
lpLogFont->lfCharSet = lfDefault.lfCharSet; /* at least 'charset' should not be hard-coded */
lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
lpLogFont->lfPitchAndFamily = DEFAULT_PITCH;
lpLogFont->lfQuality = DEFAULT_QUALITY;
spi_idx = SPI_SETICONTITLELOGFONT_IDX;
if (!spi_loaded[spi_idx])
{
/*
* The 'default GDI fonts' seems to be returned.
* If a returned font is not a correct font in your environment,
* please try to fix objects/gdiobj.c at first.
*/
GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(LOGFONTW), &lfDefault );
GetProfileStringW( Desktop, IconTitleFaceName,
lfDefault.lfFaceName,
log_font.lfFaceName,
LF_FACESIZE );
log_font.lfHeight = -GetProfileIntW( Desktop, IconTitleSize, 11 );
log_font.lfWidth = 0;
log_font.lfEscapement = log_font.lfOrientation = 0;
log_font.lfWeight = FW_NORMAL;
log_font.lfItalic = FALSE;
log_font.lfStrikeOut = FALSE;
log_font.lfUnderline = FALSE;
log_font.lfCharSet = lfDefault.lfCharSet; /* at least 'charset' should not be hard-coded */
log_font.lfOutPrecision = OUT_DEFAULT_PRECIS;
log_font.lfClipPrecision = CLIP_DEFAULT_PRECIS;
log_font.lfQuality = DEFAULT_QUALITY;
log_font.lfPitchAndFamily = DEFAULT_PITCH;
spi_loaded[spi_idx] = TRUE;
}
*(LOGFONTW *)pvParam = log_font;
break;
}
......@@ -1535,7 +1543,23 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
}
break;
}
WINE_SPI_FIXME(SPI_SETICONMETRICS); /* 46 WINVER >= 0x400 */
case SPI_SETICONMETRICS: /* 46 WINVER >= 0x400 */
{
LPICONMETRICSW lpIcon = pvParam;
if(lpIcon && lpIcon->cbSize == sizeof(*lpIcon))
{
sysMetrics[SM_CXICONSPACING] = lpIcon->iHorzSpacing;
sysMetrics[SM_CYICONSPACING] = lpIcon->iVertSpacing;
icon_title_wrap = lpIcon->iTitleWrap;
log_font = lpIcon->lfFont;
}
else
{
ret = FALSE;
}
break;
}
case SPI_SETWORKAREA: /* 47 WINVER >= 0x400 */
{
......@@ -2519,6 +2543,27 @@ BOOL WINAPI SystemParametersInfoA( UINT uiAction, UINT uiParam,
break;
}
case SPI_SETICONMETRICS: /* 46 WINVER >= 0x400 */
{
ICONMETRICSW tmp;
LPICONMETRICSA lpimA = (LPICONMETRICSA)pvParam;
if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
{
tmp.cbSize = sizeof(ICONMETRICSW);
ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
if (ret)
{
lpimA->iHorzSpacing = tmp.iHorzSpacing;
lpimA->iVertSpacing = tmp.iVertSpacing;
lpimA->iTitleWrap = tmp.iTitleWrap;
SYSPARAMS_LogFont32WTo32A( &tmp.lfFont, &lpimA->lfFont );
}
}
else
ret = FALSE;
break;
}
case SPI_GETHIGHCONTRAST: /* 66 WINVER >= 0x400 */
{
HIGHCONTRASTW tmp;
......
......@@ -27,6 +27,7 @@
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winreg.h"
#include "winuser.h"
......@@ -997,6 +998,76 @@ static void test_SPI_SETMINIMIZEDMETRICS( void ) /* 44 */
eq( lpMm_new.iArrange, lpMm_orig.iArrange, "iArrange", "%d" );
}
static void test_SPI_SETICONMETRICS( void ) /* 46 */
{
BOOL rc;
ICONMETRICSA im_orig;
ICONMETRICSA im_new;
ICONMETRICSA im_cur;
im_orig.cbSize = sizeof(ICONMETRICSA);
im_new.cbSize = sizeof(ICONMETRICSA);
im_cur.cbSize = sizeof(ICONMETRICSA);
trace("testing SPI_{GET,SET}ICONMETRICS\n");
rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_orig, FALSE );
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
im_cur.iHorzSpacing = 65;
im_cur.iVertSpacing = 65;
im_cur.iTitleWrap = 0;
im_cur.lfFont.lfHeight = 1;
im_cur.lfFont.lfWidth = 1;
im_cur.lfFont.lfEscapement = 1;
im_cur.lfFont.lfWeight = 1;
im_cur.lfFont.lfItalic = 1;
im_cur.lfFont.lfStrikeOut = 1;
im_cur.lfFont.lfUnderline = 1;
im_cur.lfFont.lfCharSet = 1;
im_cur.lfFont.lfOutPrecision = 1;
im_cur.lfFont.lfClipPrecision = 1;
im_cur.lfFont.lfPitchAndFamily = 1;
im_cur.lfFont.lfQuality = 1;
rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_cur, FALSE );
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE );
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
eq( im_new.iHorzSpacing, im_cur.iHorzSpacing, "iHorzSpacing", "%d" );
eq( im_new.iVertSpacing, im_cur.iVertSpacing, "iVertSpacing", "%d" );
eq( im_new.iTitleWrap, im_cur.iTitleWrap, "iTitleWrap", "%d" );
eq( im_new.lfFont.lfHeight, im_cur.lfFont.lfHeight, "lfHeight", "%ld" );
eq( im_new.lfFont.lfWidth, im_cur.lfFont.lfWidth, "lfWidth", "%ld" );
eq( im_new.lfFont.lfEscapement, im_cur.lfFont.lfEscapement, "lfEscapement", "%ld" );
eq( im_new.lfFont.lfWeight, im_cur.lfFont.lfWeight, "lfWeight", "%ld" );
eq( im_new.lfFont.lfItalic, im_cur.lfFont.lfItalic, "lfItalic", "%d" );
eq( im_new.lfFont.lfStrikeOut, im_cur.lfFont.lfStrikeOut, "lfStrikeOut", "%d" );
eq( im_new.lfFont.lfUnderline, im_cur.lfFont.lfUnderline, "lfUnderline", "%d" );
eq( im_new.lfFont.lfCharSet, im_cur.lfFont.lfCharSet, "lfCharSet", "%d" );
eq( im_new.lfFont.lfOutPrecision, im_cur.lfFont.lfOutPrecision, "lfOutPrecision", "%d" );
eq( im_new.lfFont.lfClipPrecision, im_cur.lfFont.lfClipPrecision, "lfClipPrecision", "%d" );
eq( im_new.lfFont.lfPitchAndFamily, im_cur.lfFont.lfPitchAndFamily, "lfPitchAndFamily", "%d" );
eq( im_new.lfFont.lfQuality, im_cur.lfFont.lfQuality, "lfQuality", "%d" );
eq( GetSystemMetrics( SM_CXICONSPACING ),
im_new.iHorzSpacing, "iHorzSpacing", "%d" );
eq( GetSystemMetrics( SM_CYICONSPACING ),
im_new.iVertSpacing, "iVertSpacing", "%d" );
rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_orig, FALSE );
ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE );
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
eq( im_new.iHorzSpacing, im_orig.iHorzSpacing, "iHorzSpacing", "%d" );
eq( im_new.iVertSpacing, im_orig.iVertSpacing, "iVertSpacing", "%d" );
eq( im_new.iTitleWrap, im_orig.iTitleWrap, "iTitleWrap", "%d" );
}
static void test_SPI_SETWORKAREA( void ) /* 47 */
{
BOOL rc;
......@@ -1343,6 +1414,7 @@ static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
test_SPI_SETFASTTASKSWITCH(); /* 36 */
test_SPI_SETDRAGFULLWINDOWS(); /* 37 */
test_SPI_SETMINIMIZEDMETRICS(); /* 44 */
test_SPI_SETICONMETRICS(); /* 46 */
test_SPI_SETWORKAREA(); /* 47 */
test_SPI_SETSHOWSOUNDS(); /* 57 */
test_SPI_SETKEYBOARDPREF(); /* 69 */
......
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