home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Plotting / aa_Intel_Only / Gnuplot / GnuplotSource / OptionsPanel.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.6 KB  |  173 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: OptionsPanel.m,v 1.9 1993/05/18 03:55:27 davis Exp $";
  12.  
  13.  
  14. #import <appkit/Application.h>
  15. #import <appkit/Cell.h>
  16. #import <appkit/Matrix.h>
  17. #import <appkit/Panel.h>
  18. #import <appkit/Text.h>
  19.  
  20. #import "Gnuplot.h"
  21. #import "GnuplotPlot.h"
  22. #import "OptionsPanel.h"
  23.  
  24.  
  25. @interface OptionsPanel (Private)
  26.  
  27. - _updatePanel;
  28.  
  29. @end
  30.  
  31.  
  32. @implementation OptionsPanel
  33.  
  34. - init
  35. {
  36.     [super init];
  37.     return self;
  38. }
  39.  
  40.  
  41. - free
  42. {
  43.     [panel free];
  44.     return [super free];
  45. }
  46.  
  47.  
  48. - panel
  49. {
  50.     return panel;
  51. }
  52.  
  53.  
  54.  
  55. - showPanel:sender
  56. {
  57.     [panel orderFront:self];
  58.     return self;
  59. }
  60.  
  61.  
  62. - forceUpdate
  63. {
  64.     id mainWindow = [NXApp mainWindow];
  65.  
  66.     if (mainWindow)
  67.     status = [[mainWindow delegate] status];
  68.     else
  69.     status = nil;
  70.  
  71.     [self _updatePanel];
  72.  
  73.     return self;
  74. }
  75.  
  76.  
  77. - windowDidUpdate:sender
  78. {
  79.     id        mainWindow = [NXApp mainWindow];
  80.     Status    *newStatus;
  81.  
  82.     if (mainWindow)
  83.     newStatus = [[mainWindow delegate] status];
  84.     else {
  85.     id    doc;
  86.     if (doc = [[NXApp delegate] currentDoc])
  87.         newStatus = [doc status];
  88.     else
  89.         newStatus = nil;
  90.     }
  91.  
  92.     if (newStatus != status) {
  93.     status = newStatus;
  94.     [self _updatePanel];
  95.     }
  96.  
  97.     return self;
  98. }
  99.  
  100.  
  101. // Shuts up the compiler about unused RCSId
  102. - (const char *) rcsid
  103. {
  104.     return RCSId;
  105. }
  106.  
  107.  
  108.  
  109. - textDidEnd:textObject endChar:(unsigned short)whyEnd
  110. {
  111.     /*  
  112.      *  Normally, a text-based control's action is sent only when 
  113.      *  editting ends with a Return.  We use this method to send the 
  114.      *  action on Tab and Backtab, too.
  115.      */
  116.  
  117.     if (_textChanged && ((whyEnd == NX_TAB) || (whyEnd == NX_BACKTAB)))  {
  118.  
  119.     id    control = [textObject delegate];
  120.     Cell    *editCell;
  121.  
  122.     /*  
  123.      *  If the Control is a Matrix, we check to see if the Cell 
  124.      *  being edited has an action, in which case we send it to 
  125.      *  the Cell's target.  Otherwise send the Control's action to 
  126.      *  the Control's target.
  127.      */
  128.     
  129.     if ([control isKindOf:[Matrix class]] &&
  130.         [(editCell = [control selectedCell]) action])
  131.  
  132.         [[editCell controlView] sendAction:[editCell action]
  133.                         to:[editCell target]];
  134.  
  135.     else            /* Otherwise, do the control's action    */
  136.  
  137.         [control sendAction:[control action] to:[control target]];
  138.  
  139.     }
  140.  
  141.     _textChanged = NO;
  142.  
  143.     return self;
  144. }
  145.  
  146.  
  147.  
  148. - (BOOL) textWillChange:textObject
  149. {
  150.     _textChanged = YES;
  151.     return NO;        /* NO means it's okay for the text to change    */
  152. }
  153.  
  154.  
  155.  
  156. @end
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. @implementation OptionsPanel (Private)
  164.  
  165.  
  166. - _updatePanel
  167. {
  168.     return self;
  169. }
  170.  
  171.  
  172. @end
  173.