This is MemoController.m in view mode; [Download] [Up]
{\rtf0\ansi{\fonttbl\f2\fswiss Helvetica;\f3\fmodern Ohlfs;} \paperw11040 \paperh8400 \margl40 \margr40 {\colortbl;\red0\green0\blue0;\red155\green103\blue77;\red0\green0\blue255;\red61\green0\blue0;\red255\green0\blue255;\red0\green41\blue0;} \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f2\b0\i0\ulnone\fs28\fc1\cf1 #import <appkit/appkit.h>\ \b #import \b0 \gray451\fc2\cf2 "MemoController.h" \gray0\fc1\cf1 \ \b #import \b0 \gray451\fc2\cf2 "MailComposer.h" \gray0\fc1\cf1 \ \b #import \b0 \gray451\fc2\cf2 "TurboTFCell.h" \gray0\fc1\cf1 \ \ \b\fs36 @implementation MemoController \b0\fs28 \ \ \b\gray108\fc3\cf3 - appDidInit:sender\ \b0\gray0\fc1\cf1 \{\ [ \b self \b0 initialize:self];\ \ \b return \b0 \b self \b0 ;\ \}\ \ \b\gray108\fc3\cf3 - deliver:sender\ \b0\gray0\fc1\cf1 \{\ \b char \b0 *to, *from, *org, *phone;\ \b int \b0 i;\ \b char \b0 *msg = ( \b char \b0 *)malloc( \f3\gray71\fc4\cf4 2048 \f2\gray0\fc1\cf1 * \b sizeof \b0 ( \b char \b0 ));\ \ \b if \b0 (strlen([toField stringValue])< \f3\gray71\fc4\cf4 3 \f2\gray0\fc1\cf1 )\ \{\ NXRunAlertPanel( \gray451\fc2\cf2 "Alert" \gray0\fc1\cf1 , \gray451\fc2\cf2 "Must specify a recipient." \gray0\fc1\cf1 , \gray451\fc2\cf2 "Ok" \gray0\fc1\cf1 , \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 , \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 );\ \b return \b0 \b nil \b0 ;\ \}\ \ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 to = (char *)malloc(30*(sizeof(char)));\ from = (char *)malloc(50*(sizeof(char)));\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 org = (char *)malloc(50*(sizeof(char)));\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 phone = (char *)malloc(40*(sizeof(char)));\ \ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 strcpy(to,[toField stringValue]);\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 strcpy(from,[fromField stringValue]?[fromField stringValue]:" ");\ strcpy(org,[companyField stringValue]?[companyField stringValue]:" ");\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 strcpy(phone,[phoneField stringValue]?[phoneField stringValue]:" ");\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 \ \b for \b0 (i= \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ;i<=strlen(to);i++)\ \{\ \b if \b0 (to[i]== \f3\gray409\fc5\cf5 0x0a \f2\gray0\fc1\cf1 )\ to[i]='\\ \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ';\ \}\ \ \b for \b0 (i= \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ;i<=strlen(from);i++)\ \{\ \b if \b0 (from[i]== \f3\gray409\fc5\cf5 0x0a \f2\gray0\fc1\cf1 )\ from[i]='\\ \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ';\ \}\ \ \b for \b0 (i= \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ;i<=strlen(org);i++)\ \{\ \b if \b0 (org[i]== \f3\gray409\fc5\cf5 0x0a \f2\gray0\fc1\cf1 )\ org[i]='\\ \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ';\ \}\ \ \b for \b0 (i= \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ;i<=strlen(phone);i++)\ \{\ \b if \b0 (phone[i]== \f3\gray409\fc5\cf5 0x0a \f2\gray0\fc1\cf1 )\ phone[i]='\\ \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ';\ \}\ \ [toField setStringValue:to];\ \ sprintf(msg, \gray451\fc2\cf2 "\\nCaller: %s from %s %s.\\nPriority: %s\\nPhone: %s\\nAction: (%s)/(%s)\\n\\nMessage: %s" \gray0\fc1\cf1 ,(strlen(from)> \f3\gray71\fc4\cf4 2 \f2\gray0\fc1\cf1 )?from: \gray451\fc2\cf2 "Mojo Nixon" \gray0\fc1\cf1 \ ,(strlen(org)> \f3\gray71\fc4\cf4 2 \f2\gray0\fc1\cf1 )?org: \gray451\fc2\cf2 "Nowhere" \gray0\fc1\cf1 ,[rs state]?[rs title]: \gray451\fc2\cf2 "called" \gray0\fc1\cf1 ,[us state]?\ \gray451\fc2\cf2 "URGENT" \gray0\fc1\cf1 : \gray451\fc2\cf2 "normal" \gray0\fc1\cf1 ,(strlen(phone)> \f3\gray71\fc4\cf4 2 \f2\gray0\fc1\cf1 )?phone: \gray451\fc2\cf2 "none" \gray0\fc1\cf1 ,[pcs state]?[pcs\ title]: \gray451\fc2\cf2 "" \gray0\fc1\cf1 ,[wcs state]?[wcs title]: \gray451\fc2\cf2 "" \gray0\fc1\cf1 ,[bodyField stringValue]?\ [bodyField stringValue]: \gray451\fc2\cf2 "No message." \gray0\fc1\cf1 );\ \ [msgField setStringValue:msg]; \ [mailComposer takeRemoteToStringValueFrom:toField];\ [mailComposer takeRemoteSubjectStringValueFrom:subField];\ [mailComposer takeRemoteBodyStringValueFrom:msgField];\ [mailComposer remoteComposeAndDeliver: \b self \b0 ];\ \ NX_FREE(msg);\ NX_FREE(to);\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 NX_FREE(org);\ NX_FREE(from);\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 NX_FREE(phone);\ \ [ \b self \b0 setMemoDirty: \gray93\fc6\cf6 FALSE \gray0\fc1\cf1 ];\ [ \b self \b0 new: \b self \b0 ];\ \b return \b0 \b self \b0 ;\ \}\ \b\gray108\fc3\cf3 \ - new:sender\ \b0\gray0\fc1\cf1 \{\ \b int \b0 i, j, rows,cols;\ \ \b if \b0 ([ \b self \b0 memoDirty])\ \{\ \b if \b0 (!NXRunAlertPanel( \gray451\fc2\cf2 "Alert" \gray0\fc1\cf1 ,\ \gray451\fc2\cf2 "You have a memo in progress. Destroy?" \gray0\fc1\cf1 , \ \gray451\fc2\cf2 "Ok" \gray0\fc1\cf1 , \gray451\fc2\cf2 "Cancel" \gray0\fc1\cf1 , \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ))\ \{\ [memoPanel makeKeyAndOrderFront: \b self \b0 ];\ \b return \b0 \b self \b0 ;\ \}\ \}\ [ \b self \b0 setMemoDirty: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ];\ [switchMatrix getNumRows:&rows numCols:&cols];\ \b for \b0 (i= \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ;i<rows;i++)\ \b for \b0 (j= \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ;j<cols;j++)\ [[switchMatrix cellAt:i :j] setIntValue: \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 ];\ \ [toField setStringValue: \gray93\fc6\cf6 NULL \gray0\fc1\cf1 ];\ [fromField setStringValue: \gray93\fc6\cf6 NULL \gray0\fc1\cf1 ];\ [bodyField setStringValue: \gray93\fc6\cf6 NULL \gray0\fc1\cf1 ];\ [companyField setStringValue: \gray93\fc6\cf6 NULL \gray0\fc1\cf1 ];\ [phoneField setStringValue: \gray93\fc6\cf6 NULL \gray0\fc1\cf1 ];\ \b if \b0 (!mailComposer)\ mailComposer = [[MailComposer alloc] init];\ [memoPanel display];\ [memoPanel makeKeyAndOrderFront: \b self \b0 ];\ [toField selectText: \b self \b0 ];\ \b return \b0 \b self \b0 ;\ \}\ \ \b\gray108\fc3\cf3 - addSliders\ \b0\gray0\fc1\cf1 \{\ \b float \b0 r,g,b;\ \b NXRect \b0 rRect;\ \b NXColor \b0 aColor;\ \b id \b0 rField,gField,bField;\ \b id \b0 aFont;\ \b const \b0 \b char \b0 *rValue, *gValue, *bValue;\ \ rValue = NXGetDefaultValue([NXApp appName], \gray451\fc2\cf2 "rValue" \gray0\fc1\cf1 );\ \b if \b0 (rValue) r=atof(rValue); \b else \b0 r= \f3\gray71\fc4\cf4 0.8 \f2\gray0\fc1\cf1 ;\ gValue = NXGetDefaultValue([NXApp appName], \gray451\fc2\cf2 "gValue" \gray0\fc1\cf1 );\ \b if \b0 (gValue) g=atof(gValue); \b else \b0 g= \f3\gray71\fc4\cf4 0.8 \f2\gray0\fc1\cf1 ;\ bValue = NXGetDefaultValue([NXApp appName], \gray451\fc2\cf2 "bValue" \gray0\fc1\cf1 );\ \b if \b0 (bValue) b=atof(bValue); \b else \b0 b= \f3\gray71\fc4\cf4 0.8 \f2\gray0\fc1\cf1 ;\ aColor = NXConvertRGBToColor(r,g,b);\ [memoPanel setBackgroundColor:aColor];\ \ rRect.origin.x = \f3\gray71\fc4\cf4 236 \f2\gray0\fc1\cf1 ;\ rRect.origin.y = \f3\gray71\fc4\cf4 220 \f2\gray0\fc1\cf1 ;\ rRect.size.height = \f3\gray71\fc4\cf4 10 \f2\gray0\fc1\cf1 ;\ rRect.size.width = \f3\gray71\fc4\cf4 50 \f2\gray0\fc1\cf1 ;\ \ aFont = [Font newFont: \gray451\fc2\cf2 "Helvetica" \gray0\fc1\cf1 size: \f3\gray71\fc4\cf4 7.0 \f2\gray0\fc1\cf1 ];\ rSlider = [[[[[[[[[Slider alloc] initFrame:&rRect] setKnobThickness: \f3\gray71\fc4\cf4 4 \f2\gray0\fc1\cf1 ]\ setMinValue: \f3\gray71\fc4\cf4 0.0 \f2\gray0\fc1\cf1 ] setMaxValue: \f3\gray71\fc4\cf4 1.0 \f2\gray0\fc1\cf1 ] setFloatValue:r]\ setAction: \b @selector \b0 (setWindowColor:)] setContinuous: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ]\ setTag: \f3\gray71\fc4\cf4 1 \f2\gray0\fc1\cf1 ];\ rRect.origin.x+= \f3\gray71\fc4\cf4 54 \f2\gray0\fc1\cf1 ;\ rField = [[[[[[TextField alloc] initFrame:&rRect] setStringValue: \gray451\fc2\cf2 "red" \gray0\fc1\cf1 ]\ setFont:aFont] setBezeled: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ] setSelectable: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ];\ rRect.origin.x-= \f3\gray71\fc4\cf4 54 \f2\gray0\fc1\cf1 ;\ rRect.origin.y += \f3\gray71\fc4\cf4 14 \f2\gray0\fc1\cf1 ;\ gSlider = [[[[[[[[[Slider alloc] initFrame:&rRect] setKnobThickness: \f3\gray71\fc4\cf4 4 \f2\gray0\fc1\cf1 ]\ setMinValue: \f3\gray71\fc4\cf4 0.0 \f2\gray0\fc1\cf1 ] setMaxValue: \f3\gray71\fc4\cf4 1.0 \f2\gray0\fc1\cf1 ] setFloatValue:g]\ setAction: \b @selector \b0 (setWindowColor:)] setContinuous: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ]\ setTag: \f3\gray71\fc4\cf4 2 \f2\gray0\fc1\cf1 ];\ rRect.origin.x+= \f3\gray71\fc4\cf4 54 \f2\gray0\fc1\cf1 ;\ gField = [[[[[[TextField alloc] initFrame:&rRect] setStringValue: \gray451\fc2\cf2 "green" \gray0\fc1\cf1 ]\ setFont:aFont] setBezeled: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ] setSelectable: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ];\ rRect.origin.x-= \f3\gray71\fc4\cf4 54 \f2\gray0\fc1\cf1 ;\ rRect.origin.y += \f3\gray71\fc4\cf4 14 \f2\gray0\fc1\cf1 ;\ bSlider = [[[[[[[[[Slider alloc] initFrame:&rRect] setKnobThickness: \f3\gray71\fc4\cf4 4 \f2\gray0\fc1\cf1 ]\ setMinValue: \f3\gray71\fc4\cf4 0.0 \f2\gray0\fc1\cf1 ] setMaxValue: \f3\gray71\fc4\cf4 1.0 \f2\gray0\fc1\cf1 ] setFloatValue:b]\ setAction: \b @selector \b0 (setWindowColor:)] setContinuous: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ]\ setTag: \f3\gray71\fc4\cf4 3 \f2\gray0\fc1\cf1 ];\ rRect.origin.x+= \f3\gray71\fc4\cf4 54 \f2\gray0\fc1\cf1 ;\ bField = [[[[[[TextField alloc] initFrame:&rRect] setStringValue: \gray451\fc2\cf2 "blue" \gray0\fc1\cf1 ]\ setFont:aFont] setBezeled: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ] setSelectable: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ];\ [[memoPanel contentView] addSubview:rSlider];\ [[memoPanel contentView] addSubview:gSlider];\ [[memoPanel contentView] addSubview:bSlider];\ [[memoPanel contentView] addSubview:rField];\ [[memoPanel contentView] addSubview:gField];\ [[memoPanel contentView] addSubview:bField];\ \ \b return \b0 \b self \b0 ;\ \}\ \ \b\gray108\fc3\cf3 - free\ \b0\gray0\fc1\cf1 \{\ [mailComposer free];\ [memoPanel free];\ \ \b return \b0 [ \b super \b0 free];\ \}\ \b\gray108\fc3\cf3 - initialize:sender\ \b0\gray0\fc1\cf1 \{\ [bodyField setAcceptsReturn: \gray93\fc6\cf6 TRUE \gray0\fc1\cf1 ];\ [ \b self \b0 addSliders];\ [ \b self \b0 new: \b self \b0 ];\ \b return \b0 \b self \b0 ;\ \}\ \ \b\gray108\fc3\cf3 - setWindowColor:sender\ \b0\gray0\fc1\cf1 \{\ \b NXColor \b0 aColor;\ \b float \b0 r,g,b;\ \b char \b0 str[ \f3\gray71\fc4\cf4 16 \f2\gray0\fc1\cf1 ];\ \ aColor = [memoPanel backgroundColor];\ NXConvertColorToRGB(aColor,&r,&g,&b);\ \ \b switch \b0 ([ \b sender \b0 tag])\ \{\ \b case \b0 \f3\gray71\fc4\cf4 1 \f2\gray0\fc1\cf1 :\ r=[ \b sender \b0 floatValue];\ sprintf(str, \gray451\fc2\cf2 "%f" \gray0\fc1\cf1 ,r);\ NXWriteDefault([NXApp appName], \gray451\fc2\cf2 "rValue" \gray0\fc1\cf1 ,str);\ \b break \b0 ;\ \b case \b0 \f3\gray71\fc4\cf4 2 \f2\gray0\fc1\cf1 :\ g=[ \b sender \b0 floatValue];\ sprintf(str, \gray451\fc2\cf2 "%f" \gray0\fc1\cf1 ,g);\ NXWriteDefault([NXApp appName], \gray451\fc2\cf2 "gValue" \gray0\fc1\cf1 ,str);\ \b break \b0 ;\ \b case \b0 \f3\gray71\fc4\cf4 3 \f2\gray0\fc1\cf1 :\ b=[ \b sender \b0 floatValue];\ sprintf(str, \gray451\fc2\cf2 "%f" \gray0\fc1\cf1 ,b);\ NXWriteDefault([NXApp appName], \gray451\fc2\cf2 "bValue" \gray0\fc1\cf1 ,str);\ \b break \b0 ;\ \}\ aColor = NXConvertRGBToColor(r,g,b);\ \ [memoPanel setBackgroundColor:aColor];\ [memoPanel display];\ \ \b return \b0 \b self \b0 ;\ \}\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\b\gray108\fc3\cf3 - quit:sender\ \b0\gray0\fc1\cf1 \{\ \b if \b0 ([self memoDirty])\ \b if \b0 (NXRunAlertPanel( \gray451\fc2\cf2 "Alert" \gray0\fc1\cf1 , \gray451\fc2\cf2 "You have an undelivered memo", \gray0\fc1\cf1 \ \gray451\fc2\cf2 "Close" \gray0\fc1\cf1 , \gray451\fc2\cf2 "Cancel" \gray0\fc1\cf1 , \f3\gray71\fc4\cf4 0 \f2\gray0\fc1\cf1 )== \gray93\fc6\cf6 NX_CANCELTAG \gray0\fc1\cf1 )\ \b return \b0 \b nil \b0 ;\ [self setMemoDirty: \gray93\fc6\cf6 NO \gray0\fc1\cf1 ];\ [NXApp terminate:self];\ \b return \b0 \b self \b0 ;\ \}\ \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc1\cf1 \ \b\gray108\fc3\cf3 - setMemoDirty:(BOOL)flag\ \b0\gray0\fc1\cf1 \{\ memoDirty = flag;\ [memoPanel setDocEdited:flag];\ \b return \b0 \b self \b0 ;\ \}\ \b\gray108\fc3\cf3 - (BOOL)memoDirty \b0\gray0\fc1\cf1 \{ \b return \b0 memoDirty; \}\ \ \b\fs36 @end \b0\fs28 \ }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.