home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Plotting / aa_Intel_Only / Gnuplot / GnuplotSource / Pane.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  3.1 KB  |  202 lines

  1. /*
  2.  *  Copyright (C) 1993  Robert Davis
  3.  *
  4.  *  This program is free software; you can redistribute it and/or
  5.  *  modify it under the terms of Version 2, or any later version, of 
  6.  *  the GNU General Public License as published by the Free Software 
  7.  *  Foundation.
  8.  */
  9.  
  10.  
  11. static char RCSId[]="$Id: Pane.m,v 1.10 1993/05/18 03:55:32 davis Exp $";
  12.  
  13.  
  14. #import <appkit/Application.h>
  15. #import <appkit/Matrix.h>
  16. #import <appkit/Text.h>            /* Pane's can be text delegates */
  17. #import <appkit/TextFieldCell.h>
  18.  
  19. #import <objc/NXStringTable.h>
  20.  
  21. #import "Pane.h"
  22.  
  23.  
  24. @implementation Pane
  25.  
  26.  
  27. - init
  28. {
  29.     [super init];
  30.  
  31.     icon = NULL;
  32.     isCurrentPane = NO;
  33.     _textChanged = NO;
  34.  
  35.     return self;
  36. }
  37.  
  38.  
  39. - free
  40. {
  41.     NXZoneFree ([self zone], title);
  42.     [window free];
  43.     if (view)
  44.     [view free];
  45.     [stringSet free];
  46.  
  47.     return [super free];
  48. }
  49.  
  50.  
  51. - awakeFromNib
  52. {
  53.     view = [window setContentView:[[View alloc] init]];
  54.     [self setTitle: [stringSet valueForStringKey:"title"]];
  55.     return self;
  56. }
  57.  
  58.  
  59. - view
  60. {
  61.     return view;
  62. }
  63.  
  64.  
  65.  
  66. - (const char *) icon
  67. {
  68.     return icon;
  69. }
  70.  
  71.  
  72. - setTitle: (const char *) aString
  73. {
  74.     NXZone *zone;
  75.  
  76.     NXZoneFree (zone = [self zone], title);
  77.  
  78.     if (aString)
  79.     title = NXCopyStringBufferFromZone (aString, zone);
  80.     else
  81.     title = NULL;
  82.  
  83.     return self;
  84. }
  85.  
  86.     
  87. - (const char *) title
  88. {
  89.     return title;
  90. }
  91.  
  92.  
  93. - selectControl:sender
  94. {
  95.     return nil;
  96. }
  97.  
  98.  
  99. /*  
  100.  *  Returns YES if the pane has changed and the view needs to be 
  101.  *  redisplayed.
  102.  */
  103. - (BOOL)updateStatus:aStatus doc:aDoc
  104. {
  105.     status = aStatus;
  106.     doc = aDoc;
  107.     return (aStatus && aDoc);
  108. }
  109.  
  110.  
  111. /*  
  112.  *  Returns YES if the pane has changed and the view needs to be 
  113.  *  redisplayed.
  114.  */
  115. - (BOOL)forceUpdateStatus:aStatus doc:aDoc
  116. {
  117.     status = nil;
  118.     doc = nil;
  119.  
  120.     if (isCurrentPane)
  121.     return [self updateStatus:aStatus doc:aDoc];
  122.     else
  123.     return NO;
  124. }
  125.  
  126.  
  127.  
  128. - didSwapIn:sender
  129. {
  130.     isCurrentPane = YES;
  131.     return self;
  132. }
  133.  
  134.  
  135. - didSwapOut:sender
  136. {
  137.     isCurrentPane = NO;
  138.     return self;
  139. }
  140.  
  141.  
  142. - (BOOL) isCurrentPane
  143. {
  144.     return isCurrentPane;
  145. }
  146.  
  147.  
  148. - textDidEnd:textObject endChar:(unsigned short)whyEnd
  149. {
  150.     /*  
  151.      *  Normally, a text-based control's action is sent only when 
  152.      *  editting ends with a Return.  We use this method to send the 
  153.      *  action on Tab and Backtab, too.
  154.      */
  155.  
  156.     if (_textChanged && ((whyEnd == NX_TAB) || (whyEnd == NX_BACKTAB)))  {
  157.  
  158.     id    control = [textObject delegate];
  159.     Cell    *editCell;
  160.  
  161.     /*  
  162.      *  If the Control is a Matrix, we check to see if the Cell 
  163.      *  being edited has an action, in which case we send it to 
  164.      *  the Cell's target.  Otherwise send the Control's action to 
  165.      *  the Control's target.
  166.      */
  167.     
  168.     if ([control isKindOf:[Matrix class]] &&
  169.         [(editCell = [control selectedCell]) action])
  170.  
  171.         [[editCell controlView] sendAction:[editCell action]
  172.                         to:[editCell target]];
  173.  
  174.     else            /* Otherwise, do the control's action    */
  175.  
  176.         [control sendAction:[control action] to:[control target]];
  177.  
  178.     }
  179.  
  180.     _textChanged = NO;
  181.  
  182.     return self;
  183. }
  184.  
  185.  
  186.  
  187. - (BOOL) textWillChange:textObject
  188. {
  189.     _textChanged = YES;
  190.     return NO;        /* NO means it's okay for the text to change    */
  191. }
  192.  
  193.  
  194. // Shuts up the compiler about unused RCSId
  195. - (const char *) rcsid
  196. {
  197.     return RCSId;
  198. }
  199.  
  200.  
  201. @end
  202.