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

  1.  
  2. #import "WWThumbWheelCell.h"
  3. #import "WWThumbWheelCellIBInspector.h"
  4.  
  5. @implementation WWThumbWheelCellIBInspector
  6.  
  7. - init 
  8. {
  9.    char buf[MAXPATHLEN + 1];
  10.    id bundle = [NXBundle bundleForClass:[WWThumbWheelCell class]];
  11.     
  12.  
  13.    [super init];
  14.  
  15.    controlStringSize = 256;
  16.    controlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  17.  
  18.    tclExpressionSize = 256;
  19.    tclExpression = (char *)NXZoneCalloc([self zone], tclExpressionSize, sizeof(char));
  20.  
  21.    [bundle getPath:buf forResource:[[self class] name] ofType:"nib"];
  22.    [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
  23.  
  24.    // since the textView was "hidden" inside the ScrollView, we couldn't do this in IB, so...
  25.    [theControlStringText setDelegate:self];
  26.    [theTclExpressionText setDelegate:self];
  27.  
  28.    [self revert:self];
  29.  
  30.    return self;
  31. }
  32. //
  33. - free
  34. {
  35.   if (controlString) { NXZoneFree([self zone], controlString); }
  36.   if (tclExpression) { NXZoneFree([self zone], tclExpression); }
  37.   return [super free];
  38. }
  39. //
  40. - revert:sender 
  41. {
  42.   [theControlStringText setText:[object controlString]];
  43.   [theTclExpressionText setText:[object tclExpression]];
  44.   [theTclVar setStringValue:[object tclVar]];
  45.   return [super revert:sender];
  46. }
  47. //
  48. - ok:sender
  49. {
  50.   int   cnt;
  51.  
  52.   cnt = [theControlStringText textLength];
  53.   while (cnt >= controlStringSize)
  54.   {  controlStringSize *= 2;
  55.      controlString = (char *)NXZoneRealloc([self zone], controlString, controlStringSize);
  56.   }
  57.   *controlString = '\0';
  58.   [theControlStringText getSubstring:controlString start:0 length:(cnt + 1)];
  59.   [object setControlString:controlString];
  60.  
  61.   cnt = [theTclExpressionText textLength];
  62.   while (cnt >= tclExpressionSize)
  63.   {  tclExpressionSize *= 2;
  64.      tclExpression = (char *)NXZoneRealloc([self zone], tclExpression, tclExpressionSize);
  65.   }
  66.   *tclExpression = '\0';
  67.   [theTclExpressionText getSubstring:tclExpression start:0 length:(cnt + 1)];
  68.   [object setTclExpression:tclExpression];
  69.  
  70.   [object setTclVar:[theTclVar stringValue]];
  71.  
  72.   return [super ok:sender]; 
  73. }
  74. //
  75. - (BOOL)wantsButtons    { return YES; }
  76.  
  77. // text delegate methods
  78. - textDidChange:sender {  return [self touch:sender]; }
  79.  
  80. @end
  81.