Merge branch '0.7b' of git@github.com:280north/cappuccino into 0.7-integration

This commit is contained in:
Ross Boucher committed 2009-05-12 16:11:25 -07:00
commit 453845dd20
71 files changed
+1452 -1077

No files matched your search

+2 -1
View File
@@ -27,6 +27,7 @@
@import "CPMenu.j"
@import "CPResponder.j"
@import "CPDocumentController.j"
@import "CPThemeBlend.j"
var CPMainCibFile = @"CPMainCibFile",
CPMainCibFileHumanFriendly = @"Main cib file base name";
@@ -807,7 +808,7 @@ var _CPAppBootstrapperActions = nil;
+ (BOOL)loadDefaultTheme
{
var blend = [[CPBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:@"Aristo.blend"]];
var blend = [[CPThemeBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:@"Aristo.blend"]];
[blend loadWithDelegate:self];
+45 -46
View File
@@ -107,12 +107,6 @@ var _CPButtonClassName = nil,
CPImage _image;
CPImage _alternateImage;
// Display Properties
CPThemedValue _bezelInset;
CPThemedValue _contentInset;
CPThemedValue _bezelColor;
// Layout Views
CPView _bezelView;
_CPImageAndTextView _contentView;
@@ -123,7 +117,24 @@ var _CPButtonClassName = nil,
CPControlSize _controlSize;
}
+ (id)themedAttributes
+ (id)standardButtonWithTitle:(CPString)aTitle
{
}
+ (id)standardCheckboxWithTitle:(CPString)aTitle
{
}
- (id)standardRadioButtonWithTitle:(CPString)aTitle
{
}
+ (CPString)themeClass
{
return @"button";
}
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil, 24.0]
forKeys:[@"bezel-inset", @"content-inset", @"bezel-color", @"default-height"]];
@@ -136,10 +147,10 @@ var _CPButtonClassName = nil,
if (self)
{
// Should we instead override the defaults?
[self setValue:CPCenterTextAlignment forThemedAttributeName:@"alignment"];
[self setValue:CPCenterVerticalTextAlignment forThemedAttributeName:@"vertical-alignment"];
[self setValue:CPImageLeft forThemedAttributeName:@"image-position"];
[self setValue:CPScaleNone forThemedAttributeName:@"image-scaling"];
[self setValue:CPCenterTextAlignment forThemeAttribute:@"alignment"];
[self setValue:CPCenterVerticalTextAlignment forThemeAttribute:@"vertical-alignment"];
[self setValue:CPImageLeft forThemeAttribute:@"image-position"];
[self setValue:CPScaleNone forThemeAttribute:@"image-scaling"];
_controlSize = CPRegularControlSize;
@@ -343,7 +354,7 @@ var _CPButtonClassName = nil,
- (CGRect)contentRectForBounds:(CGRect)bounds
{
var contentInset = [self currentValueForThemedAttributeName:@"content-inset"];
var contentInset = [self currentValueForThemeAttribute:@"content-inset"];
if (_CGInsetIsEmpty(contentInset))
return bounds;
@@ -361,7 +372,7 @@ var _CPButtonClassName = nil,
if (![self isBordered])
return _CGRectMakeZero();
var bezelInset = [self currentValueForThemedAttributeName:@"bezel-inset"];
var bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"];
if (_CGInsetIsEmpty(bezelInset))
return bounds;
@@ -380,8 +391,8 @@ var _CPButtonClassName = nil,
- (void)sizeToFit
{
var size = [([self title] || " ") sizeWithFont:[self font]],
contentInset = [self currentValueForThemedAttributeName:@"content-inset"],
defaultHeight = [self currentValueForThemedAttributeName:@"default-height"];
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
defaultHeight = [self currentValueForThemeAttribute:@"default-height"];
[self setFrameSize:CGSizeMake(size.width + contentInset.left + contentInset.right, defaultHeight)];
}
@@ -420,41 +431,35 @@ var _CPButtonClassName = nil,
relativeToEphemeralSubviewNamed:@"content-view"];
if (bezelView)
[bezelView setBackgroundColor:[self currentValueForThemedAttributeName:@"bezel-color"]];
[bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
positioned:CPWindowAbove
relativeToEphemeralSubviewNamed:@"bezel-view"];
if (contentView)
{
[contentView setText:((_controlState & CPControlStateHighlighted) && _alternateTitle) ? _alternateTitle : _title];
[contentView setImage:((_controlState & CPControlStateHighlighted) && _alternateImage) ? _alternateImage : _image];
[contentView setFont:[self currentValueForThemedAttributeName:@"font"]];
[contentView setTextColor:[self currentValueForThemedAttributeName:@"text-color"]];
[contentView setAlignment:[self currentValueForThemedAttributeName:@"alignment"]];
[contentView setVerticalAlignment:[self currentValueForThemedAttributeName:@"vertical-alignment"]];
[contentView setLineBreakMode:[self currentValueForThemedAttributeName:@"line-break-mode"]];
[contentView setTextShadowColor:[self currentValueForThemedAttributeName:@"text-shadow-color"]];
[contentView setTextShadowOffset:[self currentValueForThemedAttributeName:@"text-shadow-offset"]];
[contentView setImagePosition:[self currentValueForThemedAttributeName:@"image-position"]];
[contentView setImageScaling:[self currentValueForThemedAttributeName:@"image-scaling"]];
[contentView setText:([self hasThemeState:CPThemeStateHighlighted] && _alternateTitle) ? _alternateTitle : _title];
[contentView setImage:([self hasThemeState:CPThemeStateHighlighted] && _alternateImage) ? _alternateImage : _image];
[contentView setFont:[self currentValueForThemeAttribute:@"font"]];
[contentView setTextColor:[self currentValueForThemeAttribute:@"text-color"]];
[contentView setAlignment:[self currentValueForThemeAttribute:@"alignment"]];
[contentView setVerticalAlignment:[self currentValueForThemeAttribute:@"vertical-alignment"]];
[contentView setLineBreakMode:[self currentValueForThemeAttribute:@"line-break-mode"]];
[contentView setTextShadowColor:[self currentValueForThemeAttribute:@"text-shadow-color"]];
[contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
[contentView setImagePosition:[self currentValueForThemeAttribute:@"image-position"]];
[contentView setImageScaling:[self currentValueForThemeAttribute:@"image-scaling"]];
}
}
- (void)setDefaultButton:(BOOL)shouldBeDefaultButton
{
if ((!!(_controlState & CPControlStateDefault)) === shouldBeDefaultButton)
return;
if (shouldBeDefaultButton)
_controlState |= CPControlStateDefault;
[self setThemeState:CPThemeStateDefault];
else
_controlState &= ~CPControlStateDefault;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self unsetThemeState:CPThemeStateDefault];
}
@end
@@ -471,21 +476,15 @@ var _CPButtonClassName = nil,
- (void)setBordered:(BOOL)shouldBeBordered
{
if ((!!(_controlState & CPControlStateBordered)) === shouldBeBordered)
return;
if (shouldBeBordered)
_controlState |= CPControlStateBordered;
[self setThemeState:CPThemeStateBordered];
else
_controlState &= ~CPControlStateBordered;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self unsetThemeState:CPThemeStateBordered];
}
- (BOOL)isBordered
{
return !!(_controlState & CPControlStateBordered);
return [self hasThemeState:CPThemeStateBordered];
}
@end
+7 -2
View File
@@ -8,7 +8,12 @@
{
}
+ (id)themedAttributes
+ (CPString)themeClass
{
return @"button-bar";
}
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[nil]
forKeys:[@"bezel-color"]];
@@ -43,7 +48,7 @@
relativeToEphemeralSubviewNamed:@""];
if (bezelView)
[bezelView setBackgroundColor:[self currentValueForThemedAttributeName:@"bezel-color"]];
[bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
}
- (void)addSubview:(CPView)aSubview
+2 -2
View File
@@ -113,8 +113,8 @@
_brightnessSlider = [[CPSlider alloc] initWithFrame:CGRectMake(0, (aFrame.size.height - 34), aFrame.size.width, 15)];
[_brightnessSlider setValue:15.0 forThemedAttributeName:@"track-width"];
[_brightnessSlider setValue:[CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPColorPicker class]] pathForResource:@"brightness_bar.png"]]] forThemedAttributeName:@"track-color"];
[_brightnessSlider setValue:15.0 forThemeAttribute:@"track-width"];
[_brightnessSlider setValue:[CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPColorPicker class]] pathForResource:@"brightness_bar.png"]]] forThemeAttribute:@"track-color"];
[_brightnessSlider setMinValue:0.0];
[_brightnessSlider setMaxValue:100.0];
+11
View File
@@ -53,10 +53,19 @@ CPJavaScriptMouseWheelValues_8_15 = 1 << 23
CPOpacityRequiresFilterFeature = 1 << 24;
//Internet explorer does not allow dynamically changing the type of an input element
CPInputTypeCanBeChangedFeature = 1 << 25;
var USER_AGENT = "",
PLATFORM_ENGINE = CPUnknownBrowserEngine,
PLATFORM_FEATURES = 0;
// default these features to true
PLATFORM_FEATURES |= CPInputTypeCanBeChangedFeature;
if (typeof window != "undfined" && typeof window.navigator != "undefined")
USER_AGENT = window.navigator.userAgent;
@@ -79,6 +88,8 @@ else if (window.attachEvent) // Must follow Opera check.
PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
PLATFORM_FEATURES |= CPOpacityRequiresFilterFeature;
PLATFORM_FEATURES &= ~CPInputTypeCanBeChangedFeature;
}
// WebKit
+10 -34
View File
@@ -99,18 +99,16 @@ var CPControlBlackColor = [CPColor blackColor];
unsigned _trackingMouseDownFlags;
CGPoint _previousTrackingLocation;
CPControlState _controlState;
JSObject _ephemeralSubviewsForNames;
CPSet _ephereralSubviews;
CPString _toolTip;
CPString _toolTip;
// FIXME: Who uses this?
BOOL _isBezeled;
}
+ (CPDictionary)themedAttributes
+ (CPDictionary)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[
CPLeftTextAlignment, CPTopVerticalTextAlignment, CPLineBreakByClipping, [CPColor blackColor], [CPFont systemFontOfSize:12.0], nil, _CGSizeMakeZero(), CPImageLeft, CPScaleToFit]
@@ -123,8 +121,6 @@ var CPControlBlackColor = [CPColor blackColor];
if (self)
{
_controlState = CPControlStateNormal;
_sendActionOn = CPLeftMouseUpMask;
_trackingMouseDownFlags = 0;
}
@@ -493,11 +489,11 @@ var CPControlBlackColor = [CPColor blackColor];
#define BRIDGE(UPPERCASE, LOWERCASE, ATTRIBUTENAME) \
- (void)set##UPPERCASE:(id)aValue\
{\
[self setValue:aValue forThemedAttributeName:ATTRIBUTENAME];\
[self setValue:aValue forThemeAttribute:ATTRIBUTENAME];\
}\
- (id)LOWERCASE\
{\
return [self valueForThemedAttributeName:ATTRIBUTENAME];\
return [self valueForThemeAttribute:ATTRIBUTENAME];\
}
BRIDGE(Alignment, alignment, "alignment")
@@ -510,28 +506,17 @@ BRIDGE(TextShadowOffset, textShadowOffset, "text-shadow-offset")
BRIDGE(ImagePosition, imagePosition, "image-position")
BRIDGE(ImageScaling, imageScaling, "image-scaling")
- (int)controlState
{
return _controlState;
}
- (void)setEnabled:(BOOL)isEnabled
{
if ((!(_controlState & CPControlStateDisabled)) === isEnabled)
return;
if (isEnabled)
_controlState &= ~CPControlStateDisabled;
[self unsetThemeState:CPThemeStateDisabled];
else
_controlState |= CPControlStateDisabled;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self setThemeState:CPThemeStateDisabled];
}
- (BOOL)isEnabled
{
return !(_controlState & CPControlStateDisabled);
return ![self hasThemeState:CPThemeStateDisabled];
}
- (void)highlight:(BOOL)shouldHighlight
@@ -541,21 +526,15 @@ BRIDGE(ImageScaling, imageScaling, "image-scaling")
- (void)setHighlighted:(BOOL)isHighlighted
{
if ((!!(_controlState & CPControlStateHighlighted)) === isHighlighted)
return;
if (isHighlighted)
_controlState |= CPControlStateHighlighted;
[self setThemeState:CPThemeStateHighlighted];
else
_controlState &= ~CPControlStateHighlighted;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self unsetThemeState:CPThemeStateHighlighted];
}
- (BOOL)isHighlighted
{
return !!(_controlState & CPControlStateHighlighted);
return [self hasThemeState:CPThemeStateHighlighted];
}
- (CPView)createEphemeralSubviewNamed:(CPString)aViewName
@@ -631,8 +610,6 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
if (self)
{
_controlState = [aCoder decodeObjectForKey:CPControlControlStateKey];
[self setObjectValue:[aCoder decodeObjectForKey:CPControlValueKey]];
[self setTarget:[aCoder decodeObjectForKey:CPControlTargetKey]];
@@ -668,7 +645,6 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
if (subviews)
_subviews = subviews;
[aCoder encodeObject:_controlState forKey:CPControlControlStateKey];
[aCoder encodeObject:_value forKey:CPControlValueKey];
/*[aCoder encodeBool:_isEnabled forKey:CPControlIsEnabledKey];
+2 -2
View File
@@ -205,7 +205,7 @@ var LEFT_SHADOW_INSET = 3.0,
[super setImageScaling:anImageScaling];
#if PLATFORM(DOM)
if ([self currentValueForThemedAttributeName:@"image-scaling"] === CPScaleToFit)
if ([self currentValueForThemeAttribute:@"image-scaling"] === CPScaleToFit)
{
CPDOMDisplayServerSetStyleLeftTop(_DOMImageElement, NULL, 0.0, 0.0);
}
@@ -254,7 +254,7 @@ var LEFT_SHADOW_INSET = 3.0,
var bounds = [self bounds],
image = [self image],
imageScaling = [self currentValueForThemedAttributeName:@"image-scaling"],
imageScaling = [self currentValueForThemeAttribute:@"image-scaling"],
x = 0.0,
y = 0.0,
insetWidth = (_hasShadow ? HORIZONTAL_SHADOW_INSET : 0.0),
+17 -12
View File
@@ -30,7 +30,7 @@
var VISIBLE_MARGIN = 7.0;
CPPopUpButtonStatePullsDown = 1 << 12;
CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
/*! @class CPPopUpButton
@@ -44,6 +44,11 @@ CPPopUpButtonStatePullsDown = 1 << 12;
CPMenu _menu;
}
+ (CPString)themeClass
{
return "popup-button";
}
/*!
Initializes the pop-up button to the specified size.
@param aFrame the size for the button
@@ -59,9 +64,9 @@ CPPopUpButtonStatePullsDown = 1 << 12;
_selectedIndex = CPNotFound;
_preferredEdge = CPMaxYEdge;
[self setValue:CPImageLeft forThemedAttributeName:@"image-position"];
[self setValue:CPLeftTextAlignment forThemedAttributeName:@"alignment"];
[self setValue:CPLineBreakByTruncatingTail forThemedAttributeName:@"line-break-mode"];
[self setValue:CPImageLeft forThemeAttribute:@"image-position"];
[self setValue:CPLeftTextAlignment forThemeAttribute:@"alignment"];
[self setValue:CPLineBreakByTruncatingTail forThemeAttribute:@"line-break-mode"];
[self setMenu:[[CPMenu alloc] initWithTitle:@""]];
@@ -85,21 +90,21 @@ CPPopUpButtonStatePullsDown = 1 << 12;
*/
- (void)setPullsDown:(BOOL)shouldPullDown
{
if ((!!(_controlState & CPPopUpButtonStatePullsDown)) === shouldPullDown)
return;
if (shouldPullDown)
_controlState |= CPPopUpButtonStatePullsDown;
var changed = [self setThemeState:CPPopUpButtonStatePullsDown];
else
_controlState &= ~CPPopUpButtonStatePullsDown;
var changed = [self unsetThemeState:CPPopUpButtonStatePullsDown];
if (!changed)
return;
var items = [_menu itemArray];
if ([items count] <= 0)
return;
[items[0] setHidden:[self pullsDown]];
[self synchronizeTitleAndSelectedItem];
}
@@ -108,7 +113,7 @@ CPPopUpButtonStatePullsDown = 1 << 12;
*/
- (BOOL)pullsDown
{
return _controlState & CPPopUpButtonStatePullsDown;
return [self hasThemeState:CPPopUpButtonStatePullsDown];
}
// Inserting and Deleting Items
+20 -15
View File
@@ -71,7 +71,12 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
CGPoint _trackingStartPoint;
}
+ (id)themedAttributes
+ (CPString)themeClass
{
return "scroller";
}
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[ _CGInsetMakeZero(),
nil, nil, nil, nil,
@@ -181,14 +186,14 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
return _knobProportion;
}
- (id)currentValueForThemedAttributeName:(CPString)anAttributeName
- (id)currentValueForThemeAttribute:(CPString)anAttributeName
{
var controlState = _controlState;
var themeState = _themeState;
if (NAMES_FOR_PARTS[_hitPart] + "-color" !== anAttributeName)
controlState &= ~CPControlStateHighlighted;
themeState &= ~CPThemeStateHighlighted;
return [self valueForThemedAttributeName:anAttributeName inControlState:controlState];
return [self valueForThemeAttribute:anAttributeName inState:themeState];
}
// Calculating Layout
@@ -261,18 +266,18 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
// At this point we know we're going to need arrows.
_usableParts = CPAllScrollerParts;
var trackOverlapInset = [self currentValueForThemedAttributeName:@"track-overlap-inset"],
var trackOverlapInset = [self currentValueForThemeAttribute:@"track-overlap-inset"],
width = _CGRectGetWidth(bounds),
height = _CGRectGetHeight(bounds);
if ([self isVertical])
{
var decrementLineSize = [self currentValueForThemedAttributeName:"decrement-line-size"],
incrementLineSize = [self currentValueForThemedAttributeName:"increment-line-size"],
var decrementLineSize = [self currentValueForThemeAttribute:"decrement-line-size"],
incrementLineSize = [self currentValueForThemeAttribute:"increment-line-size"],
effectiveDecrementLineHeight = decrementLineSize.height - trackOverlapInset.top,
effectiveIncrementLineHeight = incrementLineSize.height - trackOverlapInset.bottom,
slotHeight = height - effectiveDecrementLineHeight - effectiveIncrementLineHeight,
minimumKnobSize = [self currentValueForThemedAttributeName:"minimum-knob-size"],
minimumKnobSize = [self currentValueForThemeAttribute:"minimum-knob-size"],
knobHeight = MAX(minimumKnobSize.height, (slotHeight * _knobProportion)),
knobLocation = effectiveDecrementLineHeight + (slotHeight - knobHeight) * [self floatValue];
@@ -286,12 +291,12 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
else
{
var decrementLineSize = [self currentValueForThemedAttributeName:"decrement-line-size"],
incrementLineSize = [self currentValueForThemedAttributeName:"increment-line-size"],
var decrementLineSize = [self currentValueForThemeAttribute:"decrement-line-size"],
incrementLineSize = [self currentValueForThemeAttribute:"increment-line-size"],
effectiveDecrementLineWidth = decrementLineSize.width - trackOverlapInset.left,
effectiveIncrementLineWidth = incrementLineSize.width - trackOverlapInset.right;
slotWidth = width - effectiveDecrementLineWidth - effectiveIncrementLineWidth,
minimumKnobSize = [self currentValueForThemedAttributeName:"minimum-knob-size"],
minimumKnobSize = [self currentValueForThemeAttribute:"minimum-knob-size"],
knobWidth = MAX(minimumKnobSize.width, (slotWidth * _knobProportion)),
knobLocation = effectiveDecrementLineWidth + (slotWidth - knobWidth) * [self floatValue];
@@ -377,7 +382,7 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
view = [self layoutEphemeralSubviewNamed:part positioned:CPWindowAbove relativeToEphemeralSubviewNamed:PARTS_ARRANGEMENT[index - 1]];
if (view)
[view setBackgroundColor:[self currentValueForThemedAttributeName:NAMES_FOR_PARTS[part] + "-color"]];
[view setBackgroundColor:[self currentValueForThemeAttribute:NAMES_FOR_PARTS[part] + "-color"]];
}
}
@@ -534,9 +539,9 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
_isVertical = width < height ? 1 : (width > height ? 0 : -1);
if (_isVertical === 1)
_controlState |= CPControlStateVertical;
[self setThemeState:CPThemeStateVertical];
else if (_isVertical === 0)
_controlState &= ~CPControlStateVertical;
[self unsetThemeState:CPThemeStateVertical];
}
- (void)setFrameSize:(CGSize)aSize
+144 -1
View File
@@ -24,6 +24,8 @@
@import "CPControl.j"
#include "CoreGraphics/CGGeometry.h"
/*
@global
@group CPSegmentSwitchTracking
@@ -47,6 +49,8 @@ CPSegmentSwitchTrackingMomentary = 2;
@implementation CPSegmentedControl : CPControl
{
CPArray _segments;
CPArray _themeStates;
int _selectedSegment;
int _segmentStyle;
CPSegmentSwitchTracking _trackingMode;
@@ -55,9 +59,21 @@ CPSegmentSwitchTrackingMomentary = 2;
BOOL _trackingHighlighted;
}
+ (CPString)themeClass
{
return "segmented-control";
}
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil, nil, nil, nil, 1.0, 24.0]
forKeys:[@"bezel-inset", @"content-inset", @"left-segment-bezel-color", @"right-segment-bezel-color", @"center-segment-bezel-color", @"divider-bezel-color", @"divider-thickness", @"default-height"]];
}
- (id)initWithFrame:(CGRect)aRect
{
_segments = [];
_themeStates = [];
self = [super initWithFrame:aRect];
@@ -99,6 +115,8 @@ CPSegmentSwitchTrackingMomentary = 2;
{
_segments[index] = [[_CPSegmentItem alloc] init];
_segments[index].frame.size.height = height;
_themeStates[index] = CPThemeStateNormal;
}
}
else if (aCount < _segments.length)
@@ -371,6 +389,8 @@ CPSegmentSwitchTrackingMomentary = 2;
segment.selected = isSelected;
_themeStates[aSegment] = isSelected ? CPThemeStateSelected : CPThemeStateNormal;
// We need to do some cleanup if we only allow one selection.
if (isSelected)
{
@@ -381,6 +401,7 @@ CPSegmentSwitchTrackingMomentary = 2;
if (_trackingMode == CPSegmentSwitchTrackingSelectOne && oldSelectedSegment != aSegment && oldSelectedSegment != -1)
{
_segments[oldSelectedSegment].selected = NO;
_themeStates[oldSelectedSegment] = CPThemeStateNormal;
[self drawSegmentBezel:oldSelectedSegment highlight:NO];
}
@@ -388,6 +409,8 @@ CPSegmentSwitchTrackingMomentary = 2;
if (_trackingMode != CPSegmentSwitchTrackingMomentary)
[self drawSegmentBezel:aSegment highlight:NO];
[self setNeedsLayout];
}
/*!
@@ -448,8 +471,124 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)drawSegmentBezel:(int)aSegment highlight:(BOOL)shouldHighlight
{
if (shouldHighlight)
_themeStates[aSegment] |= CPThemeStateHighlighted;
else
_themeStates[aSegment] &= ~CPThemeStateHighlighted;
[self setNeedsLayout];
}
- (float)_leftOffsetForSegment:(unsigned)segment
{
var bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"];
if (segment == 0)
return bezelInset.left;
var thickness = [self currentValueForThemeAttribute:@"divider-thickness"];
return [self _leftOffsetForSegment:segment - 1] + [self widthForSegment:segment - 1] + thickness;
}
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aName
{
var height = [self currentValueForThemeAttribute:@"default-height"],
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"],
bounds = [self bounds];
if (aName === "left-segment-bezel")
{
return CGRectMake(bezelInset.left, bezelInset.top, contentInset.left, height);
}
else if (aName === "right-segment-bezel")
{
return CGRectMake(CGRectGetMaxX(bounds) - contentInset.right, bezelInset.top, contentInset.right, height);
}
else if (aName.substring(0, "segment-bezel".length) == "segment-bezel")
{
var segment = parseInt(aName.substring("segment-bezel-".length), 10),
width = [self widthForSegment:segment],
left = [self _leftOffsetForSegment:segment];
if (_segments.length == 1)
return CGRectMake(left + contentInset.left, bezelInset.top, width - contentInset.left - contentInset.right, height);
else if (segment == 0)
return CGRectMake(left + contentInset.left, bezelInset.top, width - contentInset.left, height);
else if (segment == _segments.length - 1)
return CGRectMake(left, bezelInset.top, width - contentInset.right, height);
else
return CGRectMake(left, bezelInset.top, width, height);
}
else if (aName.substring(0, "divider-bezel".length) == "divider-bezel")
{
var segment = parseInt(aName.substring("divider-bezel-".length), 10),
width = [self widthForSegment:segment],
left = [self _leftOffsetForSegment:segment],
thickness = [self currentValueForThemeAttribute:@"divider-thickness"];
return CGRectMake(left + width, bezelInset.top, thickness, height);
}
return [super rectForEphemeralSubviewNamed:aName];
}
- (CPView)createEphemeralSubviewNamed:(CPString)aName
{
return [[CPView alloc] initWithFrame:_CGRectMakeZero()];
}
- (void)layoutSubviews
{
var leftCapColor = [self valueForThemeAttribute:@"left-segment-bezel-color"
inState:_themeStates[0]];
var leftBezelView = [self layoutEphemeralSubviewNamed:@"left-segment-bezel"
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:nil];
[leftBezelView setBackgroundColor:leftCapColor];
var rightCapColor = [self valueForThemeAttribute:@"right-segment-bezel-color"
inState:_themeStates[_themeStates.length - 1]];
var rightBezelView = [self layoutEphemeralSubviewNamed:@"right-segment-bezel"
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:nil];
[rightBezelView setBackgroundColor:rightCapColor];
for (var i=0, count = _themeStates.length; i<count; i++)
{
var bezelColor = [self valueForThemeAttribute:@"center-segment-bezel-color"
inState:_themeStates[i]];
var bezelView = [self layoutEphemeralSubviewNamed:"segment-bezel-"+i
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:nil];
[bezelView setBackgroundColor:bezelColor];
if (i == count - 1)
continue;
var borderState = _themeStates[i] | _themeStates[i+1];
borderState = (borderState & CPThemeStateSelected & ~CPThemeStateHighlighted) ? CPThemeStateSelected : CPThemeStateNormal;
var borderColor = [self valueForThemeAttribute:@"divider-bezel-color"
inState:borderState];
var borderView = [self layoutEphemeralSubviewNamed:"divider-bezel-"+i
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:nil];
[borderView setBackgroundColor:borderColor];
}
}
/*!
Draws the specified segment
@param aSegment the segment to draw
@@ -627,8 +766,8 @@ CPSegmentSwitchTrackingMomentary = 2;
{
_trackingHighlighted = YES;
_trackingSegment = [self testSegment:location];
CPLog.error("_trackingSegment="+_trackingSegment);
[self drawSegmentBezel:_trackingSegment highlight:YES];
}
@@ -680,6 +819,10 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
_segments = [aCoder decodeObjectForKey:CPSegmentedControlSegmentsKey];
_segmentStyle = [aCoder decodeIntForKey:CPSegmentedControlSegmentStyleKey];
_themeStates = [];
for (var i = 0; i < _segments.length; i++)
_themeStates[i] = 0;
if ([aCoder containsValueForKey:CPSegmentedControlSelectedKey])
_selectedSegment = [aCoder decodeIntForKey:CPSegmentedControlSelectedKey];
else
+35 -33
View File
@@ -26,8 +26,8 @@
/*! SLIDER STATES */
CPLinearSlider = 0;
CPCircularSlider = 1;
CPLinearSlider = 0;
CPCircularSlider = 1;
@implementation CPSlider : CPControl
{
@@ -38,7 +38,12 @@ CPCircularSlider = 1;
BOOL _isVertical;
}
+ (id)themedAttributes
+ (CPString)themeClass
{
return "slider";
}
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[nil, _CGSizeMakeZero(), 0.0, nil]
forKeys:[@"knob-color", @"knob-size", @"track-width", @"track-color"]];
@@ -109,31 +114,20 @@ CPCircularSlider = 1;
- (void)setSliderType:(CPSliderType)aSliderType
{
if ((aSliderType === CPCircularSlider) === (_controlState & CPControlStateCircular))
return;
if (aSliderType === CPCircularSlider)
_controlState |= CPControlStateCircular;
[self setThemeState:CPThemeStateCircular];
else
_controlState &= ~CPControlStateCircular;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self unsetThemeState:CPThemeStateCircular];
}
- (CPSliderType)sliderType
{
return (_controlState & CPControlStateCircular) ? CPCircularSlider : CPLinearSlider;
return [self hasThemeState:CPThemeStateCircular] ? CPCircularSlider : CPLinearSlider;
}
- (CGRect)trackRectForBounds:(CGRect)bounds
{
var trackWidth = [self currentValueForThemedAttributeName:@"track-width"];
if (trackWidth <= 0)
return _CGRectMakeZero();
if (_controlState & CPControlStateCircular)
if ([self hasThemeState:CPThemeStateCircular])
{
var originalBounds = CGRectCreateCopy(bounds);
@@ -145,15 +139,23 @@ CPCircularSlider = 1;
else
bounds.origin.y += (originalBounds.size.height - bounds.size.height) / 2.0;
}
else if ([self isVertical])
{
bounds.origin.x = (_CGRectGetWidth(bounds) - trackWidth) / 2.0;
bounds.size.width = trackWidth;
}
else
{
bounds.origin.y = (_CGRectGetHeight(bounds) - trackWidth) / 2.0;
bounds.size.height = trackWidth;
var trackWidth = [self currentValueForThemeAttribute:@"track-width"];
if (trackWidth <= 0)
return _CGRectMakeZero();
if ([self isVertical])
{
bounds.origin.x = (_CGRectGetWidth(bounds) - trackWidth) / 2.0;
bounds.size.width = trackWidth;
}
else
{
bounds.origin.y = (_CGRectGetHeight(bounds) - trackWidth) / 2.0;
bounds.size.height = trackWidth;
}
}
return bounds;
@@ -161,7 +163,7 @@ CPCircularSlider = 1;
- (CGRect)knobRectForBounds:(CGRect)bounds
{
var knobSize = [self currentValueForThemedAttributeName:@"knob-size"];
var knobSize = [self currentValueForThemeAttribute:@"knob-size"];
if (knobSize.width <= 0 || knobSize.height <= 0)
return _CGRectMakeZero();
@@ -173,7 +175,7 @@ CPCircularSlider = 1;
if (!trackRect || _CGRectIsEmpty(trackRect))
trackRect = bounds;
if (_controlState & CPControlStateCircular)
if ([self hasThemeState:CPThemeStateCircular])
{
var angle = 3*PI_2 - (1.0 - [self doubleValue] - _minValue) / (_maxValue - _minValue) * PI2,
radius = CGRectGetWidth(trackRect) / 2.0 - 6.0;
@@ -246,9 +248,9 @@ CPCircularSlider = 1;
_isVertical = width < height ? 1 : (width > height ? 0 : -1);
if (_isVertical === 1)
_controlState |= CPControlStateVertical;
[self setThemeState:CPThemeStateVertical];
else if (_isVertical === 0)
_controlState &= ~CPControlStateVertical;
[self unsetThemeState:CPThemeStateVertical];
}
- (int)isVertical
@@ -263,14 +265,14 @@ CPCircularSlider = 1;
relativeToEphemeralSubviewNamed:@"knob-view"];
if (trackView)
[trackView setBackgroundColor:[self currentValueForThemedAttributeName:@"track-color"]];
[trackView setBackgroundColor:[self currentValueForThemeAttribute:@"track-color"]];
var knobView = [self layoutEphemeralSubviewNamed:@"knob-view"
positioned:CPWindowAbove
relativeToEphemeralSubviewNamed:@"track-view"];
if (knobView)
[knobView setBackgroundColor:[self currentValueForThemedAttributeName:"knob-color"]];
[knobView setBackgroundColor:[self currentValueForThemeAttribute:"knob-color"]];
}
- (BOOL)tracksMouseOutsideOfFrame
@@ -284,7 +286,7 @@ CPCircularSlider = 1;
knobRect = [self knobRectForBounds:bounds],
trackRect = [self trackRectForBounds:bounds];
if (_controlState & CPControlStateCircular)
if ([self hasThemeState:CPThemeStateCircular])
{
var knobWidth = _CGRectGetWidth(knobRect);
@@ -295,7 +297,7 @@ CPCircularSlider = 1;
dx = aPoint.x - _CGRectGetMidX(trackRect),
dy = aPoint.y - _CGRectGetMidY(trackRect);
return MAX(0.0, MIN(1.0, 1.0 - (3*PI_2 - ATAN2(dy, dx))%PI2 / PI2)) * ([self maxValue] - minValue) + minValue;
return MAX(0.0, MIN(1.0, 1.0 - (3 * PI_2 - ATAN2(dy, dx)) % PI2 / PI2)) * ([self maxValue] - minValue) + minValue;
}
else if ([self isVertical])
{
+1 -1
View File
@@ -95,7 +95,7 @@ CPTableColumnUserResizingMask = 2;
_maxWidth = 1000.0;
var dataView = [[CPTextField alloc] initWithFrame:CPRectMakeZero()];
[dataView setValue:[CPColor whiteColor] forThemedAttributeName:"text-color" inControlState:CPControlStateHighlighted];
[dataView setValue:[CPColor whiteColor] forThemeAttribute:"text-color" inState:CPThemeStateHighlighted];
[self setDataView:dataView];
+107 -93
View File
@@ -23,8 +23,9 @@
@import "CPControl.j"
@import "CPStringDrawing.j"
@import "CPCompatibility.j"
#include "CoreGraphics/CGGeometry.j"
#include "CoreGraphics/CGGeometry.h"
#include "Platform/Platform.h"
#include "Platform/DOM/CPDOMDisplayServer.h"
@@ -77,6 +78,8 @@ CPTextFieldRoundedBezel = 1;
#if PLATFORM(DOM)
var CPTextFieldDOMInputElement = nil,
CPTextFieldDOMPasswordInputElement = nil,
CPTextFieldDOMStandardInputElement = nil,
CPTextFieldInputOwner = nil,
CPTextFieldTextDidChangeValue = nil,
CPTextFieldInputResigning = NO,
@@ -84,7 +87,11 @@ var CPTextFieldDOMInputElement = nil,
CPTextFieldInputIsActive = NO,
CPTextFieldCachedSelectStartFunction = nil,
CPTextFieldCachedDragFunction = nil,
CPTextFieldBlurFunction = nil;
CPTextFieldBlurFunction = nil,
CPTextFieldKeyUpFunction = nil,
CPTextFieldKeyPressFunction = nil,
CPTextFieldKeyDownFunction = nil;
#endif
@@ -102,8 +109,8 @@ var CPSecureTextFieldCharacter = "\u2022";
@end
CPTextFieldStateRounded = 1 << 12;
CPTextFieldStatePlaceholder = 1 << 13;
CPTextFieldStateRounded = CPThemeState("rounded");
CPTextFieldStatePlaceholder = CPThemeState("placeholder");
/*!
This control displays editable text in a Cappuccino application.
@@ -130,15 +137,20 @@ CPTextFieldStatePlaceholder = 1 << 13;
CPControlSize _controlSize;
}
+ (id)themedAttributes
+ (CPString)themeClass
{
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMake(2.0, 2.0, 2.0, 2.0), _CGInsetMake(2.0, 2.0, 2.0, 2.0), nil]
forKeys:[@"bezel-inset", @"content-inset", @"bezeled-content-inset", @"bezel-color"]];
return "textfield";
}
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMake(2.0, 2.0, 2.0, 2.0), nil]
forKeys:[@"bezel-inset", @"content-inset", @"bezel-color"]];
}
/* @ignore */
#if PLATFORM(DOM)
+ (DOMElement)_inputElement
- (DOMElement)_inputElement
{
if (!CPTextFieldDOMInputElement)
{
@@ -151,7 +163,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
CPTextFieldDOMInputElement.style.background = "transparent";
CPTextFieldDOMInputElement.style.outline = "none";
var blurFunction = function(anEvent)
CPTextFieldBlurFunction = function(anEvent)
{
if (CPTextFieldInputOwner && CPTextFieldInputOwner._DOMElement != CPTextFieldDOMInputElement.parentNode)
return;
@@ -168,18 +180,16 @@ CPTextFieldStatePlaceholder = 1 << 13;
return true;
}
CPTextFieldBlurFunction = blurFunction;
var keydownFunction = function(anEvent)
CPTextFieldKeyDownFunction = function(anEvent)
{
CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue];
keypressFunction(anEvent);
CPTextFieldKeyPressFunction(anEvent);
return true;
}
var keypressFunction = function(aDOMEvent)
CPTextFieldKeyPressFunction = function(aDOMEvent)
{
aDOMEvent = aDOMEvent || window.event;
@@ -210,7 +220,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
var keyupFunction = function()
CPTextFieldKeyUpFunction = function()
{
[CPTextFieldInputOwner setStringValue:CPTextFieldDOMInputElement.value];
@@ -233,31 +243,65 @@ CPTextFieldStatePlaceholder = 1 << 13;
if (document.attachEvent)
{
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyUp, keyupFunction);
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyDown, keydownFunction);
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyPress, keypressFunction);
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyUp, CPTextFieldKeyUpFunction);
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyDown, CPTextFieldKeyDownFunction);
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyPress, CPTextFieldKeyPressFunction);
}
else
{
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyUp, keyupFunction, NO);
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyDown, keydownFunction, NO);
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyPress, keypressFunction, NO);
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyUp, CPTextFieldKeyUpFunction, NO);
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyDown, CPTextFieldKeyDownFunction, NO);
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyPress, CPTextFieldKeyPressFunction, NO);
}
//FIXME make this not onblur
CPTextFieldDOMInputElement.onblur = blurFunction;
CPTextFieldDOMInputElement.onblur = CPTextFieldBlurFunction;
CPTextFieldDOMStandardInputElement = CPTextFieldDOMInputElement;
}
if (CPFeatureIsCompatible(CPInputTypeCanBeChangedFeature))
{
if ([self isSecure])
CPTextFieldDOMInputElement.type = "password";
else
CPTextFieldDOMInputElement.type = "text";
return CPTextFieldDOMInputElement;
}
if ([self isSecure])
{
if (!CPTextFieldDOMPasswordInputElement)
{
CPTextFieldDOMPasswordInputElement = document.createElement("input");
CPTextFieldDOMPasswordInputElement.style.position = "absolute";
CPTextFieldDOMPasswordInputElement.style.border = "0px";
CPTextFieldDOMPasswordInputElement.style.padding = "0px";
CPTextFieldDOMPasswordInputElement.style.margin = "0px";
CPTextFieldDOMPasswordInputElement.style.whiteSpace = "pre";
CPTextFieldDOMPasswordInputElement.style.background = "transparent";
CPTextFieldDOMPasswordInputElement.style.outline = "none";
CPTextFieldDOMPasswordInputElement.type = "password";
CPTextFieldDOMPasswordInputElement.attachEvent("on" + CPDOMEventKeyUp, CPTextFieldKeyUpFunction);
CPTextFieldDOMPasswordInputElement.attachEvent("on" + CPDOMEventKeyDown, CPTextFieldKeyDownFunction);
CPTextFieldDOMPasswordInputElement.attachEvent("on" + CPDOMEventKeyPress, CPTextFieldKeyPressFunction);
CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurFunction;
}
CPTextFieldDOMInputElement = CPTextFieldDOMPasswordInputElement;
}
else
{
CPTextFieldDOMInputElement = CPTextFieldDOMStandardInputElement;
}
return CPTextFieldDOMInputElement;
}
#endif
+ (void)initialize
{
if (CPBrowserIsEngine(CPGeckoBrowserEngine))
CPSecureTextFieldCharacter = "*";
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
@@ -269,7 +313,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
_sendActionOn = CPKeyUpMask | CPKeyDownMask;
[self setValue:CPLeftTextAlignment forThemedAttributeName:@"alignment"];
[self setValue:CPLeftTextAlignment forThemeAttribute:@"alignment"];
}
return self;
@@ -334,16 +378,10 @@ CPTextFieldStatePlaceholder = 1 << 13;
*/
- (void)setBezeled:(BOOL)shouldBeBezeled
{
if ((!!(_controlState & CPControlStateBezeled)) === shouldBeBezeled)
return;
if (shouldBeBezeled)
_controlState |= CPControlStateBezeled;
[self setThemeState:CPThemeStateBezeled];
else
_controlState &= ~CPControlStateBezeled;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self unsetThemeState:CPThemeStateBezeled];
}
/*!
@@ -351,7 +389,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
*/
- (BOOL)isBezeled
{
return !!(_controlState & CPControlStateBezeled);
return [self hasThemeState:CPThemeStateBezeled];
}
/*!
@@ -362,16 +400,10 @@ CPTextFieldStatePlaceholder = 1 << 13;
{
var shouldBeRounded = aBezelStyle === CPTextFieldRoundedBezel;
if ((!!(_controlState & CPTextFieldStateRounded)) === shouldBeRounded)
return;
if (shouldBeRounded)
_controlState |= CPTextFieldStateRounded;
[self setThemeState:CPTextFieldStateRounded];
else
_controlState &= ~CPTextFieldStateRounded;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self unsetThemeState:CPTextFieldStateRounded];
}
/*!
@@ -379,7 +411,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
*/
- (CPTextFieldBezelStyle)bezelStyle
{
if (_controlState & CPTextFieldStateRounded)
if ([self hasThemeState:CPTextFieldStateRounded])
return CPTextFieldRoundedBezel;
return CPTextFieldSquareBezel;
@@ -391,16 +423,10 @@ CPTextFieldStatePlaceholder = 1 << 13;
*/
- (void)setBordered:(BOOL)shouldBeBordered
{
if ((!!(_controlState & CPControlStateBordered)) === shouldBeBordered)
return;
if (shouldBeBordered)
_controlState |= CPControlStateBordered;
[self setThemeState:CPThemeStateBordered];
else
_controlState &= ~CPControlStateBordered;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self unsetThemeState:CPThemeStateBordered];
}
/*!
@@ -408,7 +434,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
*/
- (BOOL)isBordered
{
return !!(_controlState & CPControlStateBordered);
return [self hasThemeState:CPThemeStateBordered];
}
/*!
@@ -469,7 +495,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
if (CPTextFieldInputOwner && [CPTextFieldInputOwner window] !== [self window])
[[CPTextFieldInputOwner window] makeFirstResponder:nil];
_controlState |= CPControlStateEditing;
[self setThemeState:CPThemeStateEditing];
[self _updatePlaceholderState];
@@ -478,18 +504,13 @@ CPTextFieldStatePlaceholder = 1 << 13;
#if PLATFORM(DOM)
var string = [self stringValue],
element = [[self class] _inputElement];
element = [self _inputElement];
element.value = string;
element.style.color = [[self currentValueForThemedAttributeName:@"text-color"] cssString];
element.style.font = [[self currentValueForThemedAttributeName:@"font"] cssString];
element.style.color = [[self currentValueForThemeAttribute:@"text-color"] cssString];
element.style.font = [[self currentValueForThemeAttribute:@"font"] cssString];
element.style.zIndex = 1000;
if ([self isSecure])
element.type = "password";
else
element.type = "text";
var contentRect = [self contentRectForBounds:[self bounds]];
element.style.top = _CGRectGetMinY(contentRect) + "px";
@@ -529,7 +550,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
/* @ignore */
- (BOOL)resignFirstResponder
{
_controlState &= ~CPControlStateEditing;
[self unsetThemeState:CPThemeStateEditing];
[self _updatePlaceholderState];
@@ -537,7 +558,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
#if PLATFORM(DOM)
var element = [[self class] _inputElement];
var element = [self _inputElement];
[self setObjectValue:element.value];
@@ -601,19 +622,12 @@ CPTextFieldStatePlaceholder = 1 << 13;
- (void)_updatePlaceholderState
{
var string = [self stringValue],
controlState = _controlState;
var string = [self stringValue];
if ((!string || [string length] === 0) && !(_controlState & CPControlStateEditing))
_controlState |= CPTextFieldStatePlaceholder;
if ((!string || [string length] === 0) && ![self hasThemeState:CPThemeStateEditing])
[self setThemeState:CPTextFieldStatePlaceholder];
else
_controlState &= ~CPTextFieldStatePlaceholder;
if (_controlState !== controlState)
{
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
[self unsetThemeState:CPTextFieldStatePlaceholder];
}
/*!
@@ -628,7 +642,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
_placeholderString = aStringValue;
// Only update things if we need to show the placeholder
if (_controlState & CPTextFieldStatePlaceholder)
if ([self hasThemeState:CPTextFieldStatePlaceholder])
{
[self setNeedsLayout];
[self setNeedsDisplay:YES];
@@ -650,7 +664,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
- (void)sizeToFit
{
var size = [([self stringValue] || " ") sizeWithFont:[self font]],
contentInset = [self currentValueForThemedAttributeName:@"content-inset"];
contentInset = [self currentValueForThemeAttribute:@"content-inset"];
[self setFrameSize:CGSizeMake(size.width + contentInset.left + contentInset.right, size.height + contentInset.top + contentInset.bottom)];
}
@@ -661,7 +675,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
- (void)selectText:(id)sender
{
#if PLATFORM(DOM)
var element = [[self class] _inputElement];
var element = [self _inputElement];
if (element.parentNode == _DOMElement && ([self isEditable] || [self isSelectable]))
element.select();
@@ -715,7 +729,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
- (CGRect)contentRectForBounds:(CGRect)bounds
{
var contentInset = [self currentValueForThemedAttributeName:@"content-inset"];
var contentInset = [self currentValueForThemeAttribute:@"content-inset"];
if (!contentInset)
return bounds;
@@ -730,7 +744,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
- (CGRect)bezelRectForBounds:(CFRect)bounds
{
var bezelInset = [self currentValueForThemedAttributeName:@"bezel-inset"];
var bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"];
if (_CGInsetIsEmpty(bezelInset))
return bounds;
@@ -782,7 +796,7 @@ CPTextFieldStatePlaceholder = 1 << 13;
relativeToEphemeralSubviewNamed:@"content-view"];
if (bezelView)
[bezelView setBackgroundColor:[self currentValueForThemedAttributeName:@"bezel-color"]];
[bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
positioned:CPWindowAbove
@@ -790,11 +804,11 @@ CPTextFieldStatePlaceholder = 1 << 13;
if (contentView)
{
[contentView setHidden:_controlState & CPControlStateEditing];
[contentView setHidden:[self hasThemeState:CPThemeStateEditing]];
var string = "";
if (_controlState & CPTextFieldStatePlaceholder)
if ([self hasThemeState:CPTextFieldStatePlaceholder])
string = [self placeholderString];
else
{
@@ -806,13 +820,13 @@ CPTextFieldStatePlaceholder = 1 << 13;
[contentView setText:string];
[contentView setTextColor:[self currentValueForThemedAttributeName:@"text-color"]];
[contentView setFont:[self currentValueForThemedAttributeName:@"font"]];
[contentView setAlignment:[self currentValueForThemedAttributeName:@"alignment"]];
[contentView setVerticalAlignment:[self currentValueForThemedAttributeName:@"vertical-alignment"]];
[contentView setLineBreakMode:[self currentValueForThemedAttributeName:@"line-break-mode"]];
[contentView setTextShadowColor:[self currentValueForThemedAttributeName:@"text-shadow-color"]];
[contentView setTextShadowOffset:[self currentValueForThemedAttributeName:@"text-shadow-offset"]];
[contentView setTextColor:[self currentValueForThemeAttribute:@"text-color"]];
[contentView setFont:[self currentValueForThemeAttribute:@"font"]];
[contentView setAlignment:[self currentValueForThemeAttribute:@"alignment"]];
[contentView setVerticalAlignment:[self currentValueForThemeAttribute:@"vertical-alignment"]];
[contentView setLineBreakMode:[self currentValueForThemeAttribute:@"line-break-mode"]];
[contentView setTextShadowColor:[self currentValueForThemeAttribute:@"text-shadow-color"]];
[contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
}
}
+425 -240
View File
@@ -21,123 +21,16 @@
*/
@import <Foundation/CPObject.j>
@import <AppKit/_CPCibCustomResource.j>
@import <AppKit/_CPCibKeyedUnarchiver.j>
@import "CPThemedAttribute.j"
@import <Foundation/CPString.j>
@implementation CPBlend : CPObject
{
CPBundle _bundle;
CPArray _themes @accessors(readonly);
id _loadDelegate;
}
- (id)initWithContentsOfURL:(CPURL)aURL
{
self = [super init];
if (self)
{
_bundle = [[CPBundle alloc] initWithPath:aURL + "/Info.plist"];
}
return self;
}
- (void)loadWithDelegate:(id)aDelegate
{
_loadDelegate = aDelegate;
[_bundle loadWithDelegate:self];
}
- (void)bundleDidFinishLoading:(CPBundle)aBundle
{
var paths = [_bundle objectForInfoDictionaryKey:@"CPBundleReplacedFiles"],
index = 0,
count = paths.length,
bundlePath = [_bundle bundlePath];
while (count--)
{
var path = paths[count];
if ([path pathExtension] === "keyedtheme")
{
var unarchiver = [[_CPThemeKeyedUnarchiver alloc]
initForReadingWithData:[CPData dataWithString:objj_files[bundlePath + '/' + path].contents]
bundle:_bundle];
[unarchiver decodeObjectForKey:@"root"];
[unarchiver finishDecoding];
}
}
[_loadDelegate blendDidFinishLoading:self];
}
@end
var CPThemesByName = nil,
CPThemeDefaultTheme = nil,
CPThemeViewClass = Nil,
CPThemeWindowClass = Nil;
var CPThemesByName = { },
CPThemeDefaultTheme = nil;
@implementation CPTheme : CPObject
{
CPString _name;
Class _activeClass;
JSObject _classTable;
}
+ (void)initialize
{
if (self !== [CPTheme class])
return;
CPThemesByName = {};
CPThemeViewClass = [CPView class];
CPThemeWindowClass = [CPWindow class];
var bundle = [CPBundle bundleForClass:self];
defaultThemePath = [bundle objectForInfoDictionaryKey:@"Default Themes Path"],
defaultThemeName = [bundle objectForInfoDictionaryKey:@"Default Theme Name"];
if (!defaultThemePath)
return;
defaultThemePath = [bundle pathForResource:defaultThemePath];
var file = objj_files[defaultThemePath + "/Info.plist"];
if (!file)
return;
// Oh boy are we tricky.
var infoDictionary = CPPropertyListCreateFromData([CPData dataWithString:objj_files[defaultThemePath + "/Info.plist"].contents]);
themes = [infoDictionary objectForKey:@"CPBundleReplacedFiles"],
themeIndex = 0,
themeCount = [themes count];
for (; themeIndex < themeCount; ++themeIndex)
{
var unarchiver = [[_CPThemeKeyedUnarchiver alloc]
initForReadingWithData:[CPData dataWithString:objj_files[defaultThemePath + '/' + themes[themeIndex]].contents]
bundle:file.bundle];
[unarchiver decodeObjectForKey:@"root"];
[unarchiver finishDecoding];
}
[self setDefaultTheme:[CPTheme themeNamed:defaultThemeName]];
CPString _name;
CPDictionary _attributes;
}
+ (void)setDefaultTheme:(CPTheme)aTheme
@@ -155,24 +48,18 @@ var CPThemesByName = nil,
return CPThemesByName[aName];
}
+ (void)loadThemesAtURL:(CPURL)aURL delegate:(id)aLoadDelegate
{
}
- (id)initWithName:(CPString)aName
{
self = [super init];
if (self)
{
_name = aName;
_classTable = {};
_classTable[[[self class] className]] = {};
CPThemesByName[_name] = aName;
_attributes = [CPDictionary dictionary];
CPThemesByName[_name] = self;
}
return self;
}
@@ -181,160 +68,76 @@ var CPThemesByName = nil,
return _name;
}
- (void)setActiveClass:(Class)aClass
- (_CPThemeAttribute)_attributeWithName:(CPString)aName forClass:(CPString)aClass
{
_activeClass = aClass;
}
var attributes = [_attributes objectForKey:aClass];
- (Class)activeClass
{
return _activeClass;
}
if (!attributes)
return nil;
- (id)valueForAttributeName:(CPString)anAttributeName inClass:(CPClass)aClass
{
if (!aClass)
return nil;
var className = [aClass className],
table = _classTable[className];
if (!table)
return nil;
var value = table[anAttributeName];
if (!value)
return nil;
return value;
return [attributes objectForKey:aName];
}
- (void)takeThemeFromObject:(id)anObject
{
var attributes = [anObject _themedAttributes],
var attributes = [anObject _themeAttributeDictionary],
attributeName = nil,
attributeNames = [attributes keyEnumerator],
objectClass = [anObject class];
objectThemeClass = [[anObject class] themeClass];
while (attributeName = [attributeNames nextObject])
[self addValue:[attributes objectForKey:attributeName] forAttributeName:attributeName inClass:objectClass];
[self _recordAttribute:[attributes objectForKey:attributeName] forClass:objectThemeClass];
}
- (void)setDefaultValue:(id)aValue forAttributeName:(CPString)anAttributeName
- (void)_recordAttribute:(_CPThemeAttribute)anAttribute forClass:(CPString)aClass
{
[self addValue:aValue forAttributeName:anAttributeName inClass:[self class]];
}
- (void)addValue:(id)aValue forAttributeName:(CPString)anAttributeName inClass:(Class)aClass
{
if (!aValue)
if (![anAttribute hasValues])
return;
var className = [aClass className],
table = _classTable[className];
if (!table)
var attributes = [_attributes objectForKey:aClass];
if (!attributes)
{
var classNames = [];
while (!table && (aClass !== CPThemeViewClass) && (aClass !== CPThemeWindowClass))
{
classNames.push(className);
aClass = [aClass superclass];
className = [aClass className];
table = _classTable[className];
}
if (!table)
table = _classTable[[[self class] className]];
var count = [classNames count];
while (count--)
{
className = classNames[count];
_classTable[className] = {};
_classTable[className].prototype = table;
table = _classTable[className];
}
attributes = [CPDictionary dictionary];
[_attributes setObject:attributes forKey:aClass];
}
var existingAttribute = table[anAttributeName];
var name = [anAttribute name],
existingAttribute = [attributes objectForKey:name];
if (existingAttribute)
table[anAttributeName] = [existingAttribute themedAttributeMergedWithThemedAttribute:aValue];
[attributes setObject:[existingAttribute attributeMergedWithAttribute:anAttribute] forKey:name];
else
table[anAttributeName] = aValue;
[attributes setObject:anAttribute forKey:name];
}
@end
var CPThemeNameKey = @"CPThemeNameKey",
CPThemeClassNamesArrayKey = @"CPThemeClassNamesArrayKey";
var CPThemeNameKey = @"CPThemeNameKey",
CPThemeAttributesKey = @"CPThemeAttributesKey";
@implementation CPTheme (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
_name = [aCoder decodeObjectForKey:CPThemeNameKey];
_classTable = {};
CPThemesByName[_name] = self;
if (self)
{
var classNamesArray = [aCoder decodeObjectForKey:CPThemeClassNamesArrayKey],
count = classNamesArray.length;
while (count--)
{
var className = classNamesArray[count],
theClass = objj_getClass(className),
values = [aCoder decodeObjectForKey:className],
keys = [values allKeys],
keyCount = keys.length;
while (keyCount--)
{
var key = keys[keyCount];
[self addValue:[values objectForKey:key] forAttributeName:key inClass:theClass];
}
}
_name = [aCoder decodeObjectForKey:CPThemeNameKey];
_attributes = [aCoder decodeObjectForKey:CPThemeAttributesKey];
CPThemesByName[_name] = self;
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
var classNamesArray = [];
for (var className in _classTable)
{
if (_classTable.hasOwnProperty(className))
{
var values = _classTable[className],
valuesDictionary = [CPDictionary dictionary];
for (var key in values)
if (key !== "prototype" && values.hasOwnProperty(key))
[valuesDictionary setObject:values[key] forKey:key];
[aCoder encodeObject:valuesDictionary forKey:className];
classNamesArray.push(className);
}
}
[aCoder encodeObject:_name forKey:CPThemeNameKey];
[aCoder encodeObject:classNamesArray forKey:CPThemeClassNamesArrayKey];
[aCoder encodeObject:_attributes forKey:CPThemeAttributesKey];
}
@end
@@ -347,10 +150,10 @@ var CPThemeNameKey = @"CPThemeNameKey",
- (id)initForReadingWithData:(CPData)data bundle:(CPBundle)aBundle
{
self = [super initForReadingWithData:data];
if (self)
_bundle = aBundle;
return self;
}
@@ -365,3 +168,385 @@ var CPThemeNameKey = @"CPThemeNameKey",
}
@end
var CPThemeStates = {},
CPThemeStateNames = {},
CPThemeStateCount = 0;
function CPThemeState(aStateName)
{
var state = CPThemeStates[aStateName];
if (state === undefined)
{
if (aStateName.indexOf('+') === -1)
state = 1 << CPThemeStateCount++;
else
{
var state = 0,
states = aStateName.split('+'),
count = states.length;
while (count--)
{
var stateName = states[count],
individualState = CPThemeStates[stateName];
if (individualState === undefined)
{
individualState = 1 << CPThemeStateCount++;
CPThemeStates[stateName] = individualState;
CPThemeStateNames[individualState] = stateName;
}
state |= individualState;
}
}
CPThemeStates[aStateName] = state;
CPThemeStateNames[state] = aStateName;
}
return state;
}
function CPThemeStateName(aState)
{
var name = CPThemeStateNames[aState];
if (name !== undefined)
return name;
if (!(aState & (aState - 1)))
return "";
var state = 1,
name = "";
for (; state < aState; state <<= 1)
if (aState & state)
name += (name.length === 0 ? '' : '+') + CPThemeStateNames[state];
CPThemeStateNames[aState] = name;
return name;
}
CPThemeStateNames[0] = "normal";
CPThemeStateNormal = CPThemeStates["normal"] = 0;
CPThemeStateDisabled = CPThemeState("disabled");
CPThemeStateHighlighted = CPThemeState("highlighted");
CPThemeStateSelected = CPThemeState("selected");
CPThemeStateBezeled = CPThemeState("bezeled");
CPThemeStateBordered = CPThemeState("bordered");
CPThemeStateEditable = CPThemeState("editable");
CPThemeStateEditing = CPThemeState("editing");
CPThemeStateVertical = CPThemeState("vertical");
CPThemeStateDefault = CPThemeState("default");
CPThemeStateCircular = CPThemeState("circular");
@implementation _CPThemeAttribute : CPObject
{
CPString _name;
id _defaultValue;
CPDictionary _values;
JSObject _cache;
CPThemeAttribute _parentAttribute;
}
- (id)initWithName:(CPString)aName defaultValue:(id)aDefaultValue
{
self = [super init];
if (self)
{
_cache = { };
_name = aName;
_defaultValue = aDefaultValue;
_values = [CPDictionary dictionary];
}
return self;
}
- (CPString)name
{
return _name;
}
- (id)defaultValue
{
return _defaultValue;
}
- (BOOL)hasValues
{
return [_values count] > 0;
}
- (BOOL)isTrivial
{
return ([_values count] === 1) && (Number([_values allKeys][0]) === CPThemeStateNormal);
}
- (void)setValue:(id)aValue
{
_cache = {};
if (aValue === undefined || aValue === nil)
_values = [CPDictionary dictionary];
else
_values = [CPDictionary dictionaryWithObject:aValue forKey:String(CPThemeStateNormal)];
}
- (void)setValue:(id)aValue forState:(CPThemeState)aState
{
_cache = { };
if ((aValue === undefined) || (aValue === nil))
[_values removeObjectForKey:String(aState)];
else
[_values setObject:aValue forKey:String(aState)];
}
- (id)value
{
return [self valueForState:CPThemeStateNormal];
}
- (id)valueForState:(CPThemeState)aState
{
var value = _cache[aState];
// This can be nil.
if (value !== undefined)
return value;
value = [_values objectForKey:String(aState)];
// If we don't have a value, and we have a non-normal state...
if ((value === undefined || value === nil) && aState !== CPThemeStateNormal)
{
// If this is a composite state (not a power of 2), find the closest partial subset match.
if (aState & (aState - 1))
{
var highestOneCount = 0,
states = [_values allKeys],
count = states.length;
while (count--)
{
// states[count] is a string!
var state = Number(states[count]);
// A & B = A iff A < B
if ((state & aState) === state)
{
var oneCount = cachedNumberOfOnes[state];
if (oneCount === undefined)
oneCount = numberOfOnes(state);
if (oneCount > highestOneCount)
{
highestOneCount = oneCount;
value = [_values objectForKey:String(state)];
}
}
}
}
// Still don't have a value? OK, let's use the normal value.
if (value === undefined || value === nil)
value = [_values objectForKey:String(CPThemeStateNormal)];
}
if (value === undefined || value === nil)
value = [_parentAttribute valueForState:aState];
if (value === undefined || value === nil)
value = _defaultValue;
_cache[aState] = value;
return value;
}
- (void)setParentAttribute:(CPThemeAttribute)anAttribute
{
if (_parentAttribute === anAttribute)
return;
_cache = { };
_parentAttribute = anAttribute;
}
- (CPThemeAttribute)attributeMergedWithAttribute:(_CPThemeAttribute)anAttribute
{
var mergedAttribute = [[_CPThemeAttribute alloc] initWithName:_name defaultValue:_defaultValue];
mergedAttribute._values = [_values copy];
[mergedAttribute._values addEntriesFromDictionary:anAttribute._values];
return mergedAttribute;
}
@end
@implementation _CPThemeAttribute (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_cache = {};
_name = [aCoder decodeObjectForKey:@"name"];
_values = [CPDictionary dictionary];
if ([aCoder containsValueForKey:@"value"])
{
var state = CPThemeStateNormal;
if ([aCoder containsValueForKey:@"state"])
state = CPThemeState([aCoder decodeObjectForKey:@"state"]);
[_values setObject:[aCoder decodeObjectForKey:"value"] forKey:state];
}
else
{
var encodedValues = [aCoder decodeObjectForKey:@"values"],
keys = [encodedValues allKeys],
count = keys.length;
while (count--)
{
var key = keys[count];
[_values setObject:[encodedValues objectForKey:key] forKey:CPThemeState(key)];
}
}
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_name forKey:@"name"];
var keys = [_values allKeys],
count = keys.length;
if (count === 1)
{
var onlyKey = keys[0];
if (Number(onlyKey) !== CPThemeStateNormal)
[aCoder encodeObject:CPThemeStateName(Number(onlyKey)) forKey:@"state"];
[aCoder encodeObject:[_values objectForKey:onlyKey] forKey:@"value"];
}
else
{
var encodedValues = [CPDictionary dictionary];
while (count--)
{
var key = keys[count];
[encodedValues setObject:[_values objectForKey:key] forKey:CPThemeStateName(Number(key))];
}
[aCoder encodeObject:encodedValues forKey:@"values"];
}
}
@end
var cachedNumberOfOnes = [ 0 /*000000*/, 1 /*000001*/, 1 /*000010*/, 2 /*000011*/, 1 /*000100*/, 2 /*000101*/, 2 /*000110*/,
3 /*000111*/, 1 /*001000*/, 2 /*001001*/, 2 /*001010*/, 3 /*001011*/, 2 /*001100*/, 3 /*001101*/,
3 /*001110*/, 4 /*001111*/, 1 /*010000*/, 2 /*010001*/, 2 /*010010*/, 3 /*010011*/, 2 /*010100*/,
3 /*010101*/, 3 /*010110*/, 4 /*010111*/, 2 /*011000*/, 3 /*011001*/, 3 /*011010*/, 4 /*011011*/,
3 /*011100*/, 4 /*011101*/, 4 /*011110*/, 5 /*011111*/, 1 /*100000*/, 2 /*100001*/, 2 /*100010*/,
3 /*100011*/, 2 /*100100*/, 3 /*100101*/, 3 /*100110*/, 4 /*100111*/, 2 /*101000*/, 3 /*101001*/,
3 /*101010*/, 4 /*101011*/, 3 /*101100*/, 4 /*101101*/, 4 /*101110*/, 5 /*101111*/, 2 /*110000*/,
3 /*110001*/, 3 /*110010*/, 4 /*110011*/, 3 /*110100*/, 4 /*110101*/, 4 /*110110*/, 5 /*110111*/,
3 /*111000*/, 4 /*111001*/, 4 /*111010*/, 5 /*111011*/, 4 /*111100*/, 5 /*111101*/, 5 /*111110*/,
6 /*111111*/ ];
var numberOfOnes = function(aNumber)
{
var count = 0,
slot = aNumber;
while (aNumber)
{
++count;
aNumber &= (aNumber - 1);
}
cachedNumberOfOnes[slot] = count;
return count;
}
numberOfOnes.displayName = "numberOfOnes";
function CPThemeAttributeEncode(aCoder, aThemeAttribute)
{
var values = aThemeAttribute._values,
count = [values count],
key = "$a" + [aThemeAttribute name];
if (count === 1)
{
var state = [values allKeys][0];
if (Number(state) === 0)
{
[aCoder encodeObject:[values objectForKey:state] forKey:key];
return YES;
}
}
if (count >= 1)
{
[aCoder encodeObject:aThemeAttribute forKey:key];
return YES;
}
return NO;
}
function CPThemeAttributeDecode(aCoder, anAttributeName, aDefaultValue, aTheme, aClass)
{
var key = "$a" + anAttributeName;
if (![aCoder containsValueForKey:key])
var attribute = [[_CPThemeAttribute alloc] initWithName:anAttributeName defaultValue:aDefaultValue];
else
{
var attribute = [aCoder decodeObjectForKey:key];
if (!attribute.isa || ![attribute isKindOfClass:[_CPThemeAttribute class]])
{
var themeAttribute = [[_CPThemeAttribute alloc] initWithName:anAttributeName defaultValue:aDefaultValue];
[themeAttribute setValue:attribute];
attribute = themeAttribute;
}
}
if (aTheme && aClass)
[attribute setParentAttribute:[aTheme _attributeWithName:anAttributeName forClass:aClass]];
return attribute;
}
+82
View File
@@ -0,0 +1,82 @@
/*
* CPThemeBlend.j
* AppKit
*
* Created by Francisco Tolmasky.
* Copyright 2009, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPTheme.j>
@import <AppKit/_CPCibCustomResource.j>
@import <AppKit/_CPCibKeyedUnarchiver.j>
@implementation CPThemeBlend : CPObject
{
CPBundle _bundle;
CPArray _themes @accessors(readonly);
id _loadDelegate;
}
- (id)initWithContentsOfURL:(CPURL)aURL
{
self = [super init];
if (self)
{
_bundle = [[CPBundle alloc] initWithPath:aURL + "/Info.plist"];
}
return self;
}
- (void)loadWithDelegate:(id)aDelegate
{
_loadDelegate = aDelegate;
[_bundle loadWithDelegate:self];
}
- (void)bundleDidFinishLoading:(CPBundle)aBundle
{
var paths = [_bundle objectForInfoDictionaryKey:@"CPBundleReplacedFiles"],
index = 0,
count = paths.length,
bundlePath = [_bundle bundlePath];
while (count--)
{
var path = paths[count];
if ([path pathExtension] === "keyedtheme")
{
var unarchiver = [[_CPThemeKeyedUnarchiver alloc]
initForReadingWithData:[CPData dataWithString:objj_files[bundlePath + '/' + path].contents]
bundle:_bundle];
[unarchiver decodeObjectForKey:@"root"];
[unarchiver finishDecoding];
}
}
[_loadDelegate blendDidFinishLoading:self];
}
@end
-267
View File
@@ -1,267 +0,0 @@
@import <Foundation/CPObject.j>
CPControlStateNormal = 0,
CPControlStateHighlighted = 1 << 0,
CPControlStateDisabled = 1 << 1,
CPControlStateSelected = 1 << 2,
CPControlStateDefault = 1 << 3,
CPControlStateBordered = 1 << 4,
CPControlStateBezeled = 1 << 5,
CPControlStateVertical = 1 << 6,
CPControlStateEditable = 1 << 7,
CPControlStateEditing = 1 << 8;
CPControlStateHorizontal = 1 << 9;
CPControlStateCircular = 1 << 10;
var BIT_COUNT = [ 0 /*00000*/, 1 /*00001*/, 1 /*00010*/, 2 /*00011*/, 1 /*00100*/, 2 /*00101*/, 2 /*00110*/, 3 /*00111*/,
1 /*01000*/, 2 /*01001*/, 2 /*01010*/, 3 /*01011*/, 2 /*01100*/, 3 /*01101*/, 3 /*01110*/, 4 /*01111*/,
1 /*10000*/, 2 /*10001*/, 2 /*10010*/, 3 /*10011*/, 2 /*10100*/, 3 /*10101*/, 3 /*10110*/, 4 /*10111*/,
2 /*11000*/, 3 /*11001*/, 3 /*11010*/, 4 /*11011*/, 3 /*11100*/, 4 /*11101*/, 4 /*11110*/, 5 /*11111*/],
bit_count = function(bits)
{
var count = 0;
while (bits)
{
++count;
bits &= (bits - 1);
}
return count ;
}
@implementation CPThemedAttribute : CPObject
{
JSObject _cache;
CPString _name;
id _defaultValue;
CPTheme _theme;
Class _themedClass;
CPDictionary _values;
CPThemedAttribute _attributeFromTheme;
}
- (id)initWithName:(CPString)aName defaultValue:(id)aDefaultValue theme:(CPTheme)aTheme class:(Class)aClass
{
self = [super init];
if (self)
{
_cache = {};
_name = aName;
_defaultValue = aDefaultValue;
_theme = aTheme;
_themedClass = aClass;
_values = [CPDictionary dictionary];
_attributeFromTheme = [_theme valueForAttributeName:_name inClass:_themedClass];
}
return self;
}
- (void)setName:(CPString)aName
{
_name = aName;
}
- (CPString)name
{
return _name;
}
- (void)setDefaultValue:(id)aValue
{
_cache = {};
_defaultValue = aValue;
}
- (void)setTheme:(CPTheme)aTheme
{
if (_theme === aTheme)
return;
_cache = {};
_theme = aTheme;
_attributeFromTheme = [_theme valueForAttributeName:_name inClass:_themedClass];
}
- (void)setThemedClass:(Class)aClass
{
if (_themedClass === aClass)
return;
_cache = {};
_themedClass = aClass;
_attributeFromTheme = [_theme valueForAttributeName:_name inClass:_themedClass];
}
- (void)setValue:(id)aValue
{
_cache = {};
if (aValue === undefined || aValue === nil)
_values = [CPDictionary dictionary];
else
_values = [CPDictionary dictionaryWithObject:aValue forKey:String(CPControlStateNormal)];
}
- (id)value
{
return [self valueForControlState:CPControlStateNormal];
}
- (void)setValue:(id)aValue forControlState:(CPControlState)aState
{
//delete _cache[aState];
_cache = {};
if ((aValue === undefined) || (aValue === nil))
[_values removeObjectForKey:String(aState)];
else
[_values setObject:aValue forKey:String(aState)];
}
- (id)valueForControlState:(CPControlState)aState
{
var value = _cache[aState];
// This can be nil.
if (value !== undefined)
return value;
value = [_values objectForKey:String(aState)];
// If we don't have a value, and we have a non-normal state...
if ((value === undefined || value === nil) && aState > 0)
{
// If this is a composite state, find the closest partial subset match.
if (aState & (aState - 1))
{
var highestBitCount = 0,
states = [_values allKeys],
count = states.length;
while (count--)
{
// state is a string!
state = Number(states[count]);
// A & B = A iff A < B
if ((state & aState) === state)
{
var bitCount = (state < BIT_COUNT.length) ? BIT_COUNT[state] : bit_count(state);
if (bitCount > highestBitCount)
{
highestBitCount = bitCount;
value = [_values objectForKey:String(state)];
}
}
}
}
// Still don't have a value? OK, let's use the normal value.
if (value === undefined || value === nil)
value = [_values objectForKey:String(CPControlStateNormal)];
}
if (value === undefined || value === nil)
value = [_attributeFromTheme valueForControlState:aState];
if (value === undefined || value === nil)
value = _defaultValue;
_cache[aState] = value;
return value;
}
- (CPThemedAttribute)themedAttributeMergedWithThemedAttribute:(CPThemedAttribute)aThemedAttribute
{
var mergedAttribute = CPThemedAttributeMake(_name, _defaultValue, _theme, _themedClass);
mergedAttribute._values = [_values copy];
[mergedAttribute._values addEntriesFromDictionary:aThemedAttribute._values];
return mergedAttribute;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_cache = {};
_values = [aCoder decodeObjectForKey:@"values"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_values forKey:@"values"];
}
@end
function CPThemedAttributeMake(aName, aDefaultValue, aTheme, aClass)
{
return [[CPThemedAttribute alloc] initWithName:aName defaultValue:aDefaultValue theme:aTheme class:aClass];
}
function CPThemedAttributeEncode(aCoder, aThemedAttribute)
{
var values = aThemedAttribute._values,
count = [values count];
if (count === 1)
{
var key = [values allKeys][0];
if (Number(key) === 0)
return [aCoder encodeObject:[values objectForKey:key] forKey:"$a" + [aThemedAttribute name]];
}
if (count >= 1)
[aCoder encodeObject:aThemedAttribute forKey:"$a" + [aThemedAttribute name]];
}
function CPThemedAttributeDecode(aCoder, anAttributeName, aDefaultValue, aTheme, aClass)
{
var key = "$a" + anAttributeName;
if (![aCoder containsValueForKey:key])
return CPThemedAttributeMake(anAttributeName, aDefaultValue, aTheme, aClass);
var attribute = [aCoder decodeObjectForKey:key];
if (!attribute.isa || ![attribute isKindOfClass:[CPThemedAttribute class]])
{
var themedAttribute = CPThemedAttributeMake(anAttributeName, aDefaultValue, aTheme, aClass);
[themedAttribute setValue:attribute];
attribute = themedAttribute;
}
else
{
[attribute setName:anAttributeName];
[attribute setDefaultValue:aDefaultValue];
[attribute setTheme:aTheme];
[attribute setThemedClass:aClass];
}
return attribute;
}
+171 -97
View File
@@ -85,11 +85,8 @@ CPViewMaxYMargin = 32;
CPViewBoundsDidChangeNotification = @"CPViewBoundsDidChangeNotification";
CPViewFrameDidChangeNotification = @"CPViewFrameDidChangeNotification";
var _DOMOriginUpdateMask = 1 << 0,
_DOMSizeUpdateMask = 1 << 1;
var _CPViewNotificationCenter = nil,
_CachedThemedAttributes = nil;
var CachedNotificationCenter = nil,
CachedThemeAttributes = nil;
#if PLATFORM(DOM)
var DOMElementPrototype = nil,
@@ -178,7 +175,8 @@ var DOMElementPrototype = nil,
// Theming Support
CPTheme _theme;
JSObject _themedAttributes;
JSObject _themeAttributes;
unsigned _themeState;
// Key View Support
CPView _nextKeyView;
@@ -191,7 +189,7 @@ var DOMElementPrototype = nil,
*/
+ (void)initialize
{
if (self != [CPView class])
if (self !== [CPView class])
return;
#if PLATFORM(DOM)
@@ -205,7 +203,7 @@ var DOMElementPrototype = nil,
style.zIndex = 0;
#endif
_CPViewNotificationCenter = [CPNotificationCenter defaultCenter];
CachedNotificationCenter = [CPNotificationCenter defaultCenter];
}
- (id)init
@@ -255,9 +253,9 @@ var DOMElementPrototype = nil,
#endif
_theme = [CPTheme defaultTheme];
_themedAttributes = {};
[self _loadThemedAttributes];
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
}
return self;
@@ -588,7 +586,7 @@ var DOMElementPrototype = nil,
_inhibitFrameAndBoundsChangedNotifications = NO;
if (_postsFrameChangedNotifications)
[_CPViewNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
[CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
}
/*!
@@ -639,7 +637,7 @@ var DOMElementPrototype = nil,
origin.y = aPoint.y;
if (_postsFrameChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
[_CPViewNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
[CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
#if PLATFORM(DOM)
CPDOMDisplayServerSetStyleLeftTop(_DOMElement, _superview ? _superview._boundsTransform : NULL, origin.x, origin.y);
@@ -717,7 +715,7 @@ var DOMElementPrototype = nil,
#endif
if (_postsFrameChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
[_CPViewNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
[CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
}
/*!
@@ -738,7 +736,7 @@ var DOMElementPrototype = nil,
_inhibitFrameAndBoundsChangedNotifications = NO;
if (_postsBoundsChangedNotifications)
[_CPViewNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
[CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
}
/*!
@@ -790,7 +788,7 @@ var DOMElementPrototype = nil,
#endif
if (_postsBoundsChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
[_CPViewNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
[CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
}
/*!
@@ -828,7 +826,7 @@ var DOMElementPrototype = nil,
}
if (_postsBoundsChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
[_CPViewNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
[CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
}
@@ -1358,7 +1356,7 @@ setFrameOrigin:
_postsFrameChangedNotifications = shouldPostFrameChangedNotifications;
if (_postsFrameChangedNotifications)
[_CPViewNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
[CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
}
/*!
@@ -1389,7 +1387,7 @@ setBoundsOrigin:
_postsBoundsChangedNotifications = shouldPostBoundsChangedNotifications;
if (_postsBoundsChangedNotifications)
[_CPViewNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
[CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
}
/*!
@@ -1930,67 +1928,118 @@ setBoundsOrigin:
@end
@implementation CPView (Theming)
#pragma mark Theme States
+ (CPDictionary)themedAttributes
- (BOOL)hasThemeState:(CPThemeState)aState
{
return !!(_themeState & ((typeof aState === "string") ? CPThemeState(aState) : aState));
}
- (BOOL)setThemeState:(CPThemeState)aState
{
var newState = (typeof aState === "string") ? CPThemeState(aState) : aState;
if (_themeState & newState)
return NO;
_themeState |= newState;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
return YES;
}
- (BOOL)unsetThemeState:(CPThemeState)aState
{
var newState = ((typeof aState === "string") ? CPThemeState(aState) : aState);
if (!(_themeState & newState))
return NO;
_themeState &= ~newState;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
return YES;
}
#pragma mark Theme Attributes
+ (CPString)themeClass
{
return nil;
}
+ (CPArray)_themedAttributes
+ (CPDictionary)themeAttributes
{
if (!_CachedThemedAttributes)
_CachedThemedAttributes = {};
return nil;
}
+ (CPArray)_themeAttributes
{
if (!CachedThemeAttributes)
CachedThemeAttributes = {};
var theClass = [self class],
CPViewClass = [CPView class],
attributes = [];
while (theClass && theClass !== CPViewClass)
for (; theClass && theClass !== CPViewClass; theClass = [theClass superclass])
{
var cachedAttributes = _CachedThemedAttributes[class_getName(theClass)];
var cachedAttributes = CachedThemeAttributes[class_getName(theClass)];
if (cachedAttributes)
{
attributes = attributes.length ? attributes.concat(cachedAttributes) : attributes;
_CachedThemedAttributes[[self className]] = attributes;
CachedThemeAttributes[[self className]] = attributes;
break;
}
var attributeDictionary = [theClass themeAttributes];
var attributeDictionary = [theClass themedAttributes];
if (attributeDictionary)
if (!attributeDictionary)
continue;
var attributeKeys = [attributeDictionary allKeys],
attributeCount = attributeKeys.length;
while (attributeCount--)
{
var attributeKeys = [attributeDictionary allKeys],
attributeCount = attributeKeys.length;
while (attributeCount--)
{
var attributeName = attributeKeys[attributeCount];
attributes.push([attributeDictionary objectForKey:attributeName]);
attributes.push(attributeName);
}
var attributeName = attributeKeys[attributeCount];
attributes.push([attributeDictionary objectForKey:attributeName]);
attributes.push(attributeName);
}
theClass = [theClass superclass];
}
return attributes;
}
- (void)_loadThemedAttributes
- (void)_loadThemeAttributes
{
var theme = [self theme],
theClass = [self class],
attributes = [theClass _themedAttributes];
var theClass = [self class],
attributes = [theClass _themeAttributes],
count = attributes.length;
if (!count)
return;
var theme = [self theme],
themeClass = [theClass themeClass];
_themeAttributes = {};
while (count--)
{
var attributeName = attributes[count--];
var attributeName = attributes[count--],
attribute = [[_CPThemeAttribute alloc] initWithName:attributeName defaultValue:attributes[count]];
[attribute setParentAttribute:[theme _attributeWithName:attributeName forClass:themeClass]];
_themedAttributes[attributeName] = CPThemedAttributeMake(attributeName, attributes[count], theme, theClass);
_themeAttributes[attributeName] = attribute;
}
}
@@ -2011,73 +2060,87 @@ setBoundsOrigin:
- (void)viewDidChangeTheme
{
var theme = [self theme];
for (var attributeName in _themedAttributes)
if (_themedAttributes.hasOwnProperty(attributeName))
[_themedAttributes[attributeName] setTheme:theme];
if (!_themeAttributes)
return;
var theme = [self theme],
themeClass = [[self class] themeClass];
for (var attributeName in _themeAttributes)
if (_themeAttributes.hasOwnProperty(attributeName))
[_themeAttributes[attributeName] setParentAttribute:[theme _attributeWithName:attributeName forClass:themeClass]];
}
- (CPDictionary)_themedAttributes
- (CPDictionary)_themeAttributeDictionary
{
var dictionary = [CPDictionary dictionary];
for (var attributeName in _themedAttributes)
if (_themedAttributes.hasOwnProperty(attributeName))
[dictionary setObject:_themedAttributes[attributeName] forKey:attributeName];
if (_themeAttributes)
{
var theme = [self theme];
for (var attributeName in _themeAttributes)
if (_themeAttributes.hasOwnProperty(attributeName))
[dictionary setObject:_themeAttributes[attributeName] forKey:attributeName];
}
return dictionary;
}
- (void)setValue:(id)aValue forThemedAttributeName:(CPString)aName inControlState:(CPControlState)aControlState
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(CPThemeState)aState
{
var attribute = _themedAttributes[aName];
if (!_themeAttributes || !_themeAttributes[aName])
[CPException raise:CPInvalidArgumentException reason:[self className] + " does not contain theme attribute '" + aName + "'"];
if (!attribute)
return;
var currentValue = [self currentValueForThemeAttribute:aName];
var currentValue = [self currentValueForThemedAttributeName:aName];
[_themeAttributes[aName] setValue:aValue forState:aState];
[attribute setValue:aValue forControlState:aControlState];
if ([self currentValueForThemedAttributeName:aName] === currentValue)
if ([self currentValueForThemeAttribute:aName] === currentValue)
return;
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
- (void)setValue:(id)aValue forThemedAttributeName:(CPString)aName
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName
{
var attribute = _themedAttributes[aName];
if (!_themeAttributes || !_themeAttributes[aName])
[CPException raise:CPInvalidArgumentException reason:[self className] + " does not contain theme attribute '" + aName + "'"];
if (!attribute)
return;
var currentValue = [self currentValueForThemeAttribute:aName];
var currentValue = [self currentValueForThemedAttributeName:aName];
[_themeAttributes[aName] setValue:aValue];
[attribute setValue:aValue];
if ([self currentValueForThemedAttributeName:aName] === currentValue)
if ([self currentValueForThemeAttribute:aName] === currentValue)
return;
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
- (id)valueForThemedAttributeName:(CPString)aName inControlState:(CPControlState)aControlState
- (id)valueForThemeAttribute:(CPString)aName inState:(CPThemeState)aState
{
return [_themedAttributes[aName] valueForControlState:aControlState];
if (!_themeAttributes || !_themeAttributes[aName])
[CPException raise:CPInvalidArgumentException reason:[self className] + " does not contain theme attribute '" + aName + "'"];
return [_themeAttributes[aName] valueForState:aState];
}
- (id)valueForThemedAttributeName:(CPString)aName
- (id)valueForThemeAttribute:(CPString)aName
{
return [_themedAttributes[aName] value];
if (!_themeAttributes || !_themeAttributes[aName])
[CPException raise:CPInvalidArgumentException reason:[self className] + " does not contain theme attribute '" + aName + "'"];
return [_themeAttributes[aName] value];
}
- (void)currentValueForThemedAttributeName:(CPString)aName
- (void)currentValueForThemeAttribute:(CPString)aName
{
return [_themedAttributes[aName] valueForControlState:_controlState];//[self controlStateForThemedAttributeName:aName]];
if (!_themeAttributes || !_themeAttributes[aName])
[CPException raise:CPInvalidArgumentException reason:[self className] + " does not contain theme attribute '" + aName + "'"];
return [_themeAttributes[aName] valueForState:_themeState];
}
@end
@@ -2093,6 +2156,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
CPViewSubviewsKey = @"CPViewSubviewsKey",
CPViewSuperviewKey = @"CPViewSuperviewKey",
CPViewTagKey = @"CPViewTagKey",
CPViewThemeStateKey = @"CPViewThemeStateKey",
CPViewWindowKey = @"CPViewWindowKey",
CPViewNextKeyViewKey = @"CPViewNextKeyViewKey",
CPViewPreviousKeyViewKey = @"CPViewPreviousKeyViewKey";
@@ -2135,7 +2199,6 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
_autoresizesSubviews = [aCoder decodeBoolForKey:CPViewAutoresizesSubviewsKey];
_hitTests = [aCoder decodeObjectForKey:CPViewHitTestsKey];
_isHidden = [aCoder decodeObjectForKey:CPViewIsHiddenKey];
_opacity = [aCoder decodeIntForKey:CPViewOpacityKey];
// DOM SETUP
@@ -2160,22 +2223,29 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
[self setBackgroundColor:[aCoder decodeObjectForKey:CPViewBackgroundColorKey]];
_theme = [CPTheme defaultTheme];
_themedAttributes = {};
_themeState = [aCoder decodeIntForKey:CPViewThemeStateKey];
_themeAttributes = {};
var theClass = [self class],
attributes = [theClass _themedAttributes],
themeClass = [theClass themeClass],
attributes = [theClass _themeAttributes],
count = attributes.length;
while (count--)
{
var attributeName = attributes[count--];
_themedAttributes[attributeName] = CPThemedAttributeDecode(aCoder, attributeName, attributes[count], _theme, theClass);
_themeAttributes[attributeName] = CPThemeAttributeDecode(aCoder, attributeName, attributes[count], _theme, themeClass);
}
[self setNeedsDisplay:YES];
}
_isHidden = NO;
if ([aCoder containsValueForKey:CPViewIsHiddenKey])
[self setHidden:[aCoder decodeBoolForKey:CPViewIsHiddenKey]];
}
return self;
}
@@ -2203,15 +2273,19 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
[aCoder encodeObject:_backgroundColor forKey:CPViewBackgroundColorKey];
[aCoder encodeBool:_hitTests forKey:CPViewHitTestsKey];
[aCoder encodeBool:_isHidden forKey:CPViewIsHiddenKey];
[aCoder encodeFloat:_opacity forKey:CPViewOpacityKey];
if (_isHidden)
[aCoder encodeBool:_isHidden forKey:CPViewIsHiddenKey];
[aCoder encodeConditionalObject:[self nextKeyView] forKey:CPViewNextKeyViewKey];
[aCoder encodeConditionalObject:[self previousKeyView] forKey:CPViewPreviousKeyViewKey];
for (var attributeName in _themedAttributes)
if (_themedAttributes.hasOwnProperty(attributeName))
CPThemedAttributeEncode(aCoder, _themedAttributes[attributeName]);
[aCoder encodeInt:_themeState forKey:CPViewThemeStateKey];
for (var attributeName in _themeAttributes)
if (_themeAttributes.hasOwnProperty(attributeName))
CPThemeAttributeEncode(aCoder, _themeAttributes[attributeName]);
}
@end
+5 -5
View File
@@ -180,7 +180,7 @@ CPWebViewScrollNative = 2;
// try to get the document size so we can correctly set the frame
var win = null;
try { win = [self window]; } catch (e) {}
try { win = [self DOMWindow]; } catch (e) {}
if (win && win.document)
{
@@ -290,7 +290,7 @@ CPWebViewScrollNative = 2;
// need to give the browser a chance to reset iframe, otherwise we'll be document.write()-ing the previous document
window.setTimeout(function() {
var win = [self window];
var win = [self DOMWindow];
win.document.write(_html);
@@ -385,14 +385,14 @@ CPWebViewScrollNative = 2;
_iframe.parentNode.removeChild(_iframe);
}
- (Window)window
- (DOMWindow)DOMWindow
{
return (_iframe.contentDocument && _iframe.contentDocument.defaultView) || _iframe.contentWindow;
}
- (CPWebScriptObject)windowScriptObject
{
var win = [self window];
var win = [self DOMWindow];
if (!_wso || win != [_wso window])
{
if (win)
@@ -470,7 +470,7 @@ CPWebViewScrollNative = 2;
{
try
{
[self window].print();
[self DOMWindow].print();
}
catch (e)
{
+17
View File
@@ -439,6 +439,8 @@ CPTexturedBackgroundWindowMask
{
if (_initialFirstResponder)
[self makeFirstResponder:_initialFirstResponder];
_keyViewLoopIsDirty = ![self _hasKeyViewLoop];
}
- (void)_setWindowView:(CPView)aWindowView
@@ -1731,6 +1733,21 @@ CPTexturedBackgroundWindowMask
_keyViewLoopIsDirty = YES;
}
- (BOOL)_hasKeyViewLoop
{
var subviews = [];
[self _appendSubviewsOf:_contentView toArray:subviews];
for (var i = 0, count = [subviews count]; i<count; i++)
{
if (subviews[i]._nextKeyView)
return YES;
}
return NO;
}
- (void)recalculateKeyViewLoop
{
var subviews = [];
+3 -3
View File
@@ -154,9 +154,6 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
{
_data = [CPData dataWithString:data];
if ([_loadDelegate respondsToSelector:@selector(cibDidFinishLoading:)])
[_loadDelegate cibDidFinishLoading:self];
}
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
@@ -168,6 +165,9 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
- (void)connectionDidFinishLoading:(CPURLConnection)aConnection
{
if ([_loadDelegate respondsToSelector:@selector(cibDidFinishLoading:)])
[_loadDelegate cibDidFinishLoading:self];
_loadDelegate = nil;
}
-13
View File
@@ -40,10 +40,6 @@ var _CPCibConnectorSourceKey = @"_CPCibConnectorSourceKey",
_source = [aCoder decodeObjectForKey:_CPCibConnectorSourceKey];
_destination = [aCoder decodeObjectForKey:_CPCibConnectorDestinationKey];
_label = [aCoder decodeObjectForKey:_CPCibConnectorLabelKey];
#if DEBUG
CPLog("Connection from " + [_source description] + " to " + [_destination description] + " and label " + _label + " decoded.");
#endif
}
return self;
@@ -64,11 +60,6 @@ var _CPCibConnectorSourceKey = @"_CPCibConnectorSourceKey",
- (void)establishConnection
{
#if DEBUG
CPLog('[' + [_source description] + " setTarget: " + [_destination description] + ']');
CPLog('[' + [_source description] + " setAction: " + _label + ']');
#endif
var selectorName = _label;
if (![selectorName hasSuffix:@":"])
@@ -106,10 +97,6 @@ var _CPCibConnectorSourceKey = @"_CPCibConnectorSourceKey",
- (void)establishConnection
{
#if DEBUG
CPLog([_source description] + " setValue: " + [_destination description] + " forKey: " + _label);
#endif
[_source setValue:_destination forKey:_label];
}
+4 -2
View File
@@ -41,10 +41,12 @@ var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName";
- (id)_cibInstantiate
{
var theClass = CPClassFromString(_className);
#if DEBUG
if (!theClass)
CPLog("Unknown class \"" + _className + "\" in cib file");
#endif
if (theClass === [CPApplication class])
return [CPApplication sharedApplication];
+2 -1
View File
@@ -78,8 +78,9 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
// FIXME: Should we instead throw an exception?
if (!theClass)
{
#if DEBUG
CPLog("Unknown class \"" + _className + "\" in cib file, using CPView instead.");
#endif
theClass = [CPView class];
}
+3 -3
View File
@@ -59,10 +59,10 @@
#define _CGRectContainsPoint(aRect, aPoint) (aPoint.x >= _CGRectGetMinX(aRect) && aPoint.y >= _CGRectGetMinY(aRect) && aPoint.x < _CGRectGetMaxX(aRect) && aPoint.y < _CGRectGetMaxY(aRect))
#define _CGInsetMake(_top, _left, _bottom, _right) { top:(_top), left:(_left), bottom:(_bottom), right:(_right) }
#define _CGInsetMakeCopy(anInset) _CGInsetMake(anInset.top, anInset.left, anInset.bottom, anInset.right)
#define _CGInsetMake(_top, _right, _bottom, _left) { top:(_top), right:(_right), bottom:(_bottom), left:(_left) }
#define _CGInsetMakeCopy(anInset) _CGInsetMake(anInset.top, anInset.right, anInset.bottom, anInset.left)
#define _CGInsetMakeZero() _CGInsetMake(0, 0, 0, 0)
#define _CGInsetIsEmpty(anInset) ((anInset).left === 0 && (anInset).top === 0 && (anInset).right === 0 && (anInset).bottom === 0)
#define _CGInsetIsEmpty(anInset) ((anInset).top === 0 && (anInset).right === 0 && (anInset).bottom === 0 && (anInset).left === 0)
// DEPRECATED
#define _CGPointCreateCopy(aPoint) _CGPointMake(aPoint.x, aPoint.y)
+12 -3
View File
@@ -65,7 +65,7 @@ _function(CGRectIsNull(aRect))
_function(CGRectContainsPoint(aRect, aPoint))
_function(CGInsetMake(top, left, bottom, right))
_function(CGInsetMake(top, right, bottom, left))
_function(CGInsetMakeZero())
_function(CGInsetMakeCopy(anInset))
_function(CGInsetIsEmpty(anInset))
@@ -209,8 +209,17 @@ function CGPointFromEvent(anEvent)
return _CGPointMake(anEvent.clientX, anEvent.clientY);
}
function CPStringFromInset(anInset)
function CGInsetFromString(aString)
{
return anInset.top+" "+anInset.left+" "+anInset.bottom+" "+anInset.right;
var numbers = aString.substr(1, aString.length - 2).split(',');
return _CGInsetMake(parseFloat(numbers[0]), parseFloat(numbers[1]), parseFloat(numbers[2]), parseFloat(numbers[3]));
}
CGInsetFromCPString = CGInsetFromString;
function CPStringFromCGInset(anInset)
{
return '{' + anInset.top + ", " + anInset.left + ", " + anInset.bottom + ", " + anInset.right + '}';
}
+2 -1
View File
@@ -25,7 +25,8 @@ ObjectiveJ::BundleTask.new(:AppKit) do |t|
t.resources = FileList['Resources/*']
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-DDEBUG -g' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Release'
t.platforms = [ObjectiveJ::Platform::Browser, ObjectiveJ::Platform::Rhino]
t.type = ObjectiveJ::Bundle::Type::Framework
end
Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

+192 -117
View File
@@ -7,7 +7,7 @@
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPThemedAttribute.j>
@implementation AristoThemeDescriptor : CPObject
{
@@ -21,34 +21,34 @@
+ (CPScroller)themedVerticalScroller
{
var scroller = [[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, 17.0, 170.0)],
trackColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track.png" size:CGSizeMake(17.0, 1.0)]),
disabledTrackColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track-disabled.png" size:CGSizeMake(17.0, 1.0)]);
trackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track.png" size:CGSizeMake(17.0, 1.0)]),
disabledTrackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track-disabled.png" size:CGSizeMake(17.0, 1.0)]);
[scroller setValue:CGSizeMake(15.0, 19.0) forThemedAttributeName:@"minimum-knob-size" inControlState:CPControlStateVertical];
[scroller setValue:CGSizeMake(15.0, 19.0) forThemeAttribute:@"minimum-knob-size" inState:CPThemeStateVertical];
[scroller setValue:CGInsetMake(9.0, 9.0, 9.0, 9.0) forThemedAttributeName:@"track-overlap-inset" inControlState:CPControlStateVertical];
[scroller setValue:trackColor forThemedAttributeName:@"knob-slot-color" inControlState:CPControlStateVertical];
[scroller setValue:disabledTrackColor forThemedAttributeName:@"knob-slot-color" inControlState:CPControlStateVertical | CPControlStateDisabled];
[scroller setValue:CGInsetMake(9.0, 9.0, 9.0, 9.0) forThemeAttribute:@"track-overlap-inset" inState:CPThemeStateVertical];
[scroller setValue:trackColor forThemeAttribute:@"knob-slot-color" inState:CPThemeStateVertical];
[scroller setValue:disabledTrackColor forThemeAttribute:@"knob-slot-color" inState:CPThemeStateVertical | CPThemeStateDisabled];
var arrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow.png" size:CGSizeMake(17.0, 30.0)]),
highlightedArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
disabledArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
var arrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow.png" size:CGSizeMake(17.0, 30.0)]),
highlightedArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
disabledArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
[scroller setValue:CGSizeMake(17.0, 30.0) forThemedAttributeName:@"decrement-line-size" inControlState:CPControlStateVertical];
[scroller setValue:arrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateVertical];
[scroller setValue:highlightedArrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateVertical | CPControlStateHighlighted],
[scroller setValue:disabledArrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateVertical | CPControlStateDisabled];
[scroller setValue:CGSizeMake(17.0, 30.0) forThemeAttribute:@"decrement-line-size" inState:CPThemeStateVertical];
[scroller setValue:arrowColor forThemeAttribute:@"decrement-line-color" inState:CPThemeStateVertical];
[scroller setValue:highlightedArrowColor forThemeAttribute:@"decrement-line-color" inState:CPThemeStateVertical | CPThemeStateHighlighted],
[scroller setValue:disabledArrowColor forThemeAttribute:@"decrement-line-color" inState:CPThemeStateVertical | CPThemeStateDisabled];
var arrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow.png" size:CGSizeMake(17.0, 30.0)]),
highlightedArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
disabledArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
var arrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow.png" size:CGSizeMake(17.0, 30.0)]),
highlightedArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
disabledArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
[scroller setValue:CGSizeMake(17.0, 30.0) forThemedAttributeName:@"increment-line-size"];
[scroller setValue:arrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateVertical];
[scroller setValue:highlightedArrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateVertical | CPControlStateHighlighted];
[scroller setValue:disabledArrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateVertical | CPControlStateDisabled];
[scroller setValue:CGSizeMake(17.0, 30.0) forThemeAttribute:@"increment-line-size"];
[scroller setValue:arrowColor forThemeAttribute:@"increment-line-color" inState:CPThemeStateVertical];
[scroller setValue:highlightedArrowColor forThemeAttribute:@"increment-line-color" inState:CPThemeStateVertical | CPThemeStateHighlighted];
[scroller setValue:disabledArrowColor forThemeAttribute:@"increment-line-color" inState:CPThemeStateVertical | CPThemeStateDisabled];
var knobColor = PatterColor([[CPThreePartImage alloc] initWithImageSlices:
var knobColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices:
[
[_CPCibCustomResource imageResourceWithName:"scroller-vertical-knob-top.png" size:CGSizeMake(15.0, 8.0)],
[_CPCibCustomResource imageResourceWithName:"scroller-vertical-knob-center.png" size:CGSizeMake(15.0, 1.0)],
@@ -56,7 +56,7 @@
]
isVertical:YES]);
[scroller setValue:knobColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateVertical];
[scroller setValue:knobColor forThemeAttribute:@"knob-color" inState:CPThemeStateVertical];
[scroller setFloatValue:0.1 knobProportion:0.5];
@@ -64,36 +64,36 @@
}
+ (CPScroller)themedHorizontalScroller
{CPControlStateHorizontal = 0;
{
var scroller = [[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, 170.0, 17.0)],
trackColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-horizontal-track.png" size:CGSizeMake(1.0, 17.0)]),
disabledTrackColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track-disabled.png" size:CGSizeMake(17.0, 1.0)]);
trackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-horizontal-track.png" size:CGSizeMake(1.0, 17.0)]),
disabledTrackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track-disabled.png" size:CGSizeMake(17.0, 1.0)]);
[scroller setBackgroundColor:[CPColor blueColor]];
[scroller setValue:CGSizeMake(19.0, 15.0) forThemedAttributeName:@"minimum-knob-size" inControlState:CPControlStateHorizontal];
[scroller setValue:CGSizeMake(19.0, 15.0) forThemeAttribute:@"minimum-knob-size"];
[scroller setValue:CGInsetMake(9.0, 9.0, 9.0, 9.0) forThemedAttributeName:@"track-overlap-inset" inControlState:CPControlStateHorizontal];
[scroller setValue:trackColor forThemedAttributeName:@"knob-slot-color" inControlState:CPControlStateHorizontal];
[scroller setValue:disabledTrackColor forThemedAttributeName:@"knob-slot-color" inControlState:CPControlStateHorizontal | CPControlStateDisabled];
[scroller setValue:CGInsetMake(9.0, 9.0, 9.0, 9.0) forThemeAttribute:@"track-overlap-inset" ];
[scroller setValue:trackColor forThemeAttribute:@"knob-slot-color"];
[scroller setValue:disabledTrackColor forThemeAttribute:@"knob-slot-color" inState:CPThemeStateDisabled];
var arrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow.png" size:CGSizeMake(32.0, 17.0)]),
highlightedArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
disabledArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-up-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
var arrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow.png" size:CGSizeMake(32.0, 17.0)]),
highlightedArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
disabledArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
[scroller setValue:CGSizeMake(32.0, 17.0) forThemedAttributeName:@"decrement-line-size" inControlState:CPControlStateHorizontal];
[scroller setValue:arrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateHorizontal];
[scroller setValue:highlightedArrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateHorizontal | CPControlStateHighlighted],
[scroller setValue:disabledArrowColor forThemedAttributeName:@"decrement-line-color" inControlState:CPControlStateHorizontal | CPControlStateDisabled];
[scroller setValue:CGSizeMake(32.0, 17.0) forThemeAttribute:@"decrement-line-size"];
[scroller setValue:arrowColor forThemeAttribute:@"decrement-line-color"];
[scroller setValue:highlightedArrowColor forThemeAttribute:@"decrement-line-color" inState:CPThemeStateHighlighted],
[scroller setValue:disabledArrowColor forThemeAttribute:@"decrement-line-color" inState:CPThemeStateDisabled];
var arrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow.png" size:CGSizeMake(31.0, 17.0)]),
highlightedArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
disabledArrowColor = PatterColor([_CPCibCustomResource imageResourceWithName:"scroller-down-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
var arrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow.png" size:CGSizeMake(31.0, 17.0)]),
highlightedArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
disabledArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
[scroller setValue:CGSizeMake(31.0, 17.0) forThemedAttributeName:@"increment-line-size"];
[scroller setValue:arrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateHorizontal];
[scroller setValue:highlightedArrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateHorizontal | CPControlStateHighlighted];
[scroller setValue:disabledArrowColor forThemedAttributeName:@"increment-line-color" inControlState:CPControlStateHorizontal | CPControlStateDisabled];
[scroller setValue:CGSizeMake(31.0, 17.0) forThemeAttribute:@"increment-line-size"];
[scroller setValue:arrowColor forThemeAttribute:@"increment-line-color"];
[scroller setValue:highlightedArrowColor forThemeAttribute:@"increment-line-color" inState:CPThemeStateHighlighted];
[scroller setValue:disabledArrowColor forThemeAttribute:@"increment-line-color" inState:CPThemeStateDisabled];
var knobColor = PatterColor([[CPThreePartImage alloc] initWithImageSlices:
var knobColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices:
[
[_CPCibCustomResource imageResourceWithName:"scroller-horizontal-knob-left.png" size:CGSizeMake(11.0, 15.0)],
[_CPCibCustomResource imageResourceWithName:"scroller-horizontal-knob-center.png" size:CGSizeMake(1.0, 15.0)],
@@ -101,7 +101,7 @@
]
isVertical:NO]);
[scroller setValue:knobColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateHorizontal];
[scroller setValue:knobColor forThemeAttribute:@"knob-color"];
[scroller setFloatValue:0.1 knobProportion:0.5];
@@ -139,17 +139,15 @@
[textfield setBezeled:YES];
[textfield setValue:bezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBezeled];
[textfield setValue:bezelFocusedColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBezeled|CPControlStateEditing];
[textfield setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBezeled];
[textfield setValue:bezelFocusedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBezeled|CPThemeStateEditing];
[textfield setValue:[CPFont systemFontOfSize:12.0] forThemeAttribute:@"font" inState:CPThemeStateBezeled];
[textfield setValue:CGInsetMake(9.0, 7.0, 5.0, 8.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBezeled];
[textfield setValue:[CPFont systemFontOfSize:12.0] forThemedAttributeName:@"font"];
[textfield setValue:CGInsetMake(4.0, 4.0, 3.0, 4.0) forThemeAttribute:@"bezel-inset" inState:CPThemeStateBezeled];
[textfield setValue:CGInsetMake(0.0, 0.0, 0.0, 0.0) forThemeAttribute:@"bezel-inset" inState:CPThemeStateBezeled|CPThemeStateEditing];
[textfield setValue:CGInsetMake(9.0, 8.0, 5.0, 7.0) forThemedAttributeName:@"content-inset" inControlState:CPControlStateBezeled];
[textfield setValue:CGInsetMake(4.0, 4.0, 3.0, 4.0) forThemedAttributeName:@"bezel-inset" inControlState:CPControlStateBezeled];
[textfield setValue:CGInsetMake(0.0, 0.0, 0.0, 0.0) forThemedAttributeName:@"bezel-inset" inControlState:CPControlStateBezeled|CPControlStateEditing];
[textfield setValue:[CPColor colorWithCalibratedRed:189.0 / 255.0 green:199.0 / 255.0 blue:211.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color" inControlState:CPTextFieldStatePlaceholder];
[textfield setValue:[CPColor colorWithCalibratedRed:189.0 / 255.0 green:199.0 / 255.0 blue:211.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder];
[textfield setPlaceholderString:"cheese cheese"];
[textfield setStringValue:""];
@@ -178,16 +176,16 @@
[textfield setBezeled:YES];
[textfield setBezelStyle:CPTextFieldRoundedBezel];
[textfield setValue:bezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBezeled | CPTextFieldStateRounded];
[textfield setValue:bezelFocusedColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBezeled | CPTextFieldStateRounded | CPControlStateEditing];
[textfield setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBezeled | CPTextFieldStateRounded];
[textfield setValue:bezelFocusedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBezeled | CPTextFieldStateRounded | CPThemeStateEditing];
[textfield setValue:[CPFont systemFontOfSize:12.0] forThemedAttributeName:@"font"];
[textfield setValue:CGInsetMake(9.0, 14.0, 6.0, 14.0) forThemedAttributeName:@"content-inset" inControlState:CPControlStateBezeled | CPTextFieldStateRounded];
[textfield setValue:[CPFont systemFontOfSize:12.0] forThemeAttribute:@"font"];
[textfield setValue:CGInsetMake(9.0, 14.0, 6.0, 14.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBezeled | CPTextFieldStateRounded];
[textfield setValue:CGInsetMake(4.0, 4.0, 4.0, 4.0) forThemedAttributeName:@"bezel-inset" inControlState:CPControlStateBezeled|CPTextFieldStateRounded];
[textfield setValue:CGInsetMake(0.0, 0.0, 0.0, 0.0) forThemedAttributeName:@"bezel-inset" inControlState:CPControlStateBezeled|CPTextFieldStateRounded|CPControlStateEditing];
[textfield setValue:CGInsetMake(4.0, 4.0, 4.0, 4.0) forThemeAttribute:@"bezel-inset" inState:CPThemeStateBezeled|CPTextFieldStateRounded];
[textfield setValue:CGInsetMake(0.0, 0.0, 0.0, 0.0) forThemeAttribute:@"bezel-inset" inState:CPThemeStateBezeled|CPTextFieldStateRounded|CPThemeStateEditing];
[textfield setValue:[CPColor colorWithCalibratedRed:189.0 / 255.0 green:199.0 / 255.0 blue:211.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color" inControlState:CPTextFieldStatePlaceholder];
[textfield setValue:[CPColor colorWithCalibratedRed:189.0 / 255.0 green:199.0 / 255.0 blue:211.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder];
[textfield setPlaceholderString:"cheese cheese"];
[textfield setStringValue:""];
@@ -235,28 +233,29 @@
[button setTitle:@"Cancel"];
[button setValue:[CPFont boldSystemFontOfSize:12.0] forThemedAttributeName:@"font" inControlState:CPControlStateBordered];
[button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color"];
[button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-shadow-color" inControlState:CPControlStateBordered];
[button setValue:CGSizeMake(0.0, 1.0) forThemedAttributeName:@"text-shadow-offset" inControlState:CPControlStateBordered];
[button setValue:CPLineBreakByTruncatingTail forThemedAttributeName:@"line-break-mode"];
[button setValue:[CPFont boldSystemFontOfSize:12.0] forThemeAttribute:@"font" inState:CPThemeStateBordered];
[button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-color"];
[button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateBordered];
[button setValue:CGSizeMake(0.0, 1.0) forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateBordered];
[button setValue:CPLineBreakByTruncatingTail forThemeAttribute:@"line-break-mode"];
[button setValue:bezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBordered];
[button setValue:highlightedBezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBordered|CPControlStateHighlighted];
[button setValue:CGInsetMake(0.0, 5.0, 0.0, 5.0) forThemedAttributeName:@"content-inset" inControlState:CPControlStateBordered];
[button setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[button setValue:highlightedBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered|CPThemeStateHighlighted];
[button setValue:CGInsetMake(0.0, 5.0, 0.0, 5.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBordered];
[button setValue:defaultBezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBordered|CPControlStateDefault];
[button setValue:defaultHighlightedBezelColor forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBordered|CPControlStateHighlighted|CPControlStateDefault];
[button setValue:[CPColor colorWithCalibratedRed:13.0/255.0 green:51.0/255.0 blue:70.0/255.0 alpha:1.0] forThemedAttributeName:@"text-color" inControlState:CPControlStateDefault];
[button setValue:defaultBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered|CPThemeStateDefault];
[button setValue:defaultHighlightedBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered|CPThemeStateHighlighted|CPThemeStateDefault];
[button setValue:[CPColor colorWithCalibratedRed:13.0/255.0 green:51.0/255.0 blue:70.0/255.0 alpha:1.0] forThemeAttribute:@"text-color" inState:CPThemeStateDefault];
[button setValue:24.0 forThemedAttributeName:@"default-height"];
[button setValue:24.0 forThemeAttribute:@"default-height"];
return button;
}
+ (CPPopUpButton)themedPopUpButton
{
var button = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 24.0) pullsDown:NO],color = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:
var button = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 24.0) pullsDown:NO],
color = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:
[
[_CPCibCustomResource imageResourceWithName:"button-bezel-left.png" size:CGSizeMake(4.0, 24.0)],
[_CPCibCustomResource imageResourceWithName:"button-bezel-center.png" size:CGSizeMake(1.0, 24.0)],
@@ -266,12 +265,12 @@
[button setTitle:@"Pop Up"];
[button setValue:color forThemedAttributeName:@"bezel-color" inControlState:CPControlStateBordered];
[button setValue:CGInsetMake(0, 5, 0, 27.0 + 5.0) forThemedAttributeName:@"content-inset" inControlState:CPControlStateBordered];
[button setValue:[CPFont boldSystemFontOfSize:12.0] forThemedAttributeName:@"font"];
[button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color"];
[button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-shadow-color"];
[button setValue:CGSizeMake(0.0, 1.0) forThemedAttributeName:@"text-shadow-offset"];
[button setValue:color forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[button setValue:CGInsetMake(0, 27.0 + 5.0, 0, 5.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBordered];
[button setValue:[CPFont boldSystemFontOfSize:12.0] forThemeAttribute:@"font"];
[button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-color"];
[button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-shadow-color"];
[button setValue:CGSizeMake(0.0, 1.0) forThemeAttribute:@"text-shadow-offset"];
[button addItemWithTitle:@"item"];
@@ -288,21 +287,99 @@
[_CPCibCustomResource imageResourceWithName:"popup-bezel-right-pullsdown.png" size:CGSizeMake(27.0, 24.0)]
]
isVertical:NO]];
[button setTitle:@"Pop Up"];
[button setValue:color forThemedAttributeName:@"bezel-color" inControlState:CPPopUpButtonStatePullsDown|CPControlStateBordered];
[button setValue:CGInsetMake(0, 5, 0, 27.0 + 5.0) forThemedAttributeName:@"content-inset" inControlState:CPControlStateBordered];
[button setValue:[CPFont boldSystemFontOfSize:12.0] forThemedAttributeName:@"font"];
[button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-color"];
[button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemedAttributeName:@"text-shadow-color"];
[button setValue:CGSizeMake(0.0, 1.0) forThemedAttributeName:@"text-shadow-offset"];
[button setValue:color forThemeAttribute:@"bezel-color" inState:CPPopUpButtonStatePullsDown|CPThemeStateBordered];
[button setValue:CGInsetMake(0, 27.0 + 5.0, 0, 5.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBordered];
[button setValue:[CPFont boldSystemFontOfSize:12.0] forThemeAttribute:@"font"];
[button setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-color"];
[button setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-shadow-color"];
[button setValue:CGSizeMake(0.0, 1.0) forThemeAttribute:@"text-shadow-offset"];
[button addItemWithTitle:@"item"];
return button;
}
+ (CPPopUpButton)themedSegmentedControl
{
var segmentedControl = [[CPSegmentedControl alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 24.0)];
[segmentedControl setTrackingMode:CPSegmentSwitchTrackingSelectAny];
[segmentedControl setSegmentCount:3];
[segmentedControl setWidth:40.0 forSegment:0];
[segmentedControl setLabel:@"foo" forSegment:0];
[segmentedControl setTag:1 forSegment:0];
[segmentedControl setWidth:60.0 forSegment:1];
[segmentedControl setLabel:@"bar" forSegment:1];
[segmentedControl setTag:2 forSegment:1];
[segmentedControl setWidth:25.0 forSegment:2];
[segmentedControl setLabel:@"1" forSegment:2];
[segmentedControl setTag:3 forSegment:2];
//various colors
var centerBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-center.png" size:CGSizeMake(1.0, 24.0)]),
dividerBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-divider.png" size:CGSizeMake(1.0, 24.0)]),
centerHighlightedBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-highlighted-center.png" size:CGSizeMake(1.0, 24.0)]),
dividerHighlightedBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-highlighted-divider.png" size:CGSizeMake(1.0, 24.0)]),
leftHighlightedBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-highlighted-left.png" size:CGSizeMake(4.0, 24.0)]),
rightHighlightedBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-highlighted-right.png" size:CGSizeMake(4.0, 24.0)]),
inactiveCenterBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-inactive-center.png" size:CGSizeMake(1.0, 24.0)]),
inactiveDividerBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-inactive-divider.png" size:CGSizeMake(1.0, 24.0)]),
inactiveLeftBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-inactive-left.png" size:CGSizeMake(4.0, 24.0)]),
inactiveRightBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-inactive-right.png" size:CGSizeMake(4.0, 24.0)]),
leftBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-left.png" size:CGSizeMake(4.0, 24.0)]),
rightBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-right.png" size:CGSizeMake(4.0, 24.0)]),
pushedCenterBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-pushed-center.png" size:CGSizeMake(1.0, 24.0)]),
pushedLeftBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-pushed-left.png" size:CGSizeMake(4.0, 24.0)]),
pushedRightBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-pushed-right.png" size:CGSizeMake(4.0, 24.0)]);
pushedHighlightedCenterBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-pushed-highlighted-center.png" size:CGSizeMake(1.0, 24.0)]),
pushedHighlightedLeftBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-pushed-highlighted-left.png" size:CGSizeMake(4.0, 24.0)]),
pushedHighlightedRightBezelColor = PatternColor([_CPCibCustomResource imageResourceWithName:@"segmented-control-bezel-pushed-highlighted-right.png" size:CGSizeMake(4.0, 24.0)]);
[segmentedControl setValue:centerBezelColor forThemeAttribute:@"center-segment-bezel-color" inState:CPThemeStateNormal];
[segmentedControl setValue:inactiveCenterBezelColor forThemeAttribute:@"center-segment-bezel-color" inState:CPThemeStateDisabled];
[segmentedControl setValue:centerHighlightedBezelColor forThemeAttribute:@"center-segment-bezel-color" inState:CPThemeStateSelected];
[segmentedControl setValue:pushedCenterBezelColor forThemeAttribute:@"center-segment-bezel-color" inState:CPThemeStateHighlighted];
[segmentedControl setValue:pushedHighlightedCenterBezelColor forThemeAttribute:@"center-segment-bezel-color" inState:CPThemeStateHighlighted|CPThemeStateSelected];
[segmentedControl setValue:dividerBezelColor forThemeAttribute:@"divider-bezel-color" inState:CPThemeStateNormal];
[segmentedControl setValue:inactiveDividerBezelColor forThemeAttribute:@"divider-bezel-color" inState:CPThemeStateDisabled];
[segmentedControl setValue:dividerHighlightedBezelColor forThemeAttribute:@"divider-bezel-color" inState:CPThemeStateSelected];
[segmentedControl setValue:dividerBezelColor forThemeAttribute:@"divider-bezel-color" inState:CPThemeStateHighlighted];
[segmentedControl setValue:rightBezelColor forThemeAttribute:@"right-segment-bezel-color" inState:CPThemeStateNormal];
[segmentedControl setValue:inactiveRightBezelColor forThemeAttribute:@"right-segment-bezel-color" inState:CPThemeStateDisabled];
[segmentedControl setValue:rightHighlightedBezelColor forThemeAttribute:@"right-segment-bezel-color" inState:CPThemeStateSelected];
[segmentedControl setValue:pushedRightBezelColor forThemeAttribute:@"right-segment-bezel-color" inState:CPThemeStateHighlighted];
[segmentedControl setValue:pushedHighlightedRightBezelColor forThemeAttribute:@"right-segment-bezel-color" inState:CPThemeStateHighlighted|CPThemeStateSelected];
[segmentedControl setValue:leftBezelColor forThemeAttribute:@"left-segment-bezel-color" inState:CPThemeStateNormal];
[segmentedControl setValue:inactiveLeftBezelColor forThemeAttribute:@"left-segment-bezel-color" inState:CPThemeStateDisabled];
[segmentedControl setValue:leftHighlightedBezelColor forThemeAttribute:@"left-segment-bezel-color" inState:CPThemeStateSelected];
[segmentedControl setValue:pushedLeftBezelColor forThemeAttribute:@"left-segment-bezel-color" inState:CPThemeStateHighlighted];
[segmentedControl setValue:pushedHighlightedLeftBezelColor forThemeAttribute:@"left-segment-bezel-color" inState:CPThemeStateHighlighted|CPThemeStateSelected];
[segmentedControl setValue:CGInsetMake(0.0, 4.0, 0.0, 4.0) forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[segmentedControl setValue:CGInsetMake(0.0, 0.0, 0.0, 0.0) forThemeAttribute:@"bezel-inset" inState:CPThemeStateNormal];
[segmentedControl setValue:[CPFont boldSystemFontOfSize:12.0] forThemeAttribute:@"font"];
[segmentedControl setValue:[CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-color"];
[segmentedControl setValue:[CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0] forThemeAttribute:@"text-shadow-color"];
[segmentedControl setValue:CGSizeMake(0.0, 1.0) forThemeAttribute:@"text-shadow-offset"];
[segmentedControl setValue:CPLineBreakByTruncatingTail forThemeAttribute:@"line-break-mode"];
[segmentedControl setValue:1.0 forThemeAttribute:@"divider-thickness"];
[segmentedControl setValue:24.0 forThemeAttribute:@"default-height"];
return segmentedControl;
}
+ (CPSlider)themedHorizontalSlider
{
var slider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 50.0, 24.0)],
@@ -314,15 +391,15 @@
]
isVertical:NO]];
[slider setValue:5.0 forThemedAttributeName:@"track-width"];
[slider setValue:trackColor forThemedAttributeName:@"track-color"];
[slider setValue:5.0 forThemeAttribute:@"track-width"];
[slider setValue:trackColor forThemeAttribute:@"track-color"];
var knobColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"knob.png" size:CGSizeMake(23.0, 24.0)]];
knobHighlightedColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"knob-highlighted.png" size:CGSizeMake(23.0, 24.0)]];
[slider setValue:CGSizeMake(23.0, 24.0) forThemedAttributeName:@"knob-size"];
[slider setValue:knobColor forThemedAttributeName:@"knob-color"];
[slider setValue:knobHighlightedColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateHighlighted];
[slider setValue:CGSizeMake(23.0, 24.0) forThemeAttribute:@"knob-size"];
[slider setValue:knobColor forThemeAttribute:@"knob-color"];
[slider setValue:knobHighlightedColor forThemeAttribute:@"knob-color" inState:CPThemeStateHighlighted];
return slider;
}
@@ -338,15 +415,15 @@
]
isVertical:YES]];
[slider setValue:5.0 forThemedAttributeName:@"track-width"];
[slider setValue:trackColor forThemedAttributeName:@"track-color" inControlState:CPControlStateVertical];
[slider setValue:5.0 forThemeAttribute:@"track-width"];
[slider setValue:trackColor forThemeAttribute:@"track-color" inState:CPThemeStateVertical];
var knobColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"knob.png" size:CGSizeMake(23.0, 24.0)]];
knobHighlightedColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"knob-highlighted.png" size:CGSizeMake(23.0, 24.0)]];
[slider setValue:CGSizeMake(23.0, 24.0) forThemedAttributeName:@"knob-size"];
[slider setValue:knobColor forThemedAttributeName:@"knob-color"];
[slider setValue:knobHighlightedColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateHighlighted];
[slider setValue:CGSizeMake(23.0, 24.0) forThemeAttribute:@"knob-size"];
[slider setValue:knobColor forThemeAttribute:@"knob-color"];
[slider setValue:knobHighlightedColor forThemeAttribute:@"knob-color" inState:CPThemeStateHighlighted];
return slider;
}
@@ -354,42 +431,40 @@
+ (CPSlider)themedCircularSlider
{
var slider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 32.0, 32.0)],
trackColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"circularSliderBezel.png" size:CGSizeMake(32.0, 32.0)]];
trackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"circularSliderBezel.png" size:CGSizeMake(32.0, 32.0)]);
[slider setSliderType:CPCircularSlider];
[slider setValue:trackColor forThemedAttributeName:@"track-color" inControlState:CPControlStateCircular];
[slider setValue:trackColor forThemedAttributeName:@"track-color" inControlState:CPControlStateCircular|CPControlStateVertical];
[slider setValue:trackColor forThemeAttribute:@"track-color" inState:CPThemeStateCircular];
var knobColor = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"circularSliderKnob.png" size:CGSizeMake(5.0, 5.0)]],
knobHighlightedColor = knobColor;
[slider setValue:CGSizeMake(5.0, 5.0) forThemedAttributeName:@"knob-size" inControlState:CPControlStateCircular];
[slider setValue:knobColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateCircular];
[slider setValue:knobHighlightedColor forThemedAttributeName:@"knob-color" inControlState:CPControlStateCircular|CPControlStateHighlighted];
[slider setValue:CGSizeMake(5.0, 5.0) forThemeAttribute:@"knob-size" inState:CPThemeStateCircular];
[slider setValue:knobColor forThemeAttribute:@"knob-color" inState:CPThemeStateCircular];
[slider setValue:knobHighlightedColor forThemeAttribute:@"knob-color" inState:CPThemeStateCircular|CPThemeStateHighlighted];
return slider;
}
/*
var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 30.0)],
+ (CPButtonBar)themedButtonBar
{
var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 26.0)],
color = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:
[
[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 30.0)],
[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 30.0)],
[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel-right.png" size:CGSizeMake(13.0, 30.0)]
[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 26.0)],
[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 26.0)],
[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel-right.png" size:CGSizeMake(13.0, 26.0)]
]
isVertical:NO]];
[buttonBar setValue:color forThemedAttributeName:@"bezel-color"];
[buttonBar setNeedsLayout];
[buttonBar setValue:color forThemeAttribute:@"bezel-color"];
views.push(buttonBar);
return views;
*/
return buttonBar;
}
@end
function PatterColor(anImage)
function PatternColor(anImage)
{
return [CPColor colorWithPatternImage:anImage];
}
@@ -87,6 +87,10 @@
CPTextField _label;
}
- (void)setSelected:(BOOL)isSelected
{
}
- (void)setRepresentedObject:(id)anObject
{
if (!_label)
+2 -1
View File
@@ -20,7 +20,8 @@ ObjectiveJ::BundleTask.new(:BlendKit) do |t|
t.resources = FileList['Resources/*'].to_a
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-DDEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Release'
t.type = ObjectiveJ::Bundle::Type::Framework
end
+2 -1
View File
@@ -23,7 +23,8 @@ ObjectiveJ::BundleTask.new(:blend) do |t|
t.resources = FileList['Resources/*']
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-DDEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Debug'
end
#executable in environment directory
+9 -9
View File
@@ -49,7 +49,7 @@ function main()
cibFiles.push(argument);
}
}
if (descriptorFiles.length === 0)
return buildBlendFromCibFiles(cibFiles);
@@ -57,26 +57,26 @@ function main()
{
var themeDescriptorClasses = BKThemeDescriptorClasses(),
count = [themeDescriptorClasses count];
while (count--)
{
var theClass = themeDescriptorClasses[count],
themeTemplate = [[AKThemeTemplate alloc] init];
[themeTemplate setValue:[theClass themeName] forKey:@"name"];
var objectTemplates = BKThemeObjectTemplatesForClass(theClass);
var objectTemplates = BKThemeObjectTemplatesForClass(theClass),
data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])),
temporaryCibFile = File.createTempFile("temp", ".cib"),
temporaryCibFilePath = temporaryCibFile.getAbsolutePath(),
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temporaryCibFilePath), "UTF-8"));
writer.write([data string]);
writer.close();
cibFiles.push(temporaryCibFilePath);
}
buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath);
});
}
@@ -131,7 +131,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
fileContents = [[CPKeyedArchiver archivedDataWithRootObject:theme] string];
replacedFiles.push(filePath);
staticContent += MARKER_PATH + ';' + filePath.length + ';' + filePath + MARKER_TEXT + ';' + fileContents.length + ';' + fileContents;
}
@@ -182,7 +182,7 @@ function themeFromCibFile(aFile)
var object = topLevelObjects[count];
templates = templates.concat([object blendThemeObjectTemplates]);
if ([object isKindOfClass:[AKThemeTemplate class]])
theme = [[CPTheme alloc] initWithName:[object valueForKey:@"name"]];
}
+22 -9
View File
@@ -322,7 +322,7 @@
*/
- (BOOL)isEqualToDictionary:(CPDictionary)aDictionary
{
if (count != [aDictionary count])
if (count !== [aDictionary count])
return NO;
var index = count;
@@ -465,8 +465,10 @@
*/
- (void)removeObjectsForKeys:(CPArray)allKeys
{
for (var i=0, count = allKeys.length; i<count; i++)
dictionary_removeValue(self, allKeys[i]);
var index = allKeys.length;
while (index--)
dictionary_removeValue(self, allKeys[index]);
}
/*
@@ -527,11 +529,11 @@
return;
var keys = [aDictionary allKeys],
count = [keys count];
index = [keys count];
while (count--)
while (index--)
{
var key = keys[count];
var key = keys[index];
[self setObject:[aDictionary objectForKey:key] forKey:key];
}
@@ -547,10 +549,21 @@
var i = _keys.length;
while (i--)
description += _keys[i] +":"+[_buckets[_keys[i]] description]+"\n";
{
description += _keys[i] + ":";
var object = _buckets[_keys[i]];
if (object && object.isa)
description += [object description];
else
description += object;
description += "\n";
}
description += "}";
return description;
}
+1 -1
View File
@@ -532,7 +532,7 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional)
}
else
{
var theClass = [anObject classForKeyedArchiver],
var theClass = [object classForKeyedArchiver],
plistObject = nil;
if ((theClass === _CPKeyedArchiverStringClass) || (theClass === _CPKeyedArchiverNumberClass))// || theClass == _CPKeyedArchiverBooleanClass)
+6 -2
View File
@@ -46,6 +46,8 @@ var _CPKeyedArchiverNullString = "$
var _CPKeyedUnarchiverArrayClass = Nil,
_CPKeyedUnarchiverStringClass = Nil,
_CPKeyedUnarchiverDictionaryClass = Nil,
_CPKeyedUnarchiverNumberClass = Nil,
_CPKeyedUnarchiverDataClass = Nil,
_CPKeyedUnarchiverArchiverValueClass = Nil;
/*
@@ -111,12 +113,14 @@ var _CPKeyedUnarchiverArrayClass = Ni
*/
+ (void)initialize
{
if (self != [CPKeyedUnarchiver class])
if (self !== [CPKeyedUnarchiver class])
return;
_CPKeyedUnarchiverArrayClass = [CPArray class];
_CPKeyedUnarchiverStringClass = [CPString class];
_CPKeyedUnarchiverDictionaryClass = [CPDictionary class];
_CPKeyedUnarchiverNumberClass = [CPNumber class];
_CPKeyedUnarchiverDataClass = [CPData class];
_CPKeyedUnarchiverArchiverValueClass = [_CPKeyedArchiverValue class];
}
@@ -298,7 +302,7 @@ var _CPKeyedUnarchiverArrayClass = Ni
if ([object isKindOfClass:_CPKeyedUnarchiverDictionaryClass])
return _CPKeyedUnarchiverDecodeObjectAtIndex(self, [object objectForKey:_CPKeyedArchiverUIDKey]);
else if ([object isKindOfClass:[CPNumber class]] || [object isKindOfClass:[CPData class]])
else if ([object isKindOfClass:_CPKeyedUnarchiverNumberClass] || [object isKindOfClass:_CPKeyedUnarchiverDataClass])
return object;
else if ([object isKindOfClass:_CPKeyedUnarchiverArrayClass])
+2 -1
View File
@@ -22,7 +22,8 @@ ObjectiveJ::BundleTask.new(:Foundation) do |t|
t.resources = FileList['Resources/*'].to_a
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-DDEBUG -g' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Release'
t.type = ObjectiveJ::Bundle::Type::Framework
end
+3 -3
View File
@@ -35,7 +35,7 @@ end
file_d $RHINO_FILE => Files do |t|
flags = platform_flags(ObjectiveJ::Platform::Rhino, ObjectiveJ::Platform::ObjJ)
flags['RHINO'] = ''
flags += ' -DRHINO'
build_product(t.name, flags)
end
@@ -50,12 +50,12 @@ file_d $LICENSE_PRODUCT => [$LICENSE_FILE] do
end
def platform_flags(*platforms)
return { 'PLATFORMS' => ('"[' + platforms.uniq.map { |platform| '\"' + platform + '\"' }.join(', ') + ']"') }
return '-DPLATFORMS="[' + platforms.uniq.map { |platform| '\"' + platform + '\"' }.join(', ') + ']"'
end
def build_product(path, flags)
IO.popen("gcc #{resolve_flags(flags)} -E -x c -P -", "w+") do |preprocessor|
IO.popen("gcc #{flags} -E -x c -P -", "w+") do |preprocessor|
Files.select { |name| name.match(/\.js$/) }.each do |fileName|
preprocessor.puts IO.read(fileName)
+1 -1
View File
@@ -55,7 +55,7 @@ function compress(/*String*/ aCode, /*Object*/ flags, /*File*/ tmpFile)
writer.close();
return exec(["java", "-jar", OBJJ_HOME + "/lib/shrinksafe.jar", "-c", tmpFile.getCanonicalPath()]);
return exec(["java", "-jar", OBJJ_HOME + "/lib/objjc/shrinksafe.jar", "-c", tmpFile.getCanonicalPath()]);
}
//#define SET_CONTEXT(aFragment, aContext) aFragment.context = aContext
+10
View File
@@ -470,6 +470,16 @@ function objj_msgSend(/*id*/ aReceiver, /*SEL*/ aSelector)
CLASS_GET_METHOD_IMPLEMENTATION(var implementation, aReceiver.isa, aSelector);
switch(arguments.length)
{
case 2:
return implementation(aReceiver, aSelector);
case 3:
return implementation(aReceiver, aSelector, arguments[2]);
case 4:
return implementation(aReceiver, aSelector, arguments[2], arguments[3]);
}
return implementation.apply(aReceiver, arguments);
}
-36
View File
@@ -13,32 +13,6 @@ module ObjectiveJ
BrowserDesktop = 'browser-desktop'
BrowserIPhone = 'browser-iphone'
BrowseriPhone = 'browser-iphone'
PLATFORM_DIRECTORIES =
{
Platform::ObjJ => 'objj.platform',
Platform::Rhino => 'rhino.platform',
Platform::Browser => 'browser.platform',
Platform::BrowserDesktop => 'browser-desktop.platform',
Platform::BrowserIPhone => 'browser-iphone.platform'
}
PLATFORM_FLAGS =
{
Platform::ObjJ => [],
Platform::Rhino => ['PLATFORM_RHINO'],
Platform::Browser => ['PLATFORM_BROWSER', 'PLATFORM_DOM'],
Platform::BrowserDesktop => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_DESKTOP'],
Platform::BrowserIPhone => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_IPHONE', 'PLATFORM_MOBILE']
}
def Platform.directory(aPlatform)
return PLATFORM_DIRECTORIES[aPlatform]
end
def Platform.flags(aPlatform)
return PLATFORM_FLAGS[aPlatform]
end
end
end # module ObjectiveJ
@@ -82,13 +56,3 @@ def file_d(*args, &block)
file fileTask.name => fileDirectory
end
def resolve_flags(flags)
case flags
when nil then ''
when String then '-D' + flags
when Array then flags.map { |flag| '-D' + flag }.join(' ')
when Hash then flags.map { |flag, value| '-D' + flag + (value != '' ? '=' + value : '') }.join(' ')
end
end
+5 -5
View File
@@ -350,10 +350,10 @@ module ObjectiveJ
PLATFORM_FLAGS =
{
Platform::ObjJ => [],
Platform::Rhino => ['PLATFORM_RHINO'],
Platform::Browser => ['PLATFORM_BROWSER', 'PLATFORM_DOM'],
Platform::BrowserDesktop => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_DESKTOP'],
Platform::BrowserIPhone => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_IPHONE', 'PLATFORM_MOBILE']
Platform::Rhino => ['-DPLATFORM_RHINO'],
Platform::Browser => ['-DPLATFORM_BROWSER', '-DPLATFORM_DOM'],
Platform::BrowserDesktop => ['-DPLATFORM_BROWSER', '-DPLATFORM_DOM', '-DPLATFORM_DESKTOP'],
Platform::BrowserIPhone => ['-DPLATFORM_BROWSER', '-DPLATFORM_DOM', '-DPLATFORM_IPHONE', '-DPLATFORM_MOBILE']
}
# Objective-J Bundle spec containing the metadata for this bundle.
@@ -451,7 +451,7 @@ module ObjectiveJ
# We no longer get this for free with file_d
FileUtils.mkdir_p File.join(build_path, PLATFORM_DIRECTORIES[platform])
IO.popen("objjc #{resolve_flags(flags)} #{resolve_flags(PLATFORM_FLAGS[platform])} #{platform_sources.join(' ')} #{preprocessed_files.join(' ')}") do |objjc|
IO.popen("objjc #{flags.join(' ')} #{PLATFORM_FLAGS[platform].join(' ')} #{platform_sources.join(' ')} #{preprocessed_files.join(' ')}") do |objjc|
objjc.sync = true
while str = objjc.gets
+2 -1
View File
@@ -23,7 +23,8 @@ ObjectiveJ::BundleTask.new(:bake) do |t|
t.resources = FileList['Resources/*']
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-DDEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Release'
end
#executable in environment directory
+2 -1
View File
@@ -22,7 +22,8 @@ ObjectiveJ::BundleTask.new(:capp) do |t|
t.resources = FileList['Resources/*', 'Templates']
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-DDEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Release'
end
#executable in environment directory
-2
View File
@@ -34,8 +34,6 @@
if (self)
{
_controlState = CPControlStateNormal;
[self sendActionOn:CPLeftMouseUpMask];
var cell = [aCoder decodeObjectForKey:@"NSCell"];
+8 -5
View File
@@ -31,14 +31,17 @@
{
var flags = [aCoder decodeIntForKey:"NSsFlags"];
_hasVerticalScroller = Boolean(flags & (1 << 4));
_hasHorizontalScroller = Boolean(flags & (1 << 5));
_autohidesScrollers = Boolean(flags & (1 << 9));
_verticalScroller = [aCoder decodeObjectForKey:"NSVScroller"];
_horizontalScroller = [aCoder decodeObjectForKey:"NSHScroller"];
_contentView = [aCoder decodeObjectForKey:"NSContentView"];
_hasVerticalScroller = !Boolean(flags & (1 << 4));
_hasHorizontalScroller = !Boolean(flags & (1 << 5));
_autohidesScrollers = Boolean(flags & (1 << 9));
[self setHasHorizontalScroller:!_hasHorizontalScroller];
[self setHasVerticalScroller:!_hasVerticalScroller];
//[aCoder decodeBytesForKey:"NSScrollAmts"];
_verticalLineScroll = 10.0;
_verticalPageScroll = 10.0;
+21
View File
@@ -1,3 +1,24 @@
/*
* NSSecureTextField.j
* nib2cib
*
* Created by Francisco Tolmasky.
* Copyright 2009, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <AppKit/CPSecureTextField.j>
+1 -1
View File
@@ -38,7 +38,7 @@
//var dataViewCell = [aCoder decodeObjectForKey:@"NSDataCell"];
_dataView = [[CPTextField alloc] initWithFrame:CPRectMakeZero()];
[_dataView setValue:[CPColor whiteColor] forThemedAttributeName:"text-color" inControlState:CPControlStateHighlighted];
[_dataView setValue:[CPColor whiteColor] forThemedAttributeName:"text-color" inControlState:CPThemeStateHighlighted];
//_headerView = [aCoder decodeObjectForKey:@"NSHeaderCell"];
_headerView = [[CPTextField alloc] initWithFrame:CPRectMakeZero()];
+23
View File
@@ -1,8 +1,31 @@
/*
* NSTextField.j
* AppKit
*
* Created by Francisco Tolmasky.
* Copyright 2008, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <AppKit/CPTextField.j>
@import "NSControl.j"
@import "NSCell.j"
@implementation CPTextField (NSCoding)
- (id)NS_initWithCoder:(CPCoder)aCoder
+3 -2
View File
@@ -93,8 +93,9 @@
}
}
_themedAttributes = {};
[self _loadThemedAttributes];
_themeAttributes = {};
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
}
return self;
+2 -1
View File
@@ -22,7 +22,8 @@ ObjectiveJ::BundleTask.new(:nib2cib) do |t|
t.resources = FileList['Resources/*']
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-DDEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Release'
end
#executable in environment directory
+2 -1
View File
@@ -24,7 +24,8 @@ ObjectiveJ::BundleTask.new(:press) do |t|
t.resources = FileList['Resources/*']
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-DDEBUG' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Release'
end
#executable in environment directory