home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / PostScript / Pencil / Source / Group.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.0 KB  |  97 lines

  1. /*
  2. Pencil V1.0, Copyright 1994, 95 by Florian Marquardt.
  3. This program may be distributed under the terms of the GNU general
  4. public license (Start Pencil and select "Info>COPYING..." for a copy of the
  5. license).
  6. */
  7. #import "Group.h"
  8.  
  9. extern BOOL globalOutlines;
  10.  
  11. @implementation Group
  12. - (void)draw:(NXRect *)re
  13. {
  14.     int i, c=[slist count]; 
  15.  
  16.     switch(type)
  17.     {
  18.     case PENCIL_STANDARD_GROUP:
  19.     for(i=0;i<c;i++) [[slist objectAt:i] draw:re]; break;
  20.     case PENCIL_CLIP_GROUP:
  21.     PSgsave();
  22.     [[slist objectAt:0] drawPath];
  23.     if(globalOutlines)
  24.         DPSPrintf(DPSGetCurrentContext(), " clip 0 setgray 0 setlinewidth stroke ");
  25.     else
  26.         DPSPrintf(DPSGetCurrentContext(), " clip newpath ");
  27.     for(i=1;i<c;i++) [[slist objectAt:i] draw:re];
  28.     PSgrestore();
  29.     break;
  30.     }
  31. }
  32. - setGroupType:(char)typ { sx=sy=1; type=typ; if(type==PENCIL_CLIP_GROUP && [slist count]) [[slist objectAt:0] setDrawingMethod:"drawF"]; return self; }
  33. - select:(BOOL)yesno { selected=yesno;  return self; }
  34. - free
  35. {
  36.     int i;
  37.     if(slist)
  38.     {
  39.     i=[slist count];
  40.     while(i--) [[slist objectAt:i] free];
  41.     [slist free];
  42.     }
  43.     return [super freeOrig];
  44. }
  45. - (void)drawControl:(NXRect *)re:(int)cp:(float)bsize
  46. {
  47.     [self draw:re];
  48.     [self calculateBoundingBox:nil];
  49.     PSsetgray(.3); PSsetlinewidth(0);
  50.     PSrectstroke(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
  51.  }
  52. - freeLeaveObjects
  53. {
  54.     if(slist)
  55.         [slist free];
  56.     return [super freeOrig];
  57. }
  58. - write:(NXTypedStream *)stream
  59. {
  60.     [super write:stream];
  61.     NXWriteType(stream,"c",&type);
  62.     return self;
  63. }
  64.  
  65. - read:(NXTypedStream *)stream
  66. {
  67.     [super read:stream];
  68.     NXReadType(stream,"c",&type);
  69.     return self;
  70. }
  71.  
  72. - (BOOL)selected:(NXEvent *)te:(int *)cp:(id)view
  73. {
  74.     if(type==PENCIL_CLIP_GROUP)
  75.     {
  76.         return [[slist objectAt:0] selected:te:cp:view];
  77.     }
  78.     else
  79.         return [super selected:te:cp:view];
  80. }
  81.  
  82. - (void)writeType:(NXStream *)to
  83. {
  84.     NXPrintf(to,"2");
  85. }
  86.  
  87. - (void)writeDescription:(NXStream *)to
  88. {
  89.     int i;
  90.     
  91.     [super writeDescription:to];
  92.     NXPrintf(to, " %d ", [slist count]);
  93.     for(i=0;i<[slist count];i++) [[slist objectAt:i] writeDescription:to];
  94. }
  95.  
  96. @end
  97.