encode and decode themeClass

This makes it possible to theme any themeClass without having to subclass a CPView and return something different from defaultThemeClass. Theme a custom theme class by assigning to a control within the theme descriptor ([control setThemeClass:"your-theme-class"]).
This commit is contained in:
Klaas Pieter Annema
2010-10-26 20:41:56 +02:00
parent c7fdad883a
commit 0fa149b74f
2 changed files with 3 additions and 0 deletions
View File
+3
View File
@@ -2521,6 +2521,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
CPViewSubviewsKey = @"CPViewSubviewsKey",
CPViewSuperviewKey = @"CPViewSuperviewKey",
CPViewTagKey = @"CPViewTagKey",
CPViewThemeClassKey = @"CPViewThemeClassKey",
CPViewThemeStateKey = @"CPViewThemeStateKey",
CPViewWindowKey = @"CPViewWindowKey",
CPViewNextKeyViewKey = @"CPViewNextKeyViewKey",
@@ -2600,6 +2601,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
[self setupViewFlags];
_theme = [CPTheme defaultTheme];
_themeClass = [aCoder decodeObjectForKey:CPViewThemeClassKey];
_themeState = CPThemeState([aCoder decodeIntForKey:CPViewThemeStateKey]);
_themeAttributes = {};
@@ -2687,6 +2689,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
if (previousKeyView !== nil)
[aCoder encodeConditionalObject:previousKeyView forKey:CPViewPreviousKeyViewKey];
[aCoder encodeObject:[self themeClass] forKey:CPViewThemeClassKey];
[aCoder encodeInt:CPThemeStateName(_themeState) forKey:CPViewThemeStateKey];
for (var attributeName in _themeAttributes)