home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / IntermediateFrameworks3 / AppKit.framework / Headers / NSSpellChecker.h < prev    next >
Text File  |  1995-12-21  |  4KB  |  92 lines

  1. #import <Foundation/NSObject.h>
  2. #import <Foundation/NSGeometry.h>
  3. #import <Foundation/NSRange.h>
  4. @class NSArray;
  5.  
  6. /* The NSSpellChecker object is used by a client (e.g. a document in an application) to spell-check a given NSString.  There is only one NSSpellChecker instance per application (since spell-checking is interactive and you only have one mouse and one keyboard).
  7.  
  8. The string being spell-checked need only be valid for the duration of the call to checkSpellingOfString:... or countWordsInString:.
  9.  
  10. The usual usage of this is to implement a checkSpelling: method in an object that has text to check, then, upon receiving checkSpelling:, the object calls [[NXSpellChecker sharedInstance] checkSpellingOfString:...] with an NSString object consisting of the text that should be checked.  The caller is responsible for selecting the misspelled word that is found and for updating the panel UI if desired with the updateSpellPanelWithMisspelledWord: method.
  11. */
  12.  
  13. @interface NSSpellChecker : NSObject
  14. {
  15. @private        /* these are private and are */
  16.     id serverHashTable;    /* subject to change in any future */
  17.     id realTextStream;    /* release, so don't access them! */
  18.     id spellController;
  19.     id guessesBrowser;
  20.     id wordField;
  21.     id languagePopUp;
  22.     id guessesList;
  23.     id panel;
  24.     id checkers;
  25.     id userDictionaries;
  26.     id correctButton;
  27.     id guessButton;
  28.     id ignoreButton;
  29.     id accessoryView;
  30.     int startOffset;
  31.     int selectionOffset;
  32.     int selectionSize;
  33.     id dictionaryBrowser;
  34.     char *selectionBuffer;
  35.     void *_spellServers;
  36.     char *lastGuess;
  37.     BOOL autoShowGuessPanel;
  38.     BOOL needDelayedGuess;
  39.     BOOL haveUsed;
  40.     BOOL reserved3;
  41.     id deleteButton;
  42.     id openButton;
  43.     id learnButton;
  44.     id forgetButton;
  45.     void *reserved;
  46. }
  47.  
  48. /* Only one per application. */
  49.  
  50. + sharedSpellChecker;
  51. + (BOOL)sharedSpellCheckerExists;
  52.  
  53. /* returns a guaranteed unique tag to use as the spell document tag for a document.  You should use this method to generate tags, if possible, to avoid collisions with other objects that can be spell checked. */
  54. + (int)uniqueSpellDocumentTag;
  55.  
  56. /* Initiates a spell-check of a string.  Returns the range of the first misspelled word (and optionally the wordCount by reference). */
  57. - (NSRange)checkSpellingOfString:(NSString *)stringToCheck startingAt:(int)startingOffset langauge:(NSString *)language wrap:(BOOL)wrapFlag inSpellDocumentWithTag:(int)tag wordCount:(int *)wordCount;
  58.  
  59. - (NSRange)checkSpellingOfString:(NSString *)stringToCheck startingAt:(int)startingOffset;
  60.  
  61. /* Just counts the words without checking spelling.  Returns -1 if counting words isn't supported by the spell server selected. */
  62. - (int)countWordsInString:(NSString *)stringToCount language:(NSString *)language;
  63.  
  64. /* The checkSpellingOfString:... methods return the range of the misspelled word found.  It is up to the client to select that word in their document and to cause the spelling panel to update itself to reflect the found misspelling.  Clients can call updateSpellPanelWithMisspelledWord: to insure that the spell panel is up to date. */
  65. - (void)updateSpellingPanelWithMisspelledWord:(NSString *)word;
  66.  
  67. /* Sets and gets attributes of the spell-correction panel. */
  68.  
  69. - spellingPanel;
  70. - accessoryView;
  71. - setAccessoryView:aView;
  72.  
  73. /* This method should be called from the client's implementation of -ignoreSpelling: */
  74. - (void)ignoreWord:(NSString *)wordToIgnore inSpellDocumentWithTag:(int)tag;
  75.  
  76. - (NSArray *)ignoredWordsInSpellDocumentWithTag:(int)tag;
  77. - setIgnoredWords:(NSArray *)words inSpellDocumentWithTag:(int)tag;
  78.  
  79. /* When a document closes, it should notify the NSSpellChecker via closeSpellDocumentWithTag: so that its ignored word list gets cleaned up. */
  80. - closeSpellDocumentWithTag:(int)tag;
  81.  
  82. /* Allows programmatic setting of the language to spell-check in (normally chosen by a pop-up-list in the spelling panel and defaulted to the user's preferred language, so call this with care). */
  83.  
  84. - (NSString *)language;
  85. - setLanguage:(NSString *)language;
  86.  
  87. /* Allows programmatic setting of the misspelled word field. */
  88.  
  89. - setWordFieldStringValue:(NSString *)aString;
  90.  
  91. @end
  92.