Thread: [Scopeapp-cvs]scopeapp/src ScopeController.h,1.9,1.10 ScopeController.m,1.14,1.15 ScopeAppDelegate.m
Status: Alpha
Brought to you by:
narge
From: <sco...@li...> - 2003-04-25 07:31:26
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv18754/src Modified Files: ScopeController.h ScopeController.m ScopeAppDelegate.m Log Message: Make ScopeController take a class of input sampler to create, not an actual input sampler object; this allows the input sampler's error messages to be displayed in a more sensible manner, using a sheet on the scope window. Index: ScopeController.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/ScopeController.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ScopeController.h 5 Feb 2003 12:55:38 -0000 1.9 --- ScopeController.h 25 Apr 2003 07:31:09 -0000 1.10 *************** *** 26,29 **** --- 26,30 ---- #import <AppKit/AppKit.h> + #import "InputSampler.h" #import "ScopeView.h" #import "SpectrumView.h" *************** *** 31,35 **** //#import "WaterfallView.h" ! @interface ScopeController : NSWindowController { IBOutlet ScopeView* myScopeView; IBOutlet SpectrumView* mySpectrumView; --- 32,36 ---- //#import "WaterfallView.h" ! @interface ScopeController : NSWindowController <InputErrorHandler> { IBOutlet ScopeView* myScopeView; IBOutlet SpectrumView* mySpectrumView; *************** *** 42,48 **** @private id <InputSampler, NSObject> mySampler; } ! -(id) initWithSampler: (id <InputSampler, NSObject>) sampler; -(void) windowBecameMain: (id) notification; --- 43,50 ---- @private id <InputSampler, NSObject> mySampler; + Class mySamplerClass; } ! -(id) initWithSamplerClass: (Class) samplerClass; -(void) windowBecameMain: (id) notification; Index: ScopeController.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/ScopeController.m,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ScopeController.m 14 Feb 2003 11:52:55 -0000 1.14 --- ScopeController.m 25 Apr 2003 07:31:16 -0000 1.15 *************** *** 37,41 **** @implementation ScopeController ! -(id) initWithSampler: (id <InputSampler, NSObject>) sampler { self = [super initWithWindowNibName: @"ScopeWindow"]; --- 37,41 ---- @implementation ScopeController ! -(id) initWithSamplerClass: (Class) samplerClass { self = [super initWithWindowNibName: @"ScopeWindow"]; *************** *** 45,50 **** NSNotificationCenter *nCenter; ! mySampler = sampler; ! [mySampler retain]; nCenter = [NSNotificationCenter defaultCenter]; --- 45,49 ---- NSNotificationCenter *nCenter; ! mySamplerClass = samplerClass; nCenter = [NSNotificationCenter defaultCenter]; *************** *** 60,73 **** -(void) windowDidLoad { - [[self window] orderFront: self]; - [myScopeView retain]; [myXYPlotView retain]; [mySpectrumView retain]; [myControlPanel retain]; ! [myControlPanel orderWindow: NSWindowAbove relativeTo: [[self window] windowNumber]]; // make sure the oscilloscope tab is selected, then // display the oscilloscope; don't set the delegate until --- 59,76 ---- -(void) windowDidLoad { [myScopeView retain]; [myXYPlotView retain]; [mySpectrumView retain]; [myControlPanel retain]; ! ! [[self window] orderFront: self]; ! [myControlPanel orderWindow: NSWindowAbove relativeTo: [[self window] windowNumber]]; + mySampler = [[mySamplerClass alloc] + initWithOwner: nil + withErrorHandler: self]; + // make sure the oscilloscope tab is selected, then // display the oscilloscope; don't set the delegate until *************** *** 160,163 **** --- 163,187 ---- [myControlPanel orderWindow: NSWindowAbove relativeTo: [[self window] windowNumber]]; + } + + -(int) displayError: (NSString*) title + withExtraText: (NSString*) subtitle + withDefaultButton: (NSString*) defaultButton + withCancelButton: (NSString*) cancelButton + isFatal: (BOOL) fatal; + { + SEL sheetClosedHandler = fatal ? @selector(handleFatalError) : nil; + + NSLog(@"Displaying error message..."); + NSBeginAlertSheet(title, defaultButton, cancelButton, nil, + [self window], self, nil, sheetClosedHandler, NULL, subtitle); + + return 0; + } + + - (void) handleFatalError + { + // send a close action to the window; this will call all the appropriate // methods to deallocate everything. + [[self window] close]; } Index: ScopeAppDelegate.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/ScopeAppDelegate.m,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ScopeAppDelegate.m 5 Feb 2003 12:56:14 -0000 1.19 --- ScopeAppDelegate.m 25 Apr 2003 07:31:18 -0000 1.20 *************** *** 37,54 **** { ScopeController* controller; ! id sampler; // FIXME choose an appropriate InputSampler ! sampler = [[PortAudioSampler alloc] init]; ! if(sampler) ! { ! // FIXME eventually this program will be (sort of) document-based, ! // with an NSDocumentController keeping track of all the existing ! // ScopeControllers and their associated windows. For now, just ! // create a ScopeController and let it take care of itself ! controller = [[ScopeController alloc] initWithSampler: sampler]; ! //[controller autorelease]; ! } myLicenseWindow = nil; --- 37,52 ---- { ScopeController* controller; ! Class samplerClass; // FIXME choose an appropriate InputSampler ! samplerClass = [PortAudioSampler class]; ! // FIXME eventually this program will be (sort of) document-based, ! // with an NSDocumentController keeping track of all the existing ! // ScopeControllers and their associated windows. For now, just ! // create a ScopeController and let it take care of itself ! controller = [[ScopeController alloc] ! initWithSamplerClass: samplerClass]; ! //[controller autorelease]; myLicenseWindow = nil; |