home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / MiscKit1.2.6 / Palettes / MiscValueFieldPalette / MiscValueCellInspector.m < prev    next >
Encoding:
Text File  |  1994-02-21  |  3.4 KB  |  123 lines

  1. //
  2. //    MiscValueCellInspector.m -- an IBInspector that edits a MiscValueCell
  3. //                                  or its MiscValueField.
  4. //       Written by David Fedchenko. Copyright 1994 by David Fedchenko.
  5. //                    Version 1.0  All rights reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the author
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //    
  14.  
  15. #import "MiscValueCellInspector.h"
  16.  
  17. @implementation MiscValueCellInspector
  18.  
  19. - init
  20.     {
  21.     char    buf[MAXPATHLEN + 1];
  22.     id      bundle;
  23.     
  24.     [super init];
  25.     
  26.     bundle = [NXBundle bundleForClass:[MiscValueCell class]];
  27.     [bundle getPath:buf forResource:"MiscValueCellInspector" ofType:"nib"];
  28.     [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
  29.     
  30.     return self;
  31.     }
  32.  
  33. - updateControls
  34.     {
  35.     [idSoftLower setEnabled:[idExpandLower state]];
  36.     [idSoftLowerLabel setEnabled:[idExpandLower state]];
  37.     [idSoftUpper setEnabled:[idExpandUpper state]];
  38.     [idSoftUpperLabel setEnabled:[idExpandUpper state]];
  39.  
  40.     return self;
  41.     }
  42.  
  43. - ok:sender
  44.     {
  45.     [object setMinValue:[idHardLower doubleValue]];
  46.     [object setMaxValue:[idHardUpper doubleValue]];
  47.     [object setMinBoundary:[idSoftLower doubleValue]];
  48.     [object setMaxBoundary:[idSoftUpper doubleValue]];
  49.     [object setStepSize:[idNormal doubleValue]];
  50.     [object setAltStepSize:[idAlternate doubleValue]];
  51.     [object setExpandMin:[idExpandLower state]];
  52.     [object setExpandMax:[idExpandUpper state]];
  53.     [object setContinuous:[idContinuous state]];
  54.     
  55.     [self updateControls];
  56.  
  57.     return [super ok:sender];
  58.     }
  59.  
  60. - revert:sender
  61.     {
  62.     // there is casting here because the NeXT headers have a type conflict
  63.     // for these two methods.
  64.     [idHardLower setDoubleValue:[(MiscValueField *)object minValue]];
  65.     [idHardUpper setDoubleValue:[(MiscValueField *)object maxValue]];
  66.     [idSoftLower setDoubleValue:[object minBoundary]];
  67.     [idSoftUpper setDoubleValue:[object maxBoundary]];
  68.     [idNormal setDoubleValue:[object stepSize]];
  69.     [idAlternate setDoubleValue:[object altStepSize]];
  70.     [idExpandLower setState:[object expandMin]];
  71.     [idExpandUpper setState:[object expandMax]];
  72.     [idContinuous setState:[object isContinuous]];
  73.     
  74.     [self updateControls];
  75.  
  76.     return [super revert:sender];
  77.     }
  78.  
  79. - (BOOL)wantsButtons
  80.     {
  81.     return NO;
  82.     }
  83.  
  84. // the text delegate functions to get the info more better
  85. - textDidEnd:sender endChar:(unsigned short)whyEnd 
  86.     {
  87.     [self ok:sender];
  88.     
  89.     return self;
  90.     }
  91.  
  92. @end
  93.  
  94. @implementation MiscValueField (AttributesInspector)
  95.  
  96. - (const char *)getInspectorClassName
  97.     {
  98.     NXEvent *ev;
  99.  
  100.     ev = [NXApp currentEvent];
  101.     if (ev->flags&NX_ALTERNATEMASK) // get the superclass inspector
  102.         return [super getInspectorClassName];
  103.     else // the real inspector
  104.         return "MiscValueCellInspector";
  105.     }
  106.  
  107. @end
  108.  
  109. @implementation MiscValueCell (AttributesInspector)
  110.  
  111. - (const char *)getInspectorClassName
  112.     {
  113.     NXEvent *ev;
  114.  
  115.     ev = [NXApp currentEvent];
  116.     if (ev->flags&NX_ALTERNATEMASK) // get the superclass inspector
  117.         return [super getInspectorClassName];
  118.     else // the real inspector
  119.         return "MiscValueCellInspector";
  120.     }
  121.  
  122. @end
  123.