home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / NSTextView.h < prev    next >
Text File  |  1996-12-20  |  11KB  |  250 lines

  1. /*
  2.         NSTextView.h
  3.         Application Kit
  4.         Copyright (c) 1994-1996, NeXT Software, Inc.
  5.         All rights reserved.
  6. */
  7.  
  8. #ifndef STRICT_OPENSTEP
  9.  
  10. // NSTextView is a NSText subclass that displays the glyphs laid out in one NSTextContainer.
  11.  
  12. #import <AppKit/NSText.h>
  13. #import <AppKit/NSInputManager.h>
  14. #import <AppKit/NSTextAttachment.h>
  15. #import <AppKit/AppKitDefines.h>
  16.  
  17. @class NSTextContainer;
  18. @class NSTextStorage;
  19. @class NSLayoutManager;
  20. @class NSRulerView;
  21. @class NSRulerMarker;
  22.  
  23. typedef enum _NSSelectionGranularity {
  24.     NSSelectByCharacter = 0,
  25.     NSSelectByWord = 1,
  26.     NSSelectByParagraph = 2,
  27. } NSSelectionGranularity;
  28.  
  29. typedef enum _NSSelectionAffinity {
  30.     NSSelectionAffinityUpstream = 0,
  31.     NSSelectionAffinityDownstream = 1,
  32. } NSSelectionAffinity;
  33.  
  34. @interface NSTextView : NSText <NSTextInput> {
  35.     // no ivars allowed, use _ivars slot from superclass
  36. }
  37.  
  38. /**************************** Initializing ****************************/
  39.  
  40. + (void)registerForServices;
  41.     // This is sent each time a view is initialized.  If you subclass you should ensure that you only register once.
  42.  
  43. - (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer *)container;
  44.     // Designated Initializer. container may be nil.
  45.  
  46. - (id)initWithFrame:(NSRect)frameRect;
  47.     // This variant will create the text network (textStorage, layoutManager, and a container).
  48.  
  49. /***************** Get/Set the container and other stuff *****************/
  50.  
  51. - (NSTextContainer *)textContainer;
  52. - (void)setTextContainer:(NSTextContainer *)container;
  53.     // The set method should not be called directly, but you might want to override it.  Gets or sets the text container for this view.  Setting the text container marks the view as needing display.  The text container calls the set method from its setTextView: method.
  54.  
  55. - (void)replaceTextContainer:(NSTextContainer *)newContainer;
  56.     // This method should be used instead of the primitive -setTextContainer: if you need to replace a view's text container with a new one leaving the rest of the web intact.  This method deals with all the work of making sure the view doesn't get deallocated and removing the old container from the layoutManager and replacing it with the new one.
  57.  
  58. - (void)setTextContainerInset:(NSSize)inset;
  59. - (NSSize)textContainerInset;
  60.     // The textContianerInset determines the padding that the view provides around the container.  The container's origin will be inset by this amount from the bounds point {0,0} and padding will be left to the right and below the container of the same amount.  This inset affects the view sizing in response to new layout and is used by the rectangular text containers when they track the view's frame dimensions.
  61.  
  62. - (NSPoint)textContainerOrigin;
  63. - (void)invalidateTextContainerOrigin;
  64.     // The container's origin in the view is determined from the current usage of the container, the container inset, and the view size.  textContainerOrigin returns this point.  invalidateTextContainerOrigin is sent automatically whenever something changes that causes the origin to possibly move.  You usually do not need to call invalidate yourself. 
  65.  
  66. - (NSLayoutManager *)layoutManager;
  67. - (NSTextStorage *)textStorage;
  68.     // Convenience methods
  69.  
  70. /************************* Key binding entry-point *************************/
  71.  
  72. - (void)insertText:(NSString *)insertString;
  73.     // This method is the funnel point for text insertion after keys pass through the key binder.
  74.  
  75. /*************************** Sizing methods ***************************/
  76.  
  77. - (void)setConstrainedFrameSize:(NSSize)desiredSize;
  78.     // Sets the frame size of the view to desiredSize constrained within min and max size.
  79.  
  80. /***************** New miscellaneous API above and beyond NSText *****************/
  81.  
  82. - (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range;
  83.     // These complete the set of range: type set methods. to be equivalent to the set of non-range taking varieties.
  84.  
  85. - (void)pasteAsPlainText:(id)sender;
  86. - (void)pasteAsRichText:(id)sender;
  87.     // These methods are like paste: (from NSResponder) but they restrict the acceptable type of the pasted data.  They are suitable as menu actions for appropriate "Paste As" submenu commands.
  88.  
  89. /*************************** New Font menu commands ***************************/
  90.  
  91. - (void)turnOffKerning:(id)sender;
  92. - (void)tightenKerning:(id)sender;
  93. - (void)loosenKerning:(id)sender;
  94. - (void)useStandardKerning:(id)sender;
  95. - (void)turnOffLigatures:(id)sender;
  96. - (void)useStandardLigatures:(id)sender;
  97. - (void)useAllLigatures:(id)sender;
  98. - (void)raiseBaseline:(id)sender;
  99. - (void)lowerBaseline:(id)sender;
  100.  
  101. /*************************** New Text menu commands ***************************/
  102.  
  103. #if !defined(STRICT_40) && !defined(STRICT_41)
  104. - (void)alignJustified:(id)sender;
  105. #endif
  106.  
  107. /*************************** Ruler support ***************************/
  108.  
  109. - (void)rulerView:(NSRulerView *)ruler didMoveMarker:(NSRulerMarker *)marker;
  110. - (void)rulerView:(NSRulerView *)ruler didRemoveMarker:(NSRulerMarker *)marker;
  111. - (void)rulerView:(NSRulerView *)ruler didAddMarker:(NSRulerMarker *)marker;
  112. - (BOOL)rulerView:(NSRulerView *)ruler shouldMoveMarker:(NSRulerMarker *)marker;
  113. - (BOOL)rulerView:(NSRulerView *)ruler shouldAddMarker:(NSRulerMarker *)marker;
  114. - (float)rulerView:(NSRulerView *)ruler willMoveMarker:(NSRulerMarker *)marker toLocation:(float)location;
  115. - (BOOL)rulerView:(NSRulerView *)ruler shouldRemoveMarker:(NSRulerMarker *)marker;
  116. - (float)rulerView:(NSRulerView *)ruler willAddMarker:(NSRulerMarker *)marker atLocation:(float)location;
  117. - (void)rulerView:(NSRulerView *)ruler handleMouseDown:(NSEvent *)event;
  118.  
  119. /*************************** Fine display control ***************************/
  120.  
  121. - (void)setNeedsDisplayInRect:(NSRect)rect avoidAdditionalLayout:(BOOL)flag;
  122.  
  123. - (BOOL)shouldDrawInsertionPoint;
  124. - (void)drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag;
  125.  
  126. /*************************** Especially for subclassers ***************************/
  127.  
  128. - (void)updateRuler;
  129. - (void)updateFontPanel;
  130.  
  131. - (NSArray *)acceptableDragTypes;
  132. - (void)updateDragTypeRegistration;
  133.  
  134. - (NSRange)selectionRangeForProposedRange:(NSRange)proposedCharRange granularity:(NSSelectionGranularity)granularity;
  135.  
  136.  
  137. @end
  138.  
  139. @interface NSTextView (NSSharing)
  140.  
  141. // The methods in this category deal with settings that need to be shared by all the NSTextViews of a single NSLayoutManager.  Many of these methods are overrides of NSText or NSResponder methods.
  142.  
  143. /*************************** Selected/Marked range ***************************/
  144.  
  145. - (void)setSelectedRange:(NSRange)charRange affinity:(NSSelectionAffinity)affinity stillSelecting:(BOOL)stillSelectingFlag;
  146. - (NSSelectionAffinity)selectionAffinity;
  147. - (NSSelectionGranularity)selectionGranularity;
  148. - (void)setSelectionGranularity:(NSSelectionGranularity)granularity;
  149.  
  150. - (void)setSelectedTextAttributes:(NSDictionary *)attributeDictionary;
  151. - (NSDictionary *)selectedTextAttributes;
  152.  
  153. - (void)setInsertionPointColor:(NSColor *)color;
  154. - (NSColor *)insertionPointColor;
  155.  
  156. - (void)updateInsertionPointStateAndRestartTimer:(BOOL)restartFlag;
  157.  
  158. - (NSRange)markedRange;
  159.  
  160. - (void)setMarkedTextAttributes:(NSDictionary *)attributeDictionary;
  161. - (NSDictionary *)markedTextAttributes;
  162.  
  163. /*************************** Other NSTextView methods ***************************/
  164.  
  165. - (void)setRulerVisible:(BOOL)flag;
  166. - (BOOL)usesRuler;
  167. - (void)setUsesRuler:(BOOL)flag;
  168.  
  169. - (int)spellCheckerDocumentTag;
  170.  
  171. - (NSDictionary *)typingAttributes;
  172. - (void)setTypingAttributes:(NSDictionary *)attrs;
  173.  
  174. - (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;
  175. - (void)didChangeText;
  176.  
  177. - (NSRange)rangeForUserTextChange;
  178. - (NSRange)rangeForUserCharacterAttributeChange;
  179. - (NSRange)rangeForUserParagraphAttributeChange;
  180.  
  181. /*************************** NSText methods ***************************/
  182.  
  183. - (BOOL)isSelectable;
  184. - (void)setSelectable:(BOOL)flag;
  185. - (BOOL)isEditable;
  186. - (void)setEditable:(BOOL)flag;
  187. - (BOOL)isRichText;
  188. - (void)setRichText:(BOOL)flag;
  189. - (BOOL)importsGraphics;
  190. - (void)setImportsGraphics:(BOOL)flag;
  191. - (id)delegate;
  192. - (void)setDelegate:(id)anObject;
  193. - (BOOL)isFieldEditor;
  194. - (void)setFieldEditor:(BOOL)flag;
  195. - (BOOL)usesFontPanel;
  196. - (void)setUsesFontPanel:(BOOL)flag;
  197. - (BOOL)isRulerVisible;
  198. - (void)setBackgroundColor:(NSColor *)color;
  199. - (NSColor *)backgroundColor;
  200. - (void)setDrawsBackground:(BOOL)flag;
  201. - (BOOL)drawsBackground;
  202.  
  203. - (NSRange)selectedRange;
  204. - (void)setSelectedRange:(NSRange)charRange;
  205.  
  206. /*************************** NSResponder methods ***************************/
  207.  
  208. - (BOOL)resignFirstResponder;
  209. - (BOOL)becomeFirstResponder;
  210.  
  211. /*************************** Smart copy/paste/delete support ***************************/
  212.  
  213. - (BOOL)smartInsertDeleteEnabled;
  214. - (void)setSmartInsertDeleteEnabled:(BOOL)flag;
  215. - (NSRange)smartDeleteRangeForProposedRange:(NSRange)proposedCharRange;
  216. - (void)smartInsertForString:(NSString *)pasteString replacingRange:(NSRange)charRangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString;
  217.  
  218. @end
  219.  
  220. // Note that all delegation messages come from the first textView
  221.  
  222. @interface NSObject (NSTextViewDelegate)
  223.  
  224. - (void)textView:(NSTextView *)textView clickedOnCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame;    // Delegate only.
  225.  
  226. - (void)textView:(NSTextView *)textView doubleClickedOnCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame;
  227.     // Delegate only.
  228.  
  229. - (void)textView:(NSTextView *)view draggedCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)rect event:(NSEvent *)event;    // Delegate only
  230.  
  231. - (NSRange)textView:(NSTextView *)textView willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange toCharacterRange:(NSRange)newSelectedCharRange;
  232.     // Delegate only.
  233.  
  234. - (void)textViewDidChangeSelection:(NSNotification *)notification;
  235.  
  236. - (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;
  237.     // Delegate only.  If characters are changing, replacementString is what will replace the affectedCharRange.  If attributes only are changing, replacementString will be nil.
  238.  
  239. - (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector;
  240.  
  241. @end
  242.  
  243. APPKIT_EXTERN NSString *NSTextViewWillChangeNotifyingTextViewNotification;
  244.     // NSOldNotifyingTextView -> the old view, NSNewNotifyingTextView -> the new view.  The text view delegate is not automatically registered to receive this notification because the text machinery will automatically switch over the delegate to observe the new first text view as the first text view changes.
  245.  
  246. APPKIT_EXTERN NSString *NSTextViewDidChangeSelectionNotification;
  247.     // NSOldSelectedCharacterRange -> NSValue with old range.
  248.  
  249. #endif
  250.