Add minimal version of date picker copied over from mySTEP.

This commit is contained in:
fredkiefer 2020-01-06 22:25:54 +01:00
parent 560f68323b
commit dc955b1ce4
7 changed files with 650 additions and 0 deletions

View file

@ -1,3 +1,11 @@
2020-01-06 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSDatePickerCell.h,
* Headers/AppKit/NSDatePicker.h,
* Source/NSDatePickerCell.m,
* Source/NSDatePicker.m: Add minimal version of date picker copied
over from mySTEP.
2019-12-29 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSBundleAdditions.m (-pathForNibResource:): Report type

View file

@ -147,6 +147,8 @@
#import <AppKit/NSClickGestureRecognizer.h>
#import <AppKit/NSColorPickerTouchBarItem.h>
#import <AppKit/NSCustomTouchBarItem.h>
#import <AppKit/NSDatePicker.h>
#import <AppKit/NSDatePickerCell.h>
#import <AppKit/NSDockTile.h>
#import <AppKit/NSDocument.h>
#import <AppKit/NSDocumentController.h>

View file

@ -0,0 +1,82 @@
/* -*-objc-*-
NSDatePicker.h
The date picker class
Copyright (C) 2020 Free Software Foundation, Inc.
Created by Dr. H. Nikolaus Schaller on Sat Jan 07 2006.
Copyright (c) 2005 DSITRI.
Author: Fabian Spillner
Date: 22. October 2007
Author: Fabian Spillner <fabian.spillner@gmail.com>
Date: 7. November 2007 - aligned with 10.5
This file is part of the GNUstep GUI Library.
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 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; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_NSDatePicker
#define _GNUstep_H_NSDatePicker
#import "AppKit/NSControl.h"
#import "AppKit/NSDatePickerCell.h"
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
@interface NSDatePicker : NSControl
- (NSColor *) backgroundColor;
- (NSCalendar *) calendar;
- (NSDatePickerElementFlags) datePickerElements;
- (NSDatePickerMode) datePickerMode;
- (NSDatePickerStyle) datePickerStyle;
- (NSDate *) dateValue;
- (id) delegate;
- (BOOL) drawsBackground;
- (BOOL) isBezeled;
- (BOOL) isBordered;
- (NSLocale *) locale;
- (NSDate *) maxDate;
- (NSDate *) minDate;
- (void) setBackgroundColor:(NSColor *) color;
- (void) setBezeled:(BOOL) flag;
- (void) setBordered:(BOOL) flag;
- (void) setCalendar:(NSCalendar *) calendar;
- (void) setDatePickerElements:(NSDatePickerElementFlags) flags;
- (void) setDatePickerMode:(NSDatePickerMode) mode;
- (void) setDatePickerStyle:(NSDatePickerStyle) style;
- (void) setDateValue:(NSDate *) date;
- (void) setDelegate:(id) obj; /* DOESNT EXIST IN API */
- (void) setDrawsBackground:(BOOL) flag;
- (void) setLocale:(NSLocale *) locale;
- (void) setMaxDate:(NSDate *) date;
- (void) setMinDate:(NSDate *) date;
- (void) setTextColor:(NSColor *) color;
- (void) setTimeInterval:(NSTimeInterval) interval;
- (void) setTimeZone:(NSTimeZone *) zone;
- (NSColor *) textColor;
- (NSTimeInterval) timeInterval;
- (NSTimeZone *) timeZone;
@end
#endif
#endif /* _GNUstep_H_NSDatePicker */

View file

