[Scopeapp-cvs]scopeapp/src ScopeController.h,1.4,1.5 ScopeController.m,1.4,1.5
Status: Alpha
Brought to you by:
narge
From: <sco...@li...> - 2002-07-19 07:57:36
|
Update of /cvsroot/scopeapp/scopeapp/src In directory usw-pr-cvs1:/tmp/cvs-serv6333/src Modified Files: ScopeController.h ScopeController.m Log Message: ScopeController now programatically creates its windows, to avoid the nib vs. gmodel problem Index: ScopeController.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/ScopeController.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ScopeController.h 15 Jul 2002 06:05:18 -0000 1.4 --- ScopeController.h 19 Jul 2002 07:57:33 -0000 1.5 *************** *** 39,42 **** --- 39,47 ---- IBOutlet NSPanel* myControlPanel; IBOutlet NSTabView* myModeTabs; + IBOutlet NSTabViewItem* myScopeTab; + IBOutlet NSTabViewItem* myXYPlotTab; + IBOutlet NSTabViewItem* mySpectrumTab; + // IBOutlet NSTabViewItem* myWaterfallTab; + @private id <InputSampler, NSObject> mySampler; *************** *** 51,64 **** // tab view delegate methods - -(void) tabViewDidChangeNumberOfTabViewItems: (NSTabView*) tabView; - -(void) tabView: (NSTabView*) tabView didSelectTabViewItem: (NSTabViewItem*) tabViewItem; - - -(BOOL) tabView: (NSTabView*) tabView - shouldSelectTabViewItem: (NSTabViewItem*) tabViewItem; - - -(void) tabView: (NSTabView*) tabView - willSelectTabViewItem: (NSTabViewItem*) tabViewItem; @end --- 56,61 ---- Index: ScopeController.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/ScopeController.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ScopeController.m 15 Jul 2002 06:05:18 -0000 1.4 --- ScopeController.m 19 Jul 2002 07:57:33 -0000 1.5 *************** *** 25,35 **** // #import "ScopeController.h" ! enum { ! eOscilloscopeTab = 0, ! eXYPlotTab, ! eSpectrumTab ! }; @implementation ScopeController --- 25,43 ---- // + #import "ScopeAppGlobals.h" + #import "ScopeController.h" ! @interface ScopeController (ScopeControllerInternal) ! ! // create the trace window which is managed by this ScopeController, ! // with the appropriate subviews ! -(id) createTraceWindow; ! ! // create the NSPanel containing all the controls for this ! // ScopeController's trace views ! -(id) createControlPanel; ! ! @end @implementation ScopeController *************** *** 37,41 **** -(id) initWithSampler: (id <InputSampler, NSObject>) sampler { ! self = [super initWithWindowNibName: @"ScopeWindow"]; if(self != nil) --- 45,49 ---- -(id) initWithSampler: (id <InputSampler, NSObject>) sampler { ! self = [super initWithWindow: nil]; if(self != nil) *************** *** 44,48 **** mySampler = sampler; ! [mySampler retain]; nCenter = [NSNotificationCenter defaultCenter]; --- 52,63 ---- mySampler = sampler; ! if(mySampler != nil) ! { ! [mySampler retain]; ! } ! ! [self createTraceWindow]; ! [self createControlPanel]; ! [self windowDidLoad]; // would be called when loading from nib nCenter = [NSNotificationCenter defaultCenter]; *************** *** 73,79 **** // selectTabViewItemAtIndex: will ever call // tabView:didSelectTabViewItem: ! [myModeTabs selectTabViewItemAtIndex: eOscilloscopeTab]; ! [self tabView: myModeTabs didSelectTabViewItem: ! [myModeTabs tabViewItemAtIndex: eOscilloscopeTab]]; [myModeTabs setDelegate: self]; } --- 88,93 ---- // selectTabViewItemAtIndex: will ever call // tabView:didSelectTabViewItem: ! [myModeTabs selectTabViewItem: myScopeTab]; ! [self tabView: myModeTabs didSelectTabViewItem: myScopeTab]; [myModeTabs setDelegate: self]; } *************** *** 102,112 **** } - -(void) tabViewDidChangeNumberOfTabViewItems: (NSTabView*) tabView { } - -(void) tabView: (NSTabView *) tabView didSelectTabViewItem: (NSTabViewItem *) tabViewItem; { - int newTab = [tabView indexOfTabViewItem: tabViewItem]; - // assert that the tab view that has been switched is the mode tabs if(tabView != myModeTabs) { return; } --- 116,122 ---- *************** *** 121,147 **** // show and start drawing in the new active view ! switch(newTab) { - case eOscilloscopeTab: [[[self window] contentView] addSubview: myScopeView]; [myScopeView startDrawingWithSampler: mySampler]; ! break; ! case eXYPlotTab: [[[self window] contentView] addSubview: myXYPlotView]; [myXYPlotView startDrawingWithSampler: mySampler]; ! break; ! case eSpectrumTab: ! break; } } ! -(BOOL) tabView: (NSTabView*) tabView ! shouldSelectTabViewItem: (NSTabViewItem*) tabViewItem { ! return YES; } ! -(void) tabView: (NSTabView*) tabView ! willSelectTabViewItem: (NSTabViewItem*) tabViewItem { } ! @end --- 131,228 ---- // show and start drawing in the new active view ! if(tabViewItem == myScopeTab) { [[[self window] contentView] addSubview: myScopeView]; [myScopeView startDrawingWithSampler: mySampler]; ! } ! else if(tabViewItem == myXYPlotTab) ! { [[[self window] contentView] addSubview: myXYPlotView]; [myXYPlotView startDrawingWithSampler: mySampler]; ! } ! else if(tabViewItem == myXYPlotTab) ! { } } ! @end ! ! @implementation ScopeController (ScopeControllerInternal) ! ! - createTraceWindow { ! NSWindow* window; ! NSRect rect = NSMakeRect(0, 0, 400, 400); ! unsigned int flags; ! ! // create the window ! flags = (NSTitledWindowMask | NSClosableWindowMask | ! NSMiniaturizableWindowMask | NSResizableWindowMask); ! window = [[NSWindow alloc] initWithContentRect: rect ! styleMask: flags ! backing: NSBackingStoreBuffered ! defer: YES]; ! [window setTitle: _(@"MacCRO X")]; ! // FIXME move the window to an appropriate position ! // [window setFrameTopLeftPoint: NSMakePoint(20, 63)]; ! [window setMinSize: NSMakeSize(400, 422)]; ! [window setFrameAutosaveName: @"TraceWindow"]; ! [window setFrameUsingName: @"TraceWindow"]; ! ! // create the trace views ! // these are not placed in the window yet; that will be ! // done when a tab is selected in the control panel ! myScopeView = [[ScopeView alloc] initWithFrame: rect]; ! [myScopeView awakeFromNib]; ! [myScopeView autorelease]; ! ! myXYPlotView = [[XYPlotView alloc] initWithFrame: rect]; ! [myXYPlotView awakeFromNib]; ! [myXYPlotView autorelease]; ! ! // now claim control of the window ! [self setWindow: window]; ! [window release]; ! ! return self; } ! - createControlPanel ! { ! // the layout-related magic numbers in this code ! // were determined by running nibtool -a on the ! // original nib file. If you change them, be sure ! // that the interface still looks right. ! NSRect rect; ! unsigned int flags; ! ! // Create the panel ! rect = NSMakeRect(82, 158, 713, 375); ! flags = (NSTitledWindowMask | NSMiniaturizableWindowMask | ! NSUtilityWindowMask); ! myControlPanel = [[NSPanel alloc] initWithContentRect: rect ! styleMask: flags ! backing: NSBackingStoreBuffered ! defer: YES]; ! [myControlPanel setTitle: _(@"Display Controls")]; ! ! // Create the mode tab view ! rect = NSMakeRect(-11, -7, 735, 372); ! myModeTabs = [[NSTabView alloc] initWithFrame: rect]; ! [[myControlPanel contentView] addSubview: myModeTabs]; ! ! // add and populate the tabs ! myScopeTab = [[NSTabViewItem alloc] init]; ! [myScopeTab setLabel: _(@"Oscilloscope")]; ! [myScopeView createControls: [myScopeTab view]]; ! [myModeTabs addTabViewItem: myScopeTab]; ! ! myXYPlotTab = [[NSTabViewItem alloc] init]; ! [myXYPlotTab setLabel: _(@"X/Y Plot")]; ! [myXYPlotView createControls: [myXYPlotTab view]]; ! [myModeTabs addTabViewItem: myXYPlotTab]; ! ! return self; ! } ! @end \ No newline at end of file |