Skip to content

Commit

Permalink
Pester 1.0d1
Browse files Browse the repository at this point in the history
git-svn-id: http://dev.sabi.net/svn/dev/trunk/Cocoa/Pester@21 24bc951d-4bb6-0310-a7b7-f2527510289e
  • Loading branch information
nriley committed Oct 20, 2002
0 parents commit 6c61dec
Show file tree
Hide file tree
Showing 23 changed files with 2,353 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Read Me
Binary file not shown.
Binary file added Source/.DS_Store
Binary file not shown.
Binary file added Source/Application icon.icns
Binary file not shown.
Binary file added Source/English.lproj/InfoPlist.strings
Binary file not shown.
25 changes: 25 additions & 0 deletions Source/English.lproj/MainMenu.nib/classes.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Source/English.lproj/MainMenu.nib/info.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Source/English.lproj/MainMenu.nib/objects.nib
Binary file not shown.
13 changes: 13 additions & 0 deletions Source/English.lproj/Notifier.nib/classes.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Source/English.lproj/Notifier.nib/info.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Source/English.lproj/Notifier.nib/objects.nib
Binary file not shown.
16 changes: 16 additions & 0 deletions Source/NJRDateFormatter.h
@@ -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
53 changes: 53 additions & 0 deletions Source/NJRDateFormatter.m
@@ -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
16 changes: 16 additions & 0 deletions Source/NJRIntegerFilter.h
@@ -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
35 changes: 35 additions & 0 deletions Source/NJRIntegerFilter.m
@@ -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
19 changes: 19 additions & 0 deletions Source/PSAlarmNotifierController.h
@@ -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
37 changes: 37 additions & 0 deletions Source/PSAlarmNotifierController.m
@@ -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
33 changes: 33 additions & 0 deletions Source/PSAlarmSetController.h
@@ -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

0 comments on commit 6c61dec

Please sign in to comment.