@ -0,0 +1,122 @@
/* -*-objc-*-
NSDatePickerCell.h
The date picker cell class
Copyright (C) 2020 Free Software Foundation, Inc.
Created by Dr. H. Nikolaus Schaller on Sat Jan 07 2006.
Author: Fabian Spillner
Date: 22. October 2007
This file is part of the GNUstep GUI Library.
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 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; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_NSDatePickerCell
#define _GNUstep_H_NSDatePickerCell
#import "AppKit/NSActionCell.h"
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
enum {
NSTextFieldAndStepperDatePickerStyle = 0,
NSClockAndCalendarDatePickerStyle = 1,
NSTextFieldDatePickerStyle = 2
};
typedef NSUInteger NSDatePickerStyle;
enum {
NSSingleDateMode = 0,
NSRangeDateMode = 1
};
typedef NSUInteger NSDatePickerMode;
enum {
NSHourMinuteDatePickerElementFlag = 0x000c,
NSHourMinuteSecondDatePickerElementFlag = 0x000e,
NSTimeZoneDatePickerElementFlag = 0x0010,
NSYearMonthDatePickerElementFlag = 0x00c0,
NSYearMonthDayDatePickerElementFlag = 0x00e0,
NSEraDatePickerElementFlag = 0x0100,
};
typedef NSUInteger NSDatePickerElementFlags;
@interface NSDatePickerCell : NSActionCell
{
NSColor *_backgroundColor;
NSCalendar *_calendar;
NSDate *_dateValue;
id _delegate;
NSLocale *_locale;
NSDate *_maxDate;
NSDate *_minDate;
NSColor *_textColor;
NSTimeZone *_timeZone;
NSTimeInterval _timeInterval;
// FIXME: pack into a bitfield?
NSDatePickerElementFlags _datePickerElements;
NSDatePickerMode _datePickerMode;
NSDatePickerStyle _datePickerStyle;
BOOL _drawsBackground;
}
- (NSColor *) backgroundColor;
- (NSCalendar *) calendar;
- (NSDatePickerElementFlags) datePickerElements;
- (NSDatePickerMode) datePickerMode;
- (NSDatePickerStyle) datePickerStyle;
- (NSDate *) dateValue;
- (id) delegate;
- (BOOL) drawsBackground;
- (NSLocale *) locale;
- (NSDate *) maxDate;
- (NSDate *) minDate;
- (void) setBackgroundColor:(NSColor *) color;
- (void) setCalendar:(NSCalendar *) calendar;
- (void) setDatePickerElements:(NSDatePickerElementFlags) flags;
- (void) setDatePickerMode:(NSDatePickerMode) mode;
- (void) setDatePickerStyle:(NSDatePickerStyle) style;
- (void) setDateValue:(NSDate *) date;
- (void) setDelegate:(id) obj;
- (void) setDrawsBackground:(BOOL) flag;
- (void) setLocale:(NSLocale *) locale;
- (void) setMaxDate:(NSDate *) date;
- (void) setMinDate:(NSDate *) date;
- (void) setTextColor:(NSColor *) color;
- (void) setTimeInterval:(NSTimeInterval) interval;
- (void) setTimeZone:(NSTimeZone *) zone;
- (NSColor *) textColor;
- (NSTimeInterval) timeInterval;
- (NSTimeZone *) timeZone;
@end
@interface NSObject (NSDataPickerCellDelegate)
- (void)datePickerCell:(NSDatePickerCell *) aDatePickerCell
validateProposedDateValue:(NSDate **) proposedDateValue
timeInterval:(NSTimeInterval *) proposedTimeInterval;
@end
#endif
#endif /* _GNUstep_H_NSDatePickerCell */

View file

@ -92,6 +92,8 @@ NSCustomTouchBarItem.m \
NSDataLink.m \
NSDataLinkManager.m \
NSDataLinkPanel.m \
NSDatePicker.m \
NSDatePickerCell.m \
NSDockTile.m \
NSDocument.m \
NSDocumentController.m \
@ -373,6 +375,8 @@ NSCustomTouchBarItem.h \
NSDataLink.h \
NSDataLinkManager.h \
NSDataLinkPanel.h \
NSDatePicker.h \
NSDatePickerCell.h \
NSDockTile.h \
NSDocument.h \
NSDocumentController.h \

221
Source/NSDatePicker.m Normal file
View file

@ -0,0 +1,221 @@
/** <title>NSDatePicker</title>
<abstract>The date picker class</abstract>
Copyright (C) 2020 Free Software Foundation, Inc.
Author: Nikolaus Schaller <hns@computer.org>
Date: April 2006
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: January 2020
This file is part of the GNUstep GUI Library.
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 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; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSString.h>
#import <AppKit/NSDatePickerCell.h>
#import <AppKit/NSDatePicker.h>
#import <AppKit/NSColor.h>
static id usedCellClass = nil;
@implementation NSDatePicker
+ (void) initialize
{
if (self == [NSDatePicker class])
{
[self setVersion: 1];
[self setCellClass: [NSDatePickerCell class]];
}
}
+ (Class) cellClass
{
return usedCellClass;
}
+ (void) setCellClass: (Class)cellClass
{
usedCellClass = cellClass;
}
- (NSColor *) backgroundColor
{
return [_cell backgroundColor];
}
- (NSCalendar *) calendar
{
return [_cell calendar];
}
- (NSDatePickerElementFlags) datePickerElements
{
return [_cell datePickerElements];
}
- (NSDatePickerMode) datePickerMode
{
return [_cell datePickerMode];
}
- (NSDatePickerStyle) datePickerStyle
{
return [_cell datePickerStyle];
}
- (NSDate *) dateValue
{
return [_cell dateValue];
}
- (id) delegate
{
return [_cell delegate];
}
- (BOOL) drawsBackground
{
return [_cell drawsBackground];
}
- (BOOL) isBezeled
{
return [_cell isBezeled];
}
- (BOOL) isBordered
{
return [_cell isBordered];
}
- (NSLocale *) locale
{
return [_cell locale];
}
- (NSDate *) maxDate
{
return [_cell maxDate];
}
- (NSDate *) minDate
{
return [_cell minDate];
}
- (void) setBackgroundColor: (NSColor *)color
{
[_cell setBackgroundColor: color];
}
- (void) setBezeled: (BOOL)flag
{
[_cell setBezeled: flag];
}
- (void) setBordered: (BOOL)flag
{
[_cell setBordered: flag];
}
- (void) setCalendar: (NSCalendar *)calendar
{
[_cell setCalendar: calendar];
}
- (void) setDatePickerElements: (NSDatePickerElementFlags)flags
{
[_cell setDatePickerElements: flags];
}
- (void) setDatePickerMode: (NSDatePickerMode)mode
{
[_cell setDatePickerMode: mode];
}
- (void) setDatePickerStyle: (NSDatePickerStyle)style
{
[_cell setDatePickerStyle: style];
}
- (void) setDateValue: (NSDate *)date
{
[_cell setDateValue: date];
}
- (void) setDelegate: (id)obj
{
[_cell setDelegate: obj];
}
- (void) setDrawsBackground: (BOOL)flag
{
[_cell setDrawsBackground: flag];
}
- (void) setLocale: (NSLocale *)locale
{
[_cell setLocale: locale];
}
- (void) setMaxDate: (NSDate *)date
{
[_cell setMaxDate: date];
}
- (void) setMinDate: (NSDate *)date
{
[_cell setMinDate: date];
}
- (void) setTextColor: (NSColor *)color
{
[_cell setTextColor: color];
}
- (void) setTimeInterval: (NSTimeInterval)interval
{
[_cell setTimeInterval: interval];
}
- (void) setTimeZone: (NSTimeZone *)zone
{
[_cell setTimeZone: zone];
}
- (NSColor *) textColor
{
return [_cell textColor];
}
- (NSTimeInterval) timeInterval
{
return [_cell timeInterval];
}
- (NSTimeZone *) timeZone
{
return [_cell timeZone];
}
@end

211
Source/NSDatePickerCell.m Normal file
View file

@ -0,0 +1,211 @@
/** <title>NSDatePickerCell</title>
<abstract>The date picker cell class</abstract>
Copyright (C) 2020 Free Software Foundation, Inc.
Author: Nikolaus Schaller <hns@computer.org>
Date: April 2006
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: January 2020
This file is part of the GNUstep GUI Library.
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 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; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSString.h>
#import <AppKit/NSDatePickerCell.h>
#import <AppKit/NSColor.h>
@implementation NSDatePickerCell
- (NSColor *) backgroundColor
{
return _backgroundColor;
}
- (void) setBackgroundColor: (NSColor *)color
{
ASSIGN(_backgroundColor, color);
}
- (NSCalendar *) calendar
{
return _calendar;
}
- (void) setCalendar: (NSCalendar *)calendar
{
ASSIGN(_calendar, calendar);
}
- (NSDatePickerElementFlags) datePickerElements
{
return _datePickerElements;
}
- (void) setDatePickerElements: (NSDatePickerElementFlags)flags
{
_datePickerElements = flags;
}
- (NSDatePickerMode) datePickerMode
{
return _datePickerMode;
}
- (void) setDatePickerMode: (NSDatePickerMode)mode
{
_datePickerMode = mode;
}
- (NSDatePickerStyle) datePickerStyle
{
return _datePickerStyle;
}
- (void) setDatePickerStyle: (NSDatePickerStyle)style
{
_datePickerStyle = style;
}
- (NSDate *) dateValue
{
return (NSDate *)[self objectValue];
}
- (void) setDateValue: (NSDate *)date
{
[self setObjectValue: date];
}
- (id) delegate
{
return _delegate;
}
- (void) setDelegate: (id)obj
{
_delegate = obj;
}
- (BOOL) drawsBackground
{
return _drawsBackground;
}
- (void) setDrawsBackground: (BOOL)flag
{
_drawsBackground = flag;
}
- (NSLocale *) locale
{
return _locale;
}
- (void) setLocale: (NSLocale *)locale
{
ASSIGN(_locale, locale);
}
- (NSDate *) maxDate
{
return _maxDate;
}
- (void) setMaxDate: (NSDate *)date
{
ASSIGN(_maxDate, date);
}
- (NSDate *) minDate
{
return _minDate;
}
- (void) setMinDate: (NSDate *)date
{
ASSIGN(_minDate, date);
}
- (NSColor *) textColor
{
return _textColor;
}
- (void) setTextColor: (NSColor *)color
{
ASSIGN(_textColor, color);
}
- (NSTimeInterval) timeInterval
{
return _timeInterval;
}
- (void) setTimeInterval: (NSTimeInterval)interval
{
_timeInterval = interval;
}
- (NSTimeZone *) timeZone
{
return _timeZone;
}
- (void) setTimeZone: (NSTimeZone *)zone
{
ASSIGN(_timeZone, zone);
}
- (void) encodeWithCoder: (NSCoder *)aCoder
{
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeDouble: [self timeInterval] forKey: @"NSTimeInterval"];
[aCoder encodeInt: [self datePickerElements] forKey: @"NSDatePickerElements"];
[aCoder encodeInt: [self datePickerStyle] forKey: @"NSDatePickerType"];
[aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
}
else
{
}
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
if ((self = [super initWithCoder: aDecoder]))
{
if ([aDecoder allowsKeyedCoding])
{
[self setTimeInterval: [aDecoder decodeDoubleForKey: @"NSTimeInterval"]];
[self setDatePickerElements: [aDecoder decodeIntForKey: @"NSDatePickerElements"]];
[self setDatePickerStyle: [aDecoder decodeIntForKey: @"NSDatePickerType"]];
[self setBackgroundColor: [aDecoder decodeObjectForKey: @"NSBackgroundColor"]];
}
else
{
}
}
return self;
}
@end