Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows
@@ -55,6 +55,7 @@
|
||||
@import "CPController.j"
|
||||
@import "CPCookie.j"
|
||||
@import "CPCursor.j"
|
||||
@import "CPDatePicker.j"
|
||||
@import "CPDocument.j"
|
||||
@import "CPDocumentController.j"
|
||||
@import "CPEvent.j"
|
||||
|
||||
@@ -371,22 +371,32 @@ CPRunContinuesResponse = -1002;
|
||||
applicationVersion = [options objectForKey:@"ApplicationVersion"] || [mainInfo objectForKey:@"CPBundleShortVersionString"],
|
||||
copyright = [options objectForKey:@"Copyright"] || [mainInfo objectForKey:@"CPHumanReadableCopyright"];
|
||||
|
||||
var aboutPanelPath = [[CPBundle bundleForClass:[CPWindowController class]] pathForResource:@"AboutPanel.cib"],
|
||||
aboutPanelController = [CPWindowController alloc],
|
||||
aboutPanelController = [aboutPanelController initWithWindowCibPath:aboutPanelPath owner:aboutPanelController],
|
||||
aboutPanel = [aboutPanelController window],
|
||||
contentView = [aboutPanel contentView],
|
||||
imageView = [contentView viewWithTag:1],
|
||||
applicationLabel = [contentView viewWithTag:2],
|
||||
versionLabel = [contentView viewWithTag:3],
|
||||
copyrightLabel = [contentView viewWithTag:4],
|
||||
standardPath = [[CPBundle bundleForClass:[self class]] pathForResource:@"standardApplicationIcon.png"];
|
||||
var windowWidth = 275,
|
||||
windowHeight = 223,
|
||||
imgWidth = 100,
|
||||
imgHeight = 100,
|
||||
interField = 8,
|
||||
aboutPanel = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, windowWidth, windowHeight) styleMask:CPClosableWindowMask],
|
||||
imageView = [[CPImageView alloc] initWithFrame:CGRectMake((windowWidth / 2) - (imgWidth / 2), interField, imgWidth, imgHeight)],
|
||||
applicationLabel = [[CPTextField alloc] initWithFrame:CGRectMake(17, imgHeight + 16, windowWidth - 34, 24)],
|
||||
versionLabel = [[CPTextField alloc] initWithFrame:CGRectMake(17, imgHeight + 48, windowWidth - 34, 16)],
|
||||
copyrightLabel = [[CPTextField alloc] initWithFrame:CGRectMake(17, imgHeight + 72, windowWidth - 34, 32)],
|
||||
contentView = [aboutPanel contentView];
|
||||
|
||||
// FIXME move this into the CIB eventually
|
||||
[applicationLabel setFont:[CPFont boldSystemFontOfSize:[CPFont systemFontSize] + 2]];
|
||||
[applicationLabel setAlignment:CPCenterTextAlignment];
|
||||
[versionLabel setFont:[CPFont systemFontOfSize:[CPFont systemFontSize] - 1]];
|
||||
[versionLabel setAlignment:CPCenterTextAlignment];
|
||||
[copyrightLabel setFont:[CPFont systemFontOfSize:[CPFont systemFontSize] - 1]];
|
||||
[copyrightLabel setAlignment:CPCenterTextAlignment];
|
||||
[copyrightLabel setLineBreakMode:CPLineBreakByWordWrapping];
|
||||
|
||||
[contentView addSubview:imageView];
|
||||
[contentView addSubview:applicationLabel];
|
||||
[contentView addSubview:versionLabel];
|
||||
[contentView addSubview:copyrightLabel];
|
||||
|
||||
var standardPath = [[CPBundle bundleForClass:[self class]] pathForResource:@"standardApplicationIcon.png"];
|
||||
|
||||
[imageView setImage:applicationIcon || [[CPImage alloc] initWithContentsOfFile:standardPath
|
||||
size:CGSizeMake(256, 256)]];
|
||||
@@ -400,7 +410,7 @@ CPRunContinuesResponse = -1002;
|
||||
else
|
||||
[versionLabel setStringValue:@""];
|
||||
|
||||
[copyrightLabel setStringValue:copyright || ""];
|
||||
[copyrightLabel setStringValue:copyright || @""];
|
||||
[aboutPanel center];
|
||||
|
||||
_aboutPanel = aboutPanel;
|
||||
|
||||
@@ -65,51 +65,51 @@
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingContentArray
|
||||
{
|
||||
return [CPSet setWithObjects:"content"];
|
||||
return [CPSet setWithObjects:@"content"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingArrangedObjects
|
||||
{
|
||||
// Also depends on "filterPredicate" but we'll handle that manually.
|
||||
return [CPSet setWithObjects:"content", "sortDescriptors"];
|
||||
return [CPSet setWithObjects:@"content", @"sortDescriptors"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingSelection
|
||||
{
|
||||
return [CPSet setWithObjects:"selectionIndexes"];
|
||||
return [CPSet setWithObjects:@"selectionIndexes"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingSelectionIndex
|
||||
{
|
||||
return [CPSet setWithObjects:"selectionIndexes"];
|
||||
return [CPSet setWithObjects:@"selectionIndexes"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingSelectionIndexes
|
||||
{
|
||||
// When the arranged objects change, selection preservation may cause the indexes
|
||||
// to change.
|
||||
return [CPSet setWithObjects:"arrangedObjects"];
|
||||
return [CPSet setWithObjects:@"arrangedObjects"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingSelectedObjects
|
||||
{
|
||||
// Don't need to depend on arrangedObjects here because selectionIndexes already does.
|
||||
return [CPSet setWithObjects:"selectionIndexes"];
|
||||
return [CPSet setWithObjects:@"selectionIndexes"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingCanRemove
|
||||
{
|
||||
return [CPSet setWithObjects:"selectionIndexes"];
|
||||
return [CPSet setWithObjects:@"selectionIndexes"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingCanSelectNext
|
||||
{
|
||||
return [CPSet setWithObjects:"selectionIndexes"];
|
||||
return [CPSet setWithObjects:@"selectionIndexes"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingCanSelectPrevious
|
||||
{
|
||||
return [CPSet setWithObjects:"selectionIndexes"];
|
||||
return [CPSet setWithObjects:@"selectionIndexes"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,686 @@
|
||||
/* CPDatePicker.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Alexandre Wilhelm
|
||||
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
|
||||
*
|
||||
* 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 "CPControl.j"
|
||||
@import "CPFont.j"
|
||||
@import "CPTextField.j"
|
||||
@import "_CPDatePickerTextField.j"
|
||||
@import "_CPDatePickerCalendar.j"
|
||||
|
||||
@import <Foundation/CPArray.j>
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPDate.j>
|
||||
@import <Foundation/CPDateFormatter.j>
|
||||
@import <Foundation/CPLocale.j>
|
||||
|
||||
@class CPStepper
|
||||
@class CPApp
|
||||
|
||||
@global CPLocaleLanguageCode
|
||||
@global CPDateFormatterShortStyle
|
||||
|
||||
var CPDatePicker_validateProposedDateValue_timeInterval = 1 << 1;
|
||||
|
||||
CPSingleDateMode = 0;
|
||||
CPRangeDateMode = 1;
|
||||
|
||||
CPTextFieldAndStepperDatePickerStyle = 0;
|
||||
CPClockAndCalendarDatePickerStyle = 1;
|
||||
CPTextFieldDatePickerStyle = 2;
|
||||
|
||||
CPHourMinuteDatePickerElementFlag = 0x000c;
|
||||
CPHourMinuteSecondDatePickerElementFlag = 0x000e;
|
||||
CPTimeZoneDatePickerElementFlag = 0x0010;
|
||||
CPYearMonthDatePickerElementFlag = 0x00c0;
|
||||
CPYearMonthDayDatePickerElementFlag = 0x00e0;
|
||||
CPEraDatePickerElementFlag = 0x0100;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
This control displays a datepicker in a Cappuccino application
|
||||
*/
|
||||
@implementation CPDatePicker : CPControl
|
||||
{
|
||||
BOOL _isBordered @accessors(getter=isBordered, setter=setBordered:);
|
||||
BOOL _isBezeled @accessors(getter=isBezeled, setter=setBezeled:);
|
||||
BOOL _drawsBackground @accessors(property=drawsBackground);
|
||||
CPDate _dateValue @accessors(property=dateValue);
|
||||
CPDate _minDate @accessors(property=minDate);
|
||||
CPDate _maxDate @accessors(property=maxDate);
|
||||
CPFont _textFont @accessors(property=textFont);
|
||||
CPLocale _locale @accessors(property=locale);
|
||||
//CPCalendar _calendar @accessors(property=calendar);
|
||||
//CPTimeZone _timeZone @accessors(property=timeZone);
|
||||
CPDateFormatter _formatter @accessors(property=formatter);
|
||||
id _delegate @accessors(property=delegate);
|
||||
unsigned _datePickerElements @accessors(property=datePickerElements);
|
||||
CPInteger _datePickerMode @accessors(property=datePickerMode);
|
||||
CPInteger _datePickerStyle @accessors(property=datePickerStyle);
|
||||
CPInteger _timeInterval @accessors(property=timeInterval);
|
||||
|
||||
_CPDatePickerTextField _datePickerTextfield;
|
||||
_CPDatePickerCalendar _datePickerCalendar;
|
||||
unsigned _implementedCDatePickerDelegateMethods;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Theme methods
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"datePicker";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"bezel-color": [CPColor clearColor],
|
||||
@"border-width" : 1.0,
|
||||
@"border-color": [CPColor clearColor],
|
||||
@"content-inset": CGInsetMakeZero(),
|
||||
@"bezel-inset": CGInsetMakeZero(),
|
||||
@"datepicker-textfield-bezel-color": [CPColor clearColor],
|
||||
@"min-size-datepicker-textfield": CGSizeMakeZero(),
|
||||
@"content-inset-datepicker-textfield": CGInsetMakeZero(),
|
||||
@"content-inset-datepicker-textfield-separator": CGInsetMakeZero(),
|
||||
@"separator-content-inset": CGInsetMakeZero(),
|
||||
@"date-hour-margin": 5.0,
|
||||
@"stepper-margin": 5.0,
|
||||
@"bezel-color-calendar": [CPColor clearColor],
|
||||
@"title-text-color": [CPColor blackColor],
|
||||
@"title-text-shadow-color": [CPColor clearColor],
|
||||
@"title-text-shadow-offset": CGSizeMakeZero(),
|
||||
@"title-font": [CPNull null],
|
||||
@"weekday-text-color": [CPColor blackColor],
|
||||
@"weekday-text-shadow-color": [CPColor clearColor],
|
||||
@"weekday-text-shadow-offset": CGSizeMakeZero(),
|
||||
@"weekday-font": [CPNull null],
|
||||
@"arrow-image-left": [CPNull null],
|
||||
@"arrow-image-right": [CPNull null],
|
||||
@"arrow-image-left-highlighted": [CPNull null],
|
||||
@"arrow-image-right-highlighted": [CPNull null],
|
||||
@"arrow-inset": CGInsetMakeZero(),
|
||||
@"circle-image": [CPNull null],
|
||||
@"circle-image-highlighted": [CPNull null],
|
||||
@"tile-text-color": [CPColor blackColor],
|
||||
@"tile-text-shadow-color": [CPColor clearColor],
|
||||
@"tile-text-shadow-offset": CGSizeMakeZero(),
|
||||
@"tile-font": [CPNull null],
|
||||
@"size-tile": CGSizeMakeZero(),
|
||||
@"size-calendar": CGSizeMakeZero(),
|
||||
@"size-header": CGSizeMakeZero(),
|
||||
@"min-size-calendar": CGSizeMakeZero(),
|
||||
@"max-size-calendar": CGSizeMakeZero(),
|
||||
@"bezel-color-clock": [CPColor clearColor],
|
||||
@"clock-text-color": [CPColor blackColor],
|
||||
@"clock-text-shadow-color": [CPColor clearColor],
|
||||
@"clock-text-shadow-offset": CGSizeMakeZero(),
|
||||
@"clock-font": [CPNull null],
|
||||
@"second-hand-color": [CPColor clearColor],
|
||||
@"hour-hand-color": [CPColor clearColor],
|
||||
@"middle-hand-color": [CPColor clearColor],
|
||||
@"minute-hand-color": [CPColor clearColor],
|
||||
@"size-clock": CGSizeMakeZero(),
|
||||
@"second-hand-size": CGSizeMakeZero(),
|
||||
@"hour-hand-size": CGSizeMakeZero(),
|
||||
@"middle-hand-size": CGSizeMakeZero(),
|
||||
@"minute-hand-size": CGSizeMakeZero(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Binding methods
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)theBinding
|
||||
{
|
||||
if (theBinding == CPValueBinding || theBinding == CPMinValueBinding || theBinding == CPMaxValueBinding)
|
||||
return [_CPDatePickerValueBinder class];
|
||||
|
||||
return [super _binderClassForBinding:theBinding];
|
||||
}
|
||||
|
||||
- (id)_replacementKeyPathForBinding:(CPString)aBinding
|
||||
{
|
||||
if (aBinding == CPValueBinding)
|
||||
return @"dateValue";
|
||||
|
||||
if (aBinding == CPMinValueBinding)
|
||||
return @"minDate";
|
||||
|
||||
if (aBinding == CPMaxValueBinding)
|
||||
return @"maxDate";
|
||||
|
||||
return [super _replacementKeyPathForBinding:aBinding];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame])
|
||||
{
|
||||
_drawsBackground = YES;
|
||||
_datePickerStyle = CPTextFieldAndStepperDatePickerStyle;
|
||||
_datePickerMode = CPSingleDateMode;
|
||||
_datePickerElements = CPYearMonthDayDatePickerElementFlag | CPHourMinuteSecondDatePickerElementFlag;
|
||||
_timeInterval = 0;
|
||||
_implementedCDatePickerDelegateMethods = 0;
|
||||
_formatter = [[CPDateFormatter alloc] init];
|
||||
|
||||
[self setObjectValue:[CPDate date]];
|
||||
_minDate = [CPDate distantPast];
|
||||
_maxDate = [CPDate distantFuture];
|
||||
|
||||
[self setBezeled:YES];
|
||||
[self setBordered:YES];
|
||||
|
||||
[self _init];
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
- (void)_init
|
||||
{
|
||||
if (!_locale)
|
||||
_locale = [CPLocale currentLocale];
|
||||
|
||||
_datePickerTextfield = [[_CPDatePickerTextField alloc] initWithFrame:[self bounds] withDatePicker:self];
|
||||
|
||||
[_datePickerTextfield setDateValue:_dateValue];
|
||||
[self addSubview:_datePickerTextfield];
|
||||
|
||||
_datePickerCalendar = [[_CPDatePickerCalendar alloc] initWithFrame:[self bounds] withDatePicker:self];
|
||||
[_datePickerCalendar setDateValue:_dateValue];
|
||||
[_datePickerCalendar setHidden:YES];
|
||||
[self addSubview:_datePickerCalendar];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate methods
|
||||
|
||||
/*! Set the delegate of the datePicker
|
||||
@param aDelegate delegate of the datePicker
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
_delegate = aDelegate;
|
||||
_implementedCDatePickerDelegateMethods = 0;
|
||||
|
||||
// Look if the delegate implements or not the delegate methods
|
||||
if ([_delegate respondsToSelector:@selector(datePicker:validateProposedDateValue:timeInterval:)])
|
||||
_implementedCDatePickerDelegateMethods |= CPDatePicker_validateProposedDateValue_timeInterval;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Layout method
|
||||
|
||||
/*! Layout the subviews
|
||||
*/
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
{
|
||||
[_datePickerTextfield setHidden:NO];
|
||||
[_datePickerCalendar setHidden:YES];
|
||||
[_datePickerTextfield setNeedsLayout];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_datePickerCalendar setHidden:NO];
|
||||
[_datePickerTextfield setHidden:YES];
|
||||
[_datePickerCalendar setNeedsLayout];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Setter
|
||||
|
||||
/*! Return the objectValue of the datePicker. The objectValue is made with the current formatter of the datePicker
|
||||
*/
|
||||
- (void)objectValue
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// return [_formatter stringFromDate:_dateValue];
|
||||
// }
|
||||
// catch(e)
|
||||
// {
|
||||
return _dateValue
|
||||
// }
|
||||
}
|
||||
|
||||
/*! Set the objectValue ofhe datePier. It has to be a CPDate
|
||||
@param aDateValue the dateValue
|
||||
*/
|
||||
- (void)setObjectValue:(CPDate)aValue
|
||||
{
|
||||
[self setDateValue:aValue];
|
||||
}
|
||||
|
||||
/* Set the dateValue of the datePicker
|
||||
@param aDateValue the dateValue
|
||||
*/
|
||||
- (void)setDateValue:(CPDate)aDateValue
|
||||
{
|
||||
if (aDateValue == nil)
|
||||
return;
|
||||
|
||||
[self _setDateValue:aDateValue timeInterval:_timeInterval];
|
||||
}
|
||||
|
||||
/*! Set the dateValue and the timeInterval. This method checks the min and max date of the datePicker also. It will call the delegate if possible.
|
||||
@param aDateValue the dateValue
|
||||
@param aTimeInterval the timeInterval
|
||||
*/
|
||||
- (void)_setDateValue:(CPDate)aDateValue timeInterval:(CPTimeInterval)aTimeInterval
|
||||
{
|
||||
if (_minDate)
|
||||
aDateValue = new Date (MAX(aDateValue, _minDate));
|
||||
|
||||
if (_maxDate)
|
||||
aDateValue = new Date (MIN(aDateValue, _maxDate));
|
||||
|
||||
aTimeInterval = MAX(MIN(aTimeInterval, [_maxDate timeIntervalSinceDate:aDateValue]), [_minDate timeIntervalSinceDate:aDateValue]);
|
||||
|
||||
if ([aDateValue isEqualToDate:_dateValue] && aTimeInterval == _timeInterval)
|
||||
return;
|
||||
|
||||
if (_implementedCDatePickerDelegateMethods & CPDatePicker_validateProposedDateValue_timeInterval)
|
||||
{
|
||||
// constrain timeInterval also
|
||||
var aStartDateRef = function(x){if (typeof x == 'undefined') return aDateValue; aDateValue = x;}
|
||||
var aTimeIntervalRef = function(x){if (typeof x == 'undefined') return aTimeInterval; aTimeInterval = x;}
|
||||
|
||||
[_delegate datePicker:self validateProposedDateValue:aStartDateRef timeInterval:aTimeIntervalRef];
|
||||
}
|
||||
|
||||
[self willChangeValueForKey:@"objectValue"];
|
||||
[self willChangeValueForKey:@"dateValue"];
|
||||
_dateValue = aDateValue;
|
||||
[super setObjectValue:_dateValue];
|
||||
[self didChangeValueForKey:@"dateValue"];
|
||||
[self didChangeValueForKey:@"objectValue"];
|
||||
|
||||
[self willChangeValueForKey:@"timeInterval"];
|
||||
_timeInterval = (_datePickerMode == CPSingleDateMode)? 0 : aTimeInterval;
|
||||
[self didChangeValueForKey:@"timeInterval"];
|
||||
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield setDateValue:_dateValue];
|
||||
else
|
||||
[_datePickerCalendar setDateValue:_dateValue];
|
||||
}
|
||||
|
||||
/*! Set the minDate of the datePicker
|
||||
@param aMinDate the minDate
|
||||
*/
|
||||
- (void)setMinDate:(CPDate)aMinDate
|
||||
{
|
||||
[self willChangeValueForKey:@"minDate"];
|
||||
_minDate = aMinDate;
|
||||
[self didChangeValueForKey:@"minDate"];
|
||||
|
||||
[self _setDateValue:_dateValue timeInterval:_timeInterval];
|
||||
}
|
||||
|
||||
/*! Set the maxDate of the datePicker
|
||||
@param aMaxDate the maxDate
|
||||
*/
|
||||
- (void)setMaxDate:(CPDate)aMaxDate
|
||||
{
|
||||
[self willChangeValueForKey:@"maxDate"];
|
||||
_maxDate = aMaxDate;
|
||||
[self didChangeValueForKey:@"maxDate"];
|
||||
|
||||
[self _setDateValue:_dateValue timeInterval:_timeInterval];
|
||||
}
|
||||
|
||||
/*! Set the syle of the datePicker
|
||||
@param aDatePickerStyle the datePicker style
|
||||
*/
|
||||
- (void)setDatePickerStyle:(CPDate)aDatePickerStyle
|
||||
{
|
||||
_datePickerStyle = aDatePickerStyle;
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
/*! Set the elements of the datePicker
|
||||
@param aDatePickerElements the datePicker elements
|
||||
*/
|
||||
- (void)setDatePickerElements:(CPDate)aDatePickerElements
|
||||
{
|
||||
_datePickerElements = aDatePickerElements;
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
/*! Set the mode of the datePicker
|
||||
@param aDatePickerMode the datePicker mode
|
||||
*/
|
||||
- (void)setDatePickerMode:(CPDate)aDatePickerMode
|
||||
{
|
||||
_datePickerMode = aDatePickerMode;
|
||||
|
||||
if (_datePickerMode == CPSingleDateMode)
|
||||
[self _setDateValue:[self dateValue] timeInterval:0];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
/*! Set the timeInterval of the datePicker
|
||||
@param aTimeInterval the timeInterval of the datePicker
|
||||
*/
|
||||
- (void)setTimeInterval:(CPInteger)aTimeInterval
|
||||
{
|
||||
if (_datePickerMode == CPSingleDateMode)
|
||||
return;
|
||||
|
||||
[self _setDateValue:[self dateValue] timeInterval:aTimeInterval];
|
||||
}
|
||||
|
||||
/*! Set the locale of the datePicker. This update laso the locale of the formatter.
|
||||
@param aLocale the locale
|
||||
*/
|
||||
- (void)setLocale:(CPLocale)aLocale
|
||||
{
|
||||
_locale = aLocale;
|
||||
|
||||
if (_formatter)
|
||||
{
|
||||
[self willChangeValueForKey:@"locale"];
|
||||
[_formatter setLocale:_locale];
|
||||
[self didChangeValueForKey:@"locale"];
|
||||
}
|
||||
|
||||
// This will update the textFields (usefull when changing with a date with pm and am)
|
||||
[_datePickerTextfield setDateValue:_dateValue];
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets whether the datepicker will have a bezeled border.
|
||||
@param shouldBeBezeled \c YES means the datepicker will draw a bezeled border
|
||||
*/
|
||||
- (void)setBezeled:(BOOL)shouldBeBezeled
|
||||
{
|
||||
_isBezeled = shouldBeBezeled;
|
||||
|
||||
if (shouldBeBezeled)
|
||||
[self setThemeState:CPThemeStateBezeled];
|
||||
else
|
||||
[self unsetThemeState:CPThemeStateBezeled];
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets whether the datepicker will have a border drawn. (actually it does nothing)
|
||||
@param shouldBeBordered \c YES makes the datepicker draw a border
|
||||
*/
|
||||
- (void)setBordered:(BOOL)shouldBeBordered
|
||||
{
|
||||
_isBordered = shouldBeBordered;
|
||||
|
||||
if (shouldBeBordered)
|
||||
[self setThemeState:CPThemeStateBordered];
|
||||
else
|
||||
[self unsetThemeState:CPThemeStateBordered];
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the font of the control.
|
||||
@param aFont
|
||||
*/
|
||||
- (void)setTextFont:(CPFont)aFont
|
||||
{
|
||||
[self setFont:aFont];
|
||||
}
|
||||
|
||||
/*! Sets the enabled status of the control. Controls that are not enabled can not be used by the user and obtain the CPThemeStateDisabled theme state.
|
||||
@param a boolean. YES if the control should be enabled, otherwise NO.
|
||||
*/
|
||||
- (void)setEnabled:(BOOL)aBoolean
|
||||
{
|
||||
[super setEnabled:aBoolean];
|
||||
|
||||
[_datePickerTextfield setEnabled:aBoolean];
|
||||
[_datePickerCalendar setEnabled:aBoolean];
|
||||
}
|
||||
|
||||
/*! Set the background color of the datePicker
|
||||
@param aColor
|
||||
*/
|
||||
- (void)setBackgroundColor:(CPColor)aColor
|
||||
{
|
||||
_backgroundColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
/*! Set the boolean drawsBackgroundColor
|
||||
@param aBoolean
|
||||
*/
|
||||
- (void)setDrawsBackground:(BOOL)aBoolean
|
||||
{
|
||||
[self willChangeValueForKey:@"drawsBackground"];
|
||||
_drawsBackground = aBoolean;
|
||||
[self didChangeValueForKey:@"drawsBackground"];
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark First responder methods
|
||||
|
||||
/*! Return YES if style is set to CPTextFieldAndStepperDatePickerStyle or CPTextFieldDatePickerStyle
|
||||
*/
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield _selecteTextFieldWithFlags:[[CPApp currentEvent] modifierFlags]];
|
||||
else
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*! Return YES
|
||||
*/
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*! Return YES
|
||||
*/
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield resignFirstResponder];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark getter
|
||||
|
||||
/*!
|
||||
Returns \c YES if the textfield is bezeled.
|
||||
*/
|
||||
- (BOOL)isBezeled
|
||||
{
|
||||
return [self hasThemeState:CPThemeStateBezeled];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c YES if the textfield has a border.
|
||||
*/
|
||||
- (BOOL)isBordered
|
||||
{
|
||||
return [self hasThemeState:CPThemeStateBordered];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the font of the control.
|
||||
*/
|
||||
- (CPFont)textFont
|
||||
{
|
||||
return [self font];
|
||||
}
|
||||
|
||||
/*! Check if we are in the american format or not. Depending on the locale
|
||||
*/
|
||||
- (BOOL)_isAmericanFormat
|
||||
{
|
||||
return [[_locale objectForKey:CPLocaleCountryCode] isEqualToString:@"US"];
|
||||
}
|
||||
|
||||
/*! Check if we are in the english format or not. Depending on the locale
|
||||
*/
|
||||
- (BOOL)_isEnglishFormat
|
||||
{
|
||||
return [[_locale objectForKey:CPLocaleLanguageCode] isEqualToString:@"en"];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Key event
|
||||
|
||||
/*! Key down event
|
||||
@param anEvent
|
||||
*/
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
{
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield keyDown:anEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPDatePickerModeKey = @"CPDatePickerModeKey",
|
||||
CPIntervalKey = @"CPIntervalKey",
|
||||
CPMinDateKey = @"CPMinDateKey",
|
||||
CPMaxDateKey = @"CPMaxDateKey",
|
||||
CPBackgroundColorKey = @"CPBackgroundColorKey",
|
||||
CPDrawsBackgroundKey = @"CPDrawsBackgroundKey",
|
||||
CPTextFontKey = @"CPTextFontKey",
|
||||
CPDatePickerElementsKey = @"CPDatePickerElementsKey",
|
||||
CPDatePickerStyleKey = @"CPDatePickerStyleKey",
|
||||
CPLocaleKey = @"CPLocaleKey",
|
||||
CPFormatterKey = @"CPFormatterKey",
|
||||
CPBorderedKey = @"CPBorderedKey",
|
||||
CPDateValueKey = @"CPDateValueKey";
|
||||
|
||||
@implementation CPDatePicker (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super initWithCoder:aCoder];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_textFont = [aCoder decodeObjectForKey:CPTextFontKey];
|
||||
_minDate = [aCoder decodeObjectForKey:CPMinDateKey] || [CPDate distantPast];
|
||||
_maxDate = [aCoder decodeObjectForKey:CPMaxDateKey] || [CPDate distantFuture];
|
||||
_timeInterval = [aCoder decodeDoubleForKey:CPIntervalKey];
|
||||
_datePickerMode = [aCoder decodeIntForKey:CPDatePickerModeKey];
|
||||
_datePickerElements = [aCoder decodeIntForKey:CPDatePickerElementsKey];
|
||||
_datePickerStyle = [aCoder decodeIntForKey:CPDatePickerStyleKey];
|
||||
_locale = [aCoder decodeObjectForKey:CPLocaleKey];
|
||||
_formatter = [aCoder decodeObjectForKey:CPFormatterKey];
|
||||
_dateValue = [aCoder decodeObjectForKey:CPDateValueKey];
|
||||
_backgroundColor = [aCoder decodeObjectForKey:CPBackgroundColorKey];
|
||||
_drawsBackground = [aCoder decodeBoolForKey:CPDrawsBackgroundKey];
|
||||
_isBordered = [aCoder decodeBoolForKey:CPBorderedKey];
|
||||
[self _init];
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeDouble:_timeInterval forKey:CPIntervalKey];
|
||||
[aCoder encodeInt:_datePickerMode forKey:CPDatePickerModeKey];
|
||||
[aCoder encodeInt:_datePickerStyle forKey:CPDatePickerStyleKey];
|
||||
[aCoder encodeInt:_datePickerElements forKey:CPDatePickerElementsKey];
|
||||
[aCoder encodeObject:_minDate forKey:CPMinDateKey];
|
||||
[aCoder encodeObject:_maxDate forKey:CPMaxDateKey]
|
||||
[aCoder encodeObject:_dateValue forKey:CPDateValueKey];;
|
||||
[aCoder encodeObject:_textFont forKey:CPTextFontKey];
|
||||
[aCoder encodeObject:_locale forKey:CPLocaleKey];
|
||||
[aCoder encodeObject:_formatter forKey:CPFormatterKey];
|
||||
[aCoder encodeObject:_backgroundColor forKey:CPBackgroundColorKey];
|
||||
[aCoder encodeObject:_drawsBackground forKey:CPDrawsBackgroundKey];
|
||||
[aCoder encodeObject:_isBordered forKey:CPBorderedKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPDatePickerValueBinder : CPBinder
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPDate (CPDatePickerAdditions)
|
||||
|
||||
- (int)_daysInMonth
|
||||
{
|
||||
return 32 - new Date(self.getFullYear(), self.getMonth(), 32).getDate();
|
||||
}
|
||||
|
||||
- (void)_resetToMidnight
|
||||
{
|
||||
self.setHours(0);
|
||||
self.setMinutes(0);
|
||||
self.setSeconds(0);
|
||||
self.setMilliseconds(0);
|
||||
}
|
||||
|
||||
- (void)_resetToLastSeconds
|
||||
{
|
||||
self.setHours(23);
|
||||
self.setMinutes(59);
|
||||
self.setSeconds(59);
|
||||
self.setMilliseconds(99);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,284 @@
|
||||
/* _CPDatePickerClock.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Alexandre Wilhelm
|
||||
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
|
||||
*
|
||||
* 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 "CPView.j"
|
||||
@import "CPTextField.j"
|
||||
@import "CPImageView.j"
|
||||
@import "CALayer.j"
|
||||
|
||||
@class CPDatePicker
|
||||
|
||||
@global CPHourMinuteSecondDatePickerElementFlag
|
||||
|
||||
@implementation _CPDatePickerClock : CPView
|
||||
{
|
||||
BOOL _isEnabled;
|
||||
CALayer _rootLayer;
|
||||
CALayer _hourHandLayer;
|
||||
CALayer _minuteHandLayer;
|
||||
CALayer _secondHandLayer;
|
||||
CALayer _middleHandLayer;
|
||||
CPDatePicker _datePicker;
|
||||
CPTextField _PMAMTextField;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
|
||||
/*! Init a new _CPDatePickerClock
|
||||
@param aFrame
|
||||
@param aDatePicker
|
||||
@return a new instance of _CPDatePickerClock
|
||||
*/
|
||||
- (id)initWithFrame:(CGRect)aFrame datePicker:(CPDatePicker)aDatePicker
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame])
|
||||
{
|
||||
_datePicker = aDatePicker;
|
||||
|
||||
_PMAMTextField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[_PMAMTextField setValue:[_datePicker valueForThemeAttribute:@"clock-font" inState:CPThemeStateNormal] forThemeAttribute:@"font" inState:CPThemeStateNormal];
|
||||
[_PMAMTextField setValue:[_datePicker valueForThemeAttribute:@"clock-text-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
|
||||
[_PMAMTextField setValue:[_datePicker valueForThemeAttribute:@"clock-text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
|
||||
[_PMAMTextField setValue:[_datePicker valueForThemeAttribute:@"clock-text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
|
||||
|
||||
[_PMAMTextField setValue:[_datePicker valueForThemeAttribute:@"clock-font" inState:CPThemeStateDisabled] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
|
||||
[_PMAMTextField setValue:[_datePicker valueForThemeAttribute:@"clock-text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
|
||||
[_PMAMTextField setValue:[_datePicker valueForThemeAttribute:@"clock-text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
|
||||
[_PMAMTextField setValue:[_datePicker valueForThemeAttribute:@"clock-text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
|
||||
|
||||
[self addSubview:_PMAMTextField];
|
||||
|
||||
var middleHandSize = [_datePicker valueForThemeAttribute:@"middle-hand-size"],
|
||||
minuteHandSize = [_datePicker valueForThemeAttribute:@"minute-hand-size"],
|
||||
hourHandSize = [_datePicker valueForThemeAttribute:@"hour-hand-size"],
|
||||
secondHandSize = [_datePicker valueForThemeAttribute:@"second-hand-size"];
|
||||
|
||||
// We use layer to make the rotation possible
|
||||
_hourHandLayer = [[HandLayer alloc] initWithSize:hourHandSize];
|
||||
[_hourHandLayer setBounds:CGRectMake(0, 0, aFrame.size.width, aFrame.size.height)];
|
||||
[_hourHandLayer setAnchorPoint:CGPointMakeZero()];
|
||||
[_hourHandLayer setPosition:CGPointMake(0.0, 0.0)];
|
||||
|
||||
_minuteHandLayer = [[HandLayer alloc] initWithSize:minuteHandSize];
|
||||
[_minuteHandLayer setBounds:CGRectMake(0, 0, aFrame.size.width, aFrame.size.height)];
|
||||
[_minuteHandLayer setAnchorPoint:CGPointMakeZero()];
|
||||
[_minuteHandLayer setPosition:CGPointMake(0.0, 0.0)];
|
||||
|
||||
_secondHandLayer = [[HandLayer alloc] initWithSize:secondHandSize];
|
||||
[_secondHandLayer setBounds:CGRectMake(0, 0, aFrame.size.width, aFrame.size.height)];
|
||||
[_secondHandLayer setAnchorPoint:CGPointMakeZero()];
|
||||
[_secondHandLayer setPosition:CGPointMake(0.0, 0.0)];
|
||||
|
||||
_middleHandLayer = [[HandLayer alloc] initWithSize:middleHandSize];
|
||||
[_middleHandLayer setBounds:CGRectMake(0, 0, aFrame.size.width, aFrame.size.height)];
|
||||
[_middleHandLayer setAnchorPoint:CGPointMakeZero()];
|
||||
[_middleHandLayer setPosition:CGPointMake(0.0, 0.0)];
|
||||
|
||||
_rootLayer = [CALayer layer];
|
||||
[self setWantsLayer:YES];
|
||||
[self setLayer:_rootLayer];
|
||||
|
||||
[_hourHandLayer setNeedsDisplay];
|
||||
[_middleHandLayer setNeedsDisplay];
|
||||
[_secondHandLayer setNeedsDisplay];
|
||||
[_minuteHandLayer setNeedsDisplay];
|
||||
|
||||
[_rootLayer addSublayer:_hourHandLayer];
|
||||
[_rootLayer addSublayer:_minuteHandLayer];
|
||||
[_rootLayer addSublayer:_secondHandLayer];
|
||||
[_rootLayer addSublayer:_middleHandLayer];
|
||||
|
||||
[_rootLayer setNeedsDisplay];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Layout methods
|
||||
|
||||
/*! Layout the subviews
|
||||
*/
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
var bounds = [self bounds];
|
||||
|
||||
[self setBackgroundColor:[_datePicker valueForThemeAttribute:@"bezel-color-clock" inState:[_datePicker themeState]]];
|
||||
[_middleHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"middle-hand-color" inState:[_datePicker themeState]]];
|
||||
[_hourHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"hour-hand-color" inState:[_datePicker themeState]]];
|
||||
[_minuteHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"minute-hand-color" inState:[_datePicker themeState]]];
|
||||
[_secondHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"second-hand-color" inState:[_datePicker themeState]]];
|
||||
|
||||
if ([_datePicker _isEnglishFormat])
|
||||
{
|
||||
if ([_datePicker dateValue].getHours() > 11)
|
||||
[_PMAMTextField setStringValue:@"PM"]
|
||||
else
|
||||
[_PMAMTextField setStringValue:@"AM"];
|
||||
|
||||
[_PMAMTextField sizeToFit];
|
||||
[_PMAMTextField setFrameOrigin:CGPointMake(bounds.size.width / 2 - [_PMAMTextField frameSize].width / 2, bounds.size.height / 2 + 15)];
|
||||
[_PMAMTextField setHidden:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_PMAMTextField setHidden:YES];
|
||||
}
|
||||
|
||||
[_hourHandLayer setRotationRadians:[self _hourPositionRadianForDate:[_datePicker dateValue]]];
|
||||
[_minuteHandLayer setRotationRadians:[self _minutePositionRadianForDate:[_datePicker dateValue]]];
|
||||
[_secondHandLayer setRotationRadians:[self _secondPositionRadianForDate:[_datePicker dateValue]]];
|
||||
|
||||
// Check if we have to display the hand second
|
||||
if (([_datePicker datePickerElements] & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)
|
||||
[_secondHandLayer setHidden:NO];
|
||||
else
|
||||
[_secondHandLayer setHidden:YES];
|
||||
|
||||
[_rootLayer setNeedsDisplay];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Getter Setter methods
|
||||
|
||||
/*! Return the radian position of the hour
|
||||
*/
|
||||
- (float)_hourPositionRadianForDate:(CPDate)aDate
|
||||
{
|
||||
var hours = aDate.getHours() + aDate.getMinutes() / 60;
|
||||
|
||||
return (360 * hours / 12) * (Math.PI / 180)
|
||||
}
|
||||
|
||||
/*! Return the radian position of the second
|
||||
*/
|
||||
- (float)_secondPositionRadianForDate:(CPDate)aDate
|
||||
{
|
||||
return (360 * aDate.getSeconds() / 60) * (Math.PI / 180)
|
||||
}
|
||||
|
||||
/*! Return the radian position of the minute
|
||||
*/
|
||||
- (float)_minutePositionRadianForDate:(CPDate)aDate
|
||||
{
|
||||
var minutes = aDate.getMinutes() + aDate.getSeconds() / 60;
|
||||
|
||||
return (360 * minutes / 60) * (Math.PI / 180)
|
||||
}
|
||||
|
||||
/*! Set enabled
|
||||
@param aBoolean
|
||||
*/
|
||||
- (void)setEnabled:(BOOL)aBoolean
|
||||
{
|
||||
_isEnabled = aBoolean;
|
||||
[_PMAMTextField setEnabled:aBoolean];
|
||||
[_hourHandLayer setEnabled:aBoolean];
|
||||
[_middleHandLayer setEnabled:aBoolean];
|
||||
[_secondHandLayer setEnabled:aBoolean];
|
||||
[_minuteHandLayer setEnabled:aBoolean];
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation HandLayer : CALayer
|
||||
{
|
||||
BOOL _isEnabled @accessors(setter=setEnabled:, getter=isEnabled);
|
||||
|
||||
CALayer _imageLayer;
|
||||
float _rotationRadians;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
|
||||
/*! Init a new hand layer with an image. The image will be draw in a ImageLayer
|
||||
@param anImage
|
||||
@return a new instance of handLayer
|
||||
*/
|
||||
- (id)initWithSize:(CGSize)aSize
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_isEnabled = YES;
|
||||
_imageLayer = [CALayer layer];
|
||||
_rotationRadians = 0;
|
||||
|
||||
[_imageLayer setDelegate:self];
|
||||
[_imageLayer setBounds:CGRectMake(0.0, 0.0, aSize.width, aSize.height)];
|
||||
|
||||
[self addSublayer:_imageLayer];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Setter Getter methods
|
||||
|
||||
/*! Set the bounds of the layer. The imageLayer will be at the center of this bounds
|
||||
@param aRect
|
||||
*/
|
||||
- (void)setBounds:(CGRect)aRect
|
||||
{
|
||||
[super setBounds:aRect];
|
||||
|
||||
[_imageLayer setPosition:CGPointMake(CGRectGetMidX(aRect), CGRectGetMidY(aRect))];
|
||||
}
|
||||
|
||||
/*! Set the rotation of the imageLayer
|
||||
@param radians
|
||||
*/
|
||||
- (void)setRotationRadians:(float)radians
|
||||
{
|
||||
if (_rotationRadians == radians)
|
||||
return;
|
||||
|
||||
_rotationRadians = radians;
|
||||
|
||||
[_imageLayer setAffineTransform:CGAffineTransformScale(
|
||||
CGAffineTransformMakeRotation(_rotationRadians),
|
||||
1.0, 1.0)];
|
||||
}
|
||||
|
||||
- (void)setBackgroundHandColor:(CPColor)aColor
|
||||
{
|
||||
[_imageLayer setBackgroundColor:aColor];
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)aBoolean
|
||||
{
|
||||
_isEnabled = aBoolean;
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -257,7 +257,11 @@ var CPBindingOperationAnd = 0,
|
||||
if (valueTransformer)
|
||||
aValue = [valueTransformer transformedValue:aValue];
|
||||
|
||||
if (aValue === undefined || aValue === nil || aValue === [CPNull null])
|
||||
// If the value is nil AND the source doesn't respond to setPlaceholderString: then
|
||||
// we set the value to the placeholder. Otherwise, we do not want to short cut the process
|
||||
// of setting the placeholder that is based on the fact that the value is nil.
|
||||
if ((aValue === undefined || aValue === nil || aValue === [CPNull null])
|
||||
&& ![_source respondsToSelector:@selector(setPlaceholderString:)])
|
||||
aValue = [options objectForKey:CPNullPlaceholderBindingOption] || nil;
|
||||
|
||||
return aValue;
|
||||
|
||||
@@ -851,6 +851,8 @@ var _CPMenuBarVisible = NO,
|
||||
var theWindow = [aView window],
|
||||
menuWindow = [_CPMenuWindow menuWindowWithMenu:aMenu font:aFont];
|
||||
|
||||
[_CPMenuWindow poolMenuWindow:menuWindow];
|
||||
|
||||
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];
|
||||
|
||||
var constraintRect = [CPMenu _constraintRectForView:aView],
|
||||
|
||||
@@ -143,6 +143,7 @@
|
||||
_textColor = aColor;
|
||||
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setTextColor:) withObject:_textColor];
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setParentMenuTextColor:) withObject:_textColor];
|
||||
}
|
||||
|
||||
- (void)setTitleColor:(CPColor)aColor
|
||||
@@ -163,6 +164,7 @@
|
||||
_textShadowColor = aColor;
|
||||
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setTextShadowColor:) withObject:_textShadowColor];
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setParentMenuTextShadowColor:) withObject:_textShadowColor];
|
||||
}
|
||||
|
||||
- (void)setTitleShadowColor:(CPColor)aColor
|
||||
@@ -181,6 +183,8 @@
|
||||
return;
|
||||
|
||||
_highlightColor = aColor;
|
||||
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setParentMenuHighlightColor:) withObject:_highlightColor];
|
||||
}
|
||||
|
||||
- (void)setHighlightTextColor:(CPColor)aColor
|
||||
@@ -190,7 +194,7 @@
|
||||
|
||||
_highlightTextColor = aColor;
|
||||
|
||||
// [_menuItemViews makeObjectsPerformSelector:@selector(setActivateColor:) withObject:_highlightTextColor];
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setParentMenuHighlightTextColor:) withObject:_highlightTextColor];
|
||||
}
|
||||
|
||||
- (void)setHighlightTextShadowColor:(CPColor)aColor
|
||||
@@ -200,7 +204,7 @@
|
||||
|
||||
_highlightTextShadowColor = aColor;
|
||||
|
||||
// [_menuItemViews makeObjectsPerformSelector:@selector(setActivateShadowColor:) withObject:_highlightTextShadowColor];
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setParentMenuHighlightTextShadowColor:) withObject:_highlightTextShadowColor];
|
||||
}
|
||||
|
||||
- (void)setMenu:(CPMenu)aMenu
|
||||
|
||||
@@ -214,15 +214,6 @@ var STICKY_TIME_INTERVAL = 0.4,
|
||||
|
||||
[self _trackAgain];
|
||||
|
||||
if (_keyBuffer)
|
||||
{
|
||||
if (([anEvent timestamp] - _startTime) > (STICKY_TIME_INTERVAL + [activeMenu numberOfItems] / 2))
|
||||
[self selectNextItemBeginningWith:_keyBuffer inMenu:menu clearBuffer:YES];
|
||||
|
||||
if (type === CPPeriodic)
|
||||
return;
|
||||
}
|
||||
|
||||
// unhighlight when mouse is moved off the menu
|
||||
if (_lastGlobalLocation && CGRectContainsPoint([activeMenuContainer globalFrame], _lastGlobalLocation)
|
||||
&& !CGRectContainsPoint([activeMenuContainer globalFrame], globalLocation))
|
||||
@@ -563,6 +554,9 @@ var STICKY_TIME_INTERVAL = 0.4,
|
||||
}
|
||||
else if (!(modifierFlags & (CPCommandKeyMask | CPControlKeyMask)))
|
||||
{
|
||||
if (([anEvent timestamp] - _startTime) > STICKY_TIME_INTERVAL)
|
||||
_keyBuffer = nil;
|
||||
|
||||
if (!_keyBuffer)
|
||||
{
|
||||
_startTime = [anEvent timestamp];
|
||||
@@ -574,12 +568,12 @@ var STICKY_TIME_INTERVAL = 0.4,
|
||||
else
|
||||
_keyBuffer += character;
|
||||
|
||||
[self selectNextItemBeginningWith:_keyBuffer inMenu:menu clearBuffer:NO];
|
||||
_lastGlobalLocation = Nil;
|
||||
[self selectNextItemBeginningWith:_keyBuffer inMenu:menu];
|
||||
_lastGlobalLocation = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)selectNextItemBeginningWith:(CPString)characters inMenu:(CPMenu)menu clearBuffer:(BOOL)shouldClear
|
||||
- (void)selectNextItemBeginningWith:(CPString)characters inMenu:(CPMenu)menu
|
||||
{
|
||||
var iter = [[menu itemArray] objectEnumerator],
|
||||
obj;
|
||||
@@ -596,13 +590,7 @@ var STICKY_TIME_INTERVAL = 0.4,
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldClear)
|
||||
{
|
||||
[CPEvent stopPeriodicEvents];
|
||||
_keyBuffer = Nil;
|
||||
}
|
||||
else
|
||||
_startTime = [CPEvent currentTimestamp];
|
||||
_startTime = [CPEvent currentTimestamp];
|
||||
}
|
||||
|
||||
- (void)scrollToBeginningOfDocument:(CPMenu)menu
|
||||
|
||||
@@ -28,13 +28,18 @@
|
||||
|
||||
@implementation _CPMenuItemMenuBarView : CPView
|
||||
{
|
||||
CPColor _highlightColor @accessors(property=highlightColor);
|
||||
CPColor _textColor @accessors(property=textColor);
|
||||
CPColor _textShadowColor @accessors(property=textShadowColor);
|
||||
CPColor _highlightTextColor @accessors(property=highlightTextColor);
|
||||
CPColor _highlightTextShadowColor @accessors(property=highlightTextShadowColor);
|
||||
|
||||
CPMenuItem _menuItem @accessors(property=menuItem);
|
||||
|
||||
CPFont _font;
|
||||
CPColor _textColor;
|
||||
CPColor _textShadowColor;
|
||||
|
||||
BOOL _isDirty;
|
||||
BOOL _shouldHighlight;
|
||||
|
||||
_CPImageAndTextView _imageAndTextView;
|
||||
}
|
||||
@@ -47,8 +52,6 @@
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"menu-item-selection-color": [CPNull null],
|
||||
@"menu-item-text-shadow-color": [CPNull null],
|
||||
@"horizontal-margin": 9.0,
|
||||
@"submenu-indicator-margin": 3.0,
|
||||
@"vertical-margin": 4.0,
|
||||
@@ -81,12 +84,36 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPColor)setTextColor:(CPColor)aColor
|
||||
{
|
||||
_textColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPColor)setTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
_textShadowColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPColor)setHighlightTextColor:(CPColor)aColor
|
||||
{
|
||||
_highlightTextColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPColor)setHighlightTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
_highlightTextShadowColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPColor)textColor
|
||||
{
|
||||
if (![_menuItem isEnabled])
|
||||
return [CPColor lightGrayColor];
|
||||
|
||||
return _textColor || [CPColor colorWithCalibratedRed:70.0 / 255.0 green:69.0 / 255.0 blue:69.0 / 255.0 alpha:1.0];
|
||||
return _textColor || [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-color" forClass:_CPMenuView];
|
||||
}
|
||||
|
||||
- (CPColor)textShadowColor
|
||||
@@ -94,7 +121,28 @@
|
||||
if (![_menuItem isEnabled])
|
||||
return [CPColor clearColor];
|
||||
|
||||
return _textShadowColor || [CPColor colorWithWhite:1.0 alpha:0.8];
|
||||
return _textShadowColor || [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-shadow-color" forClass:_CPMenuView];
|
||||
}
|
||||
|
||||
- (CPColor)highlightTextColor
|
||||
{
|
||||
if (![_menuItem isEnabled])
|
||||
return [CPColor lightGrayColor];
|
||||
|
||||
return _highlightTextColor || [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-color" forClass:_CPMenuView];
|
||||
}
|
||||
|
||||
- (CPColor)highlightTextShadowColor
|
||||
{
|
||||
if (![_menuItem isEnabled])
|
||||
return [CPColor clearColor];
|
||||
|
||||
return _highlightTextShadowColor || [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-shadow-color" forClass:_CPMenuView];
|
||||
}
|
||||
|
||||
- (CPColor)highlightColor
|
||||
{
|
||||
return _highlightColor || [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-window-background-selected-color" forClass:_CPMenuView];
|
||||
}
|
||||
|
||||
- (void)update
|
||||
@@ -102,13 +150,11 @@
|
||||
var x = [self valueForThemeAttribute:@"horizontal-margin"],
|
||||
height = 0.0;
|
||||
|
||||
[_imageAndTextView setText:[_menuItem title]];
|
||||
[_imageAndTextView setFont:[_menuItem font] || [_CPMenuBarWindow font]];
|
||||
[_imageAndTextView setVerticalAlignment:CPCenterVerticalTextAlignment];
|
||||
[_imageAndTextView setImage:[_menuItem image]];
|
||||
[_imageAndTextView setText:[_menuItem title]];
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
[_imageAndTextView setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_imageAndTextView setImage:[_menuItem image]];
|
||||
[_imageAndTextView sizeToFit];
|
||||
|
||||
var imageAndTextViewFrame = [_imageAndTextView frame];
|
||||
@@ -123,6 +169,7 @@
|
||||
[self setAutoresizesSubviews:NO];
|
||||
[self setFrameSize:CGSizeMake(x + [self valueForThemeAttribute:@"horizontal-margin"], height)];
|
||||
[self setAutoresizesSubviews:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)highlight:(BOOL)shouldHighlight
|
||||
@@ -131,14 +178,20 @@
|
||||
if (![_menuItem isEnabled])
|
||||
shouldHighlight = NO;
|
||||
|
||||
if (shouldHighlight)
|
||||
_shouldHighlight = shouldHighlight;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if (_shouldHighlight)
|
||||
{
|
||||
if (![_menuItem _isMenuBarButton])
|
||||
[self setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-window-background-selected-color" forClass:_CPMenuView]];
|
||||
[self setBackgroundColor:[self highlightColor]];
|
||||
|
||||
[_imageAndTextView setImage:[_menuItem alternateImage] || [_menuItem image]];
|
||||
[_imageAndTextView setTextColor:[CPColor whiteColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self valueForThemeAttribute:@"menu-item-text-shadow-color"]];
|
||||
[_imageAndTextView setTextColor:[self highlightTextColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self highlightTextShadowColor]];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -220,6 +220,36 @@
|
||||
return [_menuItem isEnabled] ? (_textShadowColor ? _textShadowColor : [CPColor colorWithWhite:1.0 alpha:0.8]) : [CPColor colorWithWhite:0.8 alpha:0.8];
|
||||
}
|
||||
|
||||
- (void)setParentMenuHighlightColor:(CPColor)aColor
|
||||
{
|
||||
if ([_view respondsToSelector:@selector(setHighlightColor:)])
|
||||
[_view setHighlightColor:aColor];
|
||||
}
|
||||
|
||||
- (void)setParentMenuHighlightTextColor:(CPColor)aColor
|
||||
{
|
||||
if ([_view respondsToSelector:@selector(setHighlightTextColor:)])
|
||||
[_view setHighlightTextColor:aColor];
|
||||
}
|
||||
|
||||
- (void)setParentMenuHighlightTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
if ([_view respondsToSelector:@selector(setHighlightTextShadowColor:)])
|
||||
[_view setHighlightTextShadowColor:aColor];
|
||||
}
|
||||
|
||||
- (void)setParentMenuTextColor:(CPColor)aColor
|
||||
{
|
||||
if ([_view respondsToSelector:@selector(setTextColor:)])
|
||||
[_view setTextColor:aColor];
|
||||
}
|
||||
|
||||
- (void)setParentMenuTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
if ([_view respondsToSelector:@selector(setTextShadowColor:)])
|
||||
[_view setTextShadowColor:aColor];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuItemArrowView : CPView
|
||||
|
||||
@@ -63,7 +63,7 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
@outlet CPViewController _contentViewController @accessors(property=contentViewController);
|
||||
@outlet id _delegate @accessors(getter=delegate);
|
||||
|
||||
BOOL _animates @accessors(property=animates);
|
||||
BOOL _animates @accessors(getter=animates);
|
||||
int _appearance @accessors(property=appearance);
|
||||
int _behavior @accessors(getter=behavior);
|
||||
|
||||
@@ -153,6 +153,20 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
return [_popoverWindow isVisible];
|
||||
}
|
||||
|
||||
/*!
|
||||
Set if the popover should animate for open/close actions.
|
||||
|
||||
@param shouldAnimate if YES, the popover will be animated.
|
||||
*/
|
||||
- (void)setAnimates:(BOOL)shouldAnimate
|
||||
{
|
||||
if (_animates == shouldAnimate)
|
||||
return;
|
||||
|
||||
_animates = shouldAnimate;
|
||||
[_popoverWindow setAnimates:_animates];
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the behavior of the CPPopover. It can be:
|
||||
|
||||
|
||||
@@ -3623,7 +3623,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
@discussion
|
||||
Typically identifier is associated with an external CIB and the table view will automatically instantiate the CIB with the provided owner. The owner of the CIB that may be loaded and instantiated to create a new view with the particular identifier is typically the table view’s delegate. The owner is useful in setting up outlets and target and actions from the view.
|
||||
|
||||
This method will typically be called by the delegate in tableView:dataViewForTableColumn:row:, but it can also be overridden to provide custom views for the identifier. This method may also return a reused view with the same identifier that was no longer available on screen.
|
||||
This method will typically be called by the delegate in tableView:viewForTableColumn:row:, but it can also be overridden to provide custom views for the identifier. This method may also return a reused view with the same identifier that was no longer available on screen.
|
||||
*/
|
||||
- (id)makeViewWithIdentifier:(CPString)anIdentifier owner:(id)anOwner
|
||||
{
|
||||
|
||||
@@ -532,7 +532,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
/* @ignore */
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return [self isEditable] && [self isEnabled];
|
||||
return [self isEditable] && [self isEnabled] && [self _isWithinUsablePlatformRect];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
@@ -1585,9 +1585,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (BOOL)_isWithinUsablePlatformRect
|
||||
{
|
||||
// Make sure the text field is visible so the browser will not scroll
|
||||
// without the NSScrollView knowing about it.
|
||||
[self scrollRectToVisible:[self bounds]];
|
||||
// Make sure the text field is completely within the platform window
|
||||
// so the browser will not scroll it into view.
|
||||
|
||||
var wind = [self window],
|
||||
frame = [self convertRectToBase:[self bounds]],
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
@import "CPTheme.j"
|
||||
|
||||
@class CPButtonBar
|
||||
|
||||
@class CPView
|
||||
|
||||
var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
_CPCibCustomResourceResourceNameKey = @"_CPCibCustomResourceResourceNameKey",
|
||||
@@ -42,6 +42,7 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
CPString _className;
|
||||
CPString _resourceName;
|
||||
CPDictionary _properties;
|
||||
CPBundle _bundle;
|
||||
}
|
||||
|
||||
+ (id)imageResourceWithName:(CPString)aResourceName size:(CGSize)aSize
|
||||
@@ -63,6 +64,7 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
_className = aClassName;
|
||||
_resourceName = aResourceName;
|
||||
_properties = properties;
|
||||
_bundle = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -77,6 +79,7 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
_className = [aCoder decodeObjectForKey:_CPCibCustomResourceClassNameKey];
|
||||
_resourceName = [aCoder decodeObjectForKey:_CPCibCustomResourceResourceNameKey];
|
||||
_properties = [aCoder decodeObjectForKey:_CPCibCustomResourcePropertiesKey];
|
||||
_bundle = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -100,39 +103,72 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
else if (_resourceName == "CPRemoveTemplate")
|
||||
return [[CPTheme defaultTheme] valueForAttributeWithName:@"button-image-minus" forClass:[CPButtonBar class]];
|
||||
|
||||
return [self imageFromBundle:[aCoder bundle]];
|
||||
return [self imageFromCoder:aCoder];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPImage)imageFromBundle:(CPBundle)aBundle
|
||||
{
|
||||
if (!aBundle)
|
||||
{
|
||||
var bundleClass = _properties.valueForKey(@"bundleClass");
|
||||
|
||||
if (bundleClass)
|
||||
{
|
||||
bundleClass = CPClassFromString(bundleClass);
|
||||
|
||||
if (bundleClass)
|
||||
aBundle = [CPBundle bundleForClass:bundleClass];
|
||||
}
|
||||
else
|
||||
aBundle = [CPBundle mainBundle];
|
||||
}
|
||||
|
||||
return [[CPImage alloc] initWithContentsOfFile:[aBundle pathForResource:_resourceName] size:_properties.valueForKey(@"size")];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPCibCustomResource (CPImage)
|
||||
|
||||
- (CPBundle)imageBundleWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (_bundle)
|
||||
return _bundle;
|
||||
|
||||
var bundleIdentifier = [_properties valueForKey:@"bundleIdentifier"];
|
||||
|
||||
if (bundleIdentifier)
|
||||
_bundle = [CPBundle bundleWithIdentifier:bundleIdentifier];
|
||||
else
|
||||
{
|
||||
var bundleClass = [_properties valueForKey:@"bundleClass"];
|
||||
|
||||
if (bundleClass)
|
||||
{
|
||||
bundleClass = CPClassFromString(bundleClass);
|
||||
|
||||
if (bundleClass)
|
||||
_bundle = [CPBundle bundleForClass:bundleClass];
|
||||
}
|
||||
}
|
||||
|
||||
if (!_bundle)
|
||||
{
|
||||
var framework = [_properties valueForKey:@"framework"];
|
||||
|
||||
if (framework)
|
||||
{
|
||||
// Get AppKit and hope the framework is in the same directory
|
||||
var appKit = [CPBundle bundleForClass:[CPView class]],
|
||||
url = [[appKit bundleURL] URLByDeletingLastPathComponent];
|
||||
|
||||
url = [CPURL URLWithString:framework relativeToURL:url];
|
||||
_bundle = [CPBundle bundleWithURL:url];
|
||||
}
|
||||
}
|
||||
|
||||
if (!_bundle)
|
||||
{
|
||||
if (aCoder)
|
||||
_bundle = [aCoder bundle];
|
||||
else
|
||||
_bundle = [CPBundle mainBundle];
|
||||
}
|
||||
|
||||
return _bundle;
|
||||
}
|
||||
|
||||
- (CPImage)imageFromCoder:(CPCoder)aCoder
|
||||
{
|
||||
return [[CPImage alloc] initWithContentsOfFile:[[self imageBundleWithCoder:aCoder] pathForResource:_resourceName] size:[_properties valueForKey:@"size"]];
|
||||
}
|
||||
|
||||
- (CPString)filename
|
||||
{
|
||||
return [[CPBundle mainBundle] pathForResource:_resourceName];
|
||||
return [[self imageBundleWithCoder:nil] pathForResource:_resourceName];
|
||||
}
|
||||
|
||||
- (CGSize)size
|
||||
@@ -162,7 +198,7 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
var image = [self imageFromBundle:nil];
|
||||
var image = [self imageFromCoder:nil];
|
||||
|
||||
return [image description];
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
|
||||
|
||||
_sublayers = [];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement = document.createElement("div");
|
||||
|
||||
_DOMElement.style.overflow = "visible";
|
||||
@@ -167,6 +168,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
|
||||
_DOMElement.style.zIndex = 0;
|
||||
_DOMElement.style.width = "0px";
|
||||
_DOMElement.style.height = "0px";
|
||||
#endif
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -711,10 +713,12 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
|
||||
|
||||
[_sublayers insertObject:aLayer atIndex:anIndex];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
if (anIndex >= _sublayers.length - 1)
|
||||
_DOMElement.appendChild(DOM(aLayer));
|
||||
else
|
||||
_DOMElement.insertBefore(DOM(aLayer), _sublayers[anIndex + 1]._DOMElement);
|
||||
#endif
|
||||
|
||||
aLayer._superlayer = self;
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 240 B |
|
After Width: | Height: | Size: 137 B |
|
After Width: | Height: | Size: 238 B |
@@ -30,6 +30,7 @@
|
||||
@import <AppKit/CPCheckBox.j>
|
||||
@import <AppKit/CPComboBox.j>
|
||||
@import <AppKit/CPColorWell.j>
|
||||
@import <AppKit/CPDatePicker.j>
|
||||
@import <AppKit/CPLevelIndicator.j>
|
||||
@import <AppKit/CPPopUpButton.j>
|
||||
@import <AppKit/CPProgressIndicator.j>
|
||||
@@ -1094,6 +1095,228 @@ var themedButtonValues = nil,
|
||||
return searchField;
|
||||
}
|
||||
|
||||
+ (CPDatePicker)themedDatePicker
|
||||
{
|
||||
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(40,140,300,29)],
|
||||
|
||||
bezelColor = PatternColor(
|
||||
[
|
||||
["textfield-bezel-square-0.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-1.png", 1.0, 6.0],
|
||||
["textfield-bezel-square-2.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-3.png", 6.0, 1.0],
|
||||
["textfield-bezel-square-4.png", 1.0, 1.0],
|
||||
["textfield-bezel-square-5.png", 6.0, 1.0],
|
||||
["textfield-bezel-square-6.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-7.png", 1.0, 6.0],
|
||||
["textfield-bezel-square-8.png", 6.0, 6.0]
|
||||
]),
|
||||
|
||||
bezelDisabledColor = PatternColor(
|
||||
[
|
||||
["textfield-bezel-square-disabled-0.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-disabled-1.png", 1.0, 6.0],
|
||||
["textfield-bezel-square-disabled-2.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-disabled-3.png", 6.0, 1.0],
|
||||
["textfield-bezel-square-disabled-4.png", 1.0, 1.0],
|
||||
["textfield-bezel-square-disabled-5.png", 6.0, 1.0],
|
||||
["textfield-bezel-square-disabled-6.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-disabled-7.png", 1.0, 6.0],
|
||||
["textfield-bezel-square-disabled-8.png", 6.0, 6.0]
|
||||
]),
|
||||
|
||||
bezelColorDatePickerTextField = PatternColor(
|
||||
[
|
||||
[@"datepicker-date-segment-0.png", 4.0, 18.0],
|
||||
[@"datepicker-date-segment-1.png", 1.0, 18.0],
|
||||
[@"datepicker-date-segment-2.png", 4.0, 18.0]
|
||||
], PatternIsHorizontal),
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", bezelColor, CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled],
|
||||
|
||||
[@"font", [CPFont boldSystemFontOfSize:13.0]],
|
||||
[@"text-color", [CPColor colorWithWhite:0.2 alpha:0.8]],
|
||||
[@"text-color", textDisabledColor, CPThemeStateDisabled],
|
||||
|
||||
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 3.0), CPThemeStateNormal],
|
||||
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 5.0), CPThemeStateBezeled],
|
||||
[@"bezel-inset", CGInsetMake(0.0, -3.0, 0.0, -3.0), CPThemeStateBezeled],
|
||||
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal],
|
||||
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected],
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal | CPThemeStateDisabled],
|
||||
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected | CPThemeStateDisabled],
|
||||
|
||||
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 18.0)],
|
||||
|
||||
[@"separator-content-inset", CGInsetMake(0.0, -2.0, 0.0, -1.0)],
|
||||
|
||||
[@"content-inset-datepicker-textfield", CGInsetMake(2.0, 2.0, 0.0, 1.0), CPThemeStateNormal],
|
||||
[@"content-inset-datepicker-textfield-separator", CGInsetMake(2.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
|
||||
[@"content-inset-datepicker-textfield", CGInsetMake(2.0, 2.0, 0.0, 1.0), CPThemeStateSelected],
|
||||
[@"content-inset-datepicker-textfield-separator", CGInsetMake(2.0, 0.0, 0.0, 0.0), CPThemeStateSelected],
|
||||
|
||||
[@"date-hour-margin", 7.0],
|
||||
[@"stepper-margin", 2.0],
|
||||
|
||||
[@"min-size", CGSizeMake(0.0, 29.0)],
|
||||
[@"max-size", CGSizeMake(-1.0, 29.0)]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themeValues forView:datePicker];
|
||||
|
||||
return datePicker;
|
||||
}
|
||||
|
||||
+ (CPDatePicker)themedDatePickerCalendar
|
||||
{
|
||||
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(40,140,300,29)],
|
||||
|
||||
arrowImageLeft = PatternImage("datepicker-calendar-arrow-left.png", 7.0, 10.0),
|
||||
arrowImageRight = PatternImage("datepicker-calendar-arrow-right.png", 7.0, 10.0),
|
||||
circleImage = PatternImage("datepicker-circle-image.png", 9.0, 10.0),
|
||||
|
||||
arrowImageLeftHighlighted = PatternImage("datepicker-calendar-arrow-left-highlighted.png", 7.0, 10.0),
|
||||
arrowImageRightHighlighted = PatternImage("datepicker-calendar-arrow-right-highlighted.png", 7.0, 10.0),
|
||||
circleImageHighlighted = PatternImage("datepicker-circle-image-highlighted.png", 9.0, 10.0),
|
||||
|
||||
secondHandColor = PatternColor("datepicker-clock-second-hand.png", 89.0, 89.0),
|
||||
minuteHandColor = PatternColor("datepicker-clock-minute-hand.png", 85.0, 85.0),
|
||||
hourHandColor = PatternColor("datepicker-clock-hour-hand.png", 47.0, 47.0),
|
||||
middleHandColor = PatternColor("datepicker-clock-middle-hand.png", 13.0, 13.0),
|
||||
clockImageColor = PatternColor("datepicker-clock.png", 122.0, 123.0),
|
||||
|
||||
secondHandColorDisabled = PatternColor("datepicker-clock-second-hand-disabled.png", 89.0, 89.0),
|
||||
minuteHandColorDisabled = PatternColor("datepicker-clock-minute-hand-disabled.png", 85.0, 85.0),
|
||||
hourHandColorDisabled = PatternColor("datepicker-clock-hour-hand-disabled.png", 47.0, 47.0),
|
||||
middleHandColorDisabled = PatternColor("datepicker-clock-middle-hand-disabled.png", 13.0, 13.0),
|
||||
clockImageColorDisabled = PatternColor("datepicker-clock-disabled.png", 122.0, 123.0),
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:217.0 / 255.0 green:217.0 / 255.0 blue:211.0 / 255.0 alpha:1.0], CPThemeStateNormal],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:217.0 / 255.0 green:217.0 / 255.0 blue:211.0 / 255.0 alpha:0.5], CPThemeStateNormal | CPThemeStateDisabled],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:0.5], CPThemeStateSelected | CPThemeStateDisabled],
|
||||
|
||||
[@"bezel-color-calendar", [CPColor whiteColor]],
|
||||
[@"bezel-color-calendar", [CPColor colorWithCalibratedRed:159.0 / 255.0 green:201.0 / 255.0 blue:225.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"bezel-color-calendar", [CPColor colorWithCalibratedRed:159.0 / 255.0 green:201.0 / 255.0 blue:225.0 / 255.0 alpha:0.5], CPThemeStateSelected |CPThemeStateDisabled],
|
||||
[@"bezel-color-clock", clockImageColor],
|
||||
[@"bezel-color-clock", clockImageColorDisabled, CPThemeStateDisabled],
|
||||
|
||||
[@"title-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:1.0]],
|
||||
[@"title-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
|
||||
[@"title-text-shadow-offset", CGSizeMake(0,1)],
|
||||
[@"title-font", [CPFont boldSystemFontOfSize:12.0]],
|
||||
|
||||
[@"title-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:0.5], CPThemeStateDisabled],
|
||||
[@"title-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
|
||||
[@"title-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"title-font", [CPFont boldSystemFontOfSize:12.0], CPThemeStateDisabled],
|
||||
|
||||
[@"weekday-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:1.0]],
|
||||
[@"weekday-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
|
||||
[@"weekday-text-shadow-offset", CGSizeMake(0,1)],
|
||||
[@"weekday-font", [CPFont systemFontOfSize:11.0]],
|
||||
|
||||
[@"weekday-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:0.5], CPThemeStateDisabled],
|
||||
[@"weekday-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
|
||||
[@"weekday-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"weekday-font", [CPFont systemFontOfSize:11.0], CPThemeStateDisabled],
|
||||
|
||||
[@"clock-text-color", [CPColor colorWithCalibratedRed:153.0 / 255.0 green:153.0 / 255.0 blue:153.0 / 255.0 alpha:1.0]],
|
||||
[@"clock-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
|
||||
[@"clock-text-shadow-offset", CGSizeMake(0,1)],
|
||||
[@"clock-font", [CPFont systemFontOfSize:11.0]],
|
||||
|
||||
[@"clock-text-color", [CPColor colorWithCalibratedRed:153.0 / 255.0 green:153.0 / 255.0 blue:153.0 / 255.0 alpha:0.5], CPThemeStateDisabled],
|
||||
[@"clock-text-shadow-color", [CPColor whiteColor], CPThemeStateDisabled],
|
||||
[@"clock-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"clock-font", [CPFont systemFontOfSize:11.0], CPThemeStateDisabled],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:1.0], CPThemeStateNormal],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateNormal],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateNormal],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateNormal],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:1.0], CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:0.5], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateSelected],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:1.0], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:179.0 / 255.0 green:179.0 / 255.0 blue:179.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:0.5], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:0.5], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
|
||||
[@"arrow-image-left", arrowImageLeft],
|
||||
[@"arrow-image-right", arrowImageRight],
|
||||
[@"arrow-image-left-highlighted", arrowImageLeftHighlighted],
|
||||
[@"arrow-image-right-highlighted", arrowImageRightHighlighted],
|
||||
[@"circle-image", circleImage],
|
||||
[@"circle-image-highlighted", circleImageHighlighted],
|
||||
[@"arrow-inset", CGInsetMake(9.0, 4.0, 0.0, 0.0)],
|
||||
|
||||
[@"second-hand-color", secondHandColor],
|
||||
[@"hour-hand-color", hourHandColor],
|
||||
[@"middle-hand-color", middleHandColor],
|
||||
[@"minute-hand-color", minuteHandColor],
|
||||
|
||||
[@"second-hand-color", secondHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"hour-hand-color", hourHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"middle-hand-color", middleHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"minute-hand-color", minuteHandColorDisabled, CPThemeStateDisabled],
|
||||
|
||||
[@"second-hand-size", CGSizeMake(89.0, 89.0)],
|
||||
[@"hour-hand-size", CGSizeMake(47.0, 47.0)],
|
||||
[@"middle-hand-size", CGSizeMake(13.0, 13.0)],
|
||||
[@"minute-hand-size", CGSizeMake(85.0, 85.0)],
|
||||
|
||||
[@"border-width", 1.0],
|
||||
[@"size-header", CGSizeMake(141.0, 39.0)],
|
||||
[@"size-tile", CGSizeMake(20.0, 18.0)],
|
||||
[@"size-clock", CGSizeMake(122.0, 123.0)],
|
||||
[@"size-calendar", CGSizeMake(141.0, 109.0)],
|
||||
[@"min-size-calendar", CGSizeMake(141.0, 148.0)],
|
||||
[@"max-size-calendar", CGSizeMake(141.0, 148.0)]
|
||||
|
||||
];
|
||||
|
||||
[datePicker setDatePickerStyle:CPClockAndCalendarDatePickerStyle];
|
||||
[self registerThemeValues:themeValues forView:datePicker];
|
||||
|
||||
return datePicker;
|
||||
}
|
||||
|
||||
+ (CPTokenField)themedTokenField
|
||||
{
|
||||
var tokenfield = [[CPTokenField alloc] initWithFrame:CGRectMake(0.0, 0.0, 60.0, 29.0)],
|
||||
@@ -2585,8 +2808,6 @@ var themedButtonValues = nil,
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"menu-item-selection-color", [CPColor colorWithHexString:@"5C85D8"]],
|
||||
[@"menu-item-text-shadow-color", [CPColor colorWithCalibratedRed:26.0 / 255.0 green: 73.0 / 255.0 blue:109.0 / 255.0 alpha:1.0]],
|
||||
[@"horizontal-margin", 12.0],
|
||||
[@"submenu-indicator-margin", 3.0],
|
||||
[@"vertical-margin", 4.0]
|
||||
|
||||
|
After Width: | Height: | Size: 998 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 240 B |
|
After Width: | Height: | Size: 137 B |
|
After Width: | Height: | Size: 238 B |
@@ -29,6 +29,7 @@
|
||||
@import <AppKit/CPCheckBox.j>
|
||||
@import <AppKit/CPComboBox.j>
|
||||
@import <AppKit/CPColorWell.j>
|
||||
@import <AppKit/CPDatePicker.j>
|
||||
@import <AppKit/CPLevelIndicator.j>
|
||||
@import <AppKit/CPPopUpButton.j>
|
||||
@import <AppKit/CPProgressIndicator.j>
|
||||
@@ -652,6 +653,210 @@ var themedButtonValues = nil,
|
||||
return searchField;
|
||||
}
|
||||
|
||||
+ (CPDatePicker)themedDatePicker
|
||||
{
|
||||
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(40,140,300,29)],
|
||||
|
||||
bezelColor = PatternColor(
|
||||
"textfield-bezel-square{state}{position}.png",
|
||||
{
|
||||
states: ["", "disabled"],
|
||||
positions: "#",
|
||||
width: 4.0,
|
||||
height: 4.0
|
||||
}),
|
||||
|
||||
bezelColorDatePickerTextField = PatternColor(
|
||||
[
|
||||
[@"datepicker-date-segment-0.png", 4.0, 18.0],
|
||||
[@"datepicker-date-segment-1.png", 1.0, 18.0],
|
||||
[@"datepicker-date-segment-2.png", 4.0, 18.0]
|
||||
], PatternIsHorizontal),
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", bezelColor["@"], CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelColor["disabled"], CPThemeStateBezeled | CPThemeStateDisabled],
|
||||
|
||||
[@"font", [CPFont boldSystemFontOfSize:13.0]],
|
||||
[@"text-color", [CPColor colorWithWhite:0.2 alpha:0.8]],
|
||||
[@"text-color", [CPColor colorWithWhite:0.2 alpha:0.5], CPThemeStateDisabled],
|
||||
|
||||
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 3.0), CPThemeStateNormal],
|
||||
[@"content-inset", CGInsetMake(3.0, 0.0, 0.0, 3.0), CPThemeStateBezeled],
|
||||
[@"bezel-inset", CGInsetMake(3.0, 0.0, 3.0, 0.0), CPThemeStateBezeled],
|
||||
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal],
|
||||
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected],
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal | CPThemeStateDisabled],
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateSelected | CPThemeStateDisabled],
|
||||
|
||||
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 18.0)],
|
||||
|
||||
[@"separator-content-inset", CGInsetMake(0.0, -2.0, 0.0, -1.0)],
|
||||
|
||||
[@"content-inset-datepicker-textfield", CGInsetMake(2.0, 2.0, 0.0, 1.0), CPThemeStateNormal],
|
||||
[@"content-inset-datepicker-textfield-separator",CGInsetMake(2.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
|
||||
[@"content-inset-datepicker-textfield", CGInsetMake(2.0, 2.0, 0.0, 1.0) , CPThemeStateSelected],
|
||||
[@"content-inset-datepicker-textfield-separator",CGInsetMake(2.0, 0.0, 0.0, 0.0), CPThemeStateSelected],
|
||||
|
||||
[@"date-hour-margin", 7.0],
|
||||
[@"stepper-margin", 5.0],
|
||||
|
||||
[@"min-size", CGSizeMake(0.0, 29.0)],
|
||||
[@"max-size", CGSizeMake(-1.0, 29.0)]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themeValues forView:datePicker];
|
||||
|
||||
return datePicker;
|
||||
}
|
||||
|
||||
+ (CPDatePicker)themedDatePickerCalendar
|
||||
{
|
||||
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(40,140,300,29)],
|
||||
|
||||
arrowImageLeft = PatternImage("datepicker-calendar-arrow-left.png", 7.0, 10.0),
|
||||
arrowImageRight = PatternImage("datepicker-calendar-arrow-right.png", 7.0, 10.0),
|
||||
circleImage = PatternImage("datepicker-circle-image.png", 9.0, 10.0),
|
||||
|
||||
arrowImageLeftHighlighted = PatternImage("datepicker-calendar-arrow-left-highlighted.png", 7.0, 10.0),
|
||||
arrowImageRightHighlighted = PatternImage("datepicker-calendar-arrow-right-highlighted.png", 7.0, 10.0),
|
||||
circleImageHighlighted = PatternImage("datepicker-circle-image-highlighted.png", 9.0, 10.0),
|
||||
|
||||
secondHandColor = PatternColor("datepicker-clock-second-hand.png", 89.0, 89.0),
|
||||
minuteHandColor = PatternColor("datepicker-clock-minute-hand.png", 85.0, 85.0),
|
||||
hourHandColor = PatternColor("datepicker-clock-hour-hand.png", 47.0, 47.0),
|
||||
middleHandColor = PatternColor("datepicker-clock-middle-hand.png", 13.0, 13.0),
|
||||
clockImageColor = PatternColor("datepicker-clock.png", 122.0, 123.0),
|
||||
|
||||
secondHandColorDisabled = PatternColor("datepicker-clock-second-hand-disabled.png", 89.0, 89.0),
|
||||
minuteHandColorDisabled = PatternColor("datepicker-clock-minute-hand-disabled.png", 85.0, 85.0),
|
||||
hourHandColorDisabled = PatternColor("datepicker-clock-hour-hand-disabled.png", 47.0, 47.0),
|
||||
middleHandColorDisabled = PatternColor("datepicker-clock-middle-hand-disabled.png", 13.0, 13.0),
|
||||
clockImageColorDisabled = PatternColor("datepicker-clock-disabled.png", 122.0, 123.0),
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:217.0 / 255.0 green:217.0 / 255.0 blue:211.0 / 255.0 alpha:1.0], CPThemeStateNormal],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:68.0 / 255.0 green:109.0 / 255.0 blue:198.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:217.0 / 255.0 green:217.0 / 255.0 blue:211.0 / 255.0 alpha:0.5], CPThemeStateNormal | CPThemeStateDisabled],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:68.0 / 255.0 green:109.0 / 255.0 blue:198.0 / 255.0 alpha:0.5], CPThemeStateSelected | CPThemeStateDisabled],
|
||||
|
||||
[@"bezel-color-calendar", [CPColor whiteColor]],
|
||||
[@"bezel-color-calendar", [CPColor colorWithCalibratedRed:87.0 / 255.0 green:128.0 / 255.0 blue:216.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"bezel-color-calendar", [CPColor colorWithCalibratedRed:87.0 / 255.0 green:128.0 / 255.0 blue:216.0 / 255.0 alpha:0.5], CPThemeStateSelected |CPThemeStateDisabled],
|
||||
[@"bezel-color-clock", clockImageColor],
|
||||
[@"bezel-color-clock", clockImageColorDisabled, CPThemeStateDisabled],
|
||||
|
||||
[@"title-text-color", [CPColor colorWithCalibratedRed:79.0 / 255.0 green:79.0 / 255.0 blue:79.0 / 255.0 alpha:1.0]],
|
||||
[@"title-text-shadow-color", [CPColor whiteColor]],
|
||||
[@"title-text-shadow-offset", CGSizeMake(0,1)],
|
||||
[@"title-font", [CPFont boldSystemFontOfSize:12.0]],
|
||||
|
||||
[@"title-text-color", [CPColor colorWithCalibratedRed:79.0 / 255.0 green:79.0 / 255.0 blue:79.0 / 255.0 alpha:0.5], CPThemeStateDisabled],
|
||||
[@"title-text-shadow-color", [CPColor whiteColor], CPThemeStateDisabled],
|
||||
[@"title-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"title-font", [CPFont boldSystemFontOfSize:12.0], CPThemeStateDisabled],
|
||||
|
||||
[@"weekday-text-color", [CPColor colorWithCalibratedRed:79.0 / 255.0 green:79.0 / 255.0 blue:79.0 / 255.0 alpha:1.0]],
|
||||
[@"weekday-text-shadow-color", [CPColor whiteColor]],
|
||||
[@"weekday-text-shadow-offset", CGSizeMake(0,1)],
|
||||
[@"weekday-font", [CPFont systemFontOfSize:11.0]],
|
||||
|
||||
[@"weekday-text-color", [CPColor colorWithCalibratedRed:79.0 / 255.0 green:79.0 / 255.0 blue:79.0 / 255.0 alpha:0.5], CPThemeStateDisabled],
|
||||
[@"weekday-text-shadow-color", [CPColor whiteColor], CPThemeStateDisabled],
|
||||
[@"weekday-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"weekday-font", [CPFont systemFontOfSize:11.0], CPThemeStateDisabled],
|
||||
|
||||
[@"clock-text-color", [CPColor colorWithCalibratedRed:153.0 / 255.0 green:153.0 / 255.0 blue:153.0 / 255.0 alpha:1.0]],
|
||||
[@"clock-text-shadow-color", [CPColor whiteColor]],
|
||||
[@"clock-text-shadow-offset", CGSizeMake(0,1)],
|
||||
[@"clock-font", [CPFont systemFontOfSize:11.0]],
|
||||
|
||||
[@"clock-text-color", [CPColor colorWithCalibratedRed:153.0 / 255.0 green:153.0 / 255.0 blue:153.0 / 255.0 alpha:0.5], CPThemeStateDisabled],
|
||||
[@"clock-text-shadow-color", [CPColor whiteColor], CPThemeStateDisabled],
|
||||
[@"clock-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"clock-font", [CPFont systemFontOfSize:11.0], CPThemeStateDisabled],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:34.0 / 255.0 green:34.0 / 255.0 blue:34.0 / 255.0 alpha:1.0], CPThemeStateNormal],
|
||||
[@"tile-text-shadow-color", [CPColor whiteColor], CPThemeStateNormal],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateNormal],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateNormal],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:87.0 / 255.0 green:128.0 / 255.0 blue:216.0 / 255.0 alpha:1.0], CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-color", [CPColor whiteColor], CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:87.0 / 255.0 green:128.0 / 255.0 blue:216.0 / 255.0 alpha:0.5], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-color", [CPColor whiteColor], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
|
||||
[@"tile-text-color", [CPColor whiteColor], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedRed:0.0 / 255.0 green:0.0 / 255.0 blue:0.0 / 255.0 alpha:0.2], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
|
||||
[@"tile-text-color", [CPColor whiteColor], CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedRed:0.0 / 255.0 green:0.0 / 255.0 blue:0.0 / 255.0 alpha:0.2], CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateSelected],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:179.0 / 255.0 green:179.0 / 255.0 blue:179.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-color", [CPColor whiteColor], CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0 alpha:0.5], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedRed:0.0 / 255.0 green:0.0 / 255.0 blue:0.0 / 255.0 alpha:0.2], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0 alpha:0.5], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedRed:0.0 / 255.0 green:0.0 / 255.0 blue:0.0 / 255.0 alpha:0.2], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
|
||||
[@"arrow-image-left", arrowImageLeft],
|
||||
[@"arrow-image-right", arrowImageRight],
|
||||
[@"arrow-image-left-highlighted", arrowImageLeftHighlighted],
|
||||
[@"arrow-image-right-highlighted", arrowImageRightHighlighted],
|
||||
[@"circle-image", circleImage],
|
||||
[@"circle-image-highlighted", circleImageHighlighted],
|
||||
[@"arrow-inset", CGInsetMake(9.0, 4.0, 0.0, 0.0)],
|
||||
|
||||
[@"second-hand-color", secondHandColor],
|
||||
[@"hour-hand-color", hourHandColor],
|
||||
[@"middle-hand-color", middleHandColor],
|
||||
[@"minute-hand-color", minuteHandColor],
|
||||
|
||||
[@"second-hand-color", secondHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"hour-hand-color", hourHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"middle-hand-color", middleHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"minute-hand-color", minuteHandColorDisabled, CPThemeStateDisabled],
|
||||
|
||||
[@"second-hand-size", CGSizeMake(89.0, 89.0)],
|
||||
[@"hour-hand-size", CGSizeMake(47.0, 47.0)],
|
||||
[@"middle-hand-size", CGSizeMake(13.0, 13.0)],
|
||||
[@"minute-hand-size", CGSizeMake(85.0, 85.0)],
|
||||
|
||||
[@"border-width", 1.0],
|
||||
[@"size-header", CGSizeMake(141.0, 39.0)],
|
||||
[@"size-tile", CGSizeMake(20.0, 18.0)],
|
||||
[@"size-clock", CGSizeMake(122.0, 123.0)],
|
||||
[@"size-calendar", CGSizeMake(141.0, 109.0)],
|
||||
[@"min-size-calendar", CGSizeMake(141.0, 148.0)],
|
||||
[@"max-size-calendar", CGSizeMake(141.0, 148.0)]
|
||||
];
|
||||
|
||||
[datePicker setDatePickerStyle:CPClockAndCalendarDatePickerStyle];
|
||||
[self registerThemeValues:themeValues forView:datePicker];
|
||||
|
||||
return datePicker;
|
||||
}
|
||||
|
||||
+ (CPTokenField)themedTokenField
|
||||
{
|
||||
var tokenfield = [[CPTokenField alloc] initWithFrame:CGRectMake(0.0, 0.0, 160.0, 29.0)],
|
||||
@@ -2021,8 +2226,6 @@ var themedButtonValues = nil,
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"menu-item-selection-color", [CPColor colorWithHexString:@"5C85D8"]],
|
||||
[@"menu-item-text-shadow-color", [CPColor colorWithCalibratedRed:26.0 / 255.0 green: 73.0 / 255.0 blue:109.0 / 255.0 alpha:1.0]],
|
||||
[@"horizontal-margin", 9.0],
|
||||
[@"submenu-indicator-margin", 3.0],
|
||||
[@"vertical-margin", 4.0]
|
||||
|
||||
@@ -319,9 +319,6 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
if (_image == anImage)
|
||||
return;
|
||||
|
||||
if ([_image delegate] === self)
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPImageDidLoadNotification object:_image];
|
||||
|
||||
_image = anImage;
|
||||
_flags |= _CPImageAndTextViewImageChangedFlag;
|
||||
|
||||
@@ -347,6 +344,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
|
||||
- (void)imageDidLoad:(CPNotification)aNotification
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPImageDidLoadNotification object:_image];
|
||||
_flags |= _CPImageAndTextViewImageChangedFlag;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
@@ -51,6 +51,24 @@ var CPBundlesForURLStrings = { };
|
||||
return [self bundleWithURL:aPath];
|
||||
}
|
||||
|
||||
+ (CPBundle)bundleWithIdentifier:(CPString)anIdentifier
|
||||
{
|
||||
var bundle = CFBundle.bundleWithIdentifier(anIdentifier);
|
||||
|
||||
if (bundle)
|
||||
{
|
||||
var url = bundle.bundleURL(),
|
||||
cpBundle = CPBundlesForURLStrings[url.absoluteString()];
|
||||
|
||||
if (!cpBundle)
|
||||
cpBundle = [self bundleWithURL:url];
|
||||
|
||||
return cpBundle;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (CPBundle)bundleForClass:(Class)aClass
|
||||
{
|
||||
return [self bundleWithURL:CFBundle.bundleForClass(aClass).bundleURL()];
|
||||
@@ -118,12 +136,12 @@ var CPBundlesForURLStrings = { };
|
||||
|
||||
//[self load];
|
||||
|
||||
return className ? CPClassFromString(className) : Nil;
|
||||
return className ? CPClassFromString(className) : nil;
|
||||
}
|
||||
|
||||
- (CPString)bundleIdentifier
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:@"CPBundleIdentifier"];
|
||||
return _bundle.identifier();
|
||||
}
|
||||
|
||||
- (BOOL)isLoaded
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
@import "CPDate.j"
|
||||
@import "CPString.j"
|
||||
@import "CPFormatter.j"
|
||||
@import "CPLocale.j"
|
||||
|
||||
CPDateFormatterNoStyle = 0;
|
||||
CPDateFormatterShortStyle = 1;
|
||||
@@ -42,7 +43,8 @@ CPDateFormatterFullStyle = 4;
|
||||
*/
|
||||
@implementation CPDateFormatter : CPFormatter
|
||||
{
|
||||
CPDateFormatterStyle _dateStyle @accessors(property=dateStyle);
|
||||
CPDateFormatterStyle _dateStyle @accessors(property=dateStyle);
|
||||
CPLocale _locale @accessors(property=locale);
|
||||
}
|
||||
|
||||
- (id)init
|
||||
@@ -109,7 +111,8 @@ CPDateFormatterFullStyle = 4;
|
||||
|
||||
@end
|
||||
|
||||
var CPDateFormatterStyleKey = "CPDateFormatterStyle";
|
||||
var CPDateFormatterStyleKey = @"CPDateFormatterStyle",
|
||||
CPDateFormatterLocaleKey = @"CPDateFormatterLocaleKey";
|
||||
|
||||
@implementation CPDateFormatter (CPCoding)
|
||||
|
||||
@@ -120,6 +123,7 @@ var CPDateFormatterStyleKey = "CPDateFormatterStyle";
|
||||
if (self)
|
||||
{
|
||||
_dateStyle = [aCoder decodeIntForKey:CPDateFormatterStyleKey];
|
||||
_locale = [aCoder decodeObjectForKey:CPDateFormatterLocaleKey];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -130,6 +134,7 @@ var CPDateFormatterStyleKey = "CPDateFormatterStyle";
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeInt:_dateStyle forKey:CPDateFormatterStyleKey];
|
||||
[aCoder encodeInt:_locale forKey:CPDateFormatterLocaleKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
/* CPLocale.j
|
||||
* Foundation
|
||||
*
|
||||
* Created by Alexandre Wilhelm
|
||||
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
|
||||
*
|
||||
* 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 "CPObject.j"
|
||||
|
||||
@class CPDictionary
|
||||
|
||||
CPLocaleIdentifier = @"CPLocaleIdentifier";
|
||||
CPLocaleLanguageCode = @"CPLocaleLanguageCode";
|
||||
CPLocaleCountryCode = @"CPLocaleCountryCode";
|
||||
CPLocaleScriptCode = @"CPLocaleScriptCode";
|
||||
CPLocaleVariantCode = @"CPLocaleVariantCode";
|
||||
CPLocaleExemplarCharacterSet = @"CPLocaleExemplarCharacterSet";
|
||||
CPLocaleCalendar = @"CPLocaleCalendar";
|
||||
CPLocaleCollationIdentifier = @"CPLocaleCollationIdentifier";
|
||||
CPLocaleUsesMetricSystem = @"CPLocaleUsesMetricSystem";
|
||||
CPLocaleMeasurementSystem = @"CPLocaleMeasurementSystem";
|
||||
CPLocaleDecimalSeparator = @"CPLocaleDecimalSeparator";
|
||||
CPLocaleGroupingSeparator = @"CPLocaleGroupingSeparator";
|
||||
CPLocaleCurrencySymbol = @"CPLocaleCurrencySymbol";
|
||||
CPLocaleCurrencyCode = @"CPLocaleCurrencyCode";
|
||||
CPLocaleCollatorIdentifier = @"CPLocaleCollatorIdentifier";
|
||||
CPLocaleQuotationBeginDelimiterKey = @"CPLocaleQuotationBeginDelimiterKey";
|
||||
CPLocaleQuotationEndDelimiterKey = @"CPLocaleQuotationEndDelimiterKey";
|
||||
CPLocaleAlternateQuotationBeginDelimiterKey = @"CPLocaleAlternateQuotationBeginDelimiterKey";
|
||||
CPLocaleAlternateQuotationEndDelimiterKey = @"CPLocaleAlternateQuotationEndDelimiterKey";
|
||||
|
||||
CPGregorianCalendar = @"CPGregorianCalendar";
|
||||
CPBuddhistCalendar = @"CPBuddhistCalendar";
|
||||
CPChineseCalendar = @"CPChineseCalendar";
|
||||
CPHebrewCalendar = @"CPHebrewCalendar";
|
||||
CPIslamicCalendar = @"CPIslamicCalendar";
|
||||
CPIslamicCivilCalendar = @"CPIslamicCivilCalendar";
|
||||
CPJapaneseCalendar = @"CPJapaneseCalendar";
|
||||
CPRepublicOfChinaCalendar = @"CPRepublicOfChinaCalendar";
|
||||
CPPersianCalendar = @"CPPersianCalendar";
|
||||
CPIndianCalendar = @"CPIndianCalendar";
|
||||
CPISO8601Calendar = @"CPISO8601Calendar";
|
||||
|
||||
CPLocaleLanguageDirectionUnknown = @"CPLocaleLanguageDirectionUnknown";
|
||||
CPLocaleLanguageDirectionLeftToRight = @"CPLocaleLanguageDirectionLeftToRight";
|
||||
CPLocaleLanguageDirectionRightToLeft = @"CPLocaleLanguageDirectionRightToLeft";
|
||||
CPLocaleLanguageDirectionTopToBottom = @"CPLocaleLanguageDirectionTopToBottom";
|
||||
CPLocaleLanguageDirectionBottomToTop = @"CPLocaleLanguageDirectionBottomToTop";
|
||||
|
||||
var countryCodes = [@"DE", @"FR", @"ES", @"GB", @"US"],
|
||||
languageCodes = [@"en", @"de", @"es", @"fr"],
|
||||
availableLocaleIdentifiers = [@"de_DE", @"en_EN", @"en_US", @"es_ES", @"fr_FR"];
|
||||
|
||||
var sharedSystemLocale = nil,
|
||||
sharedCurrentLocale = nil;
|
||||
|
||||
@implementation CPLocale : CPObject
|
||||
{
|
||||
CPDictionary _locale;
|
||||
}
|
||||
|
||||
/*! Return the system locale. By default is en_US
|
||||
*/
|
||||
+ (id)systemLocale
|
||||
{
|
||||
if (!sharedSystemLocale)
|
||||
sharedSystemLocale = [[CPLocale alloc] initWithLocaleIdentifier:@"en_US"];
|
||||
|
||||
return sharedSystemLocale;
|
||||
}
|
||||
|
||||
/*! Return the current locale base on the navigator
|
||||
*/
|
||||
+ (id)currentLocale
|
||||
{
|
||||
if (!sharedCurrentLocale)
|
||||
{
|
||||
var localeIdentifier,
|
||||
language;
|
||||
|
||||
if (typeof navigator != "undefined")
|
||||
{
|
||||
if (navigator.appVersion.indexOf("MSIE") >= 0)
|
||||
language = navigator.browserLanguage.substring(0,2);
|
||||
else
|
||||
language = navigator.language.substring(0,2);
|
||||
|
||||
language = [CPString stringWithFormat:@"%s_%s", [language lowercaseString], [language uppercaseString]];
|
||||
|
||||
if ([availableLocaleIdentifiers indexOfObject:language])
|
||||
localeIdentifier = language;
|
||||
}
|
||||
|
||||
if (!localeIdentifier)
|
||||
localeIdentifier = @"en_US";
|
||||
|
||||
sharedCurrentLocale = [[CPLocale alloc] initWithLocaleIdentifier:localeIdentifier];
|
||||
}
|
||||
|
||||
return sharedCurrentLocale
|
||||
}
|
||||
|
||||
/*! Return an array of the availableLocaleIdentifiers
|
||||
*/
|
||||
+ (CPArray)availableLocaleIdentifiers
|
||||
{
|
||||
return availableLocaleIdentifiers;
|
||||
}
|
||||
|
||||
/*! Return an array with the ISOCountryCodes
|
||||
*/
|
||||
+ (CPArray)ISOCountryCodes
|
||||
{
|
||||
return countryCodes;
|
||||
}
|
||||
|
||||
// + (CPArray)ISOCurrencyCodes
|
||||
// {
|
||||
// // TODO
|
||||
// return;
|
||||
// }
|
||||
|
||||
/*! Return an array with the ISOLanguageCodes
|
||||
*/
|
||||
+ (CPArray)ISOLanguageCodes
|
||||
{
|
||||
return languageCodes;
|
||||
}
|
||||
|
||||
// + (CPArray)commonISOCurrencyCodes
|
||||
// {
|
||||
// // TODO
|
||||
// return;
|
||||
// }
|
||||
|
||||
/*! Init a new instance of CPLocale with a given identifier.
|
||||
This method will call the class method _platformLocaleAdditionalDescriptionForIdentifier:. It's usefull if you want to implement your CPLocale.
|
||||
@parameter anIdentifier
|
||||
*/
|
||||
- (id)initWithLocaleIdentifier:(CPString)anIdentifier
|
||||
{
|
||||
if (self == [super init])
|
||||
{
|
||||
var parts = [anIdentifier componentsSeparatedByString:@"_"],
|
||||
language = [parts objectAtIndex:0],
|
||||
country = nil;
|
||||
|
||||
if ([parts count] > 1)
|
||||
country = [parts objectAtIndex:1];
|
||||
else
|
||||
country = anIdentifier;
|
||||
|
||||
_locale = [[CPDictionary alloc] init];
|
||||
[_locale setObject:anIdentifier forKey:CPLocaleIdentifier];
|
||||
[_locale setObject:language forKey:CPLocaleLanguageCode];
|
||||
[_locale setObject:country forKey:CPLocaleCountryCode];
|
||||
|
||||
if([[self class] respondsToSelector:@selector(_platformLocaleAdditionalDescriptionForIdentifier:)])
|
||||
{
|
||||
// Use any platform specific method to fill the locale info if one is defined
|
||||
var info = [[self class] performSelector:@selector(_platformLocaleAdditionalDescriptionForIdentifier:) withObject:anIdentifier];
|
||||
[_locale addEntriesFromDictionary:info];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_locale setObject:CPGregorianCalendar forKey:CPLocaleCalendar];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// - (CPString)displayNameForKey:(id)aKey value:(id)aValue
|
||||
// {
|
||||
// // TODO
|
||||
// return;
|
||||
// }
|
||||
|
||||
/*! Return the CPLocaleIdentifier
|
||||
*/
|
||||
- (CPString)localeIdentifier
|
||||
{
|
||||
return [_locale objectForKey:CPLocaleIdentifier];
|
||||
}
|
||||
|
||||
/*! Return the object depending of the key
|
||||
@param aKey
|
||||
@return an object
|
||||
*/
|
||||
- (id)objectForKey:(id)aKey
|
||||
{
|
||||
return [_locale objectForKey:aKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPLocaleIdentifierLocaleKey = @"CPLocaleIdentifierLocaleKey";
|
||||
|
||||
@implementation CPLocale (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
_locale = [aCoder decodeObjectForKey:CPLocaleIdentifierLocaleKey];
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
//[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeObject:_locale forKey:CPLocaleIdentifierLocaleKey];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -565,11 +565,11 @@ function CPDescriptionOfObject(anObject)
|
||||
properties.sort();
|
||||
|
||||
if (properties.length === 2 && anObject.hasOwnProperty("width") && anObject.hasOwnProperty("height"))
|
||||
desc = [CPString stringWithFormat:@"CGSize: { width:%f, height:%f }", anObject.width, anObject.height];
|
||||
desc = [CPString stringWithFormat:@"CGSize: (%f, %f)", anObject.width, anObject.height];
|
||||
else if (properties.length === 2 && anObject.hasOwnProperty("x") && anObject.hasOwnProperty("y"))
|
||||
desc = [CPString stringWithFormat:@"CGPoint: { x:%f, y:%f }", anObject.x, anObject.y];
|
||||
desc = [CPString stringWithFormat:@"CGPoint: (%f, %f)", anObject.x, anObject.y];
|
||||
else if (properties.length === 2 && anObject.hasOwnProperty("origin") && anObject.hasOwnProperty("size"))
|
||||
desc = [CPString stringWithFormat:@"CGRect: { x:%f, y:%f }, { width:%f, height:%f }", anObject.origin.x, anObject.origin.y, anObject.size.width, anObject.size.height];
|
||||
desc = [CPString stringWithFormat:@"CGRect: (%f, %f), (%f, %f)", anObject.origin.x, anObject.origin.y, anObject.size.width, anObject.size.height];
|
||||
else if (properties.length === 4 && anObject.hasOwnProperty("top") && anObject.hasOwnProperty("right") && anObject.hasOwnProperty("bottom") && anObject.hasOwnProperty("left"))
|
||||
desc = [CPString stringWithFormat:@"CGInset: { top:%f, right:%f, bottom:%f, left:%f }", anObject.top, anObject.right, anObject.bottom, anObject.left];
|
||||
else
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
@import "CPKeyedUnarchiver.j"
|
||||
@import "CPKeyValueCoding.j"
|
||||
@import "CPKeyValueObserving.j"
|
||||
@import "CPLocale.j"
|
||||
@import "CPMutableArray.j"
|
||||
@import "CPMutableSet.j"
|
||||
@import "CPNotification.j"
|
||||
|
||||
@@ -27,8 +27,9 @@ var CFBundleUnloaded = 0,
|
||||
CFBundleLoadingSpritedImages = 1 << 3,
|
||||
CFBundleLoaded = 1 << 4;
|
||||
|
||||
var CFBundlesForURLStrings = { },
|
||||
CFBundlesForClasses = { },
|
||||
var CFBundlesForURLStrings = { },
|
||||
CFBundlesForClasses = { },
|
||||
CFBundlesWithIdentifiers = { },
|
||||
CFCacheBuster = new Date().getTime(),
|
||||
CFTotalBytesLoaded = 0,
|
||||
CPApplicationSizeInBytes = 0;
|
||||
@@ -108,8 +109,9 @@ function addClassToBundle(aClass, aBundle)
|
||||
|
||||
function resetBundle()
|
||||
{
|
||||
CFBundlesForURLStrings = { };
|
||||
CFBundlesForClasses = { };
|
||||
CFBundlesForURLStrings = { };
|
||||
CFBundlesForClasses = { };
|
||||
CFBundlesWithIdentifiers = { };
|
||||
//CFCacheBuster = new Date().getTime(),
|
||||
CFTotalBytesLoaded = 0;
|
||||
CPApplicationSizeInBytes = 0;
|
||||
@@ -122,9 +124,16 @@ CFBundle.bundleForClass = function(/*Class*/ aClass)
|
||||
|
||||
DISPLAY_NAME(CFBundle.bundleForClass);
|
||||
|
||||
CFBundle.bundleWithIdentifier = function(/*String*/ bundleID)
|
||||
{
|
||||
return CFBundlesWithIdentifiers[bundleID] || NULL;
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFBundle.bundleWithIdentifier);
|
||||
|
||||
CFBundle.prototype.bundleURL = function()
|
||||
{
|
||||
return this._bundleURL;
|
||||
return this._bundleURL.absoluteURL();
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.bundleURL);
|
||||
@@ -192,6 +201,13 @@ CFBundle.prototype.valueForInfoDictionaryKey = function(/*String*/ aKey)
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.valueForInfoDictionaryKey);
|
||||
|
||||
CFBundle.prototype.identifier = function()
|
||||
{
|
||||
return this._infoDictionary.valueForKey("CPBundleIdentifier");
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.identifier);
|
||||
|
||||
CFBundle.prototype.hasSpritedImages = function()
|
||||
{
|
||||
var environments = this._infoDictionary.valueForKey("CPBundleEnvironmentsWithImageSprites") || [],
|
||||
@@ -269,7 +285,7 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
|
||||
StaticResource.resolveResourceAtURL(parentURL, YES, function(aStaticResource)
|
||||
{
|
||||
var resourceName = bundleURL.absoluteURL().lastPathComponent();
|
||||
var resourceName = bundleURL.lastPathComponent();
|
||||
|
||||
self._staticResource = aStaticResource._children[resourceName] ||
|
||||
new StaticResource(bundleURL, aStaticResource, YES, NO);
|
||||
@@ -283,8 +299,15 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
self._isValid = !!infoDictionary || CFBundle.mainBundle() === self;
|
||||
|
||||
if (infoDictionary)
|
||||
{
|
||||
self._infoDictionary = infoDictionary;
|
||||
|
||||
var identifier = self._infoDictionary.valueForKey("CPBundleIdentifier");
|
||||
|
||||
if (identifier)
|
||||
CFBundlesWithIdentifiers[identifier] = self;
|
||||
}
|
||||
|
||||
if (!self._infoDictionary)
|
||||
{
|
||||
finishBundleLoadingWithError(self, new Error("Could not load bundle at \"" + path + "\""));
|
||||
@@ -698,7 +721,7 @@ DISPLAY_NAME(CFBundle.prototype.onerror);
|
||||
|
||||
CFBundle.prototype.bundlePath = function()
|
||||
{
|
||||
return this._bundleURL.absoluteURL().path();
|
||||
return this.bundleURL().path();
|
||||
};
|
||||
|
||||
CFBundle.prototype.path = function()
|
||||
|
||||
@@ -636,12 +636,9 @@
|
||||
var array = [CGRectMake(1, 2, 3, 4), CGPointMake(5, 6)],
|
||||
d = [array description];
|
||||
|
||||
[self assertTrue:d.indexOf("x:1") !== -1 message:"Can't find 'x:1' in description of array " + d];
|
||||
[self assertTrue:d.indexOf("y:2") !== -1 message:"Can't find 'y:2' in description of array " + d];
|
||||
[self assertTrue:d.indexOf("width:3") !== -1 message:"Can't find 'width:3' in description of array " + d];
|
||||
[self assertTrue:d.indexOf("height:4") !== -1 message:"Can't find 'height:4' in description of array " + d];
|
||||
[self assertTrue:d.indexOf("x:5") !== -1 message:"Can't find 'x:5' in description of array " + d];
|
||||
[self assertTrue:d.indexOf("y:6") !== -1 message:"Can't find 'y:6' in description of array " + d];
|
||||
[self assertTrue:d.indexOf("(1, 2)") !== -1 message:"Can't find '(1, 2)' in description of array " + d];
|
||||
[self assertTrue:d.indexOf("(3, 4)") !== -1 message:"Can't find '(3, 4)' in description of array " + d];
|
||||
[self assertTrue:d.indexOf("(5, 6)") !== -1 message:"Can't find '(5, 6)' in description of array " + d];
|
||||
}
|
||||
|
||||
- (void)testSortUsingDescriptorsWithDifferentSelectors
|
||||
|
||||
@@ -392,12 +392,9 @@
|
||||
var dict = [[CPDictionary alloc] initWithObjects:[CGRectMake(1, 2, 3, 4), CGPointMake(5, 6)] forKeys:[@"key1", @"key2"]],
|
||||
d = [dict description];
|
||||
|
||||
[self assertTrue:d.indexOf("x:1") !== -1 message:"Can't find 'x: 1' in description of dictionary " + d];
|
||||
[self assertTrue:d.indexOf("y:2") !== -1 message:"Can't find 'y: 2' in description of dictionary " + d];
|
||||
[self assertTrue:d.indexOf("width:3") !== -1 message:"Can't find 'width: 3' in description of dictionary " + d];
|
||||
[self assertTrue:d.indexOf("height:4") !== -1 message:"Can't find 'height: 4' in description of dictionary " + d];
|
||||
[self assertTrue:d.indexOf("x:5") !== -1 message:"Can't find 'x: 5' in description of dictionary " + d];
|
||||
[self assertTrue:d.indexOf("y:6") !== -1 message:"Can't find 'y: 6' in description of dictionary " + d];
|
||||
[self assertTrue:d.indexOf("(1, 2)") !== -1 message:"Can't find '(1, 2)' in description of dictionary " + d];
|
||||
[self assertTrue:d.indexOf("(3, 4)") !== -1 message:"Can't find '(3, 4)' in description of dictionary " + d];
|
||||
[self assertTrue:d.indexOf("(5, 6)") !== -1 message:"Can't find '(5, 6)' in description of dictionary " + d];
|
||||
|
||||
[self assert:'@{\n @"key1": @[\n @"1",\n @"2",\n @"3"\n ],\n @"key2": @"This is a string",\n @"key3": @{\n @"another": @"object"\n }\n}' equals:[json_dict description]];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* CPDatePickerTest
|
||||
*
|
||||
* Created by You on March 15, 2013.
|
||||
* Copyright 2013, Your Company All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
|
||||
|
||||
|
||||
@implementation AppController : CPObject
|
||||
{
|
||||
@outlet CPWindow theWindow;
|
||||
|
||||
@outlet CPDatePicker pickerTarget;
|
||||
@outlet CPDatePicker pickerMinDate;
|
||||
@outlet CPDatePicker pickerMaxDate;
|
||||
@outlet CPDatePicker pickerCurrentDate;
|
||||
@outlet CPPopUpButton buttonStyle;
|
||||
@outlet CPPopUpButton buttonElementsDate;
|
||||
@outlet CPPopUpButton buttonElementsTime;
|
||||
}
|
||||
|
||||
// - (void)awakeFromCib
|
||||
// {
|
||||
// [theWindow setFullPlatformWindow:YES];
|
||||
// }
|
||||
|
||||
- (IBAction)updateHasMinConstraint:(id)aSender
|
||||
{
|
||||
[pickerMinDate setDateValue:[CPDate distantPast]];
|
||||
|
||||
if ([aSender state] == CPOffState)
|
||||
[pickerMinDate setEnabled:NO];
|
||||
else
|
||||
[pickerMinDate setEnabled:YES];
|
||||
|
||||
}
|
||||
|
||||
- (IBAction)updateHasMaxConstraint:(id)aSender
|
||||
{
|
||||
[pickerMaxDate setDateValue:[CPDate distantFuture]];
|
||||
|
||||
if ([aSender state] == CPOffState)
|
||||
[pickerMaxDate setEnabled:NO];
|
||||
else
|
||||
[pickerMaxDate setEnabled:YES];
|
||||
}
|
||||
|
||||
- (IBAction)updateElements:(id)aSender
|
||||
{
|
||||
var elemDate = [[buttonElementsDate selectedItem] tag],
|
||||
elemTime = [[buttonElementsTime selectedItem] tag],
|
||||
mask;
|
||||
|
||||
mask = 0x0;
|
||||
|
||||
if (elemDate == 1)
|
||||
mask |= CPYearMonthDatePickerElementFlag;
|
||||
if (elemDate == 2)
|
||||
mask |= CPYearMonthDayDatePickerElementFlag;
|
||||
|
||||
if (elemTime == 1)
|
||||
mask |= CPHourMinuteDatePickerElementFlag;
|
||||
if (elemTime == 2)
|
||||
mask |= CPHourMinuteSecondDatePickerElementFlag;
|
||||
|
||||
[pickerTarget setDatePickerElements:mask];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Main cib file base name</key>
|
||||
<string>MainMenu.cib</string>
|
||||
<key>CPBundleName</key>
|
||||
<string>CPDatePickerTest</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Jakefile
|
||||
* CPDatePickerTest
|
||||
*
|
||||
* Created by You on March 15, 2013.
|
||||
* Copyright 2013, Your Company All rights reserved.
|
||||
*/
|
||||
|
||||
var ENV = require("system").env,
|
||||
FILE = require("file"),
|
||||
JAKE = require("jake"),
|
||||
task = JAKE.task,
|
||||
FileList = JAKE.FileList,
|
||||
app = require("cappuccino/jake").app,
|
||||
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
|
||||
OS = require("os");
|
||||
|
||||
app ("CPDatePickerTest", function(task)
|
||||
{
|
||||
task.setBuildIntermediatesPath(FILE.join("Build", "CPDatePickerTest.build", configuration));
|
||||
task.setBuildPath(FILE.join("Build", configuration));
|
||||
|
||||
task.setProductName("CPDatePickerTest");
|
||||
task.setIdentifier("com.yourcompany.CPDatePickerTest");
|
||||
task.setVersion("1.0");
|
||||
task.setAuthor("Your Company");
|
||||
task.setEmail("feedback @nospam@ yourcompany.com");
|
||||
task.setSummary("CPDatePickerTest");
|
||||
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
|
||||
task.setResources(new FileList("Resources/**"));
|
||||
task.setIndexFilePath("index.html");
|
||||
task.setInfoPlistPath("Info.plist");
|
||||
task.setNib2CibFlags("-R Resources/");
|
||||
|
||||
if (configuration === "Debug")
|
||||
task.setCompilerFlags("-DDEBUG -g");
|
||||
else
|
||||
task.setCompilerFlags("-O");
|
||||
});
|
||||
|
||||
task ("default", ["CPDatePickerTest"], function()
|
||||
{
|
||||
printResults(configuration);
|
||||
});
|
||||
|
||||
task ("build", ["default"]);
|
||||
|
||||
task ("debug", function()
|
||||
{
|
||||
ENV["CONFIGURATION"] = "Debug";
|
||||
JAKE.subjake(["."], "build", ENV);
|
||||
});
|
||||
|
||||
task ("release", function()
|
||||
{
|
||||
ENV["CONFIGURATION"] = "Release";
|
||||
JAKE.subjake(["."], "build", ENV);
|
||||
});
|
||||
|
||||
task ("run", ["debug"], function()
|
||||
{
|
||||
OS.system(["open", FILE.join("Build", "Debug", "CPDatePickerTest", "index.html")]);
|
||||
});
|
||||
|
||||
task ("run-release", ["release"], function()
|
||||
{
|
||||
OS.system(["open", FILE.join("Build", "Release", "CPDatePickerTest", "index.html")]);
|
||||
});
|
||||
|
||||
task ("deploy", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Deployment", "CPDatePickerTest"));
|
||||
OS.system(["press", "-f", FILE.join("Build", "Release", "CPDatePickerTest"), FILE.join("Build", "Deployment", "CPDatePickerTest")]);
|
||||
printResults("Deployment")
|
||||
});
|
||||
|
||||
task ("desktop", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Desktop", "CPDatePickerTest"));
|
||||
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPDatePickerTest"), FILE.join("Build", "Desktop", "CPDatePickerTest", "CPDatePickerTest.app"));
|
||||
printResults("Desktop")
|
||||
});
|
||||
|
||||
task ("run-desktop", ["desktop"], function()
|
||||
{
|
||||
OS.system([FILE.join("Build", "Desktop", "CPDatePickerTest", "CPDatePickerTest.app", "Contents", "MacOS", "NativeHost"), "-i"]);
|
||||
});
|
||||
|
||||
function printResults(configuration)
|
||||
{
|
||||
print("----------------------------");
|
||||
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPDatePickerTest"));
|
||||
print("----------------------------");
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<!--
|
||||
index-debug.html
|
||||
CPDatePickerTest
|
||||
|
||||
Created by You on March 15, 2013.
|
||||
Copyright 2013, Your Company All rights reserved.
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
|
||||
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||
|
||||
<link rel="apple-touch-icon" href="Resources/icon.png" />
|
||||
<link rel="apple-touch-startup-image" href="Resources/default.png" />
|
||||
|
||||
<title>CPDatePickerTest</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
OBJJ_MAIN_FILE = "main.j";
|
||||
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks"];
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
objj_msgSend_reset();
|
||||
|
||||
// DEBUG OPTIONS:
|
||||
|
||||
// Uncomment to enable printing of backtraces on exceptions:
|
||||
//objj_msgSend_decorate(objj_backtrace_decorator);
|
||||
|
||||
// Uncomment to supress exceptions that take place inside a message
|
||||
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
|
||||
|
||||
// Uncomment to enable runtime type checking:
|
||||
//objj_msgSend_decorate(objj_typecheck_decorator);
|
||||
|
||||
// Uncomment (along with both above) to print backtraces on type check errors:
|
||||
//objj_typecheck_prints_backtrace = true;
|
||||
|
||||
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
|
||||
//CPLogUnregister(CPLogDefault);
|
||||
|
||||
// Uncomment to enable a specific logger:
|
||||
//CPLogRegister(CPLogConsole);
|
||||
//CPLogRegister(CPLogPopup);
|
||||
|
||||
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
|
||||
// the class name of the view that created them. Comment this or set to false to disable.
|
||||
appkit_tag_dom_elements = true;
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
body{margin:0; padding:0;}
|
||||
#container {position: absolute; top:50%; left:50%;}
|
||||
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
|
||||
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
|
||||
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
|
||||
</style>
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<STYLE type="text/css">
|
||||
#container { position: relative; top: 50%; }
|
||||
#content { position: relative;}
|
||||
</STYLE>
|
||||
<![endif]-->
|
||||
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div id="cappuccino-body">
|
||||
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
|
||||
<script type="text/javascript">
|
||||
document.write("<div id='container'><p id='content'>" +
|
||||
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
|
||||
"Loading CPDatePickerTest...</p></div>");
|
||||
</script>
|
||||
|
||||
<noscript>
|
||||
<div id="container">
|
||||
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
|
||||
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
|
||||
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino-project.org/noscript">Show me how to enable JavaScript</a></p>
|
||||
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
|
||||
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
|
||||
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
|
||||
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
|
||||
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
|
||||
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
|
||||
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</noscript>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<!--
|
||||
index.html
|
||||
CPDatePickerTest
|
||||
|
||||
Created by You on March 15, 2013.
|
||||
Copyright 2013, Your Company All rights reserved.
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
|
||||
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||
|
||||
<link rel="apple-touch-icon" href="Resources/icon.png" />
|
||||
<link rel="apple-touch-startup-image" href="Resources/default.png" />
|
||||
|
||||
<title>CPDatePickerTest</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
OBJJ_MAIN_FILE = "main.j";
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body{margin:0; padding:0;}
|
||||
#container {position: absolute; top:50%; left:50%;}
|
||||
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
|
||||
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
|
||||
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
|
||||
</style>
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<STYLE type="text/css">
|
||||
#container { position: relative; top: 50%; }
|
||||
#content { position: relative;}
|
||||
</STYLE>
|
||||
<![endif]-->
|
||||
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div id="cappuccino-body">
|
||||
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
|
||||
<script type="text/javascript">
|
||||
document.write("<div id='container'><p id='content'>" +
|
||||
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
|
||||
"Loading CPDatePickerTest...</p></div>");
|
||||
</script>
|
||||
|
||||
<noscript>
|
||||
<div id="container">
|
||||
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
|
||||
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
|
||||
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino-project.org/noscript">Show me how to enable JavaScript</a></p>
|
||||
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
|
||||
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
|
||||
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
|
||||
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
|
||||
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
|
||||
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
|
||||
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</noscript>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* CPDatePickerTest
|
||||
*
|
||||
* Created by You on March 15, 2013.
|
||||
* Copyright 2013, Your Company All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
|
||||
@import "AppController.j"
|
||||
|
||||
|
||||
function main(args, namedArgs)
|
||||
{
|
||||
CPApplicationMain(args, namedArgs);
|
||||
}
|
||||
@@ -22,6 +22,9 @@ def update_general_include(project, projectBaseURL):
|
||||
def add_file(project, shadowGroup, sourceGroup, shadowHeaderPath, shadowImplementationFilePath, sourcePath, projectBaseURL):
|
||||
project.add_file(shadowHeaderPath, parent=shadowGroup)
|
||||
project.add_file(shadowImplementationFilePath, parent=shadowGroup)
|
||||
|
||||
if sourcePath in project.get_files_by_os_path(os.path.relpath(sourcePath, projectBaseURL)):
|
||||
return
|
||||
project.add_file(sourcePath, parent=sourceGroup)
|
||||
|
||||
def remove_file(project, shadowGroup, sourceGroup, shadowHeaderPath, shadowImplementationFilePath, sourcePath, projectBaseURL):
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
<string>6.0</string>
|
||||
<key>CPBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CPPrincipalClass</key>
|
||||
<string>__project.nameasidentifier__</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -6,5 +6,9 @@
|
||||
<string>MainMenu.cib</string>
|
||||
<key>CPBundleName</key>
|
||||
<string>__project.name__</string>
|
||||
<key>CPBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>CPHumanReadableCopyright</key>
|
||||
<string>Copyright © __project.year__, __organization.name__ All rights reserved.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -30,7 +30,6 @@ app ("__project.nameasidentifier__", function(task)
|
||||
task.setResources(new FileList("Resources/**"));
|
||||
task.setIndexFilePath("index.html");
|
||||
task.setInfoPlistPath("Info.plist");
|
||||
task.setNib2CibFlags("-R Resources/");
|
||||
|
||||
if (configuration === "Debug")
|
||||
task.setCompilerFlags("-DDEBUG -g");
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
require ("../../common.jake");
|
||||
|
||||
var OS = require("os"),
|
||||
task = require("jake").task;
|
||||
task = require("jake").task,
|
||||
SYSTEM = require("system");
|
||||
|
||||
task ("build", function()
|
||||
{
|
||||
@@ -16,7 +17,7 @@ task ("build", function()
|
||||
else
|
||||
args = "-sdk macosx " + args;
|
||||
|
||||
var xcodebuild = env.CAPP_BUILD ? "xcodebuild " : "CAPP_BUILD=../../Build xcodebuild ";
|
||||
var xcodebuild = SYSTEM.env.CAPP_BUILD ? "xcodebuild " : "CAPP_BUILD=../../Build xcodebuild ";
|
||||
|
||||
if (OS.system(xcodebuild + args))
|
||||
OS.exit(1);
|
||||
|
||||
@@ -20,17 +20,18 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
@import "Converter.j"
|
||||
@import "Nib2CibKeyedUnarchiver.j"
|
||||
@import "NSFont.j"
|
||||
|
||||
@class Nib2Cib
|
||||
|
||||
@implementation Converter (Mac)
|
||||
|
||||
- (void)convertedDataFromMacData:(CPData)data resourcesPath:(CPString)aResourcesPath
|
||||
- (void)convertedDataFromMacData:(CPData)data
|
||||
{
|
||||
// Unarchive the NS data
|
||||
var unarchiver = [[Nib2CibKeyedUnarchiver alloc] initForReadingWithData:data resourcesPath:aResourcesPath],
|
||||
var unarchiver = [[Nib2CibKeyedUnarchiver alloc] initForReadingWithData:data],
|
||||
objectData = [unarchiver decodeObjectForKey:@"IB.objectdata"],
|
||||
objects = [unarchiver allObjects],
|
||||
count = [objects count];
|
||||
@@ -107,7 +108,8 @@
|
||||
// nil cibFont means try to use theme font
|
||||
if (!cibFont)
|
||||
{
|
||||
var bold = [nibFont isBold];
|
||||
var bold = [nibFont isBold],
|
||||
themes = [[Nib2Cib sharedNib2Cib] themes];
|
||||
|
||||
for (var i = 0; i < themes.length; ++i)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
@import "NSFoundation.j"
|
||||
@import "NSAppKit.j"
|
||||
|
||||
@class Nib2Cib
|
||||
|
||||
@global java
|
||||
|
||||
var FILE = require("file"),
|
||||
@@ -48,13 +50,8 @@ ConverterConversionException = @"ConverterConversionException";
|
||||
|
||||
@implementation Converter : CPObject
|
||||
{
|
||||
CPString inputPath @accessors(readonly);
|
||||
CPString outputPath @accessors;
|
||||
CPString resourcesPath @accessors;
|
||||
NibFormat format @accessors(readonly);
|
||||
CPArray themes @accessors(readonly);
|
||||
CPArray userNSClasses @accessors;
|
||||
BOOL compileNib @accessors;
|
||||
CPString inputPath @accessors(readonly);
|
||||
CPString outputPath @accessors;
|
||||
}
|
||||
|
||||
+ (Converter)sharedConverter
|
||||
@@ -62,59 +59,52 @@ ConverterConversionException = @"ConverterConversionException";
|
||||
return SharedConverter;
|
||||
}
|
||||
|
||||
- (id)initWithInputPath:(CPString)aPath format:(NibFormat)nibFormat themes:(CPArray)themeList
|
||||
- (id)initWithInputPath:(CPString)anInputPath outputPath:(CPString)anOutputPath
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
SharedConverter = self;
|
||||
inputPath = aPath;
|
||||
format = nibFormat;
|
||||
themes = themeList;
|
||||
compileNib = YES;
|
||||
if (!SharedConverter)
|
||||
SharedConverter = self;
|
||||
|
||||
inputPath = anInputPath;
|
||||
outputPath = anOutputPath;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)convert
|
||||
- (CPData)convert
|
||||
{
|
||||
if ([resourcesPath length] && !FILE.isReadable(resourcesPath))
|
||||
[CPException raise:ConverterConversionException reason:@"Could not read Resources at path \"" + resourcesPath + "\""];
|
||||
// Assume its a Mac file.
|
||||
var inferredFormat = NibFormatMac;
|
||||
|
||||
var inferredFormat = format;
|
||||
// Some .xibs are iPhone nibs, check the actual contents in this case.
|
||||
if (FILE.extension(inputPath) !== ".nib" && FILE.isFile(inputPath) &&
|
||||
FILE.read(inputPath, { charset:"UTF-8" }).indexOf("<archive type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\"") !== -1)
|
||||
inferredFormat = NibFormatIPhone;
|
||||
|
||||
if (inferredFormat === NibFormatUndetermined)
|
||||
{
|
||||
// Assume its a Mac file.
|
||||
inferredFormat = NibFormatMac;
|
||||
if (inferredFormat === NibFormatMac)
|
||||
CPLog.info("Auto-detected Cocoa nib or xib File");
|
||||
else
|
||||
CPLog.info("Auto-detected CocoaTouch xib File");
|
||||
|
||||
// Some .xibs are iPhone nibs, check the actual contents in this case.
|
||||
if (FILE.extension(inputPath) !== ".nib" && FILE.isFile(inputPath) &&
|
||||
FILE.read(inputPath, { charset:"UTF-8" }).indexOf("<archive type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\"") !== -1)
|
||||
inferredFormat = NibFormatIPhone;
|
||||
|
||||
if (inferredFormat === NibFormatMac)
|
||||
CPLog.info("Auto-detected Cocoa Nib or Xib File");
|
||||
else
|
||||
CPLog.info("Auto-detected CocoaTouch Xib File");
|
||||
}
|
||||
|
||||
CPLog.info("Converting Xib file to plist...");
|
||||
CPLog.info("Converting xib file to plist...");
|
||||
|
||||
var nibData = [self CPCompliantNibDataAtFilePath:inputPath];
|
||||
|
||||
if (inferredFormat === NibFormatMac)
|
||||
var convertedData = [self convertedDataFromMacData:nibData resourcesPath:resourcesPath];
|
||||
var convertedData = [self convertedDataFromMacData:nibData];
|
||||
else
|
||||
[CPException raise:ConverterConversionException reason:@"nib2cib does not understand this nib format."];
|
||||
|
||||
if (![outputPath length])
|
||||
outputPath = inputPath.substr(0, inputPath.length - FILE.extension(inputPath).length) + ".cib";
|
||||
if ([outputPath length])
|
||||
FILE.write(outputPath, [convertedData rawString], { charset:"UTF-8" });
|
||||
|
||||
FILE.write(outputPath, [convertedData rawString], { charset:"UTF-8" });
|
||||
CPLog.info(CPLogColorize("Conversion successful", "warn"));
|
||||
|
||||
return convertedData;
|
||||
}
|
||||
|
||||
- (CPData)CPCompliantNibDataAtFilePath:(CPString)aFilePath
|
||||
@@ -124,7 +114,7 @@ ConverterConversionException = @"ConverterConversionException";
|
||||
|
||||
try
|
||||
{
|
||||
if (compileNib)
|
||||
if ([outputPath length])
|
||||
{
|
||||
// Compile xib or nib to make sure we have a non-new format nib.
|
||||
temporaryNibFilePath = FILE.join("/tmp", FILE.basename(aFilePath) + ".tmp.nib");
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
@import "NSCustomObject.j"
|
||||
@import "NSCustomResource.j"
|
||||
@import "NSCustomView.j"
|
||||
@import "NSDatePicker.j"
|
||||
@import "NSDictionaryController.j"
|
||||
@import "NSEvent.j"
|
||||
@import "NSFont.j"
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
@import "NSCell.j"
|
||||
@import "NSControl.j"
|
||||
|
||||
@class Converter
|
||||
@class Nib2Cib
|
||||
|
||||
@global NIB_CONNECTION_EQUIVALENCY_TABLE
|
||||
|
||||
@@ -217,7 +217,7 @@ var NSButtonIsBorderedMask = 0x00800000,
|
||||
- If there is just a max height, use that for only for fixed height buttons.
|
||||
- If there is no max height either, don't do any height adjustments.
|
||||
*/
|
||||
var theme = [[Converter sharedConverter] themes][0],
|
||||
var theme = [Nib2Cib defaultTheme],
|
||||
minSize = [theme valueForAttributeWithName:@"min-size" forClass:[self class]],
|
||||
maxSize = [theme valueForAttributeWithName:@"max-size" forClass:[self class]],
|
||||
adjustHeight = NO;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
@import <Foundation/CPString.j>
|
||||
@import <AppKit/_CPCibClassSwapper.j>
|
||||
|
||||
@class Converter
|
||||
@class Nib2Cib
|
||||
|
||||
@global CP_NSMapClassName
|
||||
|
||||
@@ -48,7 +48,7 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
|
||||
// If this is a userland NS class, call its KVC methods directly
|
||||
var nsClass = nil;
|
||||
|
||||
if ([[[Converter sharedConverter] userNSClasses] containsObject:aClassName])
|
||||
if ([[[Nib2Cib sharedNib2Cib] userNSClasses] containsObject:aClassName])
|
||||
nsClass = objj_lookUpClass("NS_" + aClassName);
|
||||
|
||||
var originalClass = nsClass || objj_lookUpClass(anOriginalClassName);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
@import "NSTextField.j"
|
||||
|
||||
@class Converter
|
||||
@class Nib2Cib
|
||||
|
||||
|
||||
@implementation CPComboBox (NSCoding)
|
||||
@@ -48,12 +48,13 @@
|
||||
[self setEnabled:[cell isEnabled]];
|
||||
|
||||
// Make sure the height is clipped to the max given by the theme
|
||||
var maxSize = [[[Converter sharedConverter] themes][0] valueForAttributeWithName:@"max-size" forClass:[CPComboBox class]],
|
||||
var theme = [Nib2Cib defaultTheme],
|
||||
maxSize = [theme valueForAttributeWithName:@"max-size" forClass:[CPComboBox class]],
|
||||
size = [self frameSize],
|
||||
widthOffset = -3;
|
||||
|
||||
// Adjust for differences between Cocoa and Cappuccino widget framing.
|
||||
if ([[[Converter sharedConverter] themes][0] name] == @"Aristo")
|
||||
if ([theme name] == @"Aristo")
|
||||
{
|
||||
_frame.origin.x += 1;
|
||||
widthOffset = -5;
|
||||
|
||||
@@ -41,7 +41,8 @@ var FILE = require("file"),
|
||||
_className = CP_NSMapClassName([aCoder decodeObjectForKey:@"NSClassName"]);
|
||||
_resourceName = [aCoder decodeObjectForKey:@"NSResourceName"];
|
||||
|
||||
var size = CGSizeMakeZero();
|
||||
var size = CGSizeMakeZero(),
|
||||
framework = @"";
|
||||
|
||||
if (_resourceName == "NSSwitch")
|
||||
return nil;
|
||||
@@ -50,27 +51,49 @@ var FILE = require("file"),
|
||||
// Defer resolving this path until runtime.
|
||||
_resourceName = _resourceName.replace("NS", "CP");
|
||||
}
|
||||
else if (![[aCoder resourcesPath] length])
|
||||
{
|
||||
CPLog.warn("Resources found in nib, but no resources path specified with -R option.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var resourcePath = [aCoder resourcePathForName:_resourceName];
|
||||
var match = /^(.+)@(.+)$/.exec(_resourceName),
|
||||
framework = @"",
|
||||
bundleIdentifier = @"";
|
||||
|
||||
if (!resourcePath)
|
||||
CPLog.warn("Resource \"" + _resourceName + "\" not found in the resources path: " + [aCoder resourcesPath]);
|
||||
if (match)
|
||||
{
|
||||
framework = match[1];
|
||||
_resourceName = match[2];
|
||||
}
|
||||
|
||||
var resourceInfo = [aCoder resourceInfoForName:_resourceName inFramework:framework];
|
||||
|
||||
if (!resourceInfo)
|
||||
CPLog.warn("Resource \"" + _resourceName + "\" not found in the Resources directories");
|
||||
else
|
||||
size = imageSize(FILE.canonical(resourcePath)) || CGSizeMakeZero();
|
||||
{
|
||||
size = imageSize(FILE.canonical(resourceInfo.path)) || CGSizeMakeZero();
|
||||
framework = resourceInfo.framework;
|
||||
}
|
||||
|
||||
// Account for the fact that an extension may have been inferred.
|
||||
if (resourcePath && FILE.extension(resourcePath) !== FILE.extension(_resourceName))
|
||||
_resourceName += FILE.extension(resourcePath);
|
||||
if (resourceInfo &&
|
||||
resourceInfo.path &&
|
||||
FILE.extension(resourceInfo.path) !== FILE.extension(_resourceName))
|
||||
{
|
||||
_resourceName += FILE.extension(resourceInfo.path);
|
||||
}
|
||||
|
||||
CPLog.debug(" Path: %s\n Size: %d x %d", FILE.canonical(resourcePath), size.width, size.height);
|
||||
CPLog.debug(" Resource: %s\n Framework: %s\n Path: %s\n Size: %d x %d", _resourceName, framework, resourceInfo ? FILE.canonical(resourceInfo.path) : "", size.width, size.height);
|
||||
}
|
||||
|
||||
_properties = [CPDictionary dictionaryWithObject:size forKey:@"size"];
|
||||
if (resourceInfo && resourceInfo.path && resourceInfo.framework)
|
||||
{
|
||||
var frameworkPath = FILE.dirname(FILE.dirname(resourceInfo.path)),
|
||||
bundle = [CPBundle bundleWithPath:frameworkPath];
|
||||
|
||||
[bundle loadWithDelegate:nil];
|
||||
bundleIdentifier = [bundle bundleIdentifier] || @"";
|
||||
}
|
||||
|
||||
_properties = @{ @"size":size, @"bundleIdentifier":bundleIdentifier, @"framework":framework };
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* NSDatePicker.j
|
||||
* nib2cib
|
||||
*
|
||||
* Created by cacaodev.
|
||||
*
|
||||
* 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/CPDate.j>
|
||||
|
||||
@implementation NSDate : CPDate
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
var interval = [aCoder decodeDoubleForKey:@"NS.time"] || 0;
|
||||
|
||||
return [CPDate dateWithTimeIntervalSinceReferenceDate:interval];
|
||||
}
|
||||
|
||||
- (Class)classForKeyedArchiver
|
||||
{
|
||||
return [CPDate class];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* NSDatePicker.j
|
||||
* nib2cib
|
||||
*
|
||||
* Created by cacaodev.
|
||||
*
|
||||
* 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/CPDatePicker.j>
|
||||
@import <Foundation/CPDate.j>
|
||||
|
||||
@import "NSCell.j"
|
||||
|
||||
@class Nib2Cib
|
||||
|
||||
@global CPTextFieldDatePickerStyle
|
||||
@global CPTextFieldAndStepperDatePickerStyle
|
||||
@global CPClockAndCalendarDatePickerStyle
|
||||
@global CPHourMinuteSecondDatePickerElementFlag
|
||||
@global CPHourMinuteDatePickerElementFlag
|
||||
@global IBDefaultFontFace
|
||||
@global IBDefaultFontSize
|
||||
|
||||
var NSDatePickerDefaultSize = 22,
|
||||
NSDatePickerCalendarDefaultSize = 148;
|
||||
|
||||
@implementation CPDatePicker (NSCoding)
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super NS_initWithCoder:aCoder];
|
||||
|
||||
var cell = [aCoder decodeObjectForKey:@"NSCell"];
|
||||
_minDate = [cell minDate];
|
||||
_maxDate = [cell maxDate];
|
||||
_timeInterval = [cell timeInterval];
|
||||
_datePickerMode = [cell datePickerMode];
|
||||
_datePickerElements = [cell datePickerElements];
|
||||
_datePickerStyle = [cell datePickerType];
|
||||
_dateValue = [cell objectValue];
|
||||
_backgroundColor = [cell backgroundColor];
|
||||
_drawsBackground = [cell drawsBackground];
|
||||
|
||||
[self setBezeled:[cell isBezeled]];
|
||||
[self setBordered:[cell isBordered]];
|
||||
|
||||
var theme = [Nib2Cib defaultTheme];
|
||||
|
||||
if (_datePickerStyle != CPClockAndCalendarDatePickerStyle)
|
||||
{
|
||||
var minSize = [theme valueForAttributeWithName:@"min-size" forClass:[self class]],
|
||||
maxSize = [theme valueForAttributeWithName:@"max-size" forClass:[self class]];
|
||||
|
||||
if (minSize.height > 0)
|
||||
{
|
||||
_frame.size.height = MAX(_frame.size.height, minSize.height);
|
||||
_bounds.size.height = MAX(_frame.size.height, minSize.height);
|
||||
}
|
||||
|
||||
if (maxSize.height > 0)
|
||||
{
|
||||
_frame.size.height = MIN(_frame.size.height, maxSize.height);
|
||||
_bounds.size.height = MIN(_frame.size.height, maxSize.height);
|
||||
}
|
||||
|
||||
if (minSize.width > 0)
|
||||
{
|
||||
_frame.size.width = MAX(_frame.size.width, minSize.width);
|
||||
_bounds.size.width = MAX(_frame.size.width, minSize.width);
|
||||
}
|
||||
|
||||
if (maxSize.width > 0)
|
||||
{
|
||||
_frame.size.width = MIN(_frame.size.width, maxSize.width);
|
||||
_bounds.size.width = MAX(_frame.size.width, minSize.width);
|
||||
}
|
||||
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle)
|
||||
{
|
||||
_frame.size.width -= 3;
|
||||
_bounds.size.width -= 3;
|
||||
}
|
||||
|
||||
_frame.origin.y -= _frame.size.height - NSDatePickerDefaultSize - 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
var minSize = [theme valueForAttributeWithName:@"min-size-calendar" forClass:[self class]],
|
||||
maxSize = [theme valueForAttributeWithName:@"max-size-calendar" forClass:[self class]],
|
||||
sizeClock = [theme valueForAttributeWithName:@"size-clock" forClass:[self class]];
|
||||
|
||||
if (_datePickerElements & CPHourMinuteSecondDatePickerElementFlag || _datePickerElements & CPHourMinuteDatePickerElementFlag)
|
||||
{
|
||||
minSize.width += sizeClock.width + 10;
|
||||
maxSize.width += sizeClock.width + 10;
|
||||
}
|
||||
|
||||
if (minSize.height > 0)
|
||||
{
|
||||
_frame.size.height = MAX(_frame.size.height, minSize.height);
|
||||
_bounds.size.height = MAX(_frame.size.height, minSize.height);
|
||||
}
|
||||
|
||||
if (maxSize.height > 0)
|
||||
{
|
||||
_frame.size.height = MIN(_frame.size.height, maxSize.height);
|
||||
_bounds.size.height = MIN(_frame.size.height, maxSize.height);
|
||||
}
|
||||
|
||||
if (minSize.width > 0)
|
||||
{
|
||||
_frame.size.width = MAX(_frame.size.width, minSize.width);
|
||||
_bounds.size.width = MAX(_frame.size.width, minSize.width);
|
||||
}
|
||||
|
||||
if (maxSize.width > 0)
|
||||
{
|
||||
_frame.size.width = MIN(_frame.size.width, maxSize.width);
|
||||
_bounds.size.width = MAX(_frame.size.width, minSize.width);
|
||||
}
|
||||
|
||||
_frame.origin.y -= _frame.size.height - NSDatePickerCalendarDefaultSize - 1;
|
||||
}
|
||||
|
||||
if ([cell font]._name === IBDefaultFontFace && [[cell font] size] == IBDefaultFontSize)
|
||||
[self setTextFont:[theme valueForAttributeWithName:@"font" forClass:[self class]]];
|
||||
else
|
||||
[self setTextFont:[cell font]];
|
||||
|
||||
|
||||
var textColor = [cell textColor],
|
||||
defaultColor = [self currentValueForThemeAttribute:@"text-color"];
|
||||
|
||||
// Don't change the text color if it is not the default, that messes up the theme lookups later
|
||||
if (![textColor isEqual:defaultColor])
|
||||
[self setTextColor:[cell textColor]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSDatePicker : CPDatePicker
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
return [super NS_initWithCoder:aCoder];
|
||||
}
|
||||
|
||||
- (Class)classForKeyedArchiver
|
||||
{
|
||||
return [CPDatePicker class];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSDatePickerCell : NSCell
|
||||
{
|
||||
BOOL _drawsBackground @accessors(getter=drawsBackground);
|
||||
CPDate _minDate @accessors(getter=minDate);
|
||||
CPDate _maxDate @accessors(getter=maxDate);
|
||||
CPInteger _datePickerMode @accessors(getter=datePickerMode);
|
||||
CPInteger _datePickerElements @accessors(getter=datePickerElements);
|
||||
CPinteger _datePickerType @accessors(getter=datePickerType);
|
||||
double _timeInterval @accessors(getter=timeInterval);
|
||||
CPColor _textColor @accessors(getter=textColor);
|
||||
CPColor _backgroundColor @accessors(getter=backgroundColor);
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super initWithCoder:aCoder];
|
||||
|
||||
if (self)
|
||||
{
|
||||
var flags = [aCoder decodeIntForKey:@"NSCellFlags"],
|
||||
pickerType = [aCoder decodeIntForKey:@"NSDatePickerType"] || 0;
|
||||
|
||||
if ([aCoder decodeIntForKey:@"NSSuppressStepper"] && pickerType != 1)
|
||||
pickerType = 2;
|
||||
|
||||
_timeInterval = [aCoder decodeDoubleForKey:@"NSTimeInterval"] || 0;
|
||||
_datePickerMode = [aCoder decodeIntForKey:@"NSDatePickerMode"] || 0;
|
||||
_datePickerElements = [aCoder decodeIntForKey:@"NSDatePickerElements"] || 0;
|
||||
_datePickerType = pickerType;
|
||||
_minDate = [aCoder decodeObjectForKey:@"NSMinDate"] || [CPDate distantPast];
|
||||
_maxDate = [aCoder decodeObjectForKey:@"NSMaxDate"]|| [CPDate distantFuture];;
|
||||
_textColor = [aCoder decodeObjectForKey:@"NSTextColor"];
|
||||
_backgroundColor = [aCoder decodeObjectForKey:@"NSBackgroundColor"];
|
||||
_isBordered = _isBezeled;
|
||||
|
||||
if ([aCoder containsValueForKey:@"NSDrawsBackground"])
|
||||
_drawsBackground = [aCoder decodeBoolForKey:@"NSDrawsBackground"];
|
||||
else
|
||||
_drawsBackground = YES;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSCalendarDate : CPDate
|
||||
{
|
||||
}
|
||||
|
||||
- (Class)classForKeyedArchiver
|
||||
{
|
||||
return [CPDate class];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -23,6 +23,7 @@
|
||||
@import "NSArray.j"
|
||||
@import "NSAttributedString.j"
|
||||
@import "NSByteCountFormatter.j"
|
||||
@import "NSDate.j"
|
||||
@import "NSDateFormatter.j"
|
||||
@import "NSDictionary.j"
|
||||
@import "NSExpression.j"
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
/*
|
||||
* NSNib.j
|
||||
* nib2cib
|
||||
*
|
||||
* Created by cacaodev.
|
||||
* Copyright 2013, Cappuccino Foundation.
|
||||
*
|
||||
* 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/CPCib.j>
|
||||
|
||||
@class Converter
|
||||
|
||||
var FILE = require("file"),
|
||||
@@ -12,21 +34,15 @@ var FILE = require("file"),
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
// FIXME: change /tmp/ to os.tmpDir() in Node
|
||||
var nibPath = @"/tmp/" + UUID.uuid() + ".nib",
|
||||
data = [aCoder decodeObjectForKey:@"NSNibFileData"],
|
||||
sharedConverter = [Converter sharedConverter];
|
||||
data = [aCoder decodeObjectForKey:@"NSNibFileData"];
|
||||
|
||||
FILE.write(nibPath, data.bytes(), {charset:"UTF-16" });
|
||||
FILE.write(nibPath, data.bytes(), { charset:"UTF-16" });
|
||||
|
||||
var converter = [[Converter alloc] initWithInputPath:""
|
||||
format:[sharedConverter format]
|
||||
themes:[sharedConverter themes]];
|
||||
[converter setCompileNib:NO];
|
||||
var converter = [[Converter alloc] initWithInputPath:nibPath outputPath:nil];
|
||||
|
||||
CPLog.info("Converting sub nib to plist...");
|
||||
|
||||
var nibData = [converter CPCompliantNibDataAtFilePath:nibPath];
|
||||
_data = [converter convertedDataFromMacData:nibData resourcesPath:[sharedConverter resourcesPath]];
|
||||
_data = [converter convert];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
@import <AppKit/CPProgressIndicator.j>
|
||||
|
||||
@class Converter
|
||||
@class Nib2Cib
|
||||
|
||||
var NSProgressIndicatorSpinningFlag = 1 << 12;
|
||||
|
||||
@@ -59,7 +59,7 @@ var NSProgressIndicatorSpinningFlag = 1 << 12;
|
||||
|
||||
if (_style !== CPProgressIndicatorSpinningStyle)
|
||||
{
|
||||
var theme = [[Converter sharedConverter] themes][0],
|
||||
var theme = [Nib2Cib defaultTheme],
|
||||
height = [theme valueForAttributeWithName:@"default-height" forClass:CPProgressIndicator];
|
||||
|
||||
currentFrameSize.height = height;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
@import "NSTextField.j"
|
||||
|
||||
@class Converter
|
||||
@class Nib2Cib
|
||||
|
||||
|
||||
@implementation CPSearchField (NSCoding)
|
||||
@@ -43,7 +43,7 @@
|
||||
[self setSendsWholeSearchString:[cell sendsWholeSearchString]];
|
||||
[self setSendsSearchStringImmediately:[cell sendsSearchStringImmediately]];
|
||||
|
||||
if ([[[Converter sharedConverter] themes][0] name] == @"Aristo" && [self isBezeled])
|
||||
if ([[Nib2Cib defaultTheme] name] === @"Aristo" && [self isBezeled])
|
||||
{
|
||||
// NSTextField.j makes the field +7.0 pixels tall. We want +8.0 to go to 30.
|
||||
var frame = [self frame];
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
@import "NSCell.j"
|
||||
|
||||
@class Converter
|
||||
@class Nib2Cib
|
||||
|
||||
|
||||
@implementation CPSegmentedControl (CPCoding)
|
||||
@@ -68,7 +68,7 @@
|
||||
// Adjust for differences between Cocoa and Cappuccino widget framing.
|
||||
frame.origin.x += 6;
|
||||
|
||||
if ([[[Converter sharedConverter] themes][0] name] == @"Aristo2")
|
||||
if ([[Nib2Cib defaultTheme] name] == @"Aristo2")
|
||||
frame.size.height += 1;
|
||||
|
||||
frame.size.width = originalWidth;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
@import "NSTextField.j"
|
||||
|
||||
@class Converter
|
||||
@class Nib2Cib
|
||||
|
||||
var IBDefaultFontSizeTableHeader = 11.0;
|
||||
|
||||
@@ -63,7 +64,7 @@ var IBDefaultFontSizeTableHeader = 11.0;
|
||||
|
||||
var headerCell = [aCoder decodeObjectForKey:@"NSHeaderCell"],
|
||||
headerView = [[_CPTableColumnHeaderView alloc] initWithFrame:CGRectMakeZero()],
|
||||
theme = [[Converter sharedConverter] themes][0];
|
||||
theme = [Nib2Cib defaultTheme];
|
||||
|
||||
[headerView setStringValue:[headerCell objectValue]];
|
||||
[headerView setFont:[headerCell font]];
|
||||
@@ -124,7 +125,7 @@ var IBDefaultFontSizeTableHeader = 11.0;
|
||||
|
||||
- (id)valueForDataViewThemeAttribute:(CPString)attribute inState:(int)state
|
||||
{
|
||||
var themes = [[Converter sharedConverter] themes];
|
||||
var themes = [[Nib2Cib sharedNib2Cib] themes];
|
||||
|
||||
for (var i = 0; i < themes.length; ++i)
|
||||
{
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
@import <AppKit/CPTableHeaderView.j>
|
||||
|
||||
@class Converter
|
||||
@class CPTableView
|
||||
@class Nib2Cib
|
||||
|
||||
|
||||
@implementation CPTableHeaderView (NSCoding)
|
||||
@@ -37,7 +37,7 @@
|
||||
// change the default height
|
||||
if (_bounds.size.height === 17)
|
||||
{
|
||||
var theme = [[Converter sharedConverter] themes][0],
|
||||
var theme = [Nib2Cib defaultTheme],
|
||||
height = [theme valueForAttributeWithName:@"default-row-height" forClass:CPTableView];
|
||||
|
||||
_bounds.size.height = height;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
@import <AppKit/CPTableView.j>
|
||||
|
||||
@class Converter
|
||||
@class Nib2Cib
|
||||
|
||||
|
||||
@implementation CPTableView (NSCoding)
|
||||
@@ -43,7 +43,7 @@
|
||||
// Convert xib default to cib default
|
||||
if (_rowHeight == 17)
|
||||
{
|
||||
var theme = [[Converter sharedConverter] themes][0],
|
||||
var theme = [Nib2Cib defaultTheme],
|
||||
height = [theme valueForAttributeWithName:@"default-row-height" forClass:CPTableView];
|
||||
|
||||
_rowHeight = height;
|
||||
|
||||