This is Controller.m in view mode; [Download] [Up]
/* * Controller.m * * Purpose: * This object serves as the browsers delegate, and does some initialization. * * You may freely copy, distribute, and reuse the code in this example. * NeXT disclaims any warranty of any kind, expressed or implied, as to its * fitness for any particular use. * * Written by: Mary McNabb * Created: Apr 91 * */ #import "Controller.h" #import "RightSubView.h" #import "SideSplitView.h" #import <appkit/Matrix.h> #import <appkit/Window.h> #import <appkit/NXBrowser.h> #import <appkit/NXBrowserCell.h> #import <appkit/Application.h> #define MAXLEN 20 /* maximum number of chars in a name */ #define NUM_ANIMALS 17 /* make sure this number matches the * number of strings in the following string table!! */ char *animals[] = { "doug", "elizabeth", "flip", "george", "henry", "howard", "jeff", "julie", "kate", "leonard", "mai", "mary", "michelle", "sam", "sharon", "tony", "dawn" }; @implementation Controller /* * take advantage of IB and initialize the browser from here */ - setTheBrowser:anObject { theBrowser = anObject; [theBrowser setDelegate:self]; [theBrowser reloadColumn:0]; return self; } /* * Since we have to resize the subviews don't put the window on screen * until we get here */ - appDidInit:sender { [zooSplitView initViews]; [[zooSplitView window] orderFront:self]; return self; } /* * the user selected a name. Tell the right sub view to display the picture. */ - browserCellWasSelected:sender { char path[MAXLEN]; char *p; [theBrowser getPath:path toColumn:1]; p = path; p++; /* skip the separator which precedes the name */ [rightView setAnimalPicture:p]; return self; } /* * Fill the browser up with names from the string table. */ - (int)browser:sender fillMatrix:matrix inColumn:(int)column { int i; id newCell; for (i = 0; i < NUM_ANIMALS; i++) { [matrix addRow]; newCell = [matrix cellAt:i :0]; [newCell setTag:(i * 16)]; [newCell setStringValue:animals[i]]; [newCell setLeaf:YES]; [newCell setLoaded:YES]; } return i; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.