diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j
index 11aa24aee..2b5df8ff4 100644
--- a/AppKit/CPButton.j
+++ b/AppKit/CPButton.j
@@ -24,9 +24,10 @@
@import "CGGeometry.j"
@import "CPControl.j"
+@import "CPThemedValue.j"
-#include "CPControl.h"
#include "CoreGraphics/CGGeometry.h"
+#include "CPThemedValue.h"
CPScaleProportionally = 0;
@@ -233,14 +234,11 @@ var _CPButtonClassName = nil,
int _state;
BOOL _allowsMixedState;
- CPImage _image;
- CPImage _alternateImage;
-
- CPString _title;
- CPString _alternateTitle;
+ CPControlStateValue _title;
+ CPString _alteranteTitle;
CPControlStateValue _image;
- CPControlStateValue _title;
+ CPImage _alternateImage;
// Display Properties
CPControlStateValue _bezelInset;
@@ -248,7 +246,7 @@ var _CPButtonClassName = nil,
CPControlStateValue _bezelColor;
- //
+ // Layout Views
CPView _bezelView;
_CPImageAndTextView _contentView;
@@ -256,78 +254,6 @@ var _CPButtonClassName = nil,
CPBezelStyle _bezelStyle;
BOOL _isBordered;
CPControlSize _controlSize;
-
- // bleh
- BOOL _bezelBorderNeedsUpdate;
-}
-
-/*!
- Initializes the CPButton class.
- @ignore
-*/
-+ (void)initialize
-{
- if (self != [CPButton class])
- return;
-
- _CPButtonClassName = [CPButton className];
-
- // Textured Rounded
- _CPButtonBezelStyleIdentifiers[CPRoundedBezelStyle] = @"Rounded";
- _CPButtonBezelStyleIdentifiers[CPRegularSquareBezelStyle] = @"RegularSquare";
- _CPButtonBezelStyleIdentifiers[CPThickSquareBezelStyle] = @"ThickSquare";
- _CPButtonBezelStyleIdentifiers[CPThickerSquareBezelStyle] = @"ThickerSquare";
- _CPButtonBezelStyleIdentifiers[CPDisclosureBezelStyle] = @"Disclosure";
- _CPButtonBezelStyleIdentifiers[CPShadowlessSquareBezelStyle] = @"ShadowlessSquare";
- _CPButtonBezelStyleIdentifiers[CPCircularBezelStyle] = @"Circular";
- _CPButtonBezelStyleIdentifiers[CPTexturedSquareBezelStyle] = @"TexturedSquare";
- _CPButtonBezelStyleIdentifiers[CPHelpButtonBezelStyle] = @"HelpButton";
- _CPButtonBezelStyleIdentifiers[CPSmallSquareBezelStyle] = @"SmallSquare";
- _CPButtonBezelStyleIdentifiers[CPTexturedRoundedBezelStyle] = @"TexturedRounded";
- _CPButtonBezelStyleIdentifiers[CPRoundRectBezelStyle] = @"RoundRect";
- _CPButtonBezelStyleIdentifiers[CPRecessedBezelStyle] = @"Recessed";
- _CPButtonBezelStyleIdentifiers[CPRoundedDisclosureBezelStyle] = @"RoundedDisclosure";
- _CPButtonBezelStyleIdentifiers[CPHUDBezelStyle] = @"HUD";
-
- var regularIdentifier = _CPControlIdentifierForControlSize(CPRegularControlSize),
- smallIdentifier = _CPControlIdentifierForControlSize(CPSmallControlSize),
- miniIdentifier = _CPControlIdentifierForControlSize(CPMiniControlSize);
-
- // Rounded Rect
- var prefix = _CPButtonClassName + _CPButtonBezelStyleIdentifiers[CPRoundRectBezelStyle];
-
- _CPButtonBezelStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(10.0, 18.0), _CGSizeMake(1.0, 18.0), _CGSizeMake(10.0, 18.0)];
- _CPButtonBezelStyleSizes[prefix + regularIdentifier + _CPButtonBezelStyleHighlightedIdentifier] = [_CGSizeMake(10.0, 18.0), _CGSizeMake(1.0, 18.0), _CGSizeMake(10.0, 18.0)];
-
- // HUD
- var prefix = _CPButtonClassName + _CPButtonBezelStyleIdentifiers[CPHUDBezelStyle];
-
- _CPButtonBezelStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(13.0, 20.0), _CGSizeMake(1.0, 20.0), _CGSizeMake(13.0, 20.0)];
- _CPButtonBezelStyleSizes[prefix + regularIdentifier + _CPButtonBezelStyleHighlightedIdentifier] = [_CGSizeMake(13.0, 20.0), _CGSizeMake(1.0, 20.0), _CGSizeMake(13.0, 20.0)];
-
- CPHUDBezelStyleTextColor = [CPColor whiteColor];
-
- // Textured Rounded
- var prefix = _CPButtonClassName + _CPButtonBezelStyleIdentifiers[CPTexturedRoundedBezelStyle];
-
- _CPButtonBezelStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(7.0, 20.0), _CGSizeMake(1.0, 20.0), _CGSizeMake(7.0, 20.0)];
- _CPButtonBezelStyleSizes[prefix + regularIdentifier + _CPButtonBezelStyleHighlightedIdentifier] = [_CGSizeMake(7.0, 20.0), _CGSizeMake(1.0, 20.0), _CGSizeMake(7.0, 20.0)];
-}
-
-// Configuring Buttons
-/*!
- Sets how the button highlights and shows its state.
- @param aButtonType Defines the behavior of the button.
-*/
-- (void)setButtonType:(CPButtonType)aButtonType
-{
- if (aButtonType === CPSwitchButton)
- {
- [self setBordered:NO];
- [self setImage:nil];
- [self setAlternateImage:nil];
- [self setAlignment:CPLeftTextAlignment];
- }
}
- (id)initWithFrame:(CGRect)aFrame
@@ -336,14 +262,17 @@ var _CPButtonClassName = nil,
if (self)
{
- _bezelInset = [[CPControlStateValue alloc] initWithDefaultValue:_CGInsetMakeZero()];
- _contentInset = [[CPControlStateValue alloc] initWithDefaultValue:_CGInsetMakeZero()];
+ var theme = [self theme],
+ theClass = [self class];
- _bezelColor = [[CPControlStateValue alloc] initWithDefaultValue:nil];
+ _bezelInset = CPThemedValueMake(_CGInsetMakeZero(), "bezel-inset", theme, theClass);
+ _contentInset = CPThemedValueMake(_CGInsetMakeZero(), "content-inset", theme, theClass);
+
+ _bezelColor = CPThemedValueMake(nil, "bezel-color", theme, theClass);
+
+ _image = CPThemedValueMake(nil, @"image", theme, theClass);
+ _title = CPThemedValueMake(nil, @"title", theme, theClass);
-// _image = [[CPControlStateValue alloc] initWithDefaultValue:nil];
-// _title = [[CPControlStateValue alloc] initWithDefaultValue:nil];
-
[self setAlignment:CPCenterTextAlignment];
[self setVerticalAlignment:CPCenterVerticalTextAlignment];
[self setImagePosition:CPImageLeft];
@@ -351,7 +280,7 @@ var _CPButtonClassName = nil,
_controlSize = CPRegularControlSize;
- [self setBezelStyle:CPRoundRectBezelStyle];
+// [self setBezelStyle:CPRoundRectBezelStyle];
[self setBordered:YES];
}
@@ -405,35 +334,39 @@ var _CPButtonClassName = nil,
return _state;
}
-/*!
- Sets the image that will be drawn on the button.
- @param anImage the image that will be drawn
-*/
-- (void)setImage:(CPImage)anImage
+THEMED_STATED_VALUE(Title, title)
+
+- (void)setAlternateTitle:(CPString)aTitle
{
- if (_image === anImage)
+ if (_alternateTitle === aTitle)
return;
- _image = anImage;
-
+ _alternateTitle = aTitle;
+
+ [self setNeedsLayout];
[self setNeedsDisplay:YES];
}
-/*!
- Returns the image that will be drawn on the button
-*/
-- (CPImage)image
+- (CPString)alternateTitle
{
- return _image;
+ return _alternateTitle;
}
+THEMED_STATED_VALUE(Image, image)
+
/*!
Sets the button's image which is used in its alternate state.
@param anImage the image to be used while the button is in an alternate state
*/
- (void)setAlternateImage:(CPImage)anImage
{
- _alternateImage = anImage;
+ if (_alternateImage === anImage)
+ return;
+
+ _alteranteImage = anImage;
+
+ [self setNeedsLayout];
+ [self setNeedsDisplay:YES];
}
/*!
@@ -444,114 +377,6 @@ var _CPButtonClassName = nil,
return _alternateImage;
}
-/*!
- Sets the button's title.
- @param aTitle the new title for the button
-*/
-- (void)setTitle:(CPString)aTitle
-{
- if (_title == aTitle)
- return;
-
- _title = aTitle;
-
- [self setNeedsDisplay:YES];
-}
-
-/*!
- Returns the button's title string
-*/
-- (CPString)title
-{
- return _title;
-}
-
-/*!
- Lays out the button.
-*/
-- (void)tile
-{return;
- var size = [self bounds].size;
-
- if (_isBordered)
- {
- var imageAndTitleSize = CGSizeMakeCopy(size);
-
- if (_bezelStyle == CPHUDBezelStyle)
- imageAndTitleSize.height -= 4.0;
- else if (_bezelStyle == CPRoundRectBezelStyle)
- imageAndTitleSize.height -= 2.0;
- else if (_bezelStyle == CPTexturedRoundedBezelStyle)
- imageAndTitleSize.height -= 2.0;
-
- [_imageAndTextView setFrameSize:imageAndTitleSize];
- }
- else
- [_imageAndTextView setFrameSize:size];
-}
-
-- (CGRect)contentRectForBounds:(CGRect)bounds
-{
- if (_isBordered)
- {
- if (_bezelStyle === CPHUDBezelStyle)
- {
- bounds.origin.x += 5.0;
- bounds.origin.y += 2.0;
- bounds.size.width -= 5.0 * 2;
- bounds.size.height -= 2.0 + 4.0;
- }
-
- else if (_bezelStyle === CPRoundRectBezelStyle)
- {
- bounds.origin.x += 5.0;
- bounds.origin.y += 1.0;
- bounds.size.width -= 5.0 * 2;
- bounds.size.height -= 1.0 + 2.0;
- }
-
- else if (_bezelStyle === CPTexturedRoundedBezelStyle)
- {
- bounds.origin.x += 5.0;
- bounds.origin.y += 2.0;
- bounds.size.width -= 5.0 * 2;
- bounds.size.height -= 2.0 + 3.0;
- }
- }
-
- return bounds;
-}
-
-/*!
- Compacts the button's frame to fit its contents.
-*/
-- (void)sizeToFit
-{return; if (!_imageAndTextView)
- {
- _imageAndTextView = [[_CPImageAndTextView alloc] initWithFrame:[self contentRectForBounds:[self bounds]] control:self];
-
- [self addSubview:_imageAndTextView];
- }
-
- [_imageAndTextView setText:[self isHighlighted] && _alternateTitle ? _alternateTitle : _title];
- [_imageAndTextView setImage:[self isHighlighted] && _alternateImage ? _alternateImage : _image];
-
- [_imageAndTextView sizeToFit];
-
- var frame = [_imageAndTextView frame],
- height = CGRectGetHeight(frame);
- /*
- if (_isBordered)
- if (_bezelStyle == CPHUDBezelStyle)
- height += 2.0;
- else if (_bezelStyle == CPRoundRectBezelStyle)
- height += 1.0;
- else if (_bezelStyle == CPTexturedRoundedBezelStyle)
- height += 2.0;
- */
- [self setFrameSize:CGSizeMake(CGRectGetWidth(frame), height)];
-}
-
/*!
Highlights the receiver based on aFlag.
@param If YES the button will highlight, NO the button will unhighlight.
@@ -594,123 +419,6 @@ var _CPButtonClassName = nil,
[super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp];
}
-/*!
- Sets the button's control size.
- @param aControlSize the button's new control size
-*/
-- (void)setControlSize:(CPControlSize)aControlSize
-{
- if (_controlSize == aControlSize)
- return;
-
- _controlSize = aControlSize;
-
- [self drawBezelWithHighlight:[self isHighlighted]];
- [self _updateTextAttributes];
-}
-
-/*!
- Returns the button's control size.
-*/
-- (CPControlSize)controlSize
-{
- return _controlSize;
-}
-
-/*!
- Sets whether the button has a bezeled border.
- @param If YES, the the button will have a bezeled border.
-*/
-- (void)setBordered:(BOOL)isBordered
-{
- if (_isBordered == isBordered)
- return;
-
- _isBordered = isBordered;
-
- [self updateBackgroundColors];
- [self drawBezelWithHighlight:[self isHighlighted]];
-
- [self tile];
-}
-
-/*!
- Returns YES if the border is bezeled.
-*/
-- (BOOL)isBordered
-{
- return _isBordered;
-}
-
-/*!
- Sets the button's bezel style.
- @param aBezelStye one of the predefined bezel styles
-*/
-- (void)setBezelStyle:(CPBezelStyle)aBezelStyle
-{
- // FIXME: We need real support for these:
- if (aBezelStyle == CPRoundedBezelStyle ||
- aBezelStyle == CPRoundedBezelStyle ||
- aBezelStyle == CPRegularSquareBezelStyle ||
- aBezelStyle == CPThickSquareBezelStyle ||
- aBezelStyle == CPThickerSquareBezelStyle ||
- aBezelStyle == CPDisclosureBezelStyle ||
- aBezelStyle == CPShadowlessSquareBezelStyle ||
- aBezelStyle == CPCircularBezelStyle ||
- aBezelStyle == CPTexturedSquareBezelStyle ||
- aBezelStyle == CPHelpButtonBezelStyle ||
- aBezelStyle == CPSmallSquareBezelStyle ||
- aBezelStyle == CPRecessedBezelStyle ||
- aBezelStyle == CPRoundedDisclosureBezelStyle)
- aBezelStyle = CPRoundRectBezelStyle;
-
- if (_bezelStyle == aBezelStyle)
- return;
-
- _bezelStyle = aBezelStyle;
-
- [self updateBackgroundColors];
- [self drawBezelWithHighlight:[self isHighlighted]];
-
- [self _updateTextAttributes];
- [self tile];
-}
-
-/*!
- Returns the current bezel style
-*/
-- (int)bezelStyle
-{
- return _bezelStyle;
-}
-
-/* @ignore */
-- (void)updateBackgroundColors
-{return;
- if (_isBordered)
- {
- [self setBackgroundColor:_CPControlThreePartImagePattern(
- NO,
- _CPButtonBezelStyleSizes,
- _CPButtonClassName,
- _CPButtonBezelStyleIdentifiers[_bezelStyle],
- _CPControlIdentifierForControlSize(_controlSize)) forName:CPControlNormalBackgroundColor];
-
- [self setBackgroundColor:_CPControlThreePartImagePattern(
- NO,
- _CPButtonBezelStyleSizes,
- _CPButtonClassName,
- _CPButtonBezelStyleIdentifiers[_bezelStyle],
- _CPControlIdentifierForControlSize(_controlSize),
- _CPButtonBezelStyleHighlightedIdentifier) forName:CPControlHighlightedBackgroundColor];
- }
- else
- {
- [self setBackgroundColor:nil forName:CPControlNormalBackgroundColor];
- [self setBackgroundColor:nil forName:CPControlHighlightedBackgroundColor];
- }
-}
-
/* @ignore */
- (void)drawBezelWithHighlight:(BOOL)shouldHighlight
{ return;
@@ -722,24 +430,6 @@ var _CPButtonClassName = nil,
[self setBackgroundColorWithName:shouldHighlight ? CPControlHighlightedBackgroundColor : CPControlNormalBackgroundColor];
}
-- (void)viewDidMoveToWindow
-{
- if (_bezelBorderNeedsUpdate)
- [self drawBezelWithHighlight:[self isHighlighted]];
-}
-
-/* @ignore */
-- (void)_updateTextAttributes
-{return;
- if (_bezelStyle == CPHUDBezelStyle)
- [self setTextColor:CPHUDBezelStyleTextColor];
-
- if (_controlSize == CPRegularControlSize)
- [self setFont:[CPFont systemFontOfSize:11.0]];
-}
-
-// NEW
-
- (CPView)createBezelView
{
var view = [[CPView alloc] initWithFrame:_CGRectMakeZero()];
@@ -749,7 +439,7 @@ var _CPButtonClassName = nil,
return view;
}
-CONTROL_STATE_VALUE(BezelColor, bezelColor)
+THEMED_STATED_VALUE(BezelColor, bezelColor)
- (CPView)createContentView
{
@@ -758,12 +448,15 @@ CONTROL_STATE_VALUE(BezelColor, bezelColor)
return view;
}
-CONTROL_STATE_VALUE(ContentInset, contentInset)
-CONTROL_STATE_VALUE(BezelInset, bezelInset)
+THEMED_STATED_VALUE(ContentInset, contentInset)
+THEMED_STATED_VALUE(BezelInset, bezelInset)
- (CGRect)contentRectForBounds:(CGRect)bounds
{
- var contentInset = [self contentInset];
+ if (![self isBordered])
+ return bounds;
+
+ var contentInset = [self currentContentInset];
if (!contentInset)
return bounds;
@@ -778,7 +471,10 @@ CONTROL_STATE_VALUE(BezelInset, bezelInset)
- (CGRect)bezelRectForBounds:(CFRect)bounds
{
- var bezelInset = [self bezelInset];
+ if (![self isBordered])
+ return _CGRectMakeZero();
+
+ var bezelInset = [self currentBezelInset];
if (!_CGInsetIsEmpty(bezelInset))
return bounds;
@@ -845,31 +541,91 @@ CONTROL_STATE_VALUE(BezelInset, bezelInset)
if (_contentView)
{
- [_contentView setText:[self isHighlighted] && _alternateTitle ? _alternateTitle : _title];
- [_contentView setImage:[self isHighlighted] && _alternateImage ? _alternateImage : _image];
+ [_contentView setText:[self currentTitle]];
+ [_contentView setImage:[self currentImage]];
// [_imageAndTextView setText:[self titleForControlState:_title]];
// [_imageAndTextView setImage:[self imageForControlState:_controlState]];
- [_contentView setFont:[self font]];
- [_contentView setTextColor:[self textColor]];
- [_contentView setAlignment:[self alignment]];
- [_contentView setVerticalAlignment:[self verticalAlignment]];
- [_contentView setLineBreakMode:[self lineBreakMode]];
- [_contentView setTextShadowColor:[self textShadowColor]];
- [_contentView setTextShadowOffset:[self textShadowOffset]];
- [_contentView setImagePosition:[self imagePosition]];
- [_contentView setImageScaling:[self imageScaling]];
+ [_contentView setFont:[self currentFont]];
+ [_contentView setTextColor:[self currentTextColor]];
+ [_contentView setAlignment:[self currentAlignment]];
+ [_contentView setVerticalAlignment:[self currentVerticalAlignment]];
+ [_contentView setLineBreakMode:[self currentLineBreakMode]];
+ [_contentView setTextShadowColor:[self currentTextShadowColor]];
+ [_contentView setTextShadowOffset:[self currentTextShadowOffset]];
+ [_contentView setImagePosition:[self currentImagePosition]];
+ [_contentView setImageScaling:[self currentImageScaling]];
}
}
@end
+@implementation CPButton (Theming)
+
+- (void)viewDidChangeTheme
+{
+ [super viewDidChangeTheme];
+
+ var theme = [self theme];
+
+ [_bezelInset setTheme:theme];
+ [_contentInset setTheme:theme];
+
+ [_bezelColor setTheme:theme];
+}
+
+- (CPDictionary)themedValues
+{
+ var values = [super themedValues];
+
+ [values setObject:_bezelInset forKey:@"bezel-inset"];
+ [values setObject:_contentInset forKey:@"content-inset"];
+
+ [values setObject:_bezelColor forKey:@"bezel-color"];
+
+ return values;
+}
+
+@end
+
+
+@implementation CPButton (NS)
+
+- (void)setBezelStyle:(unsigned)aBezelStyle
+{
+}
+
+- (unsigned)bezelStyle
+{
+}
+
+- (void)setBordered:(BOOL)shouldBeBordered
+{
+ if (_isBordered === shouldBeBordered)
+ return;
+
+ _isBordered = shouldBeBordered;
+
+ [self setNeedsLayout];
+ [self setNeedsDisplay:YES];
+}
+
+- (BOOL)isBordered
+{
+ return _isBordered;
+}
+
+@end
+
var CPButtonImageKey = @"CPButtonImageKey",
CPButtonAlternateImageKey = @"CPButtonAlternateImageKey",
CPButtonTitleKey = @"CPButtonTitleKey",
CPButtonAlteranteTitleKey = @"CPButtonAlternateTitleKey",
+ CPButtonContentInsetKey = @"CPButtonContentInsetKey",
+ CPButtonBezelInsetKey = @"CPButtonBezelInsetKey",
+ CPButtonBezelColorKey = @"CPButtonBezelColorKey",
CPButtonImageAndTitleViewKey = @"CPButtonImageAndTitleViewKey",
CPButtonImagePositionKey = @"CPButtonImagePositionKey",
CPButtonImageScalingKey = @"CPButtonImageScalingKey",
@@ -891,16 +647,23 @@ var CPButtonImageKey = @"CPButtonImageKey",
{
_controlSize = CPRegularControlSize;
- [self setImage:[aCoder decodeObjectForKey:CPButtonImageKey]];
+ var theme = [self theme],
+ theClass = [self class];
+
[self setAlternateImage:[aCoder decodeObjectForKey:CPButtonAlternateImageKey]];
- [self setTitle:[aCoder decodeObjectForKey:CPButtonTitleKey]];
+ _image = CPThemedValueDecode(aCoder, CPButtonImageKey, nil, @"image", theme, theClass);
+ _title = CPThemedValueDecode(aCoder, CPButtonTitleKey, nil, @"title", theme, theClass);
+
+ _contentInset = CPThemedValueDecode(aCoder, CPButtonContentInsetKey, _CGInsetMakeZero(), @"content-inset", theme, theClass);
+ _bezelInset = CPThemedValueDecode(aCoder, CPButtonBezelInsetKey, _CGInsetMakeZero(), @"bezel-inset", theme, theClass);
- [self setImagePosition:[aCoder decodeIntForKey:CPButtonImagePositionKey]];
- [self setImageScaling:[aCoder decodeIntForKey:CPButtonImageScalingKey]];
+ _bezelColor = CPThemedValueDecode(aCoder, CPButtonBezelColorKey, nil, @"bezel-color", theme, theClass);
- [self setBezelStyle:[aCoder decodeIntForKey:CPButtonBezelStyleKey]];
- [self setBordered:[aCoder decodeBoolForKey:CPButtonIsBorderedKey]];
+ _isBordered = [aCoder decodeBoolForKey:CPButtonIsBorderedKey];
+
+ [self setNeedsLayout];
+ [self setNeedsDisplay:YES];
}
return self;
@@ -923,16 +686,19 @@ var CPButtonImageKey = @"CPButtonImageKey",
_subviews = actualSubviews;
- [aCoder encodeObject:_image forKey:CPButtonImageKey];
+
[aCoder encodeObject:_alternateImage forKey:CPButtonAlternateImageKey];
- [aCoder encodeObject:_title forKey:CPButtonTitleKey];
-
- [aCoder encodeInt:_imagePosition forKey:CPButtonImagePositionKey];
- [aCoder encodeInt:_imageScaling forKey:CPButtonImageScalingKey];
-
[aCoder encodeBool:_isBordered forKey:CPButtonIsBorderedKey];
[aCoder encodeInt:_bezelStyle forKey:CPButtonBezelStyleKey];
+
+ CPThemedValueEncode(aCoder, CPButtonImageKey, _image);
+ CPThemedValueEncode(aCoder, CPButtonTitleKey, _title);
+
+ CPThemedValueEncode(aCoder, CPButtonContentInsetKey, _contentInset);
+ CPThemedValueEncode(aCoder, CPButtonBezelInsetKey, _bezelInset);
+
+ CPThemedValueEncode(aCoder, CPButtonBezelColorKey, _bezelColor);
}
@end
diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j
index e0f78b14b..bae74b528 100644
--- a/AppKit/CPControl.j
+++ b/AppKit/CPControl.j
@@ -23,10 +23,12 @@
@import "CPFont.j"
@import "CPShadow.j"
@import "CPView.j"
+@import "CPThemedValue.j"
+#include "CoreGraphics/CGGeometry.h"
+#include "CPThemedValue.h"
#include "Platform/Platform.h"
-
/*
@global
@group CPTextAlignment
@@ -86,28 +88,22 @@ var CPControlBlackColor = [CPColor blackColor];
*/
@implementation CPControl : CPView
{
- id _value;
+ id _value;
// Target-Action Support
- id _target;
- SEL _action;
- int _sendActionOn;
+ id _target;
+ SEL _action;
+ int _sendActionOn;
// Mouse Tracking Support
- BOOL _continuousTracking;
- BOOL _trackingWasWithinFrame;
- unsigned _trackingMouseDownFlags;
- CGPoint _previousTrackingLocation;
-
- // Stuff
- CPShadow _textShadow;
-
- CPDictionary _backgroundColors;
- CPString _currentBackgroundColorName;
+ BOOL _continuousTracking;
+ BOOL _trackingWasWithinFrame;
+ unsigned _trackingMouseDownFlags;
+ CGPoint _previousTrackingLocation;
// Properties
- CPControlStateValue _alignment;
- CPControlStateValue _verticalAlignment;
+ CPThemedValue _alignment;
+ CPThemedValue _verticalAlignment;
CPControlStateValue _lineBreakMode;
CPControlStateValue _textColor;
@@ -120,6 +116,9 @@ var CPControlBlackColor = [CPColor blackColor];
CPControlStateValue _imageScaling;
CPControlState _controlState;
+
+ // FIXME: Who uses this?
+ BOOL _isBezeled;
}
- (id)initWithFrame:(CGRect)aFrame
@@ -130,57 +129,32 @@ var CPControlBlackColor = [CPColor blackColor];
{
_controlState = CPControlStateNormal;
- _alignment = [[CPControlStateValue alloc] initWithDefaultValue:CPLeftTextAlignment];
- _verticalAlignment = [[CPControlStateValue alloc] initWithDefaultValue:CPTopVerticalTextAlignment];
+ var theme = [self theme],
+ theClass = [self class];
- _lineBreakMode = [[CPControlStateValue alloc] initWithDefaultValue:CPLeftTextAlignment];
- _textColor = [[CPControlStateValue alloc] initWithDefaultValue:[CPColor blackColor]];
- _font = [[CPControlStateValue alloc] initWithDefaultValue:[CPFont systemFontOfSize:12.0]];
+ _alignment = CPThemedValueMake(CPLeftTextAlignment, "alignment", theme, theClass);
+ _verticalAlignment = CPThemedValueMake(CPTopVerticalTextAlignment, "vertical-alignment", theme, theClass);
- _textShadowColor = [[CPControlStateValue alloc] initWithDefaultValue:nil];
- _textShadowOffset = [[CPControlStateValue alloc] initWithDefaultValue:CGSizeMake(0.0, 0.0)];;
+ _lineBreakMode = CPThemedValueMake(CPLineBreakByClipping, "line-break-mode", theme, theClass);
+ _textColor = CPThemedValueMake([CPColor blackColor], "text-color", theme, theClass);
+ _font = CPThemedValueMake([CPFont systemFontOfSize:12.0], "font", theme, theClass);
- _imagePosition = [[CPControlStateValue alloc] initWithDefaultValue:CPImageLeft];
- _imageScaling = [[CPControlStateValue alloc] initWithDefaultValue:CPScaleToFit];
+ _textShadowColor = CPThemedValueMake(nil, @"text-shadow-color", theme, theClass);
+ _textShadowOffset = CPThemedValueMake(_CGSizeMake(0.0, 0.0), "text-shadow-offset", theme, theClass);
+ _imagePosition = CPThemedValueMake(CPImageLeft, @"image-position", theme, theClass);
+ _imageScaling = CPThemedValueMake(CPScaleToFit, "image-scaling", theme, theClass);
+
+ [theme setActiveClass:nil];
//
_sendActionOn = CPLeftMouseUpMask;
_trackingMouseDownFlags = 0;
-
- _isEnabled = YES;
-
- _backgroundColors = [CPDictionary dictionary];
}
return self;
}
-/*!
- Sets whether the receiver responds to mouse events.
- @param isEnabled whether the receiver will respond to mouse events
-*/
-- (void)setEnabled:(BOOL)isEnabled
-{
- [self setAlphaValue:(_isEnabled = isEnabled) ? 1.0 : 0.3];
-}
-
-/*!
- Returns YES if the receiver responds to mouse events.
-*/
-- (BOOL)isEnabled
-{
- return _isEnabled;
-}
-
-/*!
- Returns the receiver's target action
-*/
-- (SEL)action
-{
- return _action;
-}
-
/*!
Sets the receiver's target action
@param anAction Sets the action message that gets sent to the target.
@@ -191,11 +165,11 @@ var CPControlBlackColor = [CPColor blackColor];
}
/*!
- Returns the receiver's target. The target receives action messages from the receiver.
+ Returns the receiver's target action
*/
-- (id)target
+- (SEL)action
{
- return _target;
+ return _action;
}
/*!
@@ -207,6 +181,54 @@ var CPControlBlackColor = [CPColor blackColor];
_target = aTarget;
}
+/*!
+ Returns the receiver's target. The target receives action messages from the receiver.
+*/
+- (id)target
+{
+ return _target;
+}
+
+/*!
+ Causes anAction to be sent to anObject.
+ @param anAction the action to send
+ @param anObject the object to which the action will be sent
+*/
+- (void)sendAction:(SEL)anAction to:(id)anObject
+{
+ [CPApp sendAction:anAction to:anObject from:self];
+}
+
+- (int)sendActionOn:(int)mask
+{
+ var previousMask = _sendActionOn;
+
+ _sendActionOn = mask;
+
+ return previousMask;
+}
+
+/*!
+ Returns whether the control can continuously send its action messages.
+*/
+- (BOOL)isContinuous
+{
+ // Some subclasses should redefine this with CPLeftMouseDraggedMask
+ return (_sendActionOn & CPPeriodicMask) !== 0;
+}
+
+/*!
+ Sets whether the cell can continuously send its action messages.
+ */
+- (void)setContinuous:(BOOL)flag
+{
+ // Some subclasses should redefine this with CPLeftMouseDraggedMask
+ if (flag)
+ _sendActionOn |= CPPeriodicMask;
+ else
+ _sendActionOn &= ~CPPeriodicMask;
+}
+
- (BOOL)tracksMouseOutsideOfFrame
{
return NO;
@@ -277,53 +299,12 @@ var CPControlBlackColor = [CPColor blackColor];
- (void)mouseDown:(CPEvent)anEvent
{
- if (!_isEnabled)
+ if (![self isEnabled])
return;
[self trackMouse:anEvent];
}
-
-/*!
- Causes anAction to be sent to anObject.
- @param anAction the action to send
- @param anObject the object to which the action will be sent
-*/
-- (void)sendAction:(SEL)anAction to:(id)anObject
-{
- [CPApp sendAction:anAction to:anObject from:self];
-}
-
-- (int)sendActionOn:(int)mask
-{
- var previousMask = _sendActionOn;
-
- _sendActionOn = mask;
-
- return previousMask;
-}
-
-/*!
- Returns whether the control can continuously send its action messages.
-*/
-- (BOOL)isContinuous
-{
- // Some subclasses should redefine this with CPLeftMouseDraggedMask
- return (_sendActionOn & CPPeriodicMask) !== 0;
-}
-
-/*!
- Sets whether the cell can continuously send its action messages.
- */
-- (void)setContinuous:(BOOL)flag
-{
- // Some subclasses should redefine this with CPLeftMouseDraggedMask
- if (flag)
- _sendActionOn |= CPPeriodicMask;
- else
- _sendActionOn &= ~CPPeriodicMask;
-}
-
/*!
Returns the receiver's object value
*/
@@ -338,6 +319,9 @@ var CPControlBlackColor = [CPColor blackColor];
- (void)setObjectValue:(id)anObject
{
_value = anObject;
+
+ [self setNeedsLayout];
+ [self setNeedsDisplay:YES];
}
/*!
@@ -391,7 +375,6 @@ var CPControlBlackColor = [CPColor blackColor];
[self setObjectValue:anObject];
}
-
/*!
Returns the receiver's int value
*/
@@ -425,7 +408,6 @@ var CPControlBlackColor = [CPColor blackColor];
[self setObjectValue:anObject];
}
-
- (void)takeDoubleValueFrom:(id)sender
{
if ([sender respondsToSelector:@selector(doubleValue)])
@@ -466,44 +448,6 @@ var CPControlBlackColor = [CPColor blackColor];
[self setStringValue:[sender stringValue]];
}
-
-- (void)setBackgroundColor:(CPColor)aColor
-{
- _backgroundColors = [CPDictionary dictionary];
-
- [self setBackgroundColor:aColor forName:CPControlNormalBackgroundColor];
-
- [super setBackgroundColor:aColor];
-}
-
-- (void)setBackgroundColor:(CPColor)aColor forName:(CPString)aName
-{
- if (!aColor)
- [_backgroundColors removeObjectForKey:aName];
- else
- [_backgroundColors setObject:aColor forKey:aName];
-
- if (_currentBackgroundColorName == aName)
- [self setBackgroundColorWithName:_currentBackgroundColorName];
-}
-
-- (CPColor)backgroundColorForName:(CPString)aName
-{
- var backgroundColor = [_backgroundColors objectForKey:aName];
-
- if (!backgroundColor && aName != CPControlNormalBackgroundColor)
- return [_backgroundColors objectForKey:CPControlNormalBackgroundColor];
-
- return backgroundColor;
-}
-
-- (void)setBackgroundColorWithName:(CPString)aName
-{
- _currentBackgroundColorName = aName;
-
- [super setBackgroundColor:[self backgroundColorForName:aName]];
-}
-
- (void)textDidBeginEditing:(CPNotification)note
{
//this looks to prevent false propagation of notifications for other objects
@@ -531,28 +475,123 @@ var CPControlBlackColor = [CPColor blackColor];
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidEndEditingNotification object:self userInfo:[CPDictionary dictionaryWithObject:[note object] forKey:"CPFieldEditor"]];
}
-/*
-Ð doubleValue
-Ð setDoubleValue:
-Ð intValue
-Ð setIntValue:
-Ð objectValue
-Ð setObjectValue:
-Ð stringValue
-Ð setStringValue:
-Ð setNeedsDisplay
-Ð attributedStringValue
-Ð setAttributedStringValue:
-*/
+THEMED_STATED_VALUE(Alignment, alignment)
+THEMED_STATED_VALUE(VerticalAlignment, verticalAlignment)
+THEMED_STATED_VALUE(LineBreakMode, lineBreakMode)
+THEMED_STATED_VALUE(TextColor, textColor)
+THEMED_STATED_VALUE(Font, font)
+THEMED_STATED_VALUE(TextShadowColor, textShadowColor)
+THEMED_STATED_VALUE(TextShadowOffset, textShadowOffset)
+THEMED_STATED_VALUE(ImagePosition, imagePosition)
+THEMED_STATED_VALUE(ImageScaling, imageScaling)
+
+- (int)controlState
+{
+ return _controlState;
+}
+
+- (void)setEnabled:(BOOL)isEnabled
+{
+ if ((!(_controlState & CPControlStateDisabled)) === isEnabled)
+ return;
+
+ if (isEnabled)
+ _controlState &= ~CPControlStateDisabled;
+ else
+ _controlState |= CPControlStateDisabled;
+
+ [self setNeedsLayout];
+ [self setNeedsDisplay:YES];
+}
+
+- (BOOL)isEnabled
+{
+ return !(_controlState & CPControlStateDisabled);
+}
+
+- (void)highlight:(BOOL)shouldHighlight
+{
+ [self setHighlighted:shouldHighlight];
+}
+
+- (void)setHighlighted:(BOOL)isHighlighted
+{
+ if ((!!(_controlState & CPControlStateHighlighted)) === isHighlighted)
+ return;
+
+ if (isHighlighted)
+ _controlState |= CPControlStateHighlighted;
+ else
+ _controlState &= ~CPControlStateHighlighted;
+
+ [self setNeedsLayout];
+ [self setNeedsDisplay:YES];
+}
+
+- (BOOL)isHighlighted
+{
+ return !!(_controlState & CPControlStateHighlighted);
+}
+
+@end
+
+@implementation CPControl (Theming)
+
+- (void)viewDidChangeTheme
+{
+ [super viewDidChangeTheme];
+
+ var theme = [self theme];
+
+ [_alignment setTheme:theme];
+ [_verticalAlignment setTheme:theme];
+
+ [_lineBreakMode setTheme:theme];
+ [_textColor setTheme:theme];
+ [_font setTheme:theme];
+
+ [_textShadowColor setTheme:theme];
+ [_textShadowOffset setTheme:theme];
+
+ [_imagePositions setTheme:theme];
+ [_imageScaling setTheme:theme];
+}
+
+- (CPDictionary)themedValues
+{
+ var values = [super themedValues];
+
+ [values setObject:_alignment forKey:@"alignment"];
+ [values setObject:_verticalAlignment forKey:@"vertical-alignment"];
+
+ [values setObject:_lineBreakMode forKey:@"line-break-mode"];
+ [values setObject:_textColor forKey:@"text-color"];
+ [values setObject:_font forKey:@"font"];
+
+ [values setObject:_textShadowColor forKey:@"text-shadow-color"];
+ [values setObject:_textShadowOffset forKey:@"text-shadow-offset"];
+
+ [values setObject:_imagePosition forKey:@"image-position"];
+ [values setObject:_imageScaling forKey:@"image-scaling"];
+
+ return values;
+}
@end
var CPControlValueKey = "CPControlValueKey",
CPControlIsEnabledKey = "CPControlIsEnabledKey",
- CPControlAlignmentKey = "CPControlAlignmentKey",
+
+ CPControlAlignmentKey = @"CPControlAlignmentKey",
CPControlVerticalAlignmentKey = @"CPControlVerticalAlignmentKey",
- CPControlFontKey = "CPControlFontKey",
- CPControlTextColorKey = "CPControlTextColorKey",
+ CPControlLineBreakModeKey = @"CPControlLineBreakModeKey",
+ CPControlFontKey = @"CPControlFontKey",
+ CPControlTextColorKey = @"CPControlTextColorKey",
+ CPControlTextShadowColorKey = @"CPControlTextShadowColorKey",
+ CPControlTextShadowOffsetKey = @"CPControlTextShadowOffsetKey",
+ CPControlImagePositionKey = @"CPControlImagePositionKey",
+ CPControlImageScalingKey = @"CPControlImageScalingKey",
+
CPControlTargetKey = "CPControlTargetKey",
CPControlActionKey = "CPControlActionKey",
CPControlSendActionOnKey = "CPControlSendActionOnKey";
@@ -574,21 +613,28 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
{
_controlState = CPControlStateNormal;
+ var theme = [self theme],
+ theClass = [self class];
+
[self setObjectValue:[aCoder decodeObjectForKey:CPControlValueKey]];
-
- if ([aCoder containsValueForKey:__Deprecated__CPImageViewImageKey])
- [self setObjectValue:[aCoder decodeObjectForKey:_DeprecatedCPImageViewImageKey]];
- [self setEnabled:[aCoder decodeBoolForKey:CPControlIsEnabledKey]];
-
- [self setAlignment:[aCoder decodeIntForKey:CPControlAlignmentKey]];
- [self setVerticalAlignment:[aCoder decodeIntForKey:CPControlVerticalAlignmentKey]];
- [self setFont:[aCoder decodeObjectForKey:CPControlFontKey]];
- [self setTextColor:[aCoder decodeObjectForKey:CPControlTextColorKey]];
-
+ _alignment = CPThemedValueDecode(aCoder, CPControlAlignmentKey, CPLeftTextAlignment, @"alignment", theme, theClass);
+ _verticalAlignment = CPThemedValueDecode(aCoder, CPControlVerticalAlignmentKey, CPTopVerticalTextAlignment, @"vertical-alignment", theme, theClass);
+
+ _lineBreakMode = CPThemedValueDecode(aCoder, CPControlLineBreakModeKey, CPLineBreakByClipping, @"line-break-mode", theme, theClass);
+ _textColor = CPThemedValueDecode(aCoder, CPControlTextColorKey, [CPColor blackColor], @"text-color", theme, theClass);
+ _font = CPThemedValueDecode(aCoder, CPControlFontKey, [CPFont systemFontOfSize:12.0], @"font", theme, theClass);
+
+ _textShadowColor = CPThemedValueDecode(aCoder, CPControlTextShadowColorKey, nil, @"text-shadow-color", theme, theClass);
+ _textShadowOffset = CPThemedValueDecode(aCoder, CPControlTextShadowOffsetKey, _CGSizeMake(0.0, 0.0), @"text-shadow-offset", theme, theClass);
+
+ _imagePosition = CPThemedValueDecode(aCoder, CPControlImagePositionKey, CPImageLeft, @"image-position", theme, theClass);
+ _imageScaling = CPThemedValueDecode(aCoder, CPControlImageScalingKey, CPScaleToFit, @"image-scaling", theme, theClass);
+
+ /*
[self setTarget:[aCoder decodeObjectForKey:CPControlTargetKey]];
[self setAction:[aCoder decodeObjectForKey:CPControlActionKey]];
- [self sendActionOn:[aCoder decodeIntForKey:CPControlSendActionOnKey]];
+ [self sendActionOn:[aCoder decodeIntForKey:CPControlSendActionOnKey]];*/
}
return self;
@@ -603,7 +649,21 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
[super encodeWithCoder:aCoder];
[aCoder encodeObject:_value forKey:CPControlValueKey];
+
+ CPThemedValueEncode(aCoder, CPControlAlignmentKey, _alignment);
+ CPThemedValueEncode(aCoder, CPControlVerticalAlignmentKey, _verticalAlignment);
+
+ CPThemedValueEncode(aCoder, CPControlLineBreakModeKey, _lineBreakMode);
+ CPThemedValueEncode(aCoder, CPControlTextColorKey, _textColor);
+ CPThemedValueEncode(aCoder, CPControlFontKey, _font);
+
+ CPThemedValueEncode(aCoder, CPControlTextShadowColorKey, _textShadowColor);
+ CPThemedValueEncode(aCoder, CPControlTextShadowOffsetKey, _textShadowOffset);
+ CPThemedValueEncode(aCoder, CPControlImagePositionKey, _imagePosition);
+ CPThemedValueEncode(aCoder, CPControlImageScalingKey, _imageScaling);
+
+ /*
[aCoder encodeBool:_isEnabled forKey:CPControlIsEnabledKey];
[aCoder encodeInt:_alignment forKey:CPControlAlignmentKey];
@@ -615,7 +675,7 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
[aCoder encodeConditionalObject:_target forKey:CPControlTargetKey];
[aCoder encodeObject:_action forKey:CPControlActionKey];
- [aCoder encodeInt:_sendActionOn forKey:CPControlSendActionOnKey];
+ [aCoder encodeInt:_sendActionOn forKey:CPControlSendActionOnKey];*/
}
@end
@@ -716,215 +776,3 @@ function _CPControlThreePartImagePattern(isVertical, sizes, aClassName)
return color;
}
-
-///
-
-#include "CPControl.h"
-
-@implementation CPControl (BETTER)
-
-CONTROL_STATE_VALUE(Alignment, alignment)
-CONTROL_STATE_VALUE(VerticalAlignment, verticalAlignment)
-CONTROL_STATE_VALUE(LineBreakMode, lineBreakMode)
-CONTROL_STATE_VALUE(TextColor, textColor)
-CONTROL_STATE_VALUE(Font, font)
-CONTROL_STATE_VALUE(TextShadowColor, textShadowColor)
-CONTROL_STATE_VALUE(TextShadowOffset, textShadowOffset)
-CONTROL_STATE_VALUE(ImagePosition, imagePosition)
-CONTROL_STATE_VALUE(ImageScaling, imageScaling)
-
-- (int)controlState
-{
- return _controlState;
-}
-
-- (void)setEnabled:(BOOL)isEnabled
-{
- if ((!(_controlState & CPControlStateDisabled)) === isEnabled)
- return;
-
- if (isEnabled)
- _controlState &= ~CPControlStateDisabled;
- else
- _controlState |= CPControlStateDisabled;
-
- [self setNeedsLayout];
- [self setNeedsDisplay:YES];
-}
-
-- (BOOL)isEnabled
-{
- return !(_controlState & CPControlStateDisabled);
-}
-
-- (void)highlight:(BOOL)shouldHighlight
-{
- [self setHighlighted:shouldHighlight];
-}
-
-- (void)setHighlighted:(BOOL)isHighlighted
-{
- if ((!!(_controlState & CPControlStateHighlighted)) === isHighlighted)
- return;
-
- if (isHighlighted)
- _controlState |= CPControlStateHighlighted;
- else
- _controlState &= ~CPControlStateHighlighted;
-
- [self setNeedsLayout];
- [self setNeedsDisplay:YES];
-}
-
-- (BOOL)isHighlighted
-{
- return !!(_controlState & CPControlStateHighlighted);
-}
-
-@end
-
-CPControlStateNormal = 0,
-CPControlStateHighlighted = 1 << 0,
-CPControlStateDisabled = 1 << 1,
-CPControlStateSelected = 1 << 2,
-CPControlStateDefault = 1 << 3;
-
-@implementation CPControlStateValue : CPObject
-{
- id _defaultValue;
- JSObject _values;
- int _highestState;
-}
-
-- (id)initWithDefaultValue:(id)aDefaultValue
-{
- self = [super init];
-
- if (self)
- {
- _defaultValue = aDefaultValue;
- _values = {};
- _highestState = 0;
- }
-
- return self;
-}
-
-- (void)setDefaultValue:(id)aDefaultValue
-{
- _defaultValue = aDefaultValue;
-}
-
-- (id)valueForControlState:(CPControlState)aState
-{
- var value = _values[aState];
-
- // If we don't have a value, and we have a non-normal state...
- if (value === undefined && aState > 0)
- {
- // If this is a composite state, retrieve what we can.
- if (!(aState & (aState - 1)))
- {
- var state = 1;
-
- while (value === undefined && state < _highestState)
- {
- if (state & aState)
- value = _values[state];
-
- state << 1;
- }
- }
-
- // Still don't have a value? OK, let's use the normal value.
- if (value === undefined && aState > 0)
- value = _values[CPControlStateNormal];
- }
-
- return value || _defaultValue;
-}
-
-- (void)setValue:(id)aValue
-{
- _values = {};
- _values[CPControlStateNormal] = aValue;
- _highestState = CPControlStateNormal;
-}
-
-- (void)setValue:(id)aValue forControlState:(CPControlState)aState
-{
- if (_highestState < aState)
- _highestState = aState;
-
- _values[aState] = aValue;
-}
-
-- (void)removeValueForControlState:(CPControlState)aState
-{
- delete _values[aState];
-
-// if (_highestState === aState)
-// _highestState = nil;
-}
-
-@end
-
-var CPControlStateValueStates = @"CPControlStateValueStates",
- CPControlStateValueValues = @"CPControlStateValueValues";
-
-@implementation CPControlStateValue (CPCoding)
-
-- (id)initWithCoder:(CPCoder)aCoder
-{
- self = [super init];
-
- if (self)
- {
- _values = {};
- _highestState = 0;
-
- var states = [aCoder decodeObjectForKey:CPControlStateValueStates];
-
- if (states)
- {
- var values = [aCoder decodeObjectForKey:CPControlStateValueValues],
- count = states.length;
-
- while (count--)
- {
- var state = states[count];
-
- if (state > _highestState)
- _highestState = state;
-
- _values[state] = values[count];
- }
- }
- }
-
- return self;
-}
-
-- (void)encodeWithCoder:(CPCoder)aCoder
-{
- var states = [],
- values = [];
-
- for (state in _values)
- {
- if (!_values.hasOwnProperty(state))
- continue;
-
- states.push(state);
- values.push(_values[state]);
- }
-
- if (states.length)
- {
- [aCoder encodeObject:states forKey:CPControlStateValueStates];
- [aCoder encodeObject:values forKey:CPControlStateValueValues];
- }
-}
-
-@end
-
diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j
index d36c8a68d..d3c836265 100644
--- a/AppKit/CPPopUpButton.j
+++ b/AppKit/CPPopUpButton.j
@@ -61,8 +61,6 @@ var CPPopUpButtonArrowsImage = nil;
_selectedIndex = CPNotFound;
_preferredEdge = CPMaxYEdge;
- [self setBezelStyle:CPTexturedRoundedBezelStyle];
-
[self setImagePosition:CPImageLeft];
[self setAlignment:CPLeftTextAlignment];
[self setLineBreakMode:CPLineBreakByTruncatingTail];
diff --git a/AppKit/CPSlider.j b/AppKit/CPSlider.j
index fd55eee84..f112e3159 100644
--- a/AppKit/CPSlider.j
+++ b/AppKit/CPSlider.j
@@ -1,8 +1,9 @@
-@import
+@import "CPControl.j"
+@import "CPThemedValue.j"
#include "CoreGraphics/CGGeometry.h"
-#include "CPControl.h"
+#include "CPThemedValue.h"
@implementation CPSlider : CPControl
@@ -11,13 +12,13 @@
double _maxValue;
double _altIncrementValue;
- CPColor _verticalTrackColor; // vertical-track-color
- CPColor _horizontalTrackColor; // horizontal-track-color
+ CPThemedValue _verticalTrackColor; // vertical-track-color
+ CPThemedValue _horizontalTrackColor; // horizontal-track-color
- CPControlStateValue _knobColor;
+ CPThemedValue _knobColor;
- float _trackWidth; // track-width
- CGSize _knobSize; // knob-size
+ CPThemedValue _trackWidth; // track-width
+ CPThemedValue _knobSize; // knob-size
CPView _trackView;
CPView _knobView;
@@ -32,8 +33,16 @@
_minValue = 0.0;
_maxValue = 100.0;
- _knobColor = [[CPControlStateValue alloc] initWithDefaultValue:nil];
-
+ var theme = [self theme],
+ theClass = [self class];
+
+ _knobColor = CPThemedValueMake(nil, "knob-color", theme, theClass);
+ _knobSize = CPThemedValueMake(_CGSizeMakeZero(), "knob-size", theme, theClass);
+
+ _trackWidth = CPThemedValueMake(0.0, "track-width", theme, theClass);
+ _verticalTrackColor = CPThemedValueMake(nil, "vertical-track-color", theme, theClass);
+ _horizontalTrackColor = CPThemedValueMake(nil, "horizonal-track-color", theme, theClass);
+
[self setObjectValue:50.0];
[self setContinuous:YES];
@@ -86,94 +95,41 @@
[self setNeedsDisplay:YES];
}
-- (void)setHorizontalTrackColor:(CPColor)aColor
-{
- if (_horizontalTrackColor === aColor)
- return;
-
- _horizontalTrackColor = aColor;
-
- [self setNeedsLayout];
- [self setNeedsDisplay:YES];
-}
-
-- (CPColor)horizontalTrackColor
-{
- return _horizontalTrackColor;
-}
-
-- (void)setVerticalTrackColor:(CPColor)aColor
-{
- if (_verticalTrackColor === aColor)
- return;
-
- _verticalTrackColor = aColor;
-
- [self setNeedsLayout];
- [self setNeedsDisplay:YES];
-}
-
-- (CPColor)verticalTrackColor
-{
- return _verticalTrackColor;
-}
-
-- (void)setTrackWidth:(float)aTrackWidth
-{
- if (_trackWidth === aTrackWidth)
- return;
-
- _trackWidth = aTrackWidth;
-
- [self setNeedsLayout];
- [self setNeedsDisplay:YES];
-}
-
-- (float)trackWidth
-{
- return _trackWidth;
-}
-
- (CGRect)trackRectForBounds:(CGRect)bounds
{
- var trackWidth = [self trackWidth];
+ var trackWidth = [self currentTrackWidth];
- if (!trackWidth)
+ if (trackWidth <= 0)
return _CGRectMakeZero();
if ([self isVertical])
{
bounds.origin.x = (_CGRectGetWidth(bounds) - trackWidth) / 2.0;
- bounds.size.width = _trackWidth;
+ bounds.size.width = trackWidth;
}
else
{
bounds.origin.y = (_CGRectGetHeight(bounds) - trackWidth) / 2.0;
- bounds.size.height = _trackWidth;
+ bounds.size.height = trackWidth;
}
return bounds;
}
-- (void)setKnobSize:(CGSize)aKnobSize
-{
- if (_knobSize && (!aKnobSize || _CGSizeEqualToSize(_knobSize, aKnobSize)))
- return;
-
- _knobSize = aKnobSize ? _CGSizeMakeCopy(aKnobSize) : nil;
-
- [self setNeedsLayout];
- [self setNeedsDisplay:YES];
-}
-
-CONTROL_STATE_VALUE(KnobColor, knobColor)
+THEMED_STATED_VALUE(KnobColor, knobColor)
+THEMED_STATED_VALUE(KnobSize, knobSize)
+THEMED_STATED_VALUE(TrackWidth, trackWidth)
+THEMED_STATED_VALUE(HorizontalTrackColor, horizontalTrackColor)
+THEMED_STATED_VALUE(VerticalTrackColor, verticalTrackColor)
- (CGRect)knobRectForBounds:(CGRect)bounds
{
- if (!_knobSize || _knobSize.width <= 0 || _knobSize.height <= 0)
+ var knobSize = [self currentKnobSize];
+
+ if (knobSize.width <= 0 || knobSize.height <= 0)
return _CGRectMakeZero();
- var knobRect = _CGRectMake(0.0, 0.0, _knobSize.width, _knobSize.height),
+ var knobRect = _CGRectMake(0.0, 0.0, knobSize.width, knobSize.height),
trackRect = [self trackRectForBounds:bounds];
// No track, do our best to approximate a place for this thing.
@@ -182,13 +138,13 @@ CONTROL_STATE_VALUE(KnobColor, knobColor)
if ([self isVertical])
{
- knobRect.origin.x = _CGRectGetMidX(trackRect) - _knobSize.width / 2.0;
- knobRect.origin.y = (([self doubleValue] - _minValue) / (_maxValue - _minValue)) * (_CGRectGetHeight(trackRect) - _knobSize.height);
+ knobRect.origin.x = _CGRectGetMidX(trackRect) - knobSize.width / 2.0;
+ knobRect.origin.y = (([self doubleValue] - _minValue) / (_maxValue - _minValue)) * (_CGRectGetHeight(trackRect) - knobSize.height);
}
else
{
- knobRect.origin.x = (([self doubleValue] - _minValue) / (_maxValue - _minValue)) * (_CGRectGetWidth(trackRect) - _knobSize.width);
- knobRect.origin.y = _CGRectGetMidY(trackRect) - _knobSize.height / 2.0;
+ knobRect.origin.x = (([self doubleValue] - _minValue) / (_maxValue - _minValue)) * (_CGRectGetWidth(trackRect) - knobSize.width);
+ knobRect.origin.y = _CGRectGetMidY(trackRect) - knobSize.height / 2.0;
}
return knobRect;
@@ -231,7 +187,7 @@ CONTROL_STATE_VALUE(KnobColor, knobColor)
{
if (!_trackView)
{
- _trackView = [self createTrackView]
+ _trackView = [self createTrackView];
if (_trackView)
[self addSubview:_trackView positioned:CPWindowBelow relativeTo:_knobView];
@@ -244,12 +200,12 @@ CONTROL_STATE_VALUE(KnobColor, knobColor)
if ([self isVertical])
{
if (_verticalTrackColor)
- [_trackView setBackgroundColor:_verticalTrackColor];
+ [_trackView setBackgroundColor:[self currentVerticalTrackColor]];
}
else
{
if (_horizontalTrackColor)
- [_trackView setBackgroundColor:_horizontalTrackColor];
+ [_trackView setBackgroundColor:[self currentHorizontalTrackColor]];
}
}
}
@@ -276,7 +232,7 @@ CONTROL_STATE_VALUE(KnobColor, knobColor)
{
[_knobView setFrame:knobRect];
- var knobColor = [self knobColor];
+ var knobColor = [self currentKnobColor];
if (knobColor)
[_knobView setBackgroundColor:knobColor];
@@ -398,13 +354,12 @@ CONTROL_STATE_VALUE(KnobColor, knobColor)
if (!theme)
return;
- //_knobColor = [theme valueForKey:@"knob-color"];
+ [_knobColor setTheme:theme];
+ [_knobSize setTheme:theme];
- [self setKnobSize:[theme valueForKey:@"knob-size"]];
-
- [self setTrackWidth:[theme valueForKey:@"track-width"]];
- [self setHorizontalTrackColor:[theme valueForKey:@"horizontal-track-color"]];
- [self setVerticalTrackColor:[theme valueForKey:@"vertical-track-color"]];
+ [_trackWidth setTheme:theme];
+ [_horizontalTrackColor setTheme:theme];
+ [_verticalTrackColor setTheme:theme];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
@@ -425,9 +380,15 @@ CONTROL_STATE_VALUE(KnobColor, knobColor)
@end
-var CPSliderMinValueKey = "CPSliderMinValueKey",
- CPSliderMaxValueKey = "CPSliderMaxValueKey",
- CPSliderAltIncrValueKey = "CPSliderAltIncrValueKey";
+var CPSliderMinValueKey = "CPSliderMinValueKey",
+ CPSliderMaxValueKey = "CPSliderMaxValueKey",
+ CPSliderAltIncrValueKey = "CPSliderAltIncrValueKey",
+
+ CPSliderKnobColorKey = "CPSliderKnobColorKey",
+ CPSliderKnobSizeKey = "CPSliderKnobSizeKey";
+ CPSliderTrackWidthKey = "CPSliderTrackWidthKey";
+ CPSliderHorizontalTrackColorKey = "CPSliderHorizontalTrackColorKey";
+ CPSliderVerticalTrackColorKey = "CPSliderVerticalTrackColorKey";
@implementation CPSlider (CPCoding)
@@ -441,9 +402,17 @@ var CPSliderMinValueKey = "CPSliderMinValueKey",
_maxValue = [aCoder decodeDoubleForKey:CPSliderMaxValueKey];
_altIncrementValue = [aCoder decodeDoubleForKey:CPSliderAltIncrValueKey];
- [self setContinuous:YES];
+ var theme = [self theme],
+ theClass = [self class];
+
+ _knobColor = CPThemedValueDecode(aCoder, CPSliderKnobColorKey, nil, "knob-color", theme, theClass);
+ _knobSize = CPThemedValueDecode(aCoder, CPSliderKnobSizeKey, nil, "knob-size", theme, theClass);
+
+ _trackWidth = CPThemedValueDecode(aCoder, CPSliderKnobColorKey, nil, "track-width", theme, theClass);
+ _horizontalTrackColor = CPThemedValueDecode(aCoder, CPSliderHorizontalTrackColorKey, nil, "horizontal-track-color", theme, theClass);
+ _verticalTrackColor = CPThemedValueDecode(aCoder, CPSliderVerticalTrackColorKey, nil, "vertical-track-color", theme, theClass);
- [self setTheme:[CPTheme defaultTheme]];
+ [self setContinuous:YES];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
@@ -455,7 +424,7 @@ var CPSliderMinValueKey = "CPSliderMinValueKey",
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
-
+ /*
var count = [_subviews count],
subviews = nil;
@@ -472,21 +441,22 @@ var CPSliderMinValueKey = "CPSliderMinValueKey",
if (_knobView)
[_subviews removeObjectIdenticalTo:_knobView];
}
- }
+ }*/
[super encodeWithCoder:aCoder];
- _subviews = subviews;
+// _subviews = subviews;
[aCoder encodeDouble:_minValue forKey:CPSliderMinValueKey];
[aCoder encodeDouble:_maxValue forKey:CPSliderMaxValueKey];
[aCoder encodeDouble:_altIncrementValue forKey:CPSliderAltIncrValueKey];
- // NO!
-/* [aCoder encodeObject:_verticalTrackColor forKey:"1"];
- [aCoder encodeObject:_horizontalTrackColor forKey:"2"];
- [aCoder encodeObject:_knobColor forKey:"3"];
- [aCoder encodeObject:_highlightedKnobColor forKey:"4"];*/
+ CPThemedValueEncode(aCoder, CPSliderKnobColorKey, _knobColor);
+ CPThemedValueEncode(aCoder, CPSliderKnobSizeKey, _knobSize);
+
+ CPThemedValueEncode(aCoder, CPSliderTrackWidthKey, _trackWidth);
+ CPThemedValueEncode(aCoder, CPSliderHorizontalTrackColorKey, _horizontalTrackColor);
+ CPThemedValueEncode(aCoder, CPSliderVerticalTrackColorKey, _verticalTrackColor);
}
@end
diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j
index 89c85aa3c..e53fd9dde 100644
--- a/AppKit/CPTheme.j
+++ b/AppKit/CPTheme.j
@@ -3,6 +3,8 @@
@import
@import
+@import "CPThemedValue.j"
+
var CPThemesByName = nil,
CPThemeDefaultTheme = nil,
@@ -122,7 +124,7 @@ var CPThemesByName = nil,
- (id)valueForKey:(CPString)aKey inClass:(CPClass)aClass
{
if (!aClass)
- throw "no!";
+ return nil;
var className = [aClass className],
table = _classTable[className];
@@ -138,6 +140,11 @@ var CPThemesByName = nil,
return value;
}
+- (id)valueForIdentifier:(CPString)anIdentifier inClass:(Class)aClass
+{
+ return [self valueForKey:anIdentifier inClass:aClass];
+}
+
- (void)takeThemeFromObject:(id)anObject
{
var values = [anObject themedValues],
@@ -192,6 +199,8 @@ var CPThemesByName = nil,
}
if (table[aKey] !== aValue)
+// {
+// if (table.hasOwnProperty(aKey)
table[aKey] = aValue;
}
diff --git a/AppKit/CPControl.h b/AppKit/CPThemedValue.h
similarity index 63%
rename from AppKit/CPControl.h
rename to AppKit/CPThemedValue.h
index ea28d45e6..e806ff010 100644
--- a/AppKit/CPControl.h
+++ b/AppKit/CPThemedValue.h
@@ -1,4 +1,20 @@
-#define CONTROL_STATE_VALUE(VALUE, LOWERCASEVALUE) \
+
+#define THEMED_VALUE(VALUE, LOWERCASEVALUE) \
+- (void)set##VALUE:(id)aValue\
+{\
+ var currentValue = [_##LOWERCASEVALUE valueForControlState:_controlState];\
+ [_##LOWERCASEVALUE setValue:aValue];\
+ if ([_##LOWERCASEVALUE valueForControlState:_controlState] === currentValue)\
+ return;\
+ [self setNeedsDisplay:YES];\
+ [self setNeedsLayout];\
+}\
+- (id)LOWERCASEVALUE\
+{\
+ return [_##LOWERCASEVALUE value];\
+}\
+
+#define THEMED_STATED_VALUE(VALUE, LOWERCASEVALUE) \
- (void)set##VALUE:(id)aValue forControlState:(CPControlState)aControlState\
{\
var currentValue = [_##LOWERCASEVALUE valueForControlState:_controlState];\
@@ -22,6 +38,10 @@
[self setNeedsLayout];\
}\
- (id)LOWERCASEVALUE\
+{\
+ return [_##LOWERCASEVALUE value];\
+}\
+- (id)current##VALUE\
{\
return [_##LOWERCASEVALUE valueForControlState:_controlState];\
}
diff --git a/AppKit/CPThemedValue.j b/AppKit/CPThemedValue.j
new file mode 100644
index 000000000..f0d747d1e
--- /dev/null
+++ b/AppKit/CPThemedValue.j
@@ -0,0 +1,273 @@
+
+@import
+
+
+CPControlStateNormal = 0,
+CPControlStateHighlighted = 1 << 0,
+CPControlStateDisabled = 1 << 1,
+CPControlStateSelected = 1 << 2,
+CPControlStateDefault = 1 << 3;
+
+var BIT_COUNT = [ 0 /*0000*/, 1 /*0001*/, 1 /*0010*/, 2 /*0011*/, 1 /*0100*/, 2 /*0101*/, 2 /*0110*/, 3 /*0111*/,
+ 1 /*1000*/, 2 /*1001*/, 2 /*1010*/, 3 /*1011*/, 2 /*1100*/, 3 /*1101*/, 3 /*1110*/, 4 /*1111*/],
+ bit_count = function(bits)
+ {
+ var count = 0;
+
+ while (bits)
+ {
+ ++count;
+ bits &= (bits - 1);
+ }
+
+ return count ;
+ }
+
+@implementation CPThemedValue : CPObject
+{
+ BOOL _isSingularObject;
+
+ CPTheme _theme;
+ CPString _identifier;
+ Class _themedClass;
+
+ id _defaultValue;
+
+ id _values;
+ id _valueFromTheme;
+}
+
+- (id)initWithDefaultValue:(id)aDefaultValue identifier:(CPString)anIdentifier theme:(CPTheme)aTheme class:(Class)aClass
+{
+ self = [super init];
+
+ if (self)
+ {
+ _theme = aTheme;
+ _themedClass = aClass;
+ _identifier = anIdentifier;
+ _defaultValue = aDefaultValue;
+
+ _isSingularObject = YES;
+ _values = nil;
+ _valueFromTheme = [_theme valueForIdentifier:_identifier inClass:_themedClass];
+ }
+
+ return self;
+}
+
+- (void)setDefaultValue:(id)aValue
+{
+ _defaultValue = aValue;
+}
+
+- (void)setIdentifier:(CPString)anIdentifier
+{
+ if (_identifier === anIdentifier)
+ return;
+
+ _identifier = anIdentifier;
+ _valueFromTheme = [_theme valueForIdentifier:_identifier inClass:_themedClass];
+}
+
+- (CPString)identifier
+{
+ return _identifier;
+}
+
+- (void)setTheme:(CPTheme)aTheme
+{
+ if (_theme === aTheme)
+ return;
+
+ _theme = aTheme;
+ _valueFromTheme = [_theme valueForIdentifier:_identifier inClass:_themedClass];
+}
+
+- (void)setThemedClass:(Class)aClass
+{
+ if (_themedClass === aClass)
+ return;
+
+ _themedClass = aClass;
+ _valueFromTheme = [_theme valueForIdentifier:_identifier inClass:_themedClass];
+}
+
+- (void)setValue:(id)aValue
+{
+ _isSingularObject = YES;
+ _values = aValue;
+}
+
+- (id)value
+{
+ return [self valueForControlState:CPControlStateNormal];
+}
+
+- (void)setValue:(id)aValue forControlState:(CPControlState)aState
+{
+ if (aState !== CPControlStateNormal)
+ {
+ if (_isSingularObject)
+ {
+ var normalValue = _values;
+
+ _isSingularObject = NO;
+
+ _values = {};
+
+ if (normalValue)
+ _values[CPControlStateNormal] = normalValue;
+ }
+
+ _values[aState] = aValue;
+ }
+
+ else if (isSingularObject)
+ _values = aValue;
+
+ else
+ _values[CPControlStateNormal] = aValue;
+}
+
+- (id)valueForControlState:(CPControlState)aState
+{
+ if (_isSingularObject)
+ return _values || [_valueFromTheme valueForControlState:aState] || _defaultValue;
+
+ var value = _values[aState];
+
+ // If we don't have a value, and we have a non-normal state...
+ if (value === undefined && aState > 0)
+ {
+ // If this is a composite state, find the closest partial subset match.
+ if (!(aState & (aState - 1)))
+ {
+ var highestBitCount = 0;
+
+ for (state in _values)
+ {
+ if (!_values.hasOwnProperty(state))
+ continue;
+
+ // 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[state];
+ }
+ }
+ }
+ }
+
+ // Still don't have a value? OK, let's use the normal value.
+ if (value === undefined)
+ value = _values[CPControlStateNormal];
+ }
+
+ return value || [_valueFromTheme valueForControlState:aState] || _defaultValue;
+}
+
+- (id)initWithCoder:(CPCoder)aCoder
+{
+ self = [super init];
+
+ if (self)
+ {
+ _isSingularObject = [aCoder containsValueForKey:@"value"];
+
+ if (_isSingularObject)
+ _values = [aCoder decodeObjectForKey:"value"];
+
+ else
+ {
+ _values = {};
+
+ var statesAndValues = [aCoder decodeObjectForKey:"statesAndValues"];
+ count = [statesAndValues count];
+
+ while (count--)
+ {
+ var value = statesAndValues[count--],
+ state = statesAndValues[count];
+
+ _values[state] = value;
+ }
+ }
+ }
+
+ return self;
+}
+
+- (void)encodeWithCoder:(CPCoder)aCoder
+{
+ if (_isSingularObject)
+ {
+ [aCoder encodeObject:_values forKey:@"value"];
+
+ return;
+ }
+
+ var statesAndValues = [];
+
+ for (state in _values)
+ {
+ if (!_values.hasOwnProperty(state))
+ continue;
+
+ statesAndValues.push(state);
+ statesAndValues.push(_values[state]);
+ }
+
+ [aCoder encodeObject:statesAndValues forKey:@"statesAndValues"];
+}
+
+@end
+
+function CPThemedValueMake(aDefaultValue, anIdentifier, aTheme, aClass)
+{
+ return [[CPThemedValue alloc] initWithDefaultValue:aDefaultValue identifier:anIdentifier theme:aTheme class:aClass];
+}
+
+function CPThemedValueEncode(aCoder, aKey, aThemedValue)
+{
+ if (aThemedValue._isSingularObject)
+ {
+ var actualValue = aThemedValue._values;
+
+ if (aThemedValue._values)
+ [aCoder encodeObject:actualValue forKey:aKey];
+ }
+ else
+ [aCoder encodeObject:aThemedValue forKey:aKey];
+}
+
+function CPThemedValueDecode(aCoder, aKey, aDefaultValue, anIdentifier, aTheme, aClass)
+{
+ if (![aCoder containsValueForKey:aKey])
+ return CPThemedValueMake(aDefaultValue, anIdentifier, aTheme, aClass);
+
+ var value = [aCoder decodeObjectForKey:aKey];
+
+ if (![value isKindOfClass:[CPThemedValue class]])
+ {
+ var themedValue = CPThemedValueMake(aDefaultValue, anIdentifier, aTheme, aClass);
+
+ [themedValue setValue:value];
+
+ value = themedValue;
+ }
+ else
+ {
+ [value setDefaultValue:aDefaultValue];
+ [value setTheme:aTheme];
+ [value setIdentifier:anIdentifier];
+ [value setThemedClass:aClass];
+ }
+
+ return value;
+}
diff --git a/AppKit/CPView.j b/AppKit/CPView.j
index 8d693b3da..8337720d2 100644
--- a/AppKit/CPView.j
+++ b/AppKit/CPView.j
@@ -243,8 +243,8 @@ var DOMElementPrototype = nil,
_DOMImageParts = [];
_DOMImageSizes = [];
#endif
-
- [self setTheme:[CPTheme defaultTheme]];
+
+ _theme = [CPTheme defaultTheme];
}
return self;
@@ -1883,6 +1883,8 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
[self setBackgroundColor:[aCoder decodeObjectForKey:CPViewBackgroundColorKey]];
+ _theme = [CPTheme defaultTheme];
+
[self setNeedsDisplay:YES];
}
diff --git a/AppKit/CoreGraphics/CGGeometry.j b/AppKit/CoreGraphics/CGGeometry.j
index 880202fb2..625e67788 100644
--- a/AppKit/CoreGraphics/CGGeometry.j
+++ b/AppKit/CoreGraphics/CGGeometry.j
@@ -66,6 +66,7 @@ _function(CGRectIsNull(aRect))
_function(CGRectContainsPoint(aRect, aPoint))
_function(CGInsetMake(top, left, bottom, right))
+_function(CGInsetMakeZero())
_function(CGInsetMakeCopy(anInset))
_function(CGInsetIsEmpty(anInset))
diff --git a/Tools/nib2cib/NSButton.j b/Tools/nib2cib/NSButton.j
index e5dc62dc2..3c746316c 100644
--- a/Tools/nib2cib/NSButton.j
+++ b/Tools/nib2cib/NSButton.j
@@ -49,6 +49,17 @@ _CPButtonBezelStyleHeights[CPHUDBezelStyle] = 20;
_isBordered = [cell isBordered];
_bezelStyle = [cell bezelStyle];
+ var theme = nil,
+ theClass = [self class];
+
+ _bezelInset = CPThemedValueMake(CGInsetMakeZero(), "bezel-inset", theme, theClass);
+ _contentInset = CPThemedValueMake(CGInsetMakeZero(), "content-inset", theme, theClass);
+
+ _bezelColor = CPThemedValueMake(nil, "bezel-color", theme, theClass);
+
+ _image = CPThemedValueMake(nil, @"image", theme, theClass);
+ _title = CPThemedValueMake(nil, @"title", theme, theClass);
+
// clean up:
switch (_bezelStyle)
diff --git a/Tools/nib2cib/NSControl.j b/Tools/nib2cib/NSControl.j
index 42a2510fe..8cdcb6ff2 100644
--- a/Tools/nib2cib/NSControl.j
+++ b/Tools/nib2cib/NSControl.j
@@ -36,6 +36,24 @@
{
[self sendActionOn:CPLeftMouseUpMask];
+ // Shoudl we stub this out?
+
+ var theme = nil,
+ theClass = [self class];
+
+ _alignment = CPThemedValueMake(CPLeftTextAlignment, "alignment", theme, theClass);
+ _verticalAlignment = CPThemedValueMake(CPTopVerticalTextAlignment, "vertical-alignment", theme, theClass);
+
+ _lineBreakMode = CPThemedValueMake(CPLineBreakByClipping, "line-break-mode", theme, theClass);
+ _textColor = CPThemedValueMake([CPColor blackColor], "text-color", theme, theClass);
+ _font = CPThemedValueMake([CPFont systemFontOfSize:12.0], "font", theme, theClass);
+
+ _textShadowColor = CPThemedValueMake(nil, @"text-shadow-color", theme, theClass);
+ _textShadowOffset = CPThemedValueMake(CGSizeMake(0.0, 0.0), "text-shadow-offset", theme, theClass);
+
+ _imagePosition = CPThemedValueMake(CPImageLeft, @"image-position", theme, theClass);
+ _imageScaling = CPThemedValueMake(CPScaleToFit, "image-scaling", theme, theClass);
+
var cell = [aCoder decodeObjectForKey:@"NSCell"];
[self setObjectValue:[cell objectValue]];
diff --git a/Tools/nib2cib/NSSlider.j b/Tools/nib2cib/NSSlider.j
index a4b828ed9..e6a1cc098 100644
--- a/Tools/nib2cib/NSSlider.j
+++ b/Tools/nib2cib/NSSlider.j
@@ -38,7 +38,16 @@
_minValue = [cell minValue];
_maxValue = [cell maxValue];
_altIncrementValue = [cell altIncrementValue];
- _isVertical = [cell isVertical];
+
+ var theme = nil,
+ theClass = [self class];
+
+ _knobColor = CPThemedValueMake(nil, "knob-color", theme, theClass);
+ _knobSize = CPThemedValueMake(CGSizeMakeZero(), "knob-size", theme, theClass);
+
+ _trackWidth = CPThemedValueMake(0.0, "track-width", theme, theClass);
+ _horizontalTrackColor = CPThemedValueMake(nil, "horizontal-track-color", theme, theClass);
+ _verticalTrackColor = CPThemedValueMake(nil, "vertical-track-color", theme, theClass);
}
return self;
diff --git a/Tools/steam/Project.js b/Tools/steam/Project.js
index 1690140f2..718d69835 100644
--- a/Tools/steam/Project.js
+++ b/Tools/steam/Project.js
@@ -26,19 +26,7 @@ function Target(dictionary)
count = exclusions.length;
for (; index < count; ++index)
- {
- var file = new File(exclusions[index]).getCanonicalFile();
-
- if (file.isDirectory())
- {
- var files = getFiles(file);
-
- if (files.length)
- this._exclusions = this._exclusions.concat(files);
- }
- else
- this._exclusions.push(file);
- }
+ this._exclusions.push(new File((exclusions[index])).getCanonicalFile());
}
return this;
@@ -102,17 +90,17 @@ function Project(/*String*/ aFilePath, /*String*/ aBuildPath)
this._infoDictionary = readPlist(new File(this._root.getAbsolutePath() + "/Info.plist"));
else
this._infoDictionary = new objj_dictionary();
-
+
this.buildPath = aBuildPath;
-
+
// Covert target dictionaries to target objects.
var targetDictionaries = dictionary_getValue(this._properties, "Targets");
-
+
this._targets = [];
-
- for (index = 0, count = targetDictionaries.length; index < count; ++index)
+
+ for (var index = 0, count = targetDictionaries.length; index < count; ++index)
this._targets.push(new Target(targetDictionaries[index]));
-
+
this.setActiveTarget(this._targets[0]);
// Covert target dictionaries to target objects.
@@ -124,7 +112,7 @@ function Project(/*String*/ aFilePath, /*String*/ aBuildPath)
this._configurations.push(new Configuration(configurationDictionaries[index]));
this.setActiveConfiguration(this._configurations[0]);
-
+
// Grab the Resources Directory (if it exists)
this._resources = new File(this._root.getAbsolutePath() + "/Resources/").getCanonicalFile();
@@ -271,13 +259,15 @@ Project.prototype.buildTheme = function()
OBJJ_INCLUDE_PATHS.push(defaultFrameworks);
}
- OBJJ_INCLUDE_PATHS = [System.getenv("STEAM_BUILD") + "/Release-Rhino/", System.getenv("STEAM_BUILD") + "/Release/"];
+ var activeConfigurationName = this.activeConfiguration().name();
+
+ OBJJ_INCLUDE_PATHS = [System.getenv("STEAM_BUILD") + "/" + activeConfigurationName + "-Rhino/", System.getenv("STEAM_BUILD") + "/" + activeConfigurationName + "/"];
// Load ALL of Foundation and AppKit, be nice to people.
- loadFrameworks([System.getenv("STEAM_BUILD") + "/Release/Foundation", System.getenv("STEAM_BUILD") + "/Release-Rhino/AppKit"], function()
+ loadFrameworks([System.getenv("STEAM_BUILD") + "/" + activeConfigurationName + "/Foundation", System.getenv("STEAM_BUILD") + "/" + activeConfigurationName + "-Rhino/AppKit"], function()
{
// Get .j files
- var jFiles = getFiles(project._root, "j", project.activeTarget().exclusions().concat("Frameworks/"));
+ var jFiles = getFiles(project._root, "j", project.activeTarget().exclusions().concat([new File("Frameworks/")]));
// Load 'em
importFiles(jFiles, function()
diff --git a/Tools/steam/build.js b/Tools/steam/build.js
index 959d22a0b..042decf11 100644
--- a/Tools/steam/build.js
+++ b/Tools/steam/build.js
@@ -12,7 +12,7 @@ function build()
projectFilePath = null,
gzip = false;
-
+
for (; index < count; ++index)
{
switch (arguments[index])
@@ -49,7 +49,7 @@ function build()
break;
}
}
-
+
// If no project file was specified, look for one.
if (!projectFilePath)
{
@@ -60,7 +60,7 @@ function build()
projectFilePath = candidates[0];
}
-
+
// Construct the Build Directory
if (!buildPath)
{
@@ -69,9 +69,9 @@ function build()
if (!buildPath)
buildPath = "Build";
}
-
+
var project = new Project(projectFilePath, buildPath);
-
+
project._gzip = gzip;
if (targetName)
@@ -93,7 +93,7 @@ function build()
project.setActiveConfiguration(configuration);
}
-
+
if (!actions.length)
actions.push("build");