Commit 3e4bdad4 authored by Frank Richter's avatar Frank Richter Committed by Alexandre Julliard

uxtheme: Split color handling out of MSSTYLES_ParseThemeIni into smaller helper functions.

parent f34412b9
...@@ -664,6 +664,61 @@ static PTHEME_PROPERTY MSSTYLES_AddMetric(PTHEME_FILE tf, int iPropertyPrimitive ...@@ -664,6 +664,61 @@ static PTHEME_PROPERTY MSSTYLES_AddMetric(PTHEME_FILE tf, int iPropertyPrimitive
return cur; return cur;
} }
/* Color-related state for theme ini parsing */
struct PARSECOLORSTATE
{
int colorCount;
int colorElements[TMT_LASTCOLOR-TMT_FIRSTCOLOR];
COLORREF colorRgb[TMT_LASTCOLOR-TMT_FIRSTCOLOR];
int captionColors;
};
inline void parse_init_color (struct PARSECOLORSTATE* state)
{
memset (state, 0, sizeof (*state));
}
static BOOL parse_handle_color_property (struct PARSECOLORSTATE* state,
int iPropertyId, LPCWSTR lpValue,
DWORD dwValueLen)
{
int r,g,b;
LPCWSTR lpValueEnd = lpValue + dwValueLen;
MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &r);
MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &g);
if(MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &b)) {
state->colorElements[state->colorCount] = iPropertyId - TMT_FIRSTCOLOR;
state->colorRgb[state->colorCount++] = RGB(r,g,b);
switch (iPropertyId)
{
case TMT_ACTIVECAPTION:
state->captionColors |= 0x1;
break;
case TMT_INACTIVECAPTION:
state->captionColors |= 0x2;
break;
case TMT_GRADIENTACTIVECAPTION:
state->captionColors |= 0x4;
break;
case TMT_GRADIENTINACTIVECAPTION:
state->captionColors |= 0x8;
break;
}
return TRUE;
}
else {
return FALSE;
}
}
static void parse_apply_color (struct PARSECOLORSTATE* state)
{
if (state->colorCount > 0)
SetSysColors(state->colorCount, state->colorElements, state->colorRgb);
if (state->captionColors == 0xf)
SystemParametersInfoW (SPI_SETGRADIENTCAPTIONS, 0, (PVOID)TRUE, 0);
}
/*********************************************************************** /***********************************************************************
* MSSTYLES_ParseThemeIni * MSSTYLES_ParseThemeIni
* *
...@@ -696,42 +751,18 @@ void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics) ...@@ -696,42 +751,18 @@ void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics)
while((lpName=UXINI_GetNextSection(ini, &dwLen))) { while((lpName=UXINI_GetNextSection(ini, &dwLen))) {
if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, lpName, dwLen, szSysMetrics, -1) == CSTR_EQUAL) { if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, lpName, dwLen, szSysMetrics, -1) == CSTR_EQUAL) {
int colorCount = 0; struct PARSECOLORSTATE colorState;
int colorElements[TMT_LASTCOLOR-TMT_FIRSTCOLOR];
COLORREF colorRgb[TMT_LASTCOLOR-TMT_FIRSTCOLOR]; parse_init_color (&colorState);
LPCWSTR lpValueEnd;
int captionColors = 0;
while((lpName=UXINI_GetNextValue(ini, &dwLen, &lpValue, &dwValueLen))) { while((lpName=UXINI_GetNextValue(ini, &dwLen, &lpValue, &dwValueLen))) {
lstrcpynW(szPropertyName, lpName, min(dwLen+1, sizeof(szPropertyName)/sizeof(szPropertyName[0]))); lstrcpynW(szPropertyName, lpName, min(dwLen+1, sizeof(szPropertyName)/sizeof(szPropertyName[0])));
if(MSSTYLES_LookupProperty(szPropertyName, &iPropertyPrimitive, &iPropertyId)) { if(MSSTYLES_LookupProperty(szPropertyName, &iPropertyPrimitive, &iPropertyId)) {
if(iPropertyId >= TMT_FIRSTCOLOR && iPropertyId <= TMT_LASTCOLOR) { if(iPropertyId >= TMT_FIRSTCOLOR && iPropertyId <= TMT_LASTCOLOR) {
int r,g,b; if (!parse_handle_color_property (&colorState, iPropertyId,
lpValueEnd = lpValue + dwValueLen; lpValue, dwValueLen))
MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &r); FIXME("Invalid color value for %s\n",
MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &g); debugstr_w(szPropertyName));
if(MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &b)) {
colorElements[colorCount] = iPropertyId - TMT_FIRSTCOLOR;
colorRgb[colorCount++] = RGB(r,g,b);
switch (iPropertyId)
{
case TMT_ACTIVECAPTION:
captionColors |= 0x1;
break;
case TMT_INACTIVECAPTION:
captionColors |= 0x2;
break;
case TMT_GRADIENTACTIVECAPTION:
captionColors |= 0x4;
break;
case TMT_GRADIENTINACTIVECAPTION:
captionColors |= 0x8;
break;
}
}
else {
FIXME("Invalid color value for %s\n", debugstr_w(szPropertyName));
}
} }
else if (setMetrics && (iPropertyId == TMT_FLATMENUS)) { else if (setMetrics && (iPropertyId == TMT_FLATMENUS)) {
BOOL flatMenus = (*lpValue == 'T') || (*lpValue == 't'); BOOL flatMenus = (*lpValue == 'T') || (*lpValue == 't');
...@@ -744,10 +775,7 @@ void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics) ...@@ -744,10 +775,7 @@ void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics)
TRACE("Unknown system metric %s\n", debugstr_w(szPropertyName)); TRACE("Unknown system metric %s\n", debugstr_w(szPropertyName));
} }
} }
if (setMetrics && (colorCount > 0)) if (setMetrics) parse_apply_color (&colorState);
SetSysColors(colorCount, colorElements, colorRgb);
if (setMetrics && (captionColors == 0xf))
SystemParametersInfoW (SPI_SETGRADIENTCAPTIONS, 0, (PVOID)TRUE, 0);
continue; continue;
} }
if(MSSTYLES_ParseIniSectionName(lpName, dwLen, szAppName, szClassName, &iPartId, &iStateId)) { if(MSSTYLES_ParseIniSectionName(lpName, dwLen, szAppName, szClassName, &iPartId, &iStateId)) {
......
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