home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / eText5 / Source / Bookmark.subproj / eTPointmark.m < prev    next >
Encoding:
Text File  |  1994-11-13  |  2.4 KB  |  93 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //    FILENAME:    eTPointmark.m 
  3. //    SUMMARY:    Implementation of single-point markers in eText
  4. //    SUPERCLASS:    eTBookmark
  5. //    INTERFACE:    None
  6. //    PROTOCOLS:    <Annotation,HTMDSupport,ASCIISupport,LaTeXSupport,Tool,
  7. //                InspectableTarget>
  8. //    AUTHOR:        Rohit Khare
  9. //    COPYRIGHT:    (c) 1994 California Institure of Technology, eText Project
  10. ///////////////////////////////////////////////////////////////////////////////
  11. //    IMPLEMENTATION COMMENTS
  12. //        This is a tricky set of workarounds for eTBookmark.
  13. ///////////////////////////////////////////////////////////////////////////////
  14. //    HISTORY
  15. //    10/31/94:    Created. Kludged together as a subclass of Bookmarks.
  16. ///////////////////////////////////////////////////////////////////////////////
  17.  
  18. #import "eTPointmark.h"
  19. #define    _eTPointmarkVERSION    10
  20.  
  21. @implementation eTPointmark
  22.  
  23. + toolAwake:theApp
  24. {
  25.     char        buf[MAXPATHLEN];
  26.     NXBundle    *bundle;
  27.  
  28.     bundle = [NXBundle bundleForClass:[eTBookmark class]];
  29.     if ([bundle getPath:buf forResource:".pm" ofType:"tiff"] ) {
  30.         theIcon = [[NXImage alloc] initFromFile:buf];
  31.         [theIcon setName:".pm"];
  32.     } else {
  33.         NXLogError("Image not found: .pm");
  34.     }
  35.     [theApp   registerAnnotation: [eTPointmark class] 
  36.                             name: "eTPointmark"
  37.                     RTFDirective: "eTPointmark"
  38.                        menuLabel: "Mark Point"
  39.                          menuKey: 0
  40.                         menuIcon: (NXImage *) theIcon];
  41.     return self;
  42. }
  43.  
  44. - init 
  45. {
  46.     [super init];
  47.     theIcon = [NXImage findImageNamed:".pm"];
  48.     if (theTextFieldCell) {
  49.         theTextFieldCell=[theTextFieldCell free];
  50.     }
  51.     collapsed = NO;
  52.     return self;
  53. }
  54.  
  55. - initFromPboard:thePboard inDoc:theDoc linked:(BOOL) linked
  56. {    
  57.     // No registration calls!
  58.     
  59.     [self init];
  60.     etDoc = theDoc;
  61.     anchorID = [NXApp uniqueID];
  62.     anchorTitle = NXUniqueString([[theDoc docInfo] docTitle]);
  63.     [etDoc registerNotification:self];
  64.     [self click:self];
  65.     return self;
  66. }
  67.  
  68. - setCondition:(const char *) newCondition {return self;}
  69. - collapse {return self;}
  70. - expand {return self;}
  71.  
  72. - doubleClick:sender
  73. {
  74.     return self;
  75. }
  76.  
  77. - highlight:sender
  78. {
  79.     int    begin,end;
  80.     
  81.     begin = [theText positionForAnnotation:self];
  82.     if (begin == -1) {NXBeep(); return self;}
  83.     
  84.     // find eoparagraph and insert an end there
  85.     end =[theText positionFromLine:([theText lineFromPosition:begin]+1)]-1;
  86.     if (end < begin) end = begin+1;
  87.         
  88.     [theText setSel:(begin) :(end+1)];
  89.     [theText scrollSelToVisible];
  90.     return self;
  91. }
  92.  
  93. @end