This is UserModel.m in view mode; [Download] [Up]
{\rtf0\ansi{\fonttbl\f0\fmodern Courier;\f1\ftech Symbol;\f2\fmodern Ohlfs;} \margl40 \margr40 \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\b0\i0\ulnone\fs24\fc0\cf0 //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\ // \i \b FILENAME \b0 : \b\i0 UserModel.m\ \b0 // \i \b SUMMARY \b0 : \b\i0 Implementation of the UserModel, which encapsulates user prefs. \b0 \ // \b\i SUPERCLASS \b0 : \i0 \b Object:UserModel \b0 \ // \b\i PROTOCOLS \b0 : \i0 \b None \b0 \ // \b\i INTERFACE \b0 : \i0 \b UserModel.nib \b0 \ // \b\i AUTHOR \b0 : \b\i0 Rohit Khare \b0 \ // \b\i COPYRIGHT \b0 : \f1\i0 Ó \f0\b 1993,94 California Institure of Technology, eText Project\ \b0 //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\ // \b\i Implementation Comments \b0\i0 \ // Just a wrapper around the NXDefaults system. For now, it's just a stub.\ // FUTURE FEATURE\ // Shadow Streams would be really cool.\ //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\ // \b\i HISTORY \b0\i0 \ // 10/30/94: \b Added "bidirectional" syntax for bindValue/bindKey \b0 \ // 09/27/94: \b Revamped for eText5 \b0 \ // 07/25/94: \b Added setHTMD:, setETFD: (see also support in eTApp, eTDocUI) \b0 \ // 01/20/94: \b Revised for eText4 \b0 \ // 08/21/93: \b Created. Gutless object \b0 \ //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\ // \b Imported Interfaces \b0 \ //\ #import " \b UserModel.h \b0 "\ \ \i @implementation UserModel\ \i0 //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\ // \b Class Management \b0 \ //\ - \b init \b0 \{\ NXAtom docdir;\ \ [NXApp \b loadNibSection \b0 :" \b UserModel.nib \b0 " owner:self withNames:NO];\ \b docdir \b0 = [userModel \b stringQuery \b0 : \b ETFDIRECTORY \b0 ];\ if (docdir && *docdir) \{\ [ \b ETFDField \b0 \b setStringValue \b0 : \b docdir \b0 ];\ \}\ \b docdir \b0 = [userModel \b stringQuery \b0 : \b HTMDIRECTORY \b0 ];\ if (docdir && *docdir) \{\ [ \b HTMDField \b0 \b setStringValue \b0 : \b docdir \b0 ];\ \}\ return self;\ \}\ \ - \b free \b0 \{\ prefsPanel = [ \b prefsPanel \b0 free];\ return self = [ \b super \b0 free];\ \}\ \ //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\ // \b Public UserModel API \b0 \ //\ - (const char*) \b stringQuery \b0 :(const char*)theQuery \{\ const char* retVal = \b NXGetDefaultValue \b0 ([NXApp appName], \b theQuery \b0 );\ return (retVal ? NXUniqueString(retVal) : NXUniqueString(""));\}\ \ - (BOOL) \b boolQuery \b0 :(const char*)theQuery \{\ NXAtom result = \b NXGetDefaultValue \b0 ([NXApp appName], \b theQuery \b0 );\ \b if \b0 ( \b !result \b0 )\{\ int choice=NXRunAlertPanel(" \b User Model \b0 ",\ " \b What is your preference for the boolean value %s? \b0 ",\ " \b No \b0 ", " \b Yes \b0 ", NULL, theQuery);\ if (choice == NX_ALERTDEFAULT)\ \b NXWriteDefault \b0 ([NXApp appName], \b theQuery \b0 , " \b NO \b0 ");\ else\ \b NXWriteDefault \b0 ([NXApp appName], \b theQuery \b0 , " \b YES \b0 ");\ return (choice == NX_ALERTALTERNATE);\ \}\ \b return \b0 ( \b strcasecmp \b0 (" \b yes \b0 ", \b result \b0 ) ? NO : YES);\ \}\ \ - (int) \b intQuery \b0 :(const char*)theQuery \{\ int i;\ NXAtom \b result \b0 = \b NXGetDefaultValue \b0 ([NXApp appName], \b theQuery \b0 );\ if ( \b !result \b0 ) return \b 0 \b0 ;\ i=0; \b sscanf \b0 (result, " \b %d \b0 ", &i);\ return \b i \b0 ;\ \}\ \ - \b bindValue \b0 :(const char*)theValue \b for \b0 :(const char*)theQuery \{\ \b NXWriteDefault \b0 ([NXApp appName], \b theQuery \b0 , \b theValue \b0 ); return self;\}\ - \b bindKey \b0 :(const char *) theQuery \b to \b0 : (const char *) theValue \{\ \b NXWriteDefault \b0 ([NXApp appName], \b theQuery \b0 , \b theValue \b0 ); return self;\}\ \ - \b defaultValue \b0 :(const char*)theValue \b for \b0 :(const char*)theQuery \{\ NXDefaultsVector theVector= \{\{NULL,NULL\}, \{NULL, NULL\}\};\ \ theVector[0].name = (char *)NXUniqueString(theQuery);\ theVector[0].value = (char *)NXUniqueString(theValue);\ theVector[1].name = theVector[1].value = NULL;\ \b NXRegisterDefaults \b0 ([NXApp appName], \b theVector \b0 ); \ return self;\ \}\ \ //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\ // \b User Interface \b0 \ //\ - \b showPreferences \b0 \{\ [ \b prefsPanel \b0 \b makeKeyAndOrderFront \b0 :self]; return self;\}\ \ - \b doQuery \b0 :sender \{\ [ \b valueField \b0 \b setStringValue \b0 :[self \b stringQuery \b0 :[ \b queryField \b0 stringValue]]];\ return self;\}\ \ - \b doBind \b0 :sender \{\ [ \b self \b0 \b bindValue \b0 :[ \b valueField \b0 stringValue] \b for \b0 :[ \b queryField \b0 stringValue]];\ return self;\}\ \ - \b setHTMD \b0 :sender \{\ [ \b self \b0 \b bindValue \b0 :[ \b HTMDField \b0 stringValue] for: \b HTMDIRECTORY \b0 ];\ return self;\}\ \ - \b setETFD \b0 :sender \{\ [ \b self \b0 \b bindValue \b0 :[ \b ETFDField \b0 stringValue] for: \b ETFDIRECTORY \b0 ];\ return self;\}\ \ \i @end }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.