home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / Palettes / PAScrollViewDeluxePalette / PARuler.m < prev    next >
Text File  |  1993-04-28  |  1KB  |  75 lines

  1. #import "PARuler.h"
  2.  
  3. @implementation PARuler : View
  4.  
  5. - initFrame:(const NXRect *)rect
  6. {
  7.     [super initFrame:rect];
  8.     return self;
  9. }
  10.  
  11. - (int)direction { return direction; }
  12. - setDirection:(int)value { direction = value; return self; }
  13. - (BOOL)isHorizontal { return direction == DIRECTION_HORIZONTAL; }
  14. - setHorizontal { return [self setDirection:DIRECTION_HORIZONTAL]; }
  15. - (BOOL)isVertical { return direction == DIRECTION_VERTICAL; }
  16. - setVertical { return [self setDirection:DIRECTION_VERTICAL]; }
  17.  
  18. - drawSelf:(const NXRect *)rect :(int)count
  19. {
  20.     int i;
  21.     
  22.     NXSetColor(NX_COLORLTGRAY);
  23.     NXRectFill(rect);
  24.     NXRectClip(rect);
  25.  
  26.     if([self isHorizontal]) {
  27.         PSnewpath();
  28.         for(i=NX_X(&bounds); i<NX_MAXX(&bounds); i+=20) {
  29.             PSmoveto(i, NX_Y(&bounds));
  30.             PSlineto(i, NX_MAXY(&bounds)/2);
  31.         }
  32.         PSgsave();
  33.         NXSetColor(NX_COLORDKGRAY);
  34.         PSstroke();
  35.         PSgrestore();
  36.         PStranslate(1,0);
  37.         NXSetColor(NX_COLORWHITE);
  38.         PSstroke();
  39.     }
  40.     
  41.     else {
  42.         PSnewpath();
  43.         for(i=NX_Y(&bounds); i<NX_MAXY(&bounds); i+=20) {
  44.             PSmoveto(NX_X(&bounds), i);
  45.             PSlineto(NX_MAXX(&bounds)/2, i);
  46.         }
  47.         PSgsave();
  48.         NXSetColor(NX_COLORDKGRAY);
  49.         PSstroke();
  50.         PSgrestore();
  51.         PStranslate(0,-1);
  52.         NXSetColor(NX_COLORWHITE);
  53.         PSstroke();
  54.     }
  55.     
  56.     return self;
  57. }
  58.  
  59. - write:(NXTypedStream *)stream
  60. {
  61.     [super write:stream];
  62.     NXWriteType(stream, "i", &direction);
  63.     return self;
  64. }
  65.  
  66. - read:(NXTypedStream *)stream
  67. {
  68.     [super read:stream];
  69.     NXReadType(stream, "i", &direction);
  70.     return self;
  71. }
  72.  
  73.  
  74. @end
  75.