Use a formatter in the NSDatePickerCell.

This commit is contained in:
fredkiefer 2020-01-07 17:38:03 +01:00
parent dc955b1ce4
commit 9a9f32d1b5
2 changed files with 24 additions and 12 deletions

View file

@ -60,17 +60,15 @@ enum {
};
typedef NSUInteger NSDatePickerElementFlags;
@class NSColor, NSDate, NSCalendar, NSLocale, NSTimeZone;
@interface NSDatePickerCell : NSActionCell
{
NSColor *_backgroundColor;
NSCalendar *_calendar;
NSDate *_dateValue;
id _delegate;
NSLocale *_locale;
NSColor *_textColor;
NSDate *_maxDate;
NSDate *_minDate;
NSColor *_textColor;
NSTimeZone *_timeZone;
id _delegate;
NSTimeInterval _timeInterval;
// FIXME: pack into a bitfield?
NSDatePickerElementFlags _datePickerElements;

View file

@ -30,11 +30,25 @@
*/
#import <Foundation/NSString.h>
#import <Foundation/NSDateFormatter.h>
#import <AppKit/NSDatePickerCell.h>
#import <AppKit/NSColor.h>
@implementation NSDatePickerCell
- (id) initTextCell: (NSString*)aString
{
if ((self = [super initTextCell: aString]))
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[self setFormatter: formatter];
RELEASE(formatter);
}
return self;
}
- (NSColor *) backgroundColor
{
return _backgroundColor;
@ -47,12 +61,12 @@
- (NSCalendar *) calendar
{
return _calendar;
return [[self formatter] calendar];
}
- (void) setCalendar: (NSCalendar *)calendar
{
ASSIGN(_calendar, calendar);
[[self formatter] setCalendar: calendar];
}
- (NSDatePickerElementFlags) datePickerElements
@ -117,12 +131,12 @@
- (NSLocale *) locale
{
return _locale;
return [[self formatter] locale];
}
- (void) setLocale: (NSLocale *)locale
{
ASSIGN(_locale, locale);
[[self formatter] setLocale: locale];
}
- (NSDate *) maxDate
@ -167,12 +181,12 @@
- (NSTimeZone *) timeZone
{
return _timeZone;
return [[self formatter] timeZone];
}
- (void) setTimeZone: (NSTimeZone *)zone
{
ASSIGN(_timeZone, zone);
[[self formatter] setTimeZone: zone];
}
- (void) encodeWithCoder: (NSCoder *)aCoder