source: releases/Pester/1.1b6/Source/NJRTableView.m

Last change on this file 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: 3.6 KB
Line 
1//
2// NJRTableView.m
3// Pester
4//
5// Created by Nicholas Riley on Sun Nov 17 2002.
6// Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import "NJRTableView.h"
10#import "NSTableView-NJRExtensions.h"
11#import "NSCharacterSet-NJRExtensions.h"
12
13/* only defined in 10.2, but we want to be able to compile without warnings on 10.1.x */
14@interface NSColor (JaguarExtras)
15+ (NSColor *)alternateSelectedControlColor;
16@end
17
18@implementation NJRTableView
19
20#pragma mark type selection
21
22- (id)typeSelectDisplay;
23{
24 return typeSelectDisplay;
25}
26
27- (void)moveToEndOfDocument:(id)sender {
28 [self scrollRowToVisible: [self numberOfRows] - 1];
29}
30
31- (void)moveToBeginningOfDocument:(id)sender {
32 [self scrollRowToVisible: 0];
33}
34
35- (void)keyDown:(NSEvent *)theEvent;
36{
37 NSString *characters;
38 unichar firstCharacter;
39 characters = [theEvent characters];
40 firstCharacter = [characters characterAtIndex: 0];
41 switch (firstCharacter) {
42 case 0177: // delete key
43 case NSDeleteFunctionKey:
44 case NSDeleteCharFunctionKey:
45 if ([self selectedRow] >= 0 && [[self dataSource] respondsToSelector: @selector(removeSelectedRowsFromTableView:)]) {
46 [[self dataSource] removeSelectedRowsFromTableView: self];
47 }
48 return;
49 case NSHomeFunctionKey:
50 [self moveToBeginningOfDocument: nil];
51 return;
52 case NSEndFunctionKey:
53 [self moveToEndOfDocument: nil];
54 return;
55 }
56 if ([[NSCharacterSet typeSelectSet] characterIsMember: firstCharacter]) {
57 // invoking -[NSResponder interpretKeyEvents:] will cause insertText: to be invoked, and allows function keys to still work.
58 [self interpretKeyEvents: [NSArray arrayWithObject: theEvent]];
59 } else {
60 [super keyDown: theEvent];
61 }
62}
63
64- (void)insertText:(id)inString;
65{
66 if (![[self delegate] respondsToSelector:@selector(selectString:inTableView:)]) {
67 // For consistency with List Manager as documented, reset the typeahead buffer after twice the delay until key repeat (in ticks).
68 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
69 int keyRepeatTicks = [defaults integerForKey: @"InitialKeyRepeat"];
70 NSTimeInterval resetDelay;
71
72 if (keyRepeatTicks == 0) keyRepeatTicks = 35; // default may be missing; if so, set default
73
74 resetDelay = MIN(2.0 / 60.0 * keyRepeatTicks, 2.0);
75
76 if (typed == nil) typed = [[NSMutableString alloc] init];
77 [typed appendString: inString];
78
79 // Cancel any previously queued future invocations of _resetTypeSelect
80 [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(_resetTypeSelect) object: nil];
81
82 // queue an invocation of clearAccumulatingTypeahead for the near future.
83 [self performSelector: @selector(_resetTypeSelect) withObject: nil afterDelay: resetDelay];
84
85 // Use stringWithString to make an autoreleased copy, since we may clear out the original string below before it can be used.
86 [[self delegate] tableView: self selectRowMatchingString: [NSString stringWithString: typed]];
87
88 // Show the current typeahead string in the optional display field, like CodeWarrior does (well, not really, CW is much more elegant because it doesn't select anything until you stop typing)
89 [typeSelectDisplay setObjectValue: typed];
90 }
91}
92
93- (void)_resetTypeSelect;
94{
95 [typed setString: @""];
96 [typeSelectDisplay setObjectValue: nil];
97}
98
99- (void)resetTypeSelect;
100{
101 [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(_resetTypeSelect) object: nil];
102 [self _resetTypeSelect];
103}
104
105@end
Note: See TracBrowser for help on using the repository browser.