This is MiscReadOnlyColorWell.m in view mode; [Download] [Up]
// // MiscReadOnlyColorWell.m -- an NXColorWell that can bemade read-only // Written by Morgan D. Wise Copyright (c) 1994 by Morgan D. Wise. // Adapted for MiscKit inclusion by Don Yacktman. // Version 0.1. All rights reserved. // // This notice may not be removed from this source code. // // This object is included in the MiscKit by permission from the author // and its use is governed by the MiscKit license, found in the file // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file // for a list of all applicable permissions and restrictions. // #import "MiscReadOnlyColorWell.h" @implementation MiscReadOnlyColorWell - setReadOnly:(BOOL)flag { _isReadOnly = flag; [self setBordered:!flag]; return self; } - (BOOL)isReadOnly { return _isReadOnly; } - (NXDragOperation)draggingEntered:(id <NXDraggingInfo>)sender { if (_isReadOnly) return NX_DragOperationNone; else return [super draggingEntered:sender]; } - (const char *)getInspectorClassName { return "ReadOnlyColorWellInspector"; } - read:(NXTypedStream *)stream { [super read:stream]; NXReadType(stream, "c", &_isReadOnly); return self; } - write:(NXTypedStream *)stream { [super write:stream]; NXWriteType(stream, "c", &_isReadOnly); return self; } // This drawSelf:: allows a ColorWell to be placed in a ScrollView; // Perhaps it should be placed in a category used to override the // one in NXColorWell instead... // donated by Michael T. H. Scott mths@longshot.demon.co.uk - drawSelf: (const NXRect *)rects : (int)rectCount { NXRect rect = bounds; int index = ( rectCount == 1 ) ? 0 : 1; PSgsave(); NXRectClipList(&rects[index], index + 1); if ( [self isBordered] ) { NXDrawButton(&rect, &rects[0]); if ( [self isActive] && NX_WIDTH(&rect) > 3.0 && NX_HEIGHT(&rect) > 3.0 ) { NXRect highlightRect; NXSetRect(&highlightRect, NX_X(&rect) + 1.0, NX_Y(&rect) + 2.0, NX_WIDTH(&rect) - 3.0, NX_HEIGHT(&rect) - 3.0); PSsetgray(NX_WHITE); NXRectFill(&highlightRect); } NXInsetRect(&rect, 6.0, 6.0); NXDrawGrayBezel(&rect, &rects[0]); NXInsetRect(&rect, 2.0, 2.0); } else { NXDrawGrayBezel (&rect, &rects[0]); NXInsetRect(&rect, 2.0, 2.0); } if ( NX_WIDTH(&rect) > 0.0 && NX_HEIGHT(&rect) > 0.0 ) { [self drawWellInside: &rect]; } PSgrestore(); return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.