Changeset 34 for trunk/Cocoa/Pester/Source
- Timestamp:
- 10/29/02 22:20:58 (22 years ago)
- Location:
- trunk/Cocoa/Pester/Source
- Files:
-
- 35 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/NSTableView-NJRExtensions.h
r26 r34 1 1 // 2 2 // NSTableView-NJRExtensions.h 3 // HostLauncher3 // Pester 4 4 // 5 // Created by Nicholas Riley on Mon Apr 222002.5 // Created by Nicholas Riley on Sun Oct 27 2002. 6 6 // Copyright (c) 2002 Nicholas Riley. All rights reserved. 7 7 // 8 8 9 #import < Cocoa/Cocoa.h>9 #import <AppKit/AppKit.h> 10 10 11 11 12 12 @interface NSTableView (NJRExtensions) 13 13 14 + (NSImage *)ascendingSortIndicator; 15 + (NSImage *)descendingSortIndicator; 16 14 17 - (float)cellHeight; 15 18 19 - (NSArray *)selectedRowIndices; 20 16 21 @end -
trunk/Cocoa/Pester/Source/NSTableView-NJRExtensions.m
r26 r34 1 1 // 2 2 // NSTableView-NJRExtensions.m 3 // HostLauncher3 // Pester 4 4 // 5 // Created by Nicholas Riley on Mon Apr 222002.5 // Created by Nicholas Riley on Sun Oct 27 2002. 6 6 // Copyright (c) 2002 Nicholas Riley. All rights reserved. 7 7 // … … 10 10 11 11 12 @interface NSTableView (PumaPrivate) 13 // Declarations of 10.1 private methods, just to make the compiler happy. 14 + (id) _defaultTableHeaderReverseSortImage; 15 + (id) _defaultTableHeaderSortImage; 16 @end 17 12 18 @implementation NSTableView (NJRExtensions) 19 20 + (NSImage *)ascendingSortIndicator; 21 { 22 NSImage *result = [NSImage imageNamed: @"NSAscendingSortIndicator"]; 23 if (result == nil && [[NSTableView class] respondsToSelector: @selector(_defaultTableHeaderSortImage)]) 24 result = [NSTableView _defaultTableHeaderSortImage]; 25 return result; 26 } 27 28 + (NSImage *)descendingSortIndicator; 29 { 30 NSImage *result = [NSImage imageNamed:@"NSDescendingSortIndicator"]; 31 if (result == nil && [[NSTableView class] respondsToSelector:@selector(_defaultTableHeaderReverseSortImage)]) 32 result = [NSTableView _defaultTableHeaderReverseSortImage]; 33 return result; 34 } 35 36 - (NSArray *)selectedRowIndices; 37 { 38 NSEnumerator *theEnum = [self selectedRowEnumerator]; 39 NSNumber *rowNumber; 40 NSMutableArray *rowNumberArray = [NSMutableArray arrayWithCapacity: [self numberOfSelectedRows]]; 41 42 while (nil != (rowNumber = [theEnum nextObject]) ) 43 [rowNumberArray addObject: rowNumber]; 44 45 return rowNumberArray; 46 } 13 47 14 48 - (float)cellHeight; -
trunk/Cocoa/Pester/Source/PSAlarm.h
r28 r34 16 16 extern NSString * const PSAlarmTimerExpiredNotification; 17 17 18 // XXX figure out how to support reading old alarms 19 20 @class PSAlert; 21 18 22 @interface PSAlarm : NSObject <NSCoding> { 19 23 PSAlarmType alarmType; … … 23 27 NSString *invalidMessage; 24 28 NSTimer *timer; 29 NSMutableArray *alerts; 25 30 } 26 31 … … 29 34 - (void)setForDate:(NSDate *)date atTime:(NSDate *)time; 30 35 - (void)setMessage:(NSString *)aMessage; 36 - (void)addAlert:(PSAlert *)alert; 37 - (void)removeAlerts; 31 38 32 39 - (NSCalendarDate *)date; 33 40 - (NSTimeInterval)interval; 34 41 - (NSString *)message; 42 - (NSArray *)alerts; 35 43 36 44 - (NSString *)shortDateString; -
trunk/Cocoa/Pester/Source/PSAlarm.m
r28 r34 8 8 9 9 #import "PSAlarm.h" 10 #import "PSAlert.h" 10 11 11 12 NSString * const PSAlarmTimerSetNotification = @"PSAlarmTimerSetNotification"; 12 13 NSString * const PSAlarmTimerExpiredNotification = @"PSAlarmTimerExpiredNotification"; 14 15 // XXX need to reset pending alarms after sleep, they "freeze" and never expire. 13 16 14 17 @implementation PSAlarm … … 22 25 [invalidMessage release]; invalidMessage = nil; 23 26 [timer invalidate]; [timer release]; timer = nil; 27 [alerts release]; alerts = nil; 24 28 [super dealloc]; 25 29 } … … 224 228 { 225 229 return [[self date] compare: [otherAlarm date]]; 230 } 231 232 - (void)addAlert:(PSAlert *)alert; 233 { 234 if (alerts == nil) alerts = [[NSMutableArray alloc] initWithCapacity: 4]; 235 [alerts addObject: alert]; 236 } 237 238 - (void)removeAlerts; 239 { 240 [alerts removeAllObjects]; 241 } 242 243 - (NSArray *)alerts; 244 { 245 return [[alerts copy] autorelease]; 226 246 } 227 247 -
trunk/Cocoa/Pester/Source/PSAlarmNotifierController.h
r26 r34 16 16 } 17 17 18 + (PSAlarmNotifierController *)controllerWithTimerExpiredNotification:(NSNotification *)notification;19 20 18 - (id)initWithAlarm:(PSAlarm *)alarm; 21 19 -
trunk/Cocoa/Pester/Source/PSAlarmNotifierController.m
r28 r34 8 8 9 9 #import "PSAlarmNotifierController.h" 10 #import "PSAlarmAlertController.h" 10 11 #import "PSAlarm.h" 11 12 … … 13 14 14 15 // XXX should use NSNonactivatingPanelMask on 10.2 15 16 + (PSAlarmNotifierController *)controllerWithTimerExpiredNotification:(NSNotification *)notification;17 {18 return [[self alloc] initWithAlarm: [notification object]];19 }20 16 21 17 - (id)initWithAlarm:(PSAlarm *)alarm; … … 25 21 [messageField setStringValue: [alarm message]]; 26 22 [dateField setObjectValue: [alarm date]]; 27 [NSApp requestUserAttention: NSInformationalRequest];28 [NSApp activateIgnoringOtherApps: YES];29 23 [[self window] makeKeyAndOrderFront: nil]; 30 24 [[self window] orderFrontRegardless]; 31 [NSApp cancelUserAttentionRequest: NSInformationalRequest];32 NSBeep();33 25 } 34 26 return self; … … 37 29 - (IBAction)close:(id)sender; 38 30 { 31 [PSAlarmAlertController stopAlerts: sender]; 39 32 [self close]; 40 33 } -
trunk/Cocoa/Pester/Source/PSAlarmSetController.h
r26 r34 10 10 #import "PSAlarm.h" 11 11 12 @class NJRFSObjectSelector; 13 @class NJRSoundPopUpButton; 14 @class NJRVoicePopUpButton; 15 12 16 @interface PSAlarmSetController : NSWindowController { 13 17 IBOutlet NSTextField *messageField; … … 15 19 IBOutlet NSTextField *timeInterval; 16 20 IBOutlet NSPopUpButton *timeIntervalUnits; 21 IBOutlet NSButton *timeIntervalRepeats; 17 22 IBOutlet NSTextField *timeOfDay; 18 23 IBOutlet NSTextField *timeDate; 19 24 IBOutlet NSPopUpButton *timeDateCompletions; // XXX should go away when bug preventing both formatters and popup menus from existing is fixed 25 IBOutlet NSButtonCell *displayMessage; 26 IBOutlet NSButton *bounceDockIcon; 27 IBOutlet NSButtonCell *playSound; 28 IBOutlet NJRSoundPopUpButton *sound; 29 IBOutlet NSTextField *soundRepetitions; 30 IBOutlet NSStepper *soundRepetitionStepper; 31 IBOutlet NSTextField *soundRepetitionsLabel; 32 IBOutlet NSButtonCell *doScript; 33 IBOutlet NJRFSObjectSelector *script; 34 IBOutlet NSButtonCell *doSpeak; 35 IBOutlet NJRVoicePopUpButton *voice; 36 IBOutlet NSButton *scriptSelectButton; 20 37 IBOutlet NSTextField *timeSummary; 21 38 IBOutlet NSButton *setButton; … … 29 46 - (IBAction)dateCompleted:(NSPopUpButton *)sender; 30 47 - (IBAction)inAtChanged:(id)sender; 48 - (IBAction)playSoundChanged:(id)sender; 49 - (IBAction)doScriptChanged:(id)sender; 50 - (IBAction)doSpeakChanged:(id)sender; 31 51 - (IBAction)setAlarm:(NSButton *)sender; 32 52 53 - (IBAction)silence:(id)sender; 54 33 55 @end -
trunk/Cocoa/Pester/Source/PSAlarmSetController.m
r28 r34 8 8 9 9 #import "PSAlarmSetController.h" 10 #import "PSAlarm NotifierController.h"10 #import "PSAlarmAlertController.h" 11 11 #import "NJRDateFormatter.h" 12 #import "NJRFSObjectSelector.h" 13 #import "NJRSoundPopUpButton.h" 14 #import "NJRVoicePopUpButton.h" 15 #import <Carbon/Carbon.h> 16 17 #import "PSDockBounceAlert.h" 18 #import "PSScriptAlert.h" 19 #import "PSNotifierAlert.h" 20 #import "PSBeepAlert.h" 21 #import "PSMovieAlert.h" 22 #import "PSSpeechAlert.h" 12 23 13 24 /* Bugs to file: … … 48 59 [[self window] center]; 49 60 [self inAtChanged: nil]; 61 [self playSoundChanged: nil]; 62 [self doScriptChanged: nil]; 63 [self doSpeakChanged: nil]; 64 [script setFileTypes: [NSArray arrayWithObjects: @"applescript", @"script", NSFileTypeForHFSTypeCode(kOSAFileType), NSFileTypeForHFSTypeCode('TEXT'), nil]]; 65 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(silence:) name: PSAlarmAlertStopNotification object: nil]; 66 [voice setDelegate: self]; 50 67 [[self window] makeKeyAndOrderFront: nil]; 51 68 } … … 131 148 [timeInterval setEnabled: isInterval]; 132 149 [timeIntervalUnits setEnabled: isInterval]; 150 [timeIntervalRepeats setEnabled: isInterval]; 133 151 [timeOfDay setEnabled: !isInterval]; 134 152 [timeDate setEnabled: !isInterval]; … … 140 158 } 141 159 160 - (IBAction)playSoundChanged:(id)sender; 161 { 162 BOOL playSoundSelected = [playSound intValue]; 163 [sound setEnabled: playSoundSelected]; 164 [soundRepetitions setEnabled: playSoundSelected]; 165 [soundRepetitionStepper setEnabled: playSoundSelected]; 166 [soundRepetitionsLabel setTextColor: playSoundSelected ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]]; 167 if (playSoundSelected && sender != nil) 168 [[self window] makeFirstResponder: sound]; 169 } 170 171 // XXX should check the 'Do script:' button when someone drops a script on the button 172 173 - (IBAction)doScriptChanged:(id)sender; 174 { 175 BOOL doScriptSelected = [doScript intValue]; 176 [script setEnabled: doScriptSelected]; 177 [scriptSelectButton setEnabled: doScriptSelected]; 178 if (doScriptSelected && sender != nil) 179 [[self window] makeFirstResponder: scriptSelectButton]; 180 } 181 182 - (IBAction)doSpeakChanged:(id)sender; 183 { 184 BOOL doSpeakSelected = [doSpeak intValue]; 185 [voice setEnabled: doSpeakSelected]; 186 if (doSpeakSelected && sender != nil) 187 [[self window] makeFirstResponder: voice]; 188 } 189 142 190 - (IBAction)dateCompleted:(NSPopUpButton *)sender; 143 191 { … … 159 207 - (IBAction)setAlarm:(NSButton *)sender; 160 208 { 161 PSAlarmNotifierController *notifier = [PSAlarmNotifierController alloc]; 162 if (notifier == nil) { 163 [self setStatus: @"Unable to set alarm."]; 164 return; 165 } 209 // set alarm 166 210 [self setAlarmDateAndInterval: sender]; 167 211 [alarm setMessage: [messageField stringValue]]; … … 170 214 return; 171 215 } 216 217 [alarm removeAlerts]; 218 // dock bounce alert 219 if ([bounceDockIcon state] == NSOnState) 220 [alarm addAlert: [PSDockBounceAlert alert]]; 221 // script alert 222 if ([doScript intValue]) { 223 BDAlias *scriptFileAlias = [script alias]; 224 if (scriptFileAlias == nil) { 225 [self setStatus: @"Unable to set script alert (no script specified?)"]; 226 return; 227 } 228 [alarm addAlert: [PSScriptAlert alertWithScriptFileAlias: scriptFileAlias]]; 229 } 230 // notifier alert 231 if ([displayMessage intValue]) 232 [alarm addAlert: [PSNotifierAlert alert]]; 233 // sound alerts 234 if ([playSound intValue]) { 235 BDAlias *soundAlias = [sound selectedAlias]; 236 unsigned short numReps = [soundRepetitions intValue]; 237 if (soundAlias == nil) // beep alert 238 [alarm addAlert: [PSBeepAlert alertWithRepetitions: numReps]]; 239 else // movie alert 240 [alarm addAlert: [PSMovieAlert alertWithMovieFileAlias: soundAlias repetitions: numReps]]; 241 } 242 // speech alert 243 if ([doSpeak intValue]) 244 [alarm addAlert: [PSSpeechAlert alertWithVoice: [voice titleOfSelectedItem]]]; 245 172 246 [self setStatus: [[alarm date] descriptionWithCalendarFormat: @"Alarm set for %x at %X" timeZone: nil locale: nil]]; 173 247 [[self window] close]; 174 248 [alarm release]; 175 249 alarm = [[PSAlarm alloc] init]; 250 } 251 252 - (IBAction)silence:(id)sender; 253 { 254 [sound stopSoundPreview: self]; 255 [voice stopVoicePreview: self]; 176 256 } 177 257 … … 206 286 { 207 287 // NSLog(@"stopping update timer"); 288 [self silence: nil]; 208 289 [self _stopUpdateTimer]; 209 290 } … … 222 303 223 304 @end 305 306 @implementation PSAlarmSetController (NJRVoicePopUpButtonDelegate) 307 308 - (NSString *)voicePopUpButton:(NJRVoicePopUpButton *)sender previewStringForVoice:(NSString *)voice; 309 { 310 return [messageField stringValue]; 311 } 312 313 @end -
trunk/Cocoa/Pester/Source/PSAlarms.h
r28 r34 4 4 // 5 5 // Created by Nicholas Riley on Fri Oct 11 2002. 6 // Copyright (c) 2002 __MyCompanyName__. All rights reserved.6 // Copyright (c) 2002 Nicholas Riley. All rights reserved. 7 7 // 8 8 -
trunk/Cocoa/Pester/Source/PSAlarmsController.m
r28 r34 122 122 123 123 @end 124 -
trunk/Cocoa/Pester/Source/PSApplication.h
r28 r34 22 22 - (IBAction)orderFrontSetAlarmPanel:(id)sender; 23 23 - (IBAction)orderFrontAlarmsPanel:(id)sender; 24 - (IBAction)stopAlerts:(id)sender; 24 25 25 26 @end -
trunk/Cocoa/Pester/Source/PSApplication.m
r28 r34 9 9 #import "PSApplication.h" 10 10 #import "PSAlarmSetController.h" 11 #import "PSAlarm NotifierController.h"11 #import "PSAlarmAlertController.h" 12 12 #import "PSAlarmsController.h" 13 13 #import "PSAlarm.h" … … 19 19 { 20 20 appIconImage = [[NSImage imageNamed: @"NSApplicationIcon"] retain]; 21 [[NSNotificationCenter defaultCenter] addObserver: [PSAlarm NotifierController class] selector: @selector(controllerWithTimerExpiredNotification:) name: PSAlarmTimerExpiredNotification object: nil];21 [[NSNotificationCenter defaultCenter] addObserver: [PSAlarmAlertController class] selector: @selector(controllerWithTimerExpiredNotification:) name: PSAlarmTimerExpiredNotification object: nil]; 22 22 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(nextAlarmDidChange:) name: PSAlarmsNextAlarmDidChangeNotification object: nil]; 23 23 [PSAlarms setUp]; … … 30 30 [[NSWorkspace sharedWorkspace] openFile: [[NSBundle mainBundle] pathForResource: @"Read Me" ofType: @"rtfd"]]; 31 31 } 32 33 - (IBAction)stopAlerts:(id)sender; 34 { 35 [PSAlarmAlertController stopAlerts: sender]; 36 } 32 37 33 38 - (IBAction)orderFrontSetAlarmPanel:(id)sender;
Note:
See TracChangeset
for help on using the changeset viewer.