home *** CD-ROM | disk | FTP | other *** search
- #import <appkit/appkit.h>
- #import "SwitchView.h"
-
- @implementation SwitchView
-
- - drawSelf:(const NXRect *)rects :(int)rectCount
- {
- // erase the entire area
- PSsetlinewidth(1.0);
- PSsetgray(NX_LTGRAY);
- NXRectFill(&bounds);
-
- // draw upper line at view's boundary
- PSsetgray(NX_DKGRAY);
- PSmoveto(bounds.origin.x,
- bounds.size.height);
- PSrlineto(bounds.size.width, 0);
- PSstroke();
-
- // draw lower line for bezel effect
- PSsetgray(NX_WHITE);
- PSmoveto(bounds.origin.x,
- bounds.size.height - 1.0);
- PSrlineto(bounds.size.width, 0);
- PSstroke();
-
- return self;
- }
-
- - switchToView:newView
- {
- NXRect rect;
-
- // remove the old view
- [accessoryView removeFromSuperview];
-
- // add the new subview
- accessoryView = newView;
- [self addSubview:accessoryView];
-
- // center the view
- [accessoryView getFrame:&rect];
- rect.origin.y = bounds.origin.y +
- (bounds.size.height -
- rect.size.height) / 2.0;
- rect.origin.x = bounds.origin.x +
- (bounds.size.width -
- rect.size.width) / 2.0;
- [accessoryView moveTo:rect.origin.x
- :rect.origin.y];
-
- // display ourselves -- display
- // sends drawSelf:: to first erase the
- // switchview and then ask the subview
- // (the accessoryView) to display itself
- [self display];
- return self;
- }
-
- @end
-