Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://dev.sabi.net/svn/dev/trunk/Cocoa/Pester@21 24bc951d-4bb6-0310-a7b7-f2527510289e
- Loading branch information
0 parents
commit 6c61dec
Showing
23 changed files
with
2,353 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// NJRDateFormatter.h | ||
// Pester | ||
// | ||
// Created by Nicholas Riley on Wed Oct 09 2002. | ||
// Copyright (c) 2002 Nicholas Riley. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
@interface NJRDateFormatter : NSDateFormatter { | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// NJRDateFormatter.m | ||
// Pester | ||
// | ||
// Created by Nicholas Riley on Wed Oct 09 2002. | ||
// Copyright (c) 2002 Nicholas Riley. All rights reserved. | ||
// | ||
|
||
#import "NJRDateFormatter.h" | ||
|
||
|
||
@implementation NJRDateFormatter | ||
|
||
// workaround for bug in Jaguar (and earlier?) NSCalendarDate dateWithNaturalLanguageString: | ||
NSString * stringByRemovingSurroundingWhitespace(NSString *string) { | ||
static NSCharacterSet *nonWhitespace = nil; | ||
NSRange firstValidCharacter, lastValidCharacter; | ||
|
||
if (!nonWhitespace) { | ||
nonWhitespace = [[[NSCharacterSet characterSetWithCharactersInString: | ||
@" \t\r\n"] invertedSet] retain]; | ||
} | ||
|
||
firstValidCharacter = [string rangeOfCharacterFromSet:nonWhitespace]; | ||
if (firstValidCharacter.length == 0) | ||
return @""; | ||
lastValidCharacter = [string rangeOfCharacterFromSet:nonWhitespace options:NSBackwardsSearch]; | ||
|
||
if (firstValidCharacter.location == 0 && lastValidCharacter.location == [string length] - 1) | ||
return string; | ||
else | ||
return [string substringWithRange:NSUnionRange(firstValidCharacter, lastValidCharacter)]; | ||
} | ||
|
||
|
||
- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error | ||
{ | ||
NSCalendarDate *date; | ||
if (![self allowsNaturalLanguage]) | ||
return [super getObjectValue: anObject forString: string errorDescription: error]; | ||
if (string == nil) return nil; | ||
NS_DURING // dateWithNaturalLanguageString: can throw an exception | ||
date = [NSCalendarDate dateWithNaturalLanguageString: stringByRemovingSurroundingWhitespace(string)]; | ||
NS_HANDLER | ||
if (error != nil) *error = [localException reason]; | ||
NS_VALUERETURN(NO, BOOL); | ||
NS_ENDHANDLER | ||
if (date == nil) return [super getObjectValue: anObject forString: string errorDescription: error]; | ||
*anObject = date; | ||
return YES; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// NJRIntegerFilter.h | ||
// HostLauncher | ||
// | ||
// Created by Nicholas Riley on Tue Dec 18 2001. | ||
// Copyright (c) 2001 Nicholas Riley. All rights reserved. | ||
// | ||
|
||
#import <AppKit/AppKit.h> | ||
|
||
|
||
@interface NJRIntegerFilter : NSNumberFormatter { | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// NJRIntegerFilter.m | ||
// HostLauncher | ||
// | ||
// Created by Nicholas Riley on Tue Dec 18 2001. | ||
// Copyright (c) 2001 Nicholas Riley. All rights reserved. | ||
// | ||
|
||
// based on MyIntegerFilter | ||
// Copyright © 2001 Bill Cheeseman. All rights reserved. | ||
|
||
#import "NJRIntegerFilter.h" | ||
|
||
@implementation NJRIntegerFilter | ||
|
||
// Input filter | ||
|
||
- (BOOL)isPartialStringValid:(NSString **)partialStringPtr proposedSelectedRange:(NSRangePointer)proposedSelRangePtr originalString:(NSString *)origString originalSelectedRange:(NSRange)origSelRange errorDescription:(NSString **)error { | ||
|
||
// Override method to enable NSControl delegate method control:didFailToValidatePartialString:errorDescription: to | ||
// reject invalid keypresses. Filters out keyboard input characters other than "1" .. "9". | ||
if ([[*partialStringPtr substringWithRange:NSMakeRange(origSelRange.location, (*proposedSelRangePtr).location - origSelRange.location)] rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet] options:NSLiteralSearch].location != NSNotFound) { | ||
*error = NSLocalizedString(@"Input is not an integer", @"Presented when user value not a numeric digit"); | ||
return NO; // Reject *partialStringPtr as typed, invoke delegate method | ||
} | ||
|
||
if ([*partialStringPtr length] == 0) { | ||
// Work around NSFormatter issue in Mac OS X 10.0. | ||
[[[NSApp keyWindow] fieldEditor:NO forObject:nil] setSelectedRange:*proposedSelRangePtr]; | ||
} | ||
|
||
return YES; // Accept *partialStringPtr as typed | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// PSAlarmNotifierController.h | ||
// Pester | ||
// | ||
// Created by Nicholas Riley on Tue Oct 08 2002. | ||
// Copyright (c) 2002 Nicholas Riley. All rights reserved. | ||
// | ||
|
||
#import <AppKit/AppKit.h> | ||
|
||
|
||
@interface PSAlarmNotifierController : NSWindowController { | ||
IBOutlet NSTextField *messageField; | ||
IBOutlet NSTextField *dateField; | ||
} | ||
|
||
- (IBAction)close:(NSButton *)sender; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// PSAlarmNotifierController.m | ||
// Pester | ||
// | ||
// Created by Nicholas Riley on Tue Oct 08 2002. | ||
// Copyright (c) 2002 Nicholas Riley. All rights reserved. | ||
// | ||
|
||
#import "PSAlarmNotifierController.h" | ||
|
||
|
||
@implementation PSAlarmNotifierController | ||
|
||
- (id)initWithTimer:(NSTimer *)timer; | ||
{ | ||
if ([self initWithWindowNibName: @"Notifier"]) { | ||
NSString *message = [timer userInfo]; | ||
|
||
[[self window] center]; | ||
if (message == nil || [message isEqualToString: @""]) | ||
message = @"Alarm!"; | ||
[messageField setStringValue: message]; | ||
[dateField setObjectValue: [timer fireDate]]; | ||
[NSApp activateIgnoringOtherApps: YES]; | ||
[[self window] makeKeyAndOrderFront: nil]; | ||
[[self window] orderFrontRegardless]; | ||
NSBeep(); | ||
} | ||
return self; | ||
} | ||
|
||
- (IBAction)close:(id)sender; | ||
{ | ||
[self close]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// PSAlarmSetController.h | ||
// Pester | ||
// | ||
// Created by Nicholas Riley on Tue Oct 08 2002. | ||
// Copyright (c) 2002 Nicholas Riley. All rights reserved. | ||
// | ||
|
||
#import <AppKit/AppKit.h> | ||
|
||
|
||
@interface PSAlarmSetController : NSWindowController { | ||
IBOutlet NSTextField *messageField; | ||
IBOutlet NSMatrix *inAtMatrix; | ||
IBOutlet NSTextField *timeInterval; | ||
IBOutlet NSPopUpButton *timeIntervalUnits; | ||
IBOutlet NSTextField *timeOfDay; | ||
IBOutlet NSTextField *timeDate; | ||
IBOutlet NSPopUpButton *timeDateCompletions; // XXX should go away when bug preventing both formatters and popup menus from existing is fixed | ||
IBOutlet NSTextField *timeSummary; | ||
IBOutlet NSButton *setButton; | ||
NSString *status; | ||
BOOL isIn; | ||
NSCalendarDate *alarmDate; | ||
NSTimeInterval alarmInterval; | ||
} | ||
|
||
- (IBAction)update:(id)sender; | ||
- (IBAction)dateCompleted:(NSPopUpButton *)sender; | ||
- (IBAction)inAtChanged:(id)sender; | ||
- (IBAction)setAlarm:(NSButton *)sender; | ||
|
||
@end |
Oops, something went wrong.