source: releases/Pester/1.1b6/Source/NJRIntervalField.m@ 517

Last change on this file since 517 was 364, checked in by Nicholas Riley, 17 years ago

English.lproj/Alarms.nib: Specify alternating row coloring in the nib,
now we're 10.4+.

English.lproj/InfoPlist.strings: Updated for 1.1b6.

English.lproj/Localizable.strings: Quote alarm message in pretty
description (used in tooltip). Change voice error now it no longer
incorporates OSStatus.

English.lproj/MainMenu.nib: Add speech prefs again; turn repetitions
field into a NJRValidatingField and hook up its delegate.

Info-Pester.plist: Updated for 1.1b6.

NJRHotKey.m: Switch to new Objective-C exception style.

NJRIntervalField.[hm]: Now a subclass of NJRValidatingField.

NJRTableDelegate.m: Get rid of our own tooltip support as NSTableView
now supports them (though with a minor visual glitch on the first
tooltip).

NJRTableView.[hm]: Remove tooltip support. Remove alternating row
coloring support.

NJRValidatingField.[hm]: Contains validation sheet stuff from
NJRIntervalField.

NJRVoicePopUpButton.[hm]: Switch to NSSpeechSynthesizer.

PSAlarm.m: Quote alarm message in pretty description (used in
tooltip). Fix repeating alarms not restoring as repeating if they
didn't expire while Pester was not running. No longer set timer on
Pester 1.0 alarm import, to help make importing atomic.

PSAlarmSetController.[hm]: Use NJRValidatingField for repetitions
field. Switch to new Objective-C exception style. Fix validation
issues on in/at changing. Temporary changes to restore speech support
and allow the sound popup to be removed entirely from the nib (rather
than being dragged out of the visible area, as it was in 1.1b5).
Changes for NSSpeechSynthesizer, which uses different voice names.

PSAlarms.m: Switch to new Objective-C exception style. Fix
duplication and error handling in Pester 1.0 alarm import, making
atomic.

PSAlarmsController.m: Use new tooltip support (since it's implemented
in the delegate rather than the data source, we have to proxy it).

PSAlerts.m: Wrap initialization in exception block so we don't leak.

PSApplication.m: Switch to new Objective-C exception style.

PSMediaAlert.m: Clamp repetitions at 1..99 so the user can't type an
invalid value, then quit and have it saved.

PSSpeechAlert.[hm]: Switch to NSSpeechSynthesizer. Throw an
intelligible exception if the voice is unavailable.

PSTimer.m: Switch to new Objective-C exception style.

Pester.xcodeproj: Remove VERSION generation; rename targets to be more
understandable.

Read Me.rtfd: Updated for 1.1b6.

SUSpeaker.[hm]: Gone in switch to NSSpeechSynthesizer.

VERSION: Gone - we use agvtool for everything now.

Updates/release-notes.html: Updated for 1.1b6.

Updates/updates.xml: Updated for 1.1b6.

package-Pester.sh: Use agvtool to get version. Atomically update
file on Web server to avoid partial downloads.

File size: 2.6 KB
Line 
1//
2// NJRIntervalField.m
3// Pester
4//
5// Created by Nicholas Riley on Wed Dec 25 2002.
6// Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import "NJRIntervalField.h"
10
11// XXX much implementation borrowed from DockCam, then factored; should replace DockCam interval selector with a NJRIntervalField at some point
12
13@implementation NJRIntervalField
14
15- (NSTimeInterval)interval;
16{
17 NSText *editor = [self currentEditor];
18 id obj = nil;
19
20 if (editor != nil) {
21 NSString *stringValue = [editor string];
22 if (![[self formatter] getObjectValue: &obj forString: stringValue errorDescription: NULL])
23 return 0;
24 } else {
25 obj = self;
26 }
27
28 return [obj intValue] * [[intervalUnits selectedItem] tag];
29}
30
31- (BOOL)setInterval:(NSTimeInterval)interval;
32{
33 // we assume that the tags are in ascending order in the array
34 NSEnumerator *e = [[intervalUnits itemArray] reverseObjectEnumerator];
35 NSMenuItem *i;
36 int multiplierTag;
37
38 while ( (i = [e nextObject]) != nil) {
39 multiplierTag = [i tag];
40 if (multiplierTag <= 0) continue;
41 if (((int)interval % multiplierTag) == 0) {
42 NSFormatter *formatter = [self formatter];
43 int intervalValue = interval / multiplierTag;
44 if (formatter != nil) {
45 id ignored;
46 if (![formatter getObjectValue: &ignored forString: [formatter stringForObjectValue: [NSNumber numberWithInt: intervalValue]] errorDescription: NULL]) return NO;
47 }
48 [self setIntValue: intervalValue];
49 [intervalUnits selectItem: i];
50 return YES;
51 }
52 }
53 return NO;
54}
55
56- (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)range replacementString:(NSString *)string;
57{
58 unsigned length = [string length];
59 if (length != 0) {
60 unichar c;
61 int tag = -1;
62 c = [string characterAtIndex: length - 1];
63 switch (c) {
64 case 's': case 'S': tag = 1; break;
65 case 'm': case 'M': tag = 60; break;
66 case 'h': case 'H': tag = 60 * 60; break;
67 case 'u': case 'U': tag = -2; break;
68 default: break;
69 }
70 if (tag != -1) {
71 int itemIndex = [intervalUnits indexOfItemWithTag: tag];
72 if (itemIndex != -1) {
73 [intervalUnits selectItemAtIndex: itemIndex];
74 [[intervalUnits menu] performActionForItemAtIndex: itemIndex];
75 }
76 if (tag < 0) return NO; // don't send update
77 }
78 }
79 return [super textView: textView shouldChangeTextInRange: range replacementString: string];
80}
81
82@end
Note: See TracBrowser for help on using the repository browser.