This is MyNSObject.m in view mode; [Download] [Up]
#import "MyNSObject.h" @implementation MyNSObject - (void)appendTextTest:(id)sender // This will get the text in appendTextInput and adds it at // the end of MyScrollView { // Gets the inputString NSString *inputString = [appendTextInput stringValue]; // Assigns the documentView of MyScrollView to the variable document document = [MyScrollView documentView]; // Appends the string of inputString to the document variable // which is in fact the documentView of MyScrollView [document setString:[[document string] stringByAppendingString:inputString]]; } - (void)backBlack:(id)sender // This will change the background color of MyScrollView { [[MyScrollView documentView] setBackgroundColor:[NSColor blackColor]]; [MyScrollView display]; } - (void)backDgray:(id)sender // This will change the background color of MyScrollView { [[MyScrollView documentView] setBackgroundColor:[NSColor darkGrayColor]]; [MyScrollView display]; } - (void)backLgray:(id)sender // This will change the background color of MyScrollView { [[MyScrollView documentView] setBackgroundColor:[NSColor lightGrayColor]]; [MyScrollView display]; } - (void)backWhite:(id)sender // This will change the background color of MyScrollView { [[MyScrollView documentView] setBackgroundColor:[NSColor whiteColor]]; [MyScrollView display]; } - (void)byteLengthTest:(id)sender // This displays how many bytes are used in the text of MyScrollView { NSBeep(); } - (void)Center:(id)sender // This will justify the text to the Centered { [[MyScrollView documentView] setAlignment:NSCenterTextAlignment]; [MyScrollView display]; } - (void)checkSpellingTest:(id)sender // This checks the spelling of the text in the MyScrollView document { // Assigns the documentView of MyScrollView to the variable document document = [MyScrollView documentView]; // Spell check [[MyScrollView documentView] checkSpelling:document]; // Guess and replace panel [[MyScrollView documentView] showGuessPanel:document]; } - (void)Left:(id)sender // This will justify the text to the left { [[MyScrollView documentView] setAlignment:NSLeftTextAlignment]; [MyScrollView display]; } - (void)Load:(id)sender { NSOpenPanel *panel; // Create or get the shared instance of NSSavePanel panel = [NSOpenPanel openPanel]; if ([panel runModal] == NSOKButton) { NSString *fileName = [panel filename]; if ([[fileName pathExtension] isEqualToString:@"rtfd"]) { [[MyScrollView documentView] readRTFDFromFile:fileName]; } } return; } - (void)MoreInfo:(id)sender { [NSBundle loadNibNamed:@"MoreInfo.nib" owner:self]; // load nib } - (void)PrintScroll:(id)sender // This method will print the scrollView to the printer // Printing is rather simple; just send print:self to the text view // you wish to print. The print panel will automatically pop up and unless // the user cancels the printout the text view will be printed. { [[MyScrollView documentView] print:self]; } - (void)PrintWindow:(id)sender // This method will print the WHOLE panel to the printer { [TheWindow print:self]; } - (void)Right:(id)sender // This will justify the text to the right */ { [[MyScrollView documentView] setAlignment:NSRightTextAlignment]; [MyScrollView display]; } - (void)Ruler:(id)sender // This method toggles a rular in the scrollview { [[MyScrollView documentView] toggleRuler:self]; } - (void)Save:(id)sender { NSSavePanel *panel; // Create or get the shared instance of NSSavePanel panel = [NSSavePanel savePanel]; [panel setRequiredFileType:@"rtfd"]; if ([panel runModal] == NSOKButton) { [[MyScrollView documentView] writeRTFDToFile:[panel filename] atomically:YES]; } } - (void)selectTextTest:(id)sender // This selects "highlights" the text in MyScrollView { [[MyScrollView documentView] selectText:document]; } - (void)setTextTest:(id)sender // This takes the text in setTextInput and displays it in MyScrollView { const char *inputString; inputString = [[setTextInput stringValue] cString]; [[MyScrollView documentView] setString:[NSString stringWithCString:inputString]]; } - (void)textBlack:(id)sender // changes the color of the text in MyScrollView { [[MyScrollView documentView] setTextColor:[NSColor blackColor]]; [MyScrollView display]; } - (void)textDgray:(id)sender // changes the color of the text in MyScrollView { [[MyScrollView documentView] setTextColor:[NSColor darkGrayColor]]; [MyScrollView display]; } - (void)textLengthTest:(id)sender // The number of characters in the Text object. { NSBeep(); } - (void)textLgray:(id)sender // changes the color of the text in MyScrollView { [[MyScrollView documentView] setTextColor:[NSColor lightGrayColor]]; [MyScrollView display]; } - (void)textWhite:(id)sender // changes the color of the text in MyScrollView { [[MyScrollView documentView] setTextColor:[NSColor whiteColor]]; [MyScrollView display]; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.