home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / Database / OTC_EOFBetaExamples_V1.0 / EOFramework / EOModelInspector / SwapView.m < prev    next >
Encoding:
Text File  |  1994-06-07  |  1.2 KB  |  69 lines

  1. /*--------------------------------------------------------------------------
  2.  *
  3.  *     You may freely copy, distribute, and reuse the code in this example.
  4.  *     SHL Systemhouse disclaims any warranty of any kind, expressed or  
  5.  *    implied, as to its fitness for any particular use.
  6.  *
  7.  *
  8.  *    SwapView
  9.  *
  10.  *    Inherits From:        View
  11.  *
  12.  *    Conforms To:        none
  13.  *
  14.  *    Declared In:        SwapView.h
  15.  *
  16.  *------------------------------------------------------------------------*/
  17.  
  18. #import "SwapView.h"
  19.  
  20.  
  21.  
  22. @implementation SwapView
  23.  
  24. - initFrame: (const NXRect *) theFrame
  25. {
  26.     [super initFrame:theFrame];
  27.     [self setAutoresizeSubviews:YES];
  28.     currentPanel = nil;
  29.     currentView = nil;
  30.     return self;
  31. }
  32.  
  33. - currentPanel
  34. {
  35.     return currentPanel;
  36. }
  37.  
  38. - swap: storagePanel;
  39. {
  40.     id
  41.         aView; 
  42.  
  43.     if (storagePanel != currentPanel)
  44.         {
  45.         aView = [currentPanel contentView];
  46.         [self swapView:[currentPanel contentView]];
  47.         [currentPanel setContentView:aView];
  48.         currentPanel = storagePanel;
  49.         }
  50.  
  51.     return self;
  52. }
  53.  
  54. - swapView: newView;
  55. {
  56.     if (newView != currentView)
  57.         {
  58.         [currentView removeFromSuperview];
  59.         currentView = newView;
  60.         [currentView setFrame:&frame];
  61.         [currentView moveTo:0.0 :0.0];
  62.         [self addSubview:currentView];
  63.         [[self window] display];
  64.         }
  65.  
  66.     return self;
  67. }
  68.  
  69. @end