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

  1. //
  2. //    MiscSliderCellInspector.m -- an IBInspector that edits a MiscSliderCell
  3. //                                  or its MiscSliderField.
  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 "MiscSliderCellInspector.h"
  16.  
  17. @implementation MiscSliderCellInspector
  18.  
  19. - init
  20.     {
  21.     char    buf[MAXPATHLEN + 1];
  22.     id      bundle;
  23.     
  24.     [super init];
  25.     
  26.     bundle = [NXBundle bundleForClass:[MiscSliderCell class]];
  27.     [bundle getPath:buf forResource:"MiscSliderCellInspector" 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.     float t;
  46.     
  47.     [object setMinValue:[idHardLower doubleValue]];
  48.     [object setMaxValue:[idHardUpper doubleValue]];
  49.     [object setMinBoundary:[idSoftLower doubleValue]];
  50.     [object setMaxBoundary:[idSoftUpper doubleValue]];
  51.     [object setExpandMin:[idExpandLower state]];
  52.     [object setExpandMax:[idExpandUpper state]];
  53.     [object setContinuous:[idContinuous state]];
  54.     [object setPosition:[[idPosition selectedCell] tag]];
  55.     t = [idSplit intValue];
  56.     t = MAX(0, t);
  57.     t = MIN(100, t);
  58.     [object setSplit:t];
  59.     [object setIntegerOnly:[idIntOnly state]];
  60.     
  61.     [self updateControls];
  62.     
  63.     return [super ok:sender];
  64.     }
  65.  
  66. - revert:sender
  67.     {
  68.     // there is casting here because the NeXT headers have a type conflict
  69.     // for these two methods.
  70.     [idHardLower setDoubleValue:[(MiscSliderField *)object minValue]];
  71.     [idHardUpper setDoubleValue:[(MiscSliderField *)object maxValue]];
  72.     [idSoftLower setDoubleValue:[object minBoundary]];
  73.     [idSoftUpper setDoubleValue:[object maxBoundary]];
  74.     [idExpandLower setState:[object expandMin]];
  75.     [idExpandUpper setState:[object expandMax]];
  76.     [idContinuous setState:[object isContinuous]];
  77.     [idPosition selectCellWithTag:[object position]];
  78.     [idSplit setIntValue:[object split]];
  79.     [idIntOnly setState:[object integerOnly]];
  80.     
  81.     [self updateControls];
  82.  
  83.     return [super revert:sender];
  84.     }
  85.  
  86. - (BOOL)wantsButtons
  87.     {
  88.     return NO;
  89.     }
  90.  
  91. // the text delegate functions to get the info more better
  92. - textDidEnd:sender endChar:(unsigned short)whyEnd 
  93.     {
  94.     [self ok:sender];
  95.     
  96.     return self;
  97.     }
  98.  
  99. @end
  100.  
  101.  
  102. @implementation MiscSliderCell (AttributesInspector)
  103.  
  104. - (const char *)getInspectorClassName
  105.     {
  106.     NXEvent *ev;
  107.  
  108.     ev = [NXApp currentEvent];
  109.     if (ev->flags&NX_ALTERNATEMASK) // get the superclass inspector
  110.         return [super getInspectorClassName];
  111.     else // the real inspector
  112.         return "MiscSliderCellInspector";
  113.     }
  114.  
  115. @end
  116.  
  117.  
  118. @implementation MiscSliderField (AttributesInspector)
  119.  
  120. - (const char *)getInspectorClassName
  121.     {
  122.     NXEvent *ev;
  123.  
  124.     ev = [NXApp currentEvent];
  125.     if (ev->flags & NX_ALTERNATEMASK) // get the superclass inspector
  126.         return [super getInspectorClassName];
  127.     else // the real inspector
  128.         return "MiscSliderCellInspector";
  129.     }
  130.  
  131. // this is an override for a category method provided by IB
  132. - placeView:(NXRect *)rect
  133.     {
  134.     float yPos;
  135.     
  136.     switch ([cell position])
  137.         {
  138.     case MSC_ABOVELEFT:
  139.     case MSC_ABOVECENTER:
  140.     case MSC_ABOVERIGHT:
  141.     case MSC_BELOWLEFT:
  142.     case MSC_BELOWCENTER:
  143.     case MSC_BELOWRIGHT:
  144.         yPos = rect->origin.y + rect->size.height;
  145.         rect->size.height -= MSC_WIDTH + MSC_SPACING;
  146.         [super placeView:rect];
  147.         rect->size.height = frame.size.height + MSC_WIDTH + MSC_SPACING;
  148.         rect->origin.y = yPos - rect->size.height;
  149.         [self setFrame:rect];
  150.         break;
  151.         
  152.     default:
  153.         [super placeView:rect];
  154.         break;
  155.         }
  156.     
  157.     return self;
  158.     }
  159.  
  160. @end
  161.