Last change
on this file since 34 was 34, checked in by Nicholas Riley, 22 years ago |
Changes for Pester 1.1d1.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[34] | 1 | //
|
---|
| 2 | // PSBeepAlert.m
|
---|
| 3 | // Pester
|
---|
| 4 | //
|
---|
| 5 | // Created by Nicholas Riley on Sat Oct 26 2002.
|
---|
| 6 | // Copyright (c) 2002 Nicholas Riley. All rights reserved.
|
---|
| 7 | //
|
---|
| 8 |
|
---|
| 9 | #import <AppKit/AppKit.h>
|
---|
| 10 | #import "PSBeepAlert.h"
|
---|
| 11 | #import "PSAlarmAlertController.h"
|
---|
| 12 |
|
---|
| 13 | @implementation PSBeepAlert
|
---|
| 14 |
|
---|
| 15 | + (PSBeepAlert *)alertWithRepetitions:(unsigned short)numReps;
|
---|
| 16 | {
|
---|
| 17 | return [[self alloc] initWithRepetitions: numReps];
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | - (id)initWithRepetitions:(unsigned short)numReps;
|
---|
| 21 | {
|
---|
| 22 | if ( (self = [super init]) != nil) {
|
---|
| 23 | repetitions = numReps;
|
---|
| 24 | }
|
---|
| 25 | return self;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | - (void)dealloc;
|
---|
| 29 | {
|
---|
| 30 | [[NSNotificationCenter defaultCenter] removeObserver: self];
|
---|
| 31 | [super dealloc];
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | - (void)beep;
|
---|
| 35 | {
|
---|
| 36 | NSBeep();
|
---|
| 37 | repetitionsRemaining--;
|
---|
| 38 | if (repetitionsRemaining == 0) {
|
---|
| 39 | [self release];
|
---|
| 40 | return;
|
---|
| 41 | }
|
---|
| 42 | [self performSelector: @selector(beep) withObject: nil afterDelay: 0.15 inModes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | - (void)_stopBeeping:(NSNotification *)notification;
|
---|
| 46 | {
|
---|
| 47 | repetitionsRemaining = 1;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | - (void)triggerForAlarm:(PSAlarm *)alarm;
|
---|
| 51 | {
|
---|
| 52 | repetitionsRemaining = repetitions;
|
---|
| 53 | [self retain];
|
---|
| 54 | [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_stopBeeping:) name: PSAlarmAlertStopNotification object: nil];
|
---|
| 55 | [self beep];
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | @end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.