home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Examples / AppKit / Yap / Document.h < prev    next >
Text File  |  1996-08-30  |  2KB  |  68 lines

  1. #import <AppKit/AppKit.h>
  2.  
  3. @interface Document : NSObject {
  4.     NSTextView *textView;
  5.     NSString *documentName;        /* If nil, never saved */
  6.     BOOL isDocumentEdited;
  7. }
  8.  
  9. /* Don't call init; call one of these methods... */
  10. - (id)initWithPath:(NSString *)filename;    /* Should be an absolute path here; nil for untitled */
  11. + (Document *)newWithPath:(NSString *)filename;    /* Brings window front. Checks to see if document already open. */
  12. + (Document *)newUntitled;            /* Brings window front */
  13. + (NSArray *)documentsFromOpenPanel;        /* Puts up an open panel and returns an array of all opened documents */
  14.  
  15. /* These set/get the documentName instance var and also set the window title accordingly. "nil" is used if no title. */
  16. - (void)setDocumentName:(NSString *)fileName;
  17. - (NSString *)documentName;
  18.  
  19. /* These determine if document has been edited since last save */
  20. - (void)setDocumentEdited:(BOOL)flag;
  21. - (BOOL)isDocumentEdited;
  22.  
  23. /* Attributes */
  24. - (NSTextView *)textView;
  25. - (NSWindow *)window;
  26.  
  27. /* Misc methods */
  28. + (Document *)documentForWindow:(NSWindow *)window;
  29. + (Document *)documentForPath:(NSString *)filename;
  30. + (NSString *)cleanedUpPath:(NSString *)filename;
  31. + (unsigned)numberOfOpenDocuments;
  32. + (BOOL)closeAllDocuments;
  33. + (BOOL)saveAllDocuments;
  34.  
  35. /* Saving helpers. These return NO or nil if user cancels the save... */
  36. - (BOOL)getDocumentName:(NSString **)newName oldName:(NSString *)oldName;
  37. - (BOOL)saveDocument:(BOOL)showSavePanel;    /* Saves under documentName; if not set, tries to set it first */
  38. - (BOOL)canCloseDocument;    /* Assures document is saved or user doesn't care about the changes; returns NO if user cancels */
  39.  
  40. /* File types to be accepted in open panel */
  41. + (NSArray *)fileTypes;
  42.  
  43. + (void)setLastOpenSavePanelDirectory:(NSString *)dir;
  44. + (NSString *)openSavePanelDirectory;
  45.  
  46. /* Action methods */
  47. - (void)saveAs:(id)sender;
  48. - (void)saveTo:(id)sender;
  49. - (void)save:(id)sender;
  50. - (void)revert:(id)sender;
  51. - (void)close:(id)sender;
  52. - (void)orderFrontFindPanel:(id)sender;
  53. - (void)findNext:(id)sender;
  54. - (void)findPrevious:(id)sender;
  55. - (void)enterSelection:(id)sender;
  56. - (void)jumpToSelection:(id)sender;
  57.  
  58. /* Delegation messages */
  59. - (void)textDidChange:(NSNotification *)textObject;
  60. - (BOOL)windowShouldClose:(id)sender;
  61. - (void)windowWillClose:(NSNotification *)notification;
  62.  
  63. /* File I/O. Returns NO if not successful. Doesn't set documentName. */
  64. - (BOOL)loadFromPath:(NSString *)fileName;
  65. - (BOOL)saveToPath:(NSString *)fileName;
  66.  
  67. @end
  68.