home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / NSTextAttachment.h < prev    next >
Text File  |  1996-10-17  |  3KB  |  91 lines

  1. /* 
  2.     NSTextAttachment.h
  3.     Copyright (c) 1994-1996, NeXT Software, Inc.
  4.     All rights reserved.
  5.  
  6.     Classes to represent text attachments.
  7.  
  8.     NSTextAttachment is used to represent text attachments. When inline, text attachments appear as the value of the NSAttachmentAttributeName attached to the special character NSAttachmentCharacter.
  9.  
  10.     NSTextAttachment uses an object obeying the NSTextAttachmentCell protocol to get input from the user and to display an image.
  11.  
  12.         NSTextAttachmentCell is a simple subclass of NSCell which provides the NSTextAttachment protocol.
  13. */
  14.  
  15. #ifndef STRICT_OPENSTEP
  16.  
  17. #import <Foundation/Foundation.h>
  18. #import <AppKit/NSCell.h>
  19. #import <AppKit/NSAttributedString.h>
  20.  
  21. @class NSFileWrapper;
  22. @class NSTextAttachment;
  23.  
  24. enum {
  25.     NSAttachmentCharacter = 0xfffc    /* To denote attachments. */
  26. };
  27.  
  28. /* These are the only methods required of cells in text attachments... The default NSCell class implements most of these; the NSTextAttachmentCell class is a subclass which implements all and provides some additional functionality.
  29.  */
  30. @protocol NSTextAttachmentCell <NSObject>
  31. - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
  32. - (BOOL)wantsToTrackMouse;
  33. - (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView *)controlView;
  34. - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag;
  35. - (NSSize)cellSize;
  36. - (NSPoint)cellBaselineOffset;
  37. - (void)setAttachment:(NSTextAttachment *)anObject;
  38. - (NSTextAttachment *)attachment;
  39. @end
  40.  
  41.  
  42. /* Simple class to provide basic attachment cell functionality. By default this class causes NSTextView to send out delegate messages when the attachment is clicked on or dragged.
  43.  */
  44. @interface NSTextAttachmentCell : NSCell <NSTextAttachmentCell> {
  45.     NSTextAttachment *_attachment;
  46. }
  47. @end
  48.  
  49.  
  50. @interface NSTextAttachment : NSObject <NSCoding> {
  51.     NSFileWrapper *_fileWrapper;
  52.     id <NSTextAttachmentCell>_cell;
  53.     struct {
  54.         unsigned int cellWasExplicitlySet:1;
  55.         unsigned int :31;
  56.     } _flags;
  57. }
  58.  
  59. /* Designated initializer.
  60.  */
  61. - (id)initWithFileWrapper:(NSFileWrapper *)fileWrapper;
  62.  
  63. /* The fileWrapper is the meat of most types of attachment.  It can be set or queried with these methods.  An NSTextAttachment usually has a fileWrapper.  setFileWrapper does not update the attachment's cell in any way.
  64.  */
  65. - (void)setFileWrapper:(NSFileWrapper *)fileWrapper;
  66. - (NSFileWrapper *)fileWrapper;
  67.  
  68. /* The cell which handles user interaction. By default an instance of NSTextAttachmentCell is used.
  69.  */
  70. - (id <NSTextAttachmentCell>)attachmentCell;
  71. - (void)setAttachmentCell:(id <NSTextAttachmentCell>)cell;
  72.  
  73. @end
  74.  
  75.  
  76. /* Convenience for creating an attributed string with an attachment.
  77.  */
  78. @interface NSAttributedString (NSAttributedStringAttachmentConveniences)
  79.  
  80. + (NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment *)attachment;
  81.  
  82. @end
  83.  
  84. @interface NSMutableAttributedString (NSMutableAttributedStringAttachmentConveniences)
  85.  
  86. - (void)updateAttachmentsFromPath:(NSString *)path;
  87.  
  88. @end
  89.  
  90. #endif
  91.