home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / Gnuplot / Source / Pane.m < prev    next >
Encoding:
Text File  |  1993-03-18  |  2.6 KB  |  161 lines

  1.  
  2. static char RCSId[]="$Id: Pane.m,v 1.1.1.1 1993/03/18 03:34:50 davis Exp $";
  3.  
  4.  
  5. #import <appkit/Application.h>
  6. #import <appkit/Matrix.h>
  7. #import <appkit/Text.h>            /* Pane's can be text delegates */
  8. #import <appkit/TextFieldCell.h>
  9. #import "Pane.h"
  10.  
  11.  
  12. @implementation Pane
  13.  
  14.  
  15. - init
  16. {
  17.     [super init];
  18.  
  19.     title = NULL;
  20.     icon = NULL;
  21.     view = nil;
  22.     status = nil;
  23.     doc = nil;
  24.  
  25.     isCurrentPane = NO;
  26.  
  27.     _textCellChanged = NO;
  28.  
  29.     return self;
  30. }
  31.  
  32.  
  33. - view
  34. {
  35.     return view;
  36. }
  37.  
  38.  
  39.  
  40. - (const char *) icon
  41. {
  42.     return icon;
  43. }
  44.  
  45.  
  46. - setTitle: (const char *) aString
  47. {
  48.     NXZone *zone;
  49.  
  50.     NXZoneFree (zone = [self zone], title);
  51.  
  52.     if (aString)
  53.     title = NXCopyStringBufferFromZone (aString, zone);
  54.     else
  55.     title = NULL;
  56.  
  57.     return self;
  58. }
  59.  
  60.     
  61. - (const char *) title
  62. {
  63.     return title;
  64. }
  65.  
  66.  
  67. - selectControl:sender
  68. {
  69.     return nil;
  70. }
  71.  
  72.  
  73. /*  
  74.  *  Returns YES if the pane has changed and the view needs to be 
  75.  *  redisplayed.
  76.  */
  77. - (BOOL)updateStatus:aStatus doc:aDoc
  78. {
  79.     if (aStatus && aDoc) {
  80.     status = aStatus;
  81.     doc = aDoc;
  82.     return YES;
  83.     } else
  84.     return NO;
  85. }
  86.  
  87.  
  88. /*  
  89.  *  Returns YES if the pane has changed and the view needs to be 
  90.  *  redisplayed.
  91.  */
  92. - (BOOL)forceUpdateStatus:aStatus doc:aDoc
  93. {
  94.     status = nil;
  95.     doc = nil;
  96.     return [self updateStatus:aStatus doc:aDoc];
  97. }
  98.  
  99.  
  100.  
  101. - didSwapIn:sender
  102. {
  103.     isCurrentPane = YES;
  104.     return self;
  105. }
  106.  
  107.  
  108. - didSwapOut:sender
  109. {
  110.     isCurrentPane = NO;
  111.     return self;
  112. }
  113.  
  114.  
  115. - textDidEnd:textObject endChar:(unsigned short)whyEnd
  116. {
  117.     /*  
  118.      *  Under most circumstances, the superview of the textObject is 
  119.      *  the Cell that was being edited.  All of the TextFieldCells in 
  120.      *  the Panes, however, are assumed to be scrollable (so the user 
  121.      *  can enter numbers larger than the space that I've allowed), so 
  122.      *  the superview of the textObject is a ClipView.  The Cell we 
  123.      *  want is the super view of the ClipView.
  124.      */
  125.     id matrix = [[textObject superview] superview];
  126.     id editCell = [matrix selectedCell];
  127.  
  128.     if (_textCellChanged && ((whyEnd == NX_TAB) || (whyEnd == NX_BACKTAB)))  {
  129.  
  130.     if ([editCell action])    /* If cell has its own action, do it    */
  131.         [[editCell controlView]
  132.         sendAction:[editCell action] to:[editCell target]];
  133.  
  134.     else            /* Otherwise, do the matrix's action    */
  135.         [matrix sendAction:[matrix action] to:[matrix target]];
  136.  
  137.     _textCellChanged = NO;
  138.  
  139.     }
  140.  
  141.     return self;
  142. }
  143.  
  144.  
  145.  
  146. - (BOOL) textWillChange:textObject
  147. {
  148.     _textCellChanged = YES;
  149.     return NO;        /* NO means it's okay for the text to change    */
  150. }
  151.  
  152.  
  153. // Shuts up the compiler about unused RCSId
  154. - (const char *) rcsid
  155. {
  156.     return RCSId;
  157. }
  158.  
  159.  
  160. @end
  161.