mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 21:17:03 +00:00
Merge branch 'runtime-theming'
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ CPCriticalAlertStyle = 2;
|
||||
id _modalDelegate;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"alert";
|
||||
}
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ CPButtonImageOffset = 3.0;
|
||||
return button;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"button";
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
return button;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"button-bar";
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ CPCheckBoxImageOffset = 4.0;
|
||||
return [self buttonWithTitle:aTitle];
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"check-box";
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
CPMenu _menu;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return "popup-button";
|
||||
}
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ CPRadioImageOffset = 4.0;
|
||||
return button;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"radio";
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
CPBorderType _borderType;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"scrollview"
|
||||
}
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
|
||||
CGPoint _trackingStartPoint;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return "scroller";
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ var RECENT_SEARCH_PREFIX = @" ";
|
||||
CPTimer _partialStringTimer;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"searchfield"
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
BOOL _trackingHighlighted;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return "segmented-control";
|
||||
}
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ CPCircularSlider = 1;
|
||||
BOOL _isVertical;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return "slider";
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ var CPSplitViewHorizontalImage = nil,
|
||||
CPArray _buttonBars;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"splitview";
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
_CPImageAndTextView _textField;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"columnHeader";
|
||||
}
|
||||
@@ -168,7 +168,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
CPTableView _tableView @accessors(property=tableView);
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"tableHeaderRow";
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
CPArray _differedColumnDataToRemove;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"tableview";
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return textField;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return "textfield";
|
||||
}
|
||||
|
||||
+8
-3
@@ -100,7 +100,7 @@ var CPThemesByName = { },
|
||||
ThemeDescriptors.j file.
|
||||
|
||||
NOTE: The names are not class names (such as "CPButton"), but the names returned
|
||||
by the class' +themeClass method. For example, the name for CPCheckBox is "check-box",
|
||||
by the class' +defaultThemeClass method. For example, the name for CPCheckBox is "check-box",
|
||||
as defined in CPCheckBox::themeClass.
|
||||
*/
|
||||
- (CPArray)classNames
|
||||
@@ -140,8 +140,13 @@ var CPThemesByName = { },
|
||||
{
|
||||
if ([aClass isKindOfClass:[CPView class]])
|
||||
{
|
||||
if ([aClass respondsToSelector:@selector(themeClass)])
|
||||
if ([aClass respondsToSelector:@selector(defaultThemeClass)])
|
||||
className = [aClass defaultThemeClass];
|
||||
else if ([aClass respondsToSelector:@selector(themeClass)])
|
||||
{
|
||||
CPLog.warn(@"%@ themeClass is deprecated in favor of defaultThemeClass",CPStringFromClass([anObject class]));
|
||||
className = [aClass themeClass];
|
||||
}
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
@@ -247,7 +252,7 @@ var CPThemesByName = { },
|
||||
var attributes = [anObject _themeAttributeDictionary],
|
||||
attributeName = nil,
|
||||
attributeNames = [attributes keyEnumerator],
|
||||
objectThemeClass = [[anObject class] themeClass];
|
||||
objectThemeClass = [anObject themeClass];
|
||||
|
||||
while (attributeName = [attributeNames nextObject])
|
||||
[self _recordAttribute:[attributes objectForKey:attributeName] forClass:objectThemeClass];
|
||||
|
||||
@@ -87,7 +87,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
return [CPCharacterSet characterSetWithCharactersInString:@","];
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return "tokenfield";
|
||||
}
|
||||
@@ -1146,7 +1146,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
CPTokenField _tokenField;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return "tokenfield-token";
|
||||
}
|
||||
@@ -1243,7 +1243,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
return attributes;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return "tokenfield-token-close-button";
|
||||
}
|
||||
|
||||
+31
-9
@@ -179,6 +179,7 @@ var CPViewFlags = { },
|
||||
|
||||
// Theming Support
|
||||
CPTheme _theme;
|
||||
CPString _themeClass;
|
||||
JSObject _themeAttributes;
|
||||
unsigned _themeState;
|
||||
|
||||
@@ -1004,7 +1005,7 @@ var CPViewFlags = { },
|
||||
{
|
||||
var mask = [self autoresizingMask];
|
||||
|
||||
if(mask == CPViewNotSizable)
|
||||
if (mask == CPViewNotSizable)
|
||||
return;
|
||||
|
||||
var frame = _superview._frame,
|
||||
@@ -1160,7 +1161,7 @@ var CPViewFlags = { },
|
||||
{
|
||||
aFlag = !!aFlag;
|
||||
|
||||
if(_isHidden === aFlag)
|
||||
if (_isHidden === aFlag)
|
||||
return;
|
||||
|
||||
// FIXME: Should we return to visibility? This breaks in FireFox, Opera, and IE.
|
||||
@@ -1352,7 +1353,7 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CPView)hitTest:(CPPoint)aPoint
|
||||
{
|
||||
if(_isHidden || !_hitTests || !CPRectContainsPoint(_frame, aPoint))
|
||||
if (_isHidden || !_hitTests || !CPRectContainsPoint(_frame, aPoint))
|
||||
return nil;
|
||||
|
||||
var view = nil,
|
||||
@@ -1960,7 +1961,7 @@ setBoundsOrigin:
|
||||
var superview = _superview,
|
||||
clipViewClass = [CPClipView class];
|
||||
|
||||
while(superview && ![superview isKindOfClass:clipViewClass])
|
||||
while (superview && ![superview isKindOfClass:clipViewClass])
|
||||
superview = superview._superview;
|
||||
|
||||
return superview;
|
||||
@@ -2056,7 +2057,7 @@ setBoundsOrigin:
|
||||
var superview = _superview,
|
||||
scrollViewClass = [CPScrollView class];
|
||||
|
||||
while(superview && ![superview isKindOfClass:scrollViewClass])
|
||||
while (superview && ![superview isKindOfClass:scrollViewClass])
|
||||
superview = superview._superview;
|
||||
|
||||
return superview;
|
||||
@@ -2252,11 +2253,29 @@ setBoundsOrigin:
|
||||
|
||||
#pragma mark Theme Attributes
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CPString)themeClass
|
||||
{
|
||||
if (_themeClass)
|
||||
return _themeClass;
|
||||
|
||||
return [[self class] defaultThemeClass];
|
||||
}
|
||||
|
||||
- (void)setThemeClass:(CPString)theClass
|
||||
{
|
||||
_themeClass = theClass;
|
||||
|
||||
[self _loadThemeAttributes];
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return nil;
|
||||
@@ -2315,7 +2334,7 @@ setBoundsOrigin:
|
||||
return;
|
||||
|
||||
var theme = [self theme],
|
||||
themeClass = [theClass themeClass];
|
||||
themeClass = [self themeClass];
|
||||
|
||||
_themeAttributes = {};
|
||||
|
||||
@@ -2351,7 +2370,7 @@ setBoundsOrigin:
|
||||
return;
|
||||
|
||||
var theme = [self theme],
|
||||
themeClass = [[self class] themeClass];
|
||||
themeClass = [self themeClass];
|
||||
|
||||
for (var attributeName in _themeAttributes)
|
||||
if (_themeAttributes.hasOwnProperty(attributeName))
|
||||
@@ -2502,6 +2521,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
CPViewSubviewsKey = @"CPViewSubviewsKey",
|
||||
CPViewSuperviewKey = @"CPViewSuperviewKey",
|
||||
CPViewTagKey = @"CPViewTagKey",
|
||||
CPViewThemeClassKey = @"CPViewThemeClassKey",
|
||||
CPViewThemeStateKey = @"CPViewThemeStateKey",
|
||||
CPViewWindowKey = @"CPViewWindowKey",
|
||||
CPViewNextKeyViewKey = @"CPViewNextKeyViewKey",
|
||||
@@ -2581,11 +2601,12 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
[self setupViewFlags];
|
||||
|
||||
_theme = [CPTheme defaultTheme];
|
||||
_themeClass = [aCoder decodeObjectForKey:CPViewThemeClassKey];
|
||||
_themeState = CPThemeState([aCoder decodeIntForKey:CPViewThemeStateKey]);
|
||||
_themeAttributes = {};
|
||||
|
||||
var theClass = [self class],
|
||||
themeClass = [theClass themeClass],
|
||||
themeClass = [self themeClass],
|
||||
attributes = [theClass _themeAttributes],
|
||||
count = attributes.length;
|
||||
|
||||
@@ -2668,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)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
{
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"cornerview";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user