New: CPDatePicker Support
- Added CPDatePicker - Added CPLocale - nib2cib for CPDatePicker Test app in Tests/Manual/CPDatePickerTest
No files matched your search
@@ -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"
|
||||
|
||||
@@ -0,0 +1,683 @@
|
||||
/* 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;
|
||||
[self didChangeValueForKey:@"dateValue"];
|
||||
[self didChangeValueForKey:@"objectValue"];
|
||||
|
||||
[self willChangeValueForKey:@"timeInterval"];
|
||||
_timeInterval = (_datePickerMode == CPSingleDateMode)? 0 : aTimeInterval;
|
||||
[self didChangeValueForKey:@"timeInterval"];
|
||||
|
||||
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
|
||||
|
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)],
|
||||
|
||||
|
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)],
|
||||
|
||||
@@ -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 (navigator)
|
||||
{
|
||||
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
|
||||
@@ -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"
|
||||
|
||||
@@ -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("----------------------------");
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;0E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;4E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;0E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;1;7E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;1;9E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;11E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;13E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;15E;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;17E;D;K;6;CP$UIDd;2;18E;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;20E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;22E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;24E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;26E;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;2;31E;D;K;6;CP$UIDd;2;32E;D;K;6;CP$UIDd;2;33E;D;K;6;CP$UIDd;2;34E;D;K;6;CP$UIDd;2;35E;D;K;6;CP$UIDd;2;36E;D;K;6;CP$UIDd;2;37E;D;K;6;CP$UIDd;2;38E;D;K;6;CP$UIDd;2;39E;D;K;6;CP$UIDd;2;40E;D;K;6;CP$UIDd;2;41E;D;K;6;CP$UIDd;2;42E;D;K;6;CP$UIDd;2;43E;D;K;6;CP$UIDd;2;44E;D;K;6;CP$UIDd;2;45E;D;K;6;CP$UIDd;2;46E;D;K;6;CP$UIDd;2;47E;D;K;6;CP$UIDd;2;48E;D;K;6;CP$UIDd;2;49E;D;K;6;CP$UIDd;2;50E;D;K;6;CP$UIDd;2;51E;D;K;6;CP$UIDd;2;52E;D;K;6;CP$UIDd;2;53E;D;K;6;CP$UIDd;2;54E;D;K;6;CP$UIDd;2;55E;D;K;6;CP$UIDd;2;56E;D;K;6;CP$UIDd;2;57E;D;K;6;CP$UIDd;2;58E;D;K;6;CP$UIDd;2;59E;D;K;6;CP$UIDd;2;60E;D;K;6;CP$UIDd;2;61E;D;K;6;CP$UIDd;2;62E;D;K;6;CP$UIDd;2;63E;D;K;6;CP$UIDd;2;64E;D;K;6;CP$UIDd;2;65E;D;K;6;CP$UIDd;2;67E;D;K;6;CP$UIDd;2;68E;D;K;6;CP$UIDd;2;69E;D;K;6;CP$UIDd;2;70E;D;K;6;CP$UIDd;2;71E;D;K;6;CP$UIDd;2;72E;D;K;6;CP$UIDd;2;73E;D;K;6;CP$UIDd;2;74E;D;K;6;CP$UIDd;2;75E;D;K;6;CP$UIDd;2;76E;D;K;6;CP$UIDd;2;77E;D;K;6;CP$UIDd;2;78E;D;K;6;CP$UIDd;2;79E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;80E;D;K;6;CP$UIDd;2;82E;D;K;6;CP$UIDd;2;84E;D;K;6;CP$UIDd;2;85E;D;K;6;CP$UIDd;2;86E;D;K;6;CP$UIDd;2;87E;D;K;6;CP$UIDd;2;88E;D;K;6;CP$UIDd;2;89E;D;K;6;CP$UIDd;2;90E;D;K;6;CP$UIDd;2;91E;D;K;6;CP$UIDd;2;92E;D;K;6;CP$UIDd;2;93E;D;K;6;CP$UIDd;2;94E;D;K;6;CP$UIDd;2;95E;D;K;6;CP$UIDd;2;96E;D;K;6;CP$UIDd;2;97E;D;K;6;CP$UIDd;2;98E;D;K;6;CP$UIDd;2;99E;D;K;6;CP$UIDd;3;100E;D;K;6;CP$UIDd;3;101E;D;K;6;CP$UIDd;3;102E;D;K;6;CP$UIDd;3;103E;D;K;6;CP$UIDd;3;104E;D;K;6;CP$UIDd;3;105E;D;K;6;CP$UIDd;3;106E;D;K;6;CP$UIDd;3;107E;D;K;6;CP$UIDd;3;108E;D;K;6;CP$UIDd;3;109E;D;K;6;CP$UIDd;3;110E;D;K;6;CP$UIDd;3;111E;D;K;6;CP$UIDd;3;112E;D;K;6;CP$UIDd;3;113E;D;K;6;CP$UIDd;3;114E;D;K;6;CP$UIDd;3;115E;D;K;6;CP$UIDd;3;116E;D;K;6;CP$UIDd;3;117E;D;K;6;CP$UIDd;3;118E;D;K;6;CP$UIDd;3;119E;D;K;6;CP$UIDd;3;120E;D;K;6;CP$UIDd;3;121E;D;K;6;CP$UIDd;3;122E;D;K;6;CP$UIDd;3;123E;D;K;6;CP$UIDd;3;124E;D;K;6;CP$UIDd;3;125E;D;K;6;CP$UIDd;3;126E;D;K;6;CP$UIDd;3;127E;D;K;6;CP$UIDd;3;128E;D;K;6;CP$UIDd;3;129E;D;K;6;CP$UIDd;3;130E;D;K;6;CP$UIDd;3;131E;D;K;6;CP$UIDd;3;132E;D;K;6;CP$UIDd;3;133E;D;K;6;CP$UIDd;3;134E;D;K;6;CP$UIDd;3;135E;D;K;6;CP$UIDd;3;136E;D;K;6;CP$UIDd;3;137E;D;K;6;CP$UIDd;3;138E;D;K;6;CP$UIDd;3;139E;D;K;6;CP$UIDd;3;140E;D;K;6;CP$UIDd;3;141E;D;K;6;CP$UIDd;3;142E;D;K;6;CP$UIDd;3;143E;D;K;6;CP$UIDd;3;144E;D;K;6;CP$UIDd;3;145E;D;K;6;CP$UIDd;3;146E;D;K;6;CP$UIDd;3;147E;D;K;6;CP$UIDd;3;148E;D;K;6;CP$UIDd;3;150E;D;K;6;CP$UIDd;3;151E;D;K;6;CP$UIDd;3;153E;D;K;6;CP$UIDd;3;155E;D;K;6;CP$UIDd;3;157E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;159E;D;K;6;CP$UIDd;3;161E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;162E;D;K;6;CP$UIDd;3;163E;D;K;6;CP$UIDd;3;164E;D;K;6;CP$UIDd;3;165E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;166E;D;K;6;CP$UIDd;3;167E;D;K;6;CP$UIDd;3;168E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;169E;D;K;6;CP$UIDd;3;170E;D;K;6;CP$UIDd;3;171E;D;K;6;CP$UIDd;3;172E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;173E;D;K;6;CP$UIDd;3;174E;D;K;6;CP$UIDd;3;175E;D;K;6;CP$UIDd;3;177E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;178E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;179E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;181E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;182E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;183E;D;K;6;CP$UIDd;3;184E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;185E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;186E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;187E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;188E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;189E;D;K;6;CP$UIDd;3;190E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;191E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;192E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;193E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;194E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;3;195E;D;K;6;CP$UIDd;1;0E;DLine truncated
|
||||
|
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);
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
@@ -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 Converter
|
||||
|
||||
@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 = [[Converter sharedConverter] themes][0];
|
||||
|
||||
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"
|
||||
|
||||