home *** CD-ROM | disk | FTP | other *** search
-
- #import "WWSlider.h"
- #import "WWSliderCell.h"
- #import "WWTCLInterp.h"
- #import <dpsclient/psops.h>
-
- #import "avoidStupidWarnings.h"
-
- @implementation WWSliderCell
-
-
- + initialize { [WWSliderCell setVersion:5]; return self; }
- ////////////////////////////////////////////////////////
- //
- - init
- {
- [super init];
- controlStringSize = 32;
- controlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- tclExpressionSize = 32;
- tclExpression = (char *)NXZoneCalloc([self zone], tclExpressionSize, sizeof(char));
- tclVarSize = 32;
- tclVar = (char *)NXZoneCalloc([self zone], tclVarSize, sizeof(char));
- tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- autoSendP = YES;
- interp = nil;
- usingPrivateImage = NO;
- color = NXConvertGrayToColor(.5);
- tclCommandDirty = YES;
-
- return self;
- }
- //
- - awake
- {
- [super awake];
- usingPrivateImage = NO;
- tclCommandDirty = YES;
-
- return self;
- }
-
- - free
- {
- if (controlString) { NXZoneFree([self zone], controlString); }
- if (sprintfControlString) { NXZoneFree([self zone], sprintfControlString); }
- if (tclExpression) { NXZoneFree([self zone], tclExpression); }
- if (tclVar) { NXZoneFree([self zone], tclVar); }
- if (tclCommand) { NXZoneFree([self zone], tclCommand); }
- return [super free];
- }
-
- //
- - awakeFromNib
- {
- [minText setFloatValue:[self minValue]];
- [maxText setFloatValue:[self maxValue]];
- [valText setFloatValue:[self floatValue]];
- return self;
- }
- //
- - setMinValue:(double)aDouble
- {
- [minText setFloatValue:aDouble];
- return [super setMinValue:aDouble];
- }
- //
- - setMaxValue:(double)aDouble
- {
- [maxText setFloatValue:aDouble];
- return [super setMaxValue:aDouble];
- }
-
- //
- - setAutoSendP:(BOOL)newFlag { autoSendP = newFlag; return self; }
- - (BOOL)autoSendP { return autoSendP; }
-
- - setStringValue:(const char *)str
- {
- char *theStr;
-
- [super setStringValue:str];
-
- // why am I doing this? cause I did it in WWThumbWheel, but I don't
- // remember why...
- // I think maybe that if it's zero, it make the string value NULL, not "0"
- [super setFloatValue:(float)atof(str)];
-
- theStr = (char *)[self stringValue];
- [minText setStringValue:theStr];
- [maxText setStringValue:theStr];
- [valText setStringValue:theStr];
- tclCommandDirty = YES;
- return self;
- }
-
- - setIntValue:(int)val
- {
- int theVal;
-
-
- [super setIntValue:val];
- theVal = [self intValue];
- [minText setIntValue:theVal];
- [maxText setIntValue:theVal];
- [valText setIntValue:theVal];
- tclCommandDirty = YES;
- return self;
- }
-
- - setFloatValue:(float)val
- {
- float theVal;
-
-
- [super setFloatValue:val];
- theVal = [self floatValue];
- [minText setFloatValue:theVal];
- [maxText setFloatValue:theVal];
- [valText setFloatValue:theVal];
- tclCommandDirty = YES;
- return self;
- }
-
- - setDoubleValue:(double)val
- {
- double theVal;
-
-
- [super setDoubleValue:val];
- theVal = [self doubleValue];
- [minText setDoubleValue:theVal];
- [maxText setDoubleValue:theVal];
- [valText setDoubleValue:theVal];
- tclCommandDirty = YES;
- return self;
- }
-
- - reinitializeControlStringAndTclVarFromZone:(NXZone *)zone
- {
- controlString = (char *)NXZoneCalloc(zone, controlStringSize, sizeof(char));
- sprintfControlString = (char *)NXZoneCalloc(zone, controlStringSize, sizeof(char));
- tclExpression = (char *)NXZoneCalloc(zone, tclExpressionSize, sizeof(char));
- tclVar = (char *)NXZoneCalloc(zone, tclVarSize, sizeof(char));
- tclCommand = (char *)NXZoneCalloc(zone, tclCommandSize, sizeof(char));
- return self;
- }
-
- - copyFromZone:(NXZone *)zone
- {
- id newCopy = [super copyFromZone:zone];
-
-
- [newCopy reinitializeControlStringAndTclVarFromZone:zone];
- [newCopy setControlString:controlString];
- [newCopy setTclExpression:tclExpression];
- [newCopy setTclVar:tclVar];
- [newCopy setTclCommand:tclCommand];
- [newCopy setColor:color];
-
- return newCopy;
- }
-
- - setInterp:newInterp { interp = newInterp; return self; }
- - interp { return interp; }
-
- - resizeTclCommandForArgVector:(char *)argOrderVector
- {
- BOOL done = NO;
-
- // there has got to be a better, less pathological way of doing this...
-
- if (!done && !strcmp("d", argOrderVector))
- { while (tclCommandSize < (controlStringSize + 32))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
- if (!done && (!strcmp("Td", argOrderVector) || !strcmp("dT", argOrderVector)))
- { while (tclCommandSize < (controlStringSize + (2 * 32)))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
- if (!done && !strcmp("T", argOrderVector))
- { while (tclCommandSize < (controlStringSize + 32))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
- if (!done && !strcmp("f", argOrderVector))
- { while (tclCommandSize < (controlStringSize + 32) )
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
- if (!done && (!strcmp("Tf", argOrderVector) || !strcmp("fT", argOrderVector)))
- { while (tclCommandSize < (controlStringSize + (2 * 32)))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
- if (!done && !strcmp("fff", argOrderVector))
- { while (tclCommandSize < (controlStringSize + (2 + (3 * 32))))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
-
- if (!done && !strcmp("RGB", argOrderVector))
- { while (tclCommandSize < (controlStringSize + (2 + (3 * 32))))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
- if (!done && (!strcmp("RGBf", argOrderVector) || !strcmp("fRGB", argOrderVector) || !strcmp("dRGB", argOrderVector) || !strcmp("RGBd", argOrderVector)))
- { while (tclCommandSize < (controlStringSize + (2 + (4 * 32))))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
-
- if (!done && !strcmp("s", argOrderVector))
- { const char *str = [self stringValue];
- int strLen = strlen(str);
-
- while (tclCommandSize < (controlStringSize + strLen))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
- if (!done && (!strcmp("sT", argOrderVector) || !strcmp("Ts", argOrderVector)))
- { const char *str = [self stringValue];
- int strLen = strlen(str);
-
- while (tclCommandSize < (controlStringSize + (strLen + 32)))
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- done = YES;
- }
- // those were the easy ones; now for the permutations...
-
- return self;
- }
-
-
- - updateTclCommand
- {
- char *controlStringPtr, *sprintfControlStringPtr;
- BOOL done;
- int argOrderSize = 32;
- char *argOrderVector = (char *)NXZoneCalloc([self zone], argOrderSize, sizeof(char));
- int argOrderOffset = 0;
-
-
- if (!controlString)
- { return nil;
- }
-
- // we want to grovel over the controlString,
- // for right now, we really only tend to have the following patterns
- // in the controlString: 1 %f, 1 %d, 1 %s, %R, %G, %B, 1 %T
- controlStringPtr = controlString;
- sprintfControlStringPtr = sprintfControlString;
- strcpy(sprintfControlString, controlString);
- while (*controlStringPtr)
- { if (*controlStringPtr == '%')
- { sprintfControlStringPtr++; controlStringPtr++;
- if (*controlStringPtr)
- { switch (*controlStringPtr)
- { case 'd': while (argOrderOffset >= argOrderSize)
- { argOrderSize *= 2;
- argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
- }
- argOrderVector[argOrderOffset++] = 'd';
- sprintfControlStringPtr++; controlStringPtr++;
- break;
- case 'T': while (argOrderOffset >= argOrderSize)
- { argOrderSize *= 2;
- argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
- }
- argOrderVector[argOrderOffset++] = 'T';
- *sprintfControlStringPtr++ = 'd'; controlStringPtr++;
- break;
- case 'f': while (argOrderOffset >= argOrderSize)
- { argOrderSize *= 2;
- argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
- }
- argOrderVector[argOrderOffset++] = 'f';
- sprintfControlStringPtr++; controlStringPtr++;
- break;
- case 's': while (argOrderOffset >= argOrderSize)
- { argOrderSize *= 2;
- argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
- }
- argOrderVector[argOrderOffset++] = 's';
- sprintfControlStringPtr++; controlStringPtr++;
- break;
- case 'R': while (argOrderOffset >= argOrderSize)
- { argOrderSize *= 2;
- argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
- }
- argOrderVector[argOrderOffset++] = 'R';
- *sprintfControlStringPtr++ = 'f'; controlStringPtr++;
- break;
- case 'G': while (argOrderOffset >= argOrderSize)
- { argOrderSize *= 2;
- argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
- }
- argOrderVector[argOrderOffset++] = 'G';
- *sprintfControlStringPtr++ = 'f'; controlStringPtr++;
- break;
- case 'B': while (argOrderOffset >= argOrderSize)
- { argOrderSize *= 2;
- argOrderVector = (char *)NXZoneRealloc([self zone], argOrderVector, argOrderSize);
- }
- argOrderVector[argOrderOffset++] = 'B'; *sprintfControlStringPtr++ = 'f';
- controlStringPtr++;
- break;
- case '%': sprintfControlStringPtr++; controlStringPtr++;
- break;
- default: NXLogError("WWSliderCell: unknown specifier <%c> in controlString.\n", *controlStringPtr);
- sprintfControlStringPtr++; controlStringPtr++;
- break;
- }
- }
- }
- else
- { sprintfControlStringPtr++; controlStringPtr++;
- }
- }
- argOrderVector[argOrderOffset] = 0;
-
- done = NO;
-
- if (!done && !strcmp("d", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self intValue]);
- done = YES;
- }
- if (!done && !strcmp("f", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self floatValue]);
- done = YES;
- }
- if (!done && !strcmp("s", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self stringValue]);
- done = YES;
- }
- if (!done && !strcmp("T", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self tag]);
- done = YES;
- }
- if (!done && !strcmp("dT", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self intValue], [self tag]);
- done = YES;
- }
- if (!done && !strcmp("fT", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self floatValue], [self tag]);
- done = YES;
- }
- if (!done && !strcmp("sT", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self stringValue], [self tag]);
- done = YES;
- }
- if (!done && !strcmp("Td", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self tag], [self intValue]);
- done = YES;
- }
- if (!done && !strcmp("Tf", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self tag], [self floatValue]);
- done = YES;
- }
- if (!done && !strcmp("Ts", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self tag], [self stringValue]);
- done = YES;
- }
- // for back compatibility
- if (!done && !strcmp("fff", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color));
- done = YES;
- }
- if (!done && !strcmp("RGB", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color));
- done = YES;
- }
- if (!done && !strcmp("fRGB", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self floatValue], NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color));
- done = YES;
- }
- if (!done && !strcmp("RGBf", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color), [self floatValue]);
- done = YES;
- }
- if (!done && !strcmp("dRGB", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, [self intValue], NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color));
- done = YES;
- }
- if (!done && !strcmp("RGBd", argOrderVector))
- { [self resizeTclCommandForArgVector:argOrderVector];
- sprintf(tclCommand, sprintfControlString, NXRedComponent(color), NXGreenComponent(color), NXBlueComponent(color), [self intValue]);
- done = YES;
- }
-
- if (!done)
- { while (tclCommandSize < controlStringSize)
- { if (!tclCommandSize)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- else
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- }
- strcpy(tclCommand, controlString);
- }
- tclCommandDirty = NO;
-
- NXZoneFree([self zone], argOrderVector);
-
- return self;
- }
-
-
- - evaluateSelf
- {
- int ret;
- char *newStringValue;
- id retID;
-
-
- newStringValue = [interp globalEval:tclExpression :&ret];
- if ((ret == TCL_OK) || (ret == TCL_RETURN))
- { //if (ret == TCL_RETURN)
- //{ NXLogError("got TCL_RETURN for <%s>\n", newStringValue);
- //}
- [self setStringValue:newStringValue];
- retID = self;
- }
- else
- { NXLogError("WWSliderCell: error <%s> evaluating tcl expression <%s>\n",
- newStringValue, tclExpression);
- if (newStringValue) { free(newStringValue); }
- retID = nil;
- }
- return retID;
- }
-
-
- - updateInterp
- {
- if ([interp eval:[self tclCommand]])
- { return self;
- }
- return nil;
- }
-
-
- - setControlString:(const char *)str
- {
- int cnt;
-
-
- if (!str) { return self; }
- if (controlStringSize <= 0)
- { controlStringSize = 32;
- controlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- }
- cnt = strlen(str);
- while (cnt >= controlStringSize)
- { controlStringSize *= 2;
- controlString = (char *)NXZoneRealloc([self zone], controlString, controlStringSize);
- }
- if (sprintfControlString)
- { sprintfControlString = (char *)NXZoneRealloc([self zone], sprintfControlString, controlStringSize);
- }
- else
- { sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- }
- strcpy(controlString, str);
- tclCommandDirty = YES;
- return self;
- }
- //
- - (const char *)controlString { return controlString; }
-
- - setTclExpression:(const char *)str
- {
- int cnt;
-
-
- if (!str) { return self; }
- if (tclExpressionSize <= 0)
- { tclExpressionSize = 32;
- tclExpression = (char *)NXZoneCalloc([self zone], tclExpressionSize, sizeof(char));
- }
- cnt = strlen(str);
- while (cnt >= tclExpressionSize)
- { tclExpressionSize *= 2;
- tclExpression = (char *)NXZoneRealloc([self zone], tclExpression, tclExpressionSize);
- }
- strcpy(tclExpression, str);
- return self;
- }
- //
- - (const char *)tclExpression { return tclExpression; }
-
- - setTclVar:(const char *)str
- {
- int cnt;
-
-
- if (!str) { return self; }
- if (tclVarSize <= 0)
- { tclVarSize = 32;
- tclVar = (char *)NXZoneCalloc([self zone], tclVarSize, sizeof(char));
- }
- cnt = strlen(str);
- while (cnt >= tclVarSize)
- { tclVarSize *= 2;
- tclVar = (char *)NXZoneRealloc([self zone], tclVar, tclVarSize);
- }
- strcpy(tclVar, str);
- return self;
- }
- //
- - (const char *)tclVar { return tclVar; }
-
- - setTclCommand:(const char *)str
- {
- int cnt;
-
-
- if (!str) { return self; }
- if (tclCommandSize <= 0)
- { tclCommandSize = 32;
- tclCommand = (char *)NXZoneCalloc([self zone], tclCommandSize, sizeof(char));
- }
- cnt = strlen(str);
- while (cnt >= tclCommandSize)
- { tclCommandSize *= 2;
- tclCommand = (char *)NXZoneRealloc([self zone], tclCommand, tclCommandSize);
- }
- strcpy(tclCommand, str);
- return self;
- }
- //
- - (const char *)tclCommand
- {
- if (tclCommandDirty)
- { [self updateTclCommand];
- }
- return tclCommand;
- }
-
- - setMinText:sender { minText = sender; return self;}
- - setMaxText:sender { maxText = sender; return self;}
- - setValText:sender { valText = sender; return self;}
-
-
- #define NOTEQUAL(a,b) (ABS((a)-(b))>0.0001)
-
- - drawSelf:(const NXRect *)theFrame inView:view
- {
- NXSize imageSize;
- NXImage *oldImage;
-
-
- if (usingPrivateImage || colorChanged)
- { oldImage = [self image];
- if (oldImage)
- { [oldImage getSize:&imageSize];
- if(NOTEQUAL(imageSize.width,NX_WIDTH(theFrame)) || NOTEQUAL(imageSize.height,NX_HEIGHT(theFrame)) || colorChanged)
- { [self generateImage:theFrame];
- }
- }
- else
- { [self generateImage:theFrame];
- }
- }
- return [super drawSelf:theFrame inView:view];
- }
-
-
- - setColor:(NXColor)newColor { color = newColor; colorChanged = YES; tclCommandDirty = YES; return self; }
- - (NXColor)color { return color; }
-
- - generateImage:(const NXRect *)theFrame
- {
- NXImage *oldImage, *newImage;
-
-
- oldImage = [self image];
- if (oldImage && usingPrivateImage)
- { [oldImage free];
- }
- newImage = [[NXImage alloc] initSize:&(theFrame->size)];
- usingPrivateImage = YES;
- [newImage lockFocus];
- NXSetColor(color);
- PSrectfill(theFrame->origin.x, theFrame->origin.y, theFrame->size.width, theFrame->size.height);
- [newImage unlockFocus];
- [self setImage:newImage];
- colorChanged = NO;
-
- return self;
- }
-
- - write:(NXTypedStream *)stream
- {
- [super write:stream];
- NXWriteType(stream, "*", &controlString);
- NXWriteType(stream, "*", &tclVar);
- NXWriteType(stream, "*", &tclExpression);
- NXWriteType(stream, "*", &tclCommand);
- NXWriteType(stream, "c", &autoSendP);
- NXWriteObjectReference(stream, interp);
- NXWriteColor(stream, color);
- return self;
- }
- //
- - read:(NXTypedStream *)stream
- {
- int version;
-
- [super read:stream];
-
- version = NXTypedStreamClassVersion(stream, "WWSliderCell");
- if (version == 1)
- { NXReadType(stream, "*", &controlString);
- if (controlString)
- { controlStringSize = strlen(controlString) + 1;
- sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- }
- else
- { controlStringSize = 0;
- sprintfControlString = NULL;
- }
- NXReadType(stream, "*", &tclVar);
- if (tclVar)
- { tclVarSize = strlen(tclVar) + 1;
- }
- else
- { tclVarSize = 0;
- }
- autoSendP = YES;
- interp = nil;
- color = NX_COLORLTGRAY;
- tclCommandSize = 0;
- tclCommand = NULL;
- }
- if (version == 2)
- { NXReadType(stream, "*", &controlString);
- if (controlString)
- { controlStringSize = strlen(controlString) + 1;
- sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- }
- else
- { controlStringSize = 0;
- sprintfControlString = NULL;
- }
- NXReadType(stream, "*", &tclVar);
- if (tclVar)
- { tclVarSize = strlen(tclVar) + 1;
- }
- else
- { tclVarSize = 0;
- }
- NXReadType(stream, "*", &tclExpression);
- if (tclExpression)
- { tclExpressionSize = strlen(tclExpression) + 1;
- }
- else
- { tclExpressionSize = 0;
- }
- tclCommandSize = 0;
- tclCommand = NULL;
- autoSendP = YES;
- interp = nil;
- color = NX_COLORLTGRAY;
- }
- if (version == 3)
- { NXReadType(stream, "*", &controlString);
- if (controlString)
- { controlStringSize = strlen(controlString) + 1;
- sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- }
- else
- { controlStringSize = 0;
- sprintfControlString = NULL;
- }
- NXReadType(stream, "*", &tclVar);
- if (tclVar)
- { tclVarSize = strlen(tclVar) + 1;
- }
- else
- { tclVarSize = 0;
- }
- NXReadType(stream, "*", &tclExpression);
- if (tclExpression)
- { tclExpressionSize = strlen(tclExpression) + 1;
- }
- else
- { tclExpressionSize = 0;
- }
- NXReadType(stream, "*", &tclCommand);
- if (tclCommand)
- { tclCommandSize = strlen(tclCommand) + 1;
- }
- else
- { tclCommandSize = 0;
- }
- NXReadType(stream, "c", &autoSendP);
- interp = NXReadObject(stream);
- color = NX_COLORLTGRAY;
- }
- if (version == 4)
- { NXReadType(stream, "*", &controlString);
- if (controlString)
- { controlStringSize = strlen(controlString) + 1;
- }
- else
- { controlStringSize = 0;
- sprintfControlString = NULL;
- }
- NXReadType(stream, "*", &tclVar);
- if (tclVar)
- { tclVarSize = strlen(tclVar) + 1;
- }
- else
- { tclVarSize = 0;
- }
- NXReadType(stream, "*", &tclExpression);
- if (tclExpression)
- { tclExpressionSize = strlen(tclExpression) + 1;
- }
- else
- { tclExpressionSize = 0;
- }
- NXReadType(stream, "*", &tclCommand);
- if (tclCommand)
- { tclCommandSize = strlen(tclCommand) + 1;
- }
- else
- { tclCommandSize = 0;
- }
- NXReadType(stream, "c", &autoSendP);
- interp = NXReadObject(stream);
- color = NXReadColor(stream);
- NXReadType(stream, "*", &sprintfControlString);
- if (sprintfControlString) { free(sprintfControlString); }
- if (controlStringSize)
- { sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- }
- else
- { sprintfControlString = NULL;
- }
- }
- if (version == 5)
- { NXReadType(stream, "*", &controlString);
- if (controlString)
- { controlStringSize = strlen(controlString) + 1;
- sprintfControlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
- }
- else
- { controlStringSize = 0;
- sprintfControlString = NULL;
- }
- NXReadType(stream, "*", &tclVar);
- if (tclVar)
- { tclVarSize = strlen(tclVar) + 1;
- }
- else
- { tclVarSize = 0;
- }
- NXReadType(stream, "*", &tclExpression);
- if (tclExpression)
- { tclExpressionSize = strlen(tclExpression) + 1;
- }
- else
- { tclExpressionSize = 0;
- }
- NXReadType(stream, "*", &tclCommand);
- if (tclCommand)
- { tclCommandSize = strlen(tclCommand) + 1;
- }
- else
- { tclCommandSize = 0;
- }
- NXReadType(stream, "c", &autoSendP);
- interp = NXReadObject(stream);
- color = NXReadColor(stream);
- }
- return self;
- }
-
- // IB stuff
- - (const char *)getInspectorClassName
- {
- NXEvent *event = [NXApp currentEvent];
-
- if (event->flags & NX_ALTERNATEMASK)
- { return [super getInspectorClassName];
- }
-
- return "WWSliderCellIBInspector";
- }
-
-
-
-
- @end
-