/*********************************************************************** * MSSTYLES_FindProperty * * Locate a property in a class. Part and state IDs will be used as a * preference, but may be ignored in the attempt to locate the property. * Will scan the entire chain of overrides for this class. */ PTHEME_PROPERTY MSSTYLES_FindProperty(PTHEME_CLASS tc, int iPartId, int iStateId, int iPropertyPrimitive, int iPropertyId) { PTHEME_CLASS next = tc; PTHEME_PARTSTATE ps; PTHEME_PROPERTY tp; TRACE("(%p, %d, %d, %d)\n", tc, iPartId, iStateId, iPropertyId); /* Try and find an exact match on part & state */ while(next && (ps = MSSTYLES_FindPartState(next, iPartId, iStateId, &next))) { if((tp = MSSTYLES_PSFindProperty(ps, iPropertyPrimitive, iPropertyId))) { return tp; } } /* If that fails, and we didn't already try it, search for just part */ if(iStateId != 0) iStateId = 0; /* As a last ditch attempt..go for just class */ else if(iPartId != 0) iPartId = 0; else return NULL; if((tp = MSSTYLES_FindProperty(tc, iPartId, iStateId, iPropertyPrimitive, iPropertyId))) return tp; return NULL; }
/*********************************************************************** * IsThemePartDefined (UXTHEME.@) */ BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId) { TRACE("(%p,%d,%d)\n", hTheme, iPartId, iStateId); if(!hTheme) { SetLastError(E_HANDLE); return FALSE; } if(MSSTYLES_FindPartState(hTheme, iPartId, iStateId, NULL)) return TRUE; return FALSE; }
/*********************************************************************** * MSSTYLES_AddPartState * * Add a part/state to a class * * PARAMS * tc Theme class * iPartId Part ID to add * iStateId State ID to add * * RETURNS * The part/state added, or a part/state previously added with the same IDs */ static PTHEME_PARTSTATE MSSTYLES_AddPartState(PTHEME_CLASS tc, int iPartId, int iStateId) { PTHEME_PARTSTATE cur = MSSTYLES_FindPartState(tc, iPartId, iStateId, NULL); if(cur) return cur; cur = HeapAlloc(GetProcessHeap(), 0, sizeof(THEME_PARTSTATE)); cur->iPartId = iPartId; cur->iStateId = iStateId; cur->properties = NULL; cur->next = tc->partstate; tc->partstate = cur; return cur; }
/*********************************************************************** * MSSTYLES_FindPartState * * Find a part/state * * PARAMS * tc Class to search * iPartId Part ID to find * iStateId State ID to find * tcNext Receives the next class in the override chain * * RETURNS * The part/state found, or NULL */ PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId, PTHEME_CLASS *tcNext) { PTHEME_PARTSTATE cur = tc->partstate; while(cur) { if(cur->iPartId == iPartId && cur->iStateId == iStateId) { if(tcNext) *tcNext = tc->overrides; return cur; } cur = cur->next; } if(tc->overrides) return MSSTYLES_FindPartState(tc->overrides, iPartId, iStateId, tcNext); return NULL; }