home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / Palettes / MailComposer / MailComposerInspector.m < prev    next >
Encoding:
Text File  |  1993-01-18  |  2.3 KB  |  85 lines

  1. //----------------------------------------------------------------------------------------------------
  2. //
  3. //    MailComposerInspector
  4. //
  5. //    Inherits From:        IBInspector
  6. //
  7. //    Declared In:        MailComposerInspector.h
  8. //
  9. //    Disclaimer
  10. //
  11. //        You may freely copy, distribute and reuse this software and its
  12. //        associated documentation. I disclaim any warranty of any kind, 
  13. //        expressed or implied, as to its fitness for any particular use.
  14. //
  15. //----------------------------------------------------------------------------------------------------
  16. #import "MailComposerInspector.h"
  17. #import "MailComposer.h"
  18.  
  19.  
  20. @implementation MailComposerInspector
  21.  
  22. - init
  23. {
  24.     //  Initialize and return an instance of this class.  Call [self revert:] to sync with
  25.     //  inspected object.  Set self as delegate for Text and TextFields.  This will 
  26.     //  notify us when inspector is dirty (has been changed).
  27.     
  28.         char     path[MAXPATHLEN+1];
  29.         id         bundle;
  30.         
  31.         [super init];
  32.  
  33.         if ( ! (bundle = [NXBundle bundleForClass: [MailComposerInspector class]] ) ) return nil;        if ( ! [bundle getPath: path forResource: "MailComposerInspector" ofType: "nib"] ) return nil;
  34.         [NXApp loadNibFile: path owner: self  withNames: NO fromZone: [self zone]];
  35.  
  36.     [to setTextDelegate: self];
  37.     [subject setTextDelegate: self];
  38.     [cc setTextDelegate: self];
  39.     [body setDelegate: self];
  40.  
  41.     [self revert: nil];
  42.         return self;
  43. }
  44.  
  45. - revert:sender
  46. {
  47.     //  Sync with inspected object.  Must call [super revert: ].
  48.     
  49.     [to setStringValue: [object to]];
  50.         [subject setStringValue: [object subject]];
  51.         [cc setStringValue: [object cc]];
  52.     [body setSel: 0 :[body textLength]];
  53.     [body replaceSel: [object body]];
  54.  
  55.     [to selectText: nil];
  56.         return [super revert:sender];
  57. }
  58.  
  59. - ok: sender
  60. {
  61.     //  Make changes to object .  Notify IB changes have occurred.
  62.     //  Must call [super ok: ].
  63.  
  64.     STR     bodyText = malloc ([body textLength] + 1);
  65.     [body getSubstring: bodyText  start: 0 length: [body textLength]];
  66.         [object body: bodyText];
  67.     if (bodyText) free(bodyText);
  68.         
  69.         [object to: (STR)[to stringValue]];
  70.         [object subject: (STR)[subject stringValue]];
  71.         [object cc: (STR)[cc stringValue]];
  72.  
  73.     [[NXApp activeDocument] touch];
  74.         return [super ok: sender];
  75. }
  76.  
  77. - (BOOL)wantsButtons
  78. {
  79.     //  Tell IB we do want 'Revert' and 'Ok' buttons...
  80.  
  81.         return YES;
  82. }
  83.  
  84. @end
  85.