home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / eText5 / Source / DebugCounter.bproj / DebugCounter.m next >
Encoding:
Text File  |  1994-11-01  |  1.9 KB  |  56 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //    FILENAME:    DebugCounter.m
  3. //    SUMMARY:    a debugging tool that displays the number of draw: messages
  4. //    SUPERCLASS:    Object
  5. //    INTERFACE:    None
  6. //    PROTOCOLS:    <Annotation, Tool>
  7. //    AUTHOR:        Rohit Khare
  8. //    COPYRIGHT:    (c) 1994 California Institure of Technology, eText Project
  9. ///////////////////////////////////////////////////////////////////////////////
  10. //    DESCRIPTION
  11. //        Does its job by displaying a counter var.
  12. ///////////////////////////////////////////////////////////////////////////////
  13. //    HISTORY
  14. //    10/31/94:    Brought into eText5.
  15. //    05/13/94:    Created. First actual implementation.
  16. ///////////////////////////////////////////////////////////////////////////////
  17.  
  18. #import "../eTextKernel.h"
  19. @interface DebugCounter:Object <Annotation, Tool>
  20. {int counter,highlighted;}
  21. @end
  22. @implementation DebugCounter
  23. + toolAwake:theApp
  24. {
  25.     [theApp   registerAnnotation: [DebugCounter class] 
  26.                             name: "DebugCounter"
  27.                     RTFDirective: "DebugCounter"
  28.                        menuLabel: "Debug/Insert counter..."
  29.                          menuKey: '\0'
  30.                         menuIcon: (NXImage *) nil];
  31.     return self;
  32. }
  33. - init {[super init]; counter = highlighted = 0; return self;}
  34. - initFromPboard:thePB inDoc:theDoc linked:(BOOL) linked {return [self init];}
  35. - calcCellSize:(NXSize *)theSize 
  36.     {theSize->width = theSize->height = 16.0; return self;}
  37. - drawSelf:(const NXRect *)rect inView:view
  38.     {    char tmp[10];
  39.         NXEraseRect(rect);
  40.         PSsetgray(highlighted ? NX_DKGRAY : NX_BLACK);
  41.         PSmoveto(NX_X(rect), NX_Y(rect) + NX_HEIGHT(rect));
  42.         sprintf(tmp,"%d",counter++);
  43.         PSshow(tmp);
  44.         return self;
  45.     }
  46. - highlight:(const NXRect *)rect inView:view lit:(BOOL)flag
  47.     {highlighted = !highlighted; NXHighlightRect(rect);return self;}
  48. - (BOOL)    trackMouse:(NXEvent *)theEvent
  49.             inRect:(const NXRect *)rect
  50.             ofView:view
  51.     {return NO;}
  52. - readRichText:(NXStream *)stream forView:view 
  53.     {return self;}
  54. - writeRichText:(NXStream *)stream forView:view
  55.     {return self;}
  56. @end