home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / IBPalettes / WWTCLKit / WWThumbWheelCell.m < prev    next >
Encoding:
Text File  |  1995-03-22  |  20.5 KB  |  725 lines

  1.  
  2. #import "WWThumbWheel.h"
  3. #import "WWThumbWheelCell.h"
  4. #import "WWTCLInterp.h"
  5. #import <ctype.h>
  6.  
  7. @implementation WWThumbWheelCell
  8.  
  9.  
  10. + initialize { [WWThumbWheelCell setVersion:5]; return self; }
  11. ////////////////////////////////////////////////////////
  12. //
  13. - init
  14. {
  15.   [super init];
  16.   controlStringSize = 32;
  17.   controlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  18.   sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  19.   tclExpressionSize = 32;
  20.   tclExpression = (char *)NXZoneCalloc([self zone], tclExpressionSize, sizeof(char));
  21.   tclVarSize = 32;
  22.   tclVar = (char *)NXZoneCalloc([self zone], tclVarSize, sizeof(char));
  23.   tclCommandSize = 32;
  24.   tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
  25.   tclCommandDirty = YES;
  26.  
  27.   return self;
  28. }
  29. //
  30. - awake
  31. {
  32.   [super awake];
  33.   tclCommandDirty = YES;
  34.   return self;
  35. }
  36.  
  37. - free
  38. {
  39.   if (controlString) { NXZoneFree([self zone], controlString); }
  40.   if (sprintfControlString) { NXZoneFree([self zone], sprintfControlString); }
  41.   if (tclExpression) { NXZoneFree([self zone], tclExpression); }
  42.   if (tclVar) { NXZoneFree([self zone], tclVar); }
  43.   if (tclCommand) { NXZoneFree([self zone], tclCommand); }
  44.   return [super free];
  45. }
  46.  
  47. //
  48. - awakeFromNib
  49. {
  50.   [visibleMinText setFloatValue:[self visibleMin]];
  51.   [visibleMaxText setFloatValue:[self visibleMax]];
  52.   [absoluteMinText setFloatValue:[self absoluteMin]];
  53.   [absoluteMaxText setFloatValue:[self absoluteMax]];
  54.   [valText setFloatValue:[self floatValue]];
  55.   [relativeValText setFloatValue:[self relativeFloatValue]];
  56.   return self;
  57. }
  58. //
  59. - setVisibleMin:(float)value
  60. {
  61.    [visibleMinText setFloatValue:value];
  62.    return [super setVisibleMin:value];
  63. }
  64. //
  65. - setVisibleMax:(float)value
  66. {
  67.    [visibleMaxText setFloatValue:value];
  68.    return [super setVisibleMax:value];
  69. }
  70. //
  71. - setAbsoluteMin:(float)value
  72. {
  73.    [absoluteMinText setFloatValue:value];
  74.    return [super setAbsoluteMin:value];
  75. }
  76. //
  77. - setAbsoluteMax:(float)value
  78. {
  79.    [absoluteMaxText setFloatValue:value];
  80.    return [super setAbsoluteMax:value];
  81. }
  82.  
  83. - setStringValue:(const char *)str
  84. {
  85.   char  *theStr;
  86.  
  87.   [super setStringValue:str];
  88.  
  89.   // boy, this is kind of a hack - this should just work...
  90.   // use super method to avoid redoing the rest...
  91.   [super setFloatValue:(float)atof(str)];
  92.  
  93.   theStr = (char *)[self stringValue];
  94.   [visibleMaxText setStringValue:theStr];
  95.   [visibleMinText setStringValue:theStr];
  96.   [absoluteMaxText setStringValue:theStr];
  97.   [absoluteMinText setStringValue:theStr];
  98.   [valText setStringValue:theStr];
  99.   [relativeValText setStringValue:theStr];
  100.   tclCommandDirty = YES;
  101.   return self;
  102. }
  103.  
  104. - setIntValue:(int)val
  105. {
  106.   int   theVal;
  107.  
  108.  
  109.   [super setIntValue:val];
  110.   theVal = [self intValue];
  111.   [visibleMaxText setIntValue:theVal];
  112.   [visibleMinText setIntValue:theVal];
  113.   [absoluteMaxText setIntValue:theVal];
  114.   [absoluteMinText setIntValue:theVal];
  115.   [valText setIntValue:theVal];
  116.   [relativeValText setIntValue:theVal];
  117.   tclCommandDirty = YES;
  118.   return self;
  119. }
  120.  
  121. - setFloatValue:(float)val
  122. {
  123.   float  theVal;
  124.  
  125.  
  126.   [super setFloatValue:val];
  127.   theVal = [self floatValue];
  128.   [visibleMaxText setFloatValue:theVal];
  129.   [visibleMinText setFloatValue:theVal];
  130.   [absoluteMaxText setFloatValue:theVal];
  131.   [absoluteMinText setFloatValue:theVal];
  132.   [valText setFloatValue:theVal];
  133.   [relativeValText setFloatValue:theVal];
  134.   tclCommandDirty = YES;
  135.   return self;
  136. }
  137.  
  138. - setDoubleValue:(double)val
  139. {
  140.   double  theVal;
  141.  
  142.  
  143.   [super setDoubleValue:val];
  144.   theVal = [self doubleValue];
  145.   [visibleMaxText setDoubleValue:theVal];
  146.   [visibleMinText setDoubleValue:theVal];
  147.   [absoluteMaxText setDoubleValue:theVal];
  148.   [absoluteMinText setDoubleValue:theVal];
  149.   [valText setDoubleValue:theVal];
  150.   [relativeValText setDoubleValue:theVal];
  151.   tclCommandDirty = YES;
  152.   return self;
  153. }
  154.  
  155. - reinitializeControlStringAndTclVarFromZone:(NXZone *)zone
  156. {
  157.   controlString = (char *)NXZoneCalloc(zone, controlStringSize, sizeof(char));
  158.   sprintfControlString = (char *)NXZoneCalloc(zone, controlStringSize, sizeof(char));
  159.   tclExpression = (char *)NXZoneCalloc(zone, tclExpressionSize, sizeof(char));
  160.   tclVar = (char *)NXZoneCalloc(zone, tclVarSize, sizeof(char));
  161.   tclCommand = (char *)NXZoneCalloc(zone, tclCommandSize, sizeof(char));
  162.   return self;
  163. }
  164.  
  165. - copyFromZone:(NXZone *)zone
  166. {
  167.   id newCopy = [super copyFromZone:zone];
  168.  
  169.  
  170.   [newCopy reinitializeControlStringAndTclVarFromZone:zone];
  171.   [newCopy setControlString:controlString];
  172.   [newCopy setTclExpression:tclExpression];
  173.   [newCopy setTclVar:tclVar];
  174.   [newCopy setTclCommand:tclCommand];
  175.  
  176.   return newCopy;
  177. }
  178.  
  179. - setInterp:newInterp {  interp = newInterp; return self; }
  180. - interp { return interp; }
  181.  
  182. - resizeTclCommandForArgVector:(char *)argOrderVector
  183. {
  184.   BOOL    done = NO;
  185.  
  186.  
  187.   if (!done && !strcmp("d", argOrderVector))
  188.   {  while (tclCommandSize < (controlStringSize + 32))
  189.      {  if (!tclCommandSize)
  190.     {  tclCommandSize = 32;
  191.            tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
  192.         }
  193.         else
  194.         {  tclCommandSize *= 2;
  195.            tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
  196.         }
  197.      }
  198.      done = YES;
  199.   }
  200.   if (!done && !strcmp("f", argOrderVector))
  201.   {  while (tclCommandSize < (controlStringSize + 32) )
  202.      {  if (!tclCommandSize)
  203.     {  tclCommandSize = 32;
  204.            tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
  205.         }
  206.         else
  207.         {  tclCommandSize *= 2;
  208.            tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
  209.         }
  210.      }
  211.      done = YES;
  212.   }
  213.   if (!done && !strcmp("fff", argOrderVector))
  214.   {  while (tclCommandSize  < (controlStringSize + (2 + (3 * 32))))
  215.      {  if (!tclCommandSize)
  216.     {  tclCommandSize = 32;
  217.            tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
  218.         }
  219.         else
  220.         {  tclCommandSize *= 2;
  221.            tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
  222.         }
  223.      }
  224.      done = YES;
  225.   }
  226.  
  227.   if (!done && !strcmp("RGB", argOrderVector))
  228.   {  while (tclCommandSize  < (controlStringSize + (2 + (3 * 32))))
  229.      {  if (!tclCommandSize)
  230.     {  tclCommandSize = 32;
  231.            tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
  232.         }
  233.         else
  234.         {  tclCommandSize *= 2;
  235.            tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
  236.         }
  237.      }
  238.      done = YES;
  239.   }
  240.  
  241.   if (!done && !strcmp("s", argOrderVector))
  242.   {  const char  *str = [self stringValue]; 
  243.      int   strLen = strlen(str);
  244.  
  245.      while (tclCommandSize < (controlStringSize + strLen))
  246.      {  if (!tclCommandSize)
  247.     {  tclCommandSize = 32;
  248.            tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
  249.         }
  250.         else
  251.         {  tclCommandSize *= 2;
  252.            tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
  253.         }
  254.      }
  255.      done = YES;
  256.   }
  257.   // those were the easy ones; now for the permutations...
  258.  
  259.   return self;
  260. }
  261.  
  262.  
  263. - updateTclCommand
  264. {
  265.   char    *controlStringPtr, *sprintfControlStringPtr;
  266.   BOOL    done;
  267.   int     argOrderSize = 32;
  268.   char    *argOrderVector = (char *)NXZoneCalloc([self zone], argOrderSize, sizeof(char));
  269.   int     argOrderOffset = 0;
  270.  
  271.  
  272.   if (!controlString)
  273.   {  return nil;
  274.   }
  275.  
  276.   // we want to grovel over the controlString, 
  277.   // for right now, we really only tend to have the following patterns 
  278.   // in the controlString: 1 %f, 1 %d, 1 %s, %R, %G, %B
  279.   controlStringPtr = controlString;
  280.   sprintfControlStringPtr = sprintfControlString;
  281.   strcpy(sprintfControlString, controlString);
  282.   while (*controlStringPtr)
  283.   {  if (*controlStringPtr == '%')
  284.      {  sprintfControlStringPtr++;  controlStringPtr++;
  285.         if (*controlStringPtr)
  286.         {  switch (*controlStringPtr)
  287.            {  case 'd':    while (argOrderOffset >= argOrderSize)
  288.                         {  argOrderSize *= 2;
  289.                            argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
  290.                         }
  291.                         argOrderVector[argOrderOffset++] = 'd';
  292.                         sprintfControlStringPtr++; controlStringPtr++;
  293.             break;
  294.               case 'f':    while (argOrderOffset >= argOrderSize)
  295.                         {  argOrderSize *= 2;
  296.                            argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
  297.                         }
  298.                         argOrderVector[argOrderOffset++] = 'f';
  299.                         sprintfControlStringPtr++; controlStringPtr++;
  300.             break;
  301.               case 's':    while (argOrderOffset >= argOrderSize)
  302.                         {  argOrderSize *= 2;
  303.                            argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
  304.                         }
  305.                         argOrderVector[argOrderOffset++] = 's';
  306.                         sprintfControlStringPtr++; controlStringPtr++;
  307.             break;
  308.               case 'R':    while (argOrderOffset >= argOrderSize)
  309.                         {  argOrderSize *= 2;
  310.                            argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
  311.                         }
  312.                         argOrderVector[argOrderOffset++] = 'R';
  313.                         *sprintfControlStringPtr++ = 'f'; controlStringPtr++;
  314.                         break;
  315.               case 'G':    while (argOrderOffset >= argOrderSize)
  316.                         {  argOrderSize *= 2;
  317.                            argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
  318.                         }
  319.                         argOrderVector[argOrderOffset++] = 'G';
  320.                         *sprintfControlStringPtr++ = 'f'; controlStringPtr++;
  321.                         break;
  322.               case 'B':    while (argOrderOffset >= argOrderSize)
  323.                         {  argOrderSize *= 2;
  324.                            argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
  325.                         }
  326.                         argOrderVector[argOrderOffset++] = 'B'; *sprintfControlStringPtr++ = 'f';
  327.                         controlStringPtr++;
  328.                         break;
  329.               case '%':    sprintfControlStringPtr++; controlStringPtr++;
  330.                         break;
  331.                default:    NXLogError("WWSliderCell: unknown specifier <%c> in controlString.\n", *controlStringPtr);
  332.                         sprintfControlStringPtr++; controlStringPtr++;
  333.             break;
  334.            }
  335.        }
  336.      }
  337.      else
  338.      {  sprintfControlStringPtr++;  controlStringPtr++;
  339.      }
  340.   }
  341.   argOrderVector[argOrderOffset] = 0;
  342.  
  343.   done = NO;
  344.  
  345.   if (!done && !strcmp("d", argOrderVector))
  346.   {  [self resizeTclCommandForArgVector:argOrderVector];
  347.      sprintf(tclCommand, sprintfControlString, [self intValue]);
  348.      done = YES;
  349.   }
  350.   if (!done && !strcmp("f", argOrderVector))
  351.   {  [self resizeTclCommandForArgVector:argOrderVector];
  352.      sprintf(tclCommand, sprintfControlString, [self floatValue]);
  353.      done = YES;
  354.   }
  355.   if (!done && !strcmp("s", argOrderVector))
  356.   {  [self resizeTclCommandForArgVector:argOrderVector];
  357.      sprintf(tclCommand, sprintfControlString, [self stringValue]);
  358.      done = YES;
  359.   }
  360.   // for back compatibility
  361.   if (!done && !strcmp("fff", argOrderVector))
  362.   {  [self resizeTclCommandForArgVector:argOrderVector];
  363.      sprintf(tclCommand, sprintfControlString, NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color));
  364.      done = YES;
  365.   }
  366.   if (!done && !strcmp("RGB", argOrderVector))
  367.   {  [self resizeTclCommandForArgVector:argOrderVector];
  368.      sprintf(tclCommand, sprintfControlString, NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color));
  369.      done = YES;
  370.   }
  371.   if (!done && !strcmp("fRGB", argOrderVector))
  372.   {  [self resizeTclCommandForArgVector:argOrderVector];
  373.      sprintf(tclCommand, sprintfControlString, [self floatValue], NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color));
  374.      done = YES;
  375.   }
  376.   if (!done && !strcmp("RGBf", argOrderVector))
  377.   {  [self resizeTclCommandForArgVector:argOrderVector];
  378.      sprintf(tclCommand, sprintfControlString, NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color), [self floatValue]);
  379.      done = YES;
  380.   }
  381.   if (!done && !strcmp("dRGB", argOrderVector))
  382.   {  [self resizeTclCommandForArgVector:argOrderVector];
  383.      sprintf(tclCommand, sprintfControlString, [self intValue], NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color));
  384.      done = YES;
  385.   }
  386.   if (!done && !strcmp("RGBd", argOrderVector))
  387.   {  [self resizeTclCommandForArgVector:argOrderVector];
  388.      sprintf(tclCommand, sprintfControlString, NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color), [self intValue]);
  389.      done = YES;
  390.   }
  391.  
  392.   if (!done)
  393.   {  while (tclCommandSize < controlStringSize)
  394.      {  if (!tclCommandSize)
  395.     {  tclCommandSize = 32;
  396.            tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
  397.         }
  398.         else
  399.         {  tclCommandSize *= 2;
  400.            tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
  401.         }
  402.      }
  403.      strcpy(tclCommand, controlString);
  404.   }
  405.   tclCommandDirty = NO;
  406.  
  407.   NXZoneFree([self zone], argOrderVector);
  408.  
  409.   return self;
  410. }
  411.  
  412.  
  413. - evaluateSelf
  414. {
  415.    int   ret;
  416.    char  *newStringValue;
  417.    id    retID;
  418.  
  419.  
  420.   newStringValue = [interp globalEval:tclExpression :&ret];
  421.   if ((ret == TCL_OK) || (ret == TCL_RETURN))
  422.   {  [self setStringValue:newStringValue];
  423.      retID = self;
  424.   }
  425.   else
  426.   {  NXLogError("WWSliderCell: error <%s> evaluating tcl expression <%s>\n", 
  427.         newStringValue, tclExpression);
  428.      if (newStringValue) { free(newStringValue); }
  429.      retID = nil;
  430.   }
  431.   return retID;
  432. }
  433.  
  434. - updateInterp
  435. {
  436.   if ([interp eval:[self tclCommand]])
  437.   {  return self;
  438.   }
  439.   return nil;
  440. }
  441.  
  442.  
  443. - setControlString:(const char *)str 
  444.   int   cnt;
  445.  
  446.  
  447.   if (!str) { return self; }
  448.   if (controlStringSize <= 0) 
  449.   {  controlStringSize = 32; 
  450.      controlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  451.   }
  452.   cnt = strlen(str);
  453.   while (cnt >= controlStringSize)
  454.   {  controlStringSize *= 2;
  455.      controlString = (char *)NXZoneRealloc([self zone], controlString, controlStringSize);
  456.   }
  457.   if (sprintfControlString)
  458.   {  sprintfControlString = (char *)NXZoneRealloc([self zone], sprintfControlString, controlStringSize);
  459.   }
  460.   else
  461.   {  sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  462.   }
  463.   strcpy(controlString, str); 
  464.   tclCommandDirty = YES;
  465.   return self; 
  466. }
  467. //
  468. - (const char *)controlString { return controlString; }
  469.  
  470. - setTclExpression:(const char *)str 
  471.   int   cnt;
  472.  
  473.  
  474.   if (!str) { return self; }
  475.   if (tclExpressionSize <= 0) 
  476.   {  tclExpressionSize = 32; 
  477.      tclExpression = (char *)NXZoneCalloc([self zone], tclExpressionSize, sizeof(char));
  478.   }
  479.   cnt = strlen(str);
  480.   while (cnt >= tclExpressionSize)
  481.   {  tclExpressionSize *= 2;
  482.      tclExpression = (char *)NXZoneRealloc([self zone], tclExpression, tclExpressionSize);
  483.   }
  484.   strcpy(tclExpression, str); 
  485.   return self; 
  486. }
  487. //
  488. - (const char *)tclExpression { return tclExpression; }
  489.  
  490. - setTclVar:(const char *)str 
  491.   int   cnt;
  492.  
  493.  
  494.   if (!str) { return self; }
  495.   if (tclVarSize <= 0) 
  496.   {  tclVarSize = 32; 
  497.      tclVar = (char *)NXZoneCalloc([self zone], tclVarSize, sizeof(char));
  498.   }
  499.   cnt = strlen(str);
  500.   while (cnt >= tclVarSize)
  501.   {  tclVarSize *= 2;
  502.      tclVar = (char *)NXZoneRealloc([self zone], tclVar, tclVarSize);
  503.   }
  504.   strcpy(tclVar, str); 
  505.   return self; 
  506. }
  507. //
  508. - (const char *)tclVar { return tclVar; }
  509.  
  510. - setTclCommand:(const char *)str 
  511.   int   cnt;
  512.  
  513.  
  514.   if (!str) { return self; }
  515.   if (tclCommandSize <= 0) 
  516.   {  tclCommandSize = 32; 
  517.      tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
  518.   }
  519.   cnt = strlen(str);
  520.   while (cnt >= tclCommandSize)
  521.   {  tclCommandSize *= 2;
  522.      tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
  523.   }
  524.   strcpy(tclCommand, str); 
  525.   return self; 
  526. }
  527. //
  528. - (const char *)tclCommand 
  529.   if (tclCommandDirty)
  530.   {  [self updateTclCommand];
  531.   }
  532.   return tclCommand; 
  533. }
  534.  
  535.  
  536. - write:(NXTypedStream *)stream 
  537. {
  538.    [super write:stream];
  539.    NXWriteType(stream, "*", &controlString);
  540.    NXWriteType(stream, "*", &tclVar);
  541.    NXWriteType(stream, "*", &tclExpression);
  542.    NXWriteType(stream, "*", &tclCommand);
  543.    NXWriteObjectReference(stream, interp);
  544.    return self;
  545. }
  546. //
  547. - read:(NXTypedStream *)stream 
  548. {
  549.    int version;
  550.  
  551.    [super read:stream];
  552.  
  553.    version = NXTypedStreamClassVersion(stream, "WWThumbWheelCell");
  554.    if (version == 1)
  555.    {  NXReadType(stream, "*", &controlString);
  556.       if (controlString) 
  557.       {  controlStringSize = strlen(controlString) + 1;
  558.          sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  559.       }
  560.       else
  561.       {  controlStringSize = 0;
  562.          sprintfControlString = NULL;
  563.       }
  564.       NXReadType(stream, "*", &tclVar);
  565.       if (tclVar) 
  566.       {  tclVarSize = strlen(tclVar) + 1;
  567.       }
  568.       else
  569.       { tclVarSize = 0;
  570.       }
  571.       tclCommandSize = 0;
  572.       tclCommand = NULL;
  573.    }
  574.    if (version == 2)
  575.    {  NXReadType(stream, "*", &controlString);
  576.       if (controlString) 
  577.       {  controlStringSize = strlen(controlString) + 1;
  578.          sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  579.       }
  580.       else
  581.       {  controlStringSize = 0;
  582.          sprintfControlString = NULL;
  583.       }
  584.       NXReadType(stream, "*", &tclVar);
  585.       if (tclVar) 
  586.       {  tclVarSize = strlen(tclVar) + 1;
  587.       }
  588.       else
  589.       { tclVarSize = 0;
  590.       }
  591.       NXReadType(stream, "*", &tclExpression);
  592.       if (tclExpression) 
  593.       {  tclExpressionSize = strlen(tclExpression) + 1;
  594.       }
  595.       else
  596.       {  tclExpressionSize = 0;
  597.       }
  598.       tclCommandSize = 0;
  599.       tclCommand = NULL;
  600.    }
  601.    if (version == 3)
  602.    {  NXReadType(stream, "*", &controlString);
  603.       if (controlString) 
  604.       {  controlStringSize = strlen(controlString) + 1;
  605.       }
  606.       else
  607.       {  controlStringSize = 0;
  608.       }
  609.       NXReadType(stream, "*", &tclVar);
  610.       if (tclVar) 
  611.       {  tclVarSize = strlen(tclVar) + 1;
  612.       }
  613.       else
  614.       { tclVarSize = 0;
  615.       }
  616.       NXReadType(stream, "*", &tclExpression);
  617.       if (tclExpression) 
  618.       {  tclExpressionSize = strlen(tclExpression) + 1;
  619.       }
  620.       else
  621.       {  tclExpressionSize = 0;
  622.       }
  623.       NXReadType(stream, "*", &tclCommand);
  624.       if (tclCommand) 
  625.       {  tclCommandSize = strlen(tclCommand) + 1;
  626.       }
  627.       else
  628.       { tclCommandSize = 0;
  629.       }
  630.       NXReadType(stream, "*", &sprintfControlString);
  631.    }
  632.    if (version == 4)
  633.    {  NXReadType(stream, "*", &controlString);
  634.       if (controlString) 
  635.       {  controlStringSize = strlen(controlString) + 1;
  636.       }
  637.       else
  638.       {  controlStringSize = 0;
  639.       }
  640.       NXReadType(stream, "*", &tclVar);
  641.       if (tclVar) 
  642.       {  tclVarSize = strlen(tclVar) + 1;
  643.       }
  644.       else
  645.       { tclVarSize = 0;
  646.       }
  647.       NXReadType(stream, "*", &tclExpression);
  648.       if (tclExpression) 
  649.       {  tclExpressionSize = strlen(tclExpression) + 1;
  650.       }
  651.       else
  652.       {  tclExpressionSize = 0;
  653.       }
  654.       NXReadType(stream, "*", &tclCommand);
  655.       if (tclCommand) 
  656.       {  tclCommandSize = strlen(tclCommand) + 1;
  657.       }
  658.       else
  659.       { tclCommandSize = 0;
  660.       }
  661.       NXReadType(stream, "*", &sprintfControlString);
  662.       interp = NXReadObject(stream);
  663.       if (sprintfControlString) {  free(sprintfControlString); }
  664.       if (controlStringSize)
  665.       {  sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  666.       }
  667.       else
  668.       {  sprintfControlString = NULL;
  669.       }
  670.    }
  671.    if (version == 5)
  672.    {  NXReadType(stream, "*", &controlString);
  673.       if (controlString) 
  674.       {  controlStringSize = strlen(controlString) + 1;
  675.          sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  676.       }
  677.       else
  678.       {  controlStringSize = 0;
  679.          sprintfControlString = NULL;
  680.       }
  681.       NXReadType(stream, "*", &tclVar);
  682.       if (tclVar) 
  683.       {  tclVarSize = strlen(tclVar) + 1;
  684.       }
  685.       else
  686.       { tclVarSize = 0;
  687.       }
  688.       NXReadType(stream, "*", &tclExpression);
  689.       if (tclExpression) 
  690.       {  tclExpressionSize = strlen(tclExpression) + 1;
  691.       }
  692.       else
  693.       {  tclExpressionSize = 0;
  694.       }
  695.       NXReadType(stream, "*", &tclCommand);
  696.       if (tclCommand) 
  697.       {  tclCommandSize = strlen(tclCommand) + 1;
  698.       }
  699.       else
  700.       { tclCommandSize = 0;
  701.       }
  702.       interp = NXReadObject(stream);
  703.    }
  704.    return self;
  705. }
  706.  
  707. // IB stuff
  708. - (const char *)getInspectorClassName 
  709. {  
  710.    NXEvent  *event = [NXApp currentEvent];
  711.  
  712.    if (event->flags & NX_ALTERNATEMASK)
  713.    {  return [super getInspectorClassName];
  714.    }
  715.    
  716.    return "WWThumbWheelCellIBInspector"; 
  717. }
  718.  
  719. @end
  720.