home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / AlexNeXTSTEPSource / Source / Chapter8_Prefs / Money / SwitchView.m < prev   
Encoding:
Text File  |  1993-04-14  |  1.2 KB  |  61 lines

  1. #import <appkit/appkit.h>
  2. #import "SwitchView.h"
  3.  
  4. @implementation SwitchView
  5.  
  6. - drawSelf:(const NXRect *)rects :(int)rectCount
  7. {
  8.     // erase the entire area
  9.     PSsetlinewidth(1.0);
  10.     PSsetgray(NX_LTGRAY);
  11.     NXRectFill(&bounds);
  12.  
  13.     // draw upper line at view's boundary
  14.     PSsetgray(NX_DKGRAY);
  15.     PSmoveto(bounds.origin.x,
  16.         bounds.size.height);
  17.     PSrlineto(bounds.size.width, 0);
  18.     PSstroke();
  19.  
  20.     // draw lower line for bezel effect
  21.     PSsetgray(NX_WHITE);
  22.     PSmoveto(bounds.origin.x,
  23.         bounds.size.height - 1.0);
  24.     PSrlineto(bounds.size.width, 0);
  25.     PSstroke();
  26.  
  27.     return self;
  28. }
  29.  
  30. - switchToView:newView
  31. {
  32.     NXRect rect;
  33.  
  34.     // remove the old view
  35.     [accessoryView removeFromSuperview];
  36.  
  37.     // add the new subview
  38.     accessoryView = newView;
  39.     [self addSubview:accessoryView];
  40.  
  41.     // center the view
  42.     [accessoryView getFrame:&rect];    
  43.         rect.origin.y = bounds.origin.y +
  44.         (bounds.size.height -
  45.     rect.size.height) / 2.0;
  46.     rect.origin.x = bounds.origin.x +
  47.         (bounds.size.width  -
  48.         rect.size.width) / 2.0;
  49.     [accessoryView moveTo:rect.origin.x
  50.         :rect.origin.y];
  51.  
  52.     // display ourselves -- display
  53.     // sends drawSelf:: to first erase the
  54.     // switchview and then ask the subview
  55.     // (the accessoryView) to display itself    
  56.     [self display];
  57.     return self;
  58. }
  59.  
  60. @end
  61.