This is IKCellInspector.m in view mode; [Download] [Up]
/* File IKCellInspector.m Release 1.2, 7 June 1994 Copyright (C) 1994 by H. Scott Roy This code is part of IconKit, a general toolbox for drag-and-drop applications. IconKit is free for noncommercial use, but costs money for a commercial license. You should have received a copy of the license agreement with this file. If not, a copy of the license and the complete source of IconKit can be obtained from the author: H. Scott Roy 2573 Stowe Ct. Northbrook, IL 60062-8103 iconkit@cs.stanford.edu For your editing convenience, this file is best viewed using an editor that automatically wraps long lines, in a fixed point font at 80 columns, with tabs every 4 spaces. */ /* ========================================================================== */ /* This file implements a custom inspector for an IKCell. The inspector lets one set the editing, dragging, shelf behavior, title, and icon. */ #import "IKCellInspector.h" #import "IKCell.h" @implementation IKCellInspector /* ========================================================================== */ /* Here are the tags used to identify all the different cells. */ #define TITLE 0 #define ICON 1 #define TAG 0 #define NOCONTAINER 0 #define UNLOCKED 1 #define LOCKED 2 #define REALLYLOCKED 3 #define DRAGGABLE 0 #define DRAGACCEPTING 1 #define EDITABLE 2 #define SINGLE 0 #define MULTIPLE 1 /* ========================================================================== */ - init { char path [MAXPATHLEN + 1]; id bundle; [super init]; bundle = [NXBundle bundleForClass: [IKCell class]]; [bundle getPath: path forResource: "IKCellInspector" ofType: "nib"]; [NXApp loadNibFile: path owner: self withNames: NO fromZone: [self zone]]; return self; } /* ========================================================================== */ /* Reset the various options as needed. Only changes to the image and title require redrawing. This code doubtless leaks memory, since it doesn't free the images when it resets them, but it seems rather unsafe to start freeing named images. */ - updateLook: sender { const char * title = [[look findCellWithTag: TITLE] stringValue], * icon = [[look findCellWithTag: ICON] stringValue]; [object setTitle: title]; [object setImage: icon ? [NXImage findImageNamed: icon] : nil]; [self ok: sender]; return self; } - updateContainer: sender { [object setShelfMode: [[sender selectedCell] tag]]; [self ok: sender]; return self; } - updateOptions: sender { [object setEditable: [[sender findCellWithTag: EDITABLE] state]]; [object setDraggable: [[sender findCellWithTag: DRAGGABLE] state]]; [object setDragAccepting: [[sender findCellWithTag: DRAGACCEPTING] state]]; [self ok: sender]; return self; } - updateLayout: sender { [object setMultipleLines: [sender selectedTag]]; [self ok: sender]; return self; } - updateTag: sender { [object setTag: [[sender findCellWithTag: TAG] intValue]]; [self ok: sender]; return self; } /* ========================================================================== */ /* The ok: method does nothing. The revert method needs to initialize itself from the current selection. */ - ok: sender { [self touch: self]; return [super ok: sender]; } - revert: sender { const char * title = [object title], * icon = [[object image] name]; int state; [[look findCellWithTag: TITLE] setStringValue: title]; [[look findCellWithTag: ICON] setStringValue: icon]; [[tag findCellWithTag: TAG] setIntValue: [object tag]]; [[options findCellWithTag: EDITABLE] setIntValue: [object isEditable]]; [[options findCellWithTag: DRAGGABLE] setIntValue: [object isDraggable]]; [[options findCellWithTag: DRAGACCEPTING] setIntValue: [object isDragAccepting]]; [layout selectCellWithTag: [object isMultipleLines]]; state = ![object isContainer] ? NOCONTAINER: ![object isLocked] ? UNLOCKED: ![object isReallyLocked] ? LOCKED: REALLYLOCKED; [container setTitle: [[[container target] findCellWithTag: state] title]]; [[[container target] itemList] selectCellWithTag: state]; return [super revert: sender]; } - (BOOL) wantsButtons { return NO; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.