home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / Cookbook / 18.scrollText / Document.m < prev    next >
Encoding:
Text File  |  1993-01-19  |  823 b   |  49 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "Document.h"
  5.  
  6. @implementation Document
  7.  
  8. +new
  9. {
  10.     self = [super new];
  11.     [NXApp setDelegate:self];
  12.     openReq = [OpenPanel new];
  13.     return self;
  14. }
  15.  
  16. - setDocument:anObject
  17. {
  18.     document = anObject;
  19.     return self;
  20. }
  21.  
  22. - showError: (char *)errorMessage
  23. {
  24.     NXAlert(errorMessage, "OK", NULL, NULL);
  25. }
  26.  
  27. - openRequest:sender
  28. {
  29.     const char *fileName;
  30.     const char *const types[3] = {"m", "h", NULL};
  31.     NXStream *stream;
  32.         
  33.     if ([openReq runModalForTypes: types] && (fileName = [openReq filename])) {
  34.         if (stream = NXMapFile(fileName, NX_READONLY)) {
  35.             [self showError:"Could not open file"];
  36.             return;
  37.         }
  38.         [[document docView] readText:stream];
  39.         [[document window] setTitle: fileName];
  40.         [document display];
  41.     } else {
  42.         [self showError: "Unable to open file"];
  43.     }
  44.     return self;
  45. }
  46.  
  47.  
  48. @end
  49.