home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscDimpleCell.m -- An NXBrowserCell subclass that adds a mark image so
- // a list can have an appearance similar to the IB
- // connection inspector list.
- //
- // Written by David Fedchenko. Copyright 1994 by David Fedchenko.
- // Version 1.0 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 "MiscDimpleCell.h"
-
- @implementation MiscDimpleCell
-
- static id MDMarkImage;
- static id MDAltMarkImage;
-
- + initialize
- {
- id idBundle;
- char buf[MAXPATHLEN + 1];
-
- [super initialize];
-
- idBundle = [NXBundle bundleForClass:[self class]];
- [idBundle getPath:buf forResource:"Dimple" ofType:"tiff"];
- MDMarkImage = [[NXImage alloc] initFromFile:buf];
-
- [idBundle getPath:buf forResource:"DimpleH" ofType:"tiff"];
- MDAltMarkImage = [[NXImage alloc] initFromFile:buf];
-
- return self;
- }
-
- + setMarkImage:anImage
- {
- id idT = MDMarkImage;
-
- MDMarkImage = anImage;
-
- return idT;
- }
-
- + markImage
- {
- return MDMarkImage;
- }
-
- + setAltMarkImage:anImage
- {
- id idT = MDAltMarkImage;
-
- MDAltMarkImage = anImage;
-
- return idT;
- }
-
- + altMarkImage
- {
- return MDAltMarkImage;
- }
-
- - setMarked:(BOOL)flag
- {
- fMarked = flag;
-
- if (fMarked)
- {
- [self setLeaf:YES];
- }
-
- return self;
- }
-
- -(BOOL) marked
- {
- return fMarked;
- }
-
- - drawInside:(const NXRect *)cellFrame inView:controlView
- {
- [super drawInside:cellFrame inView:controlView];
-
- [self drawMark:cellFrame];
-
- return self;
- }
-
- - highlight:(const NXRect *)cellFrame inView:aView lit:(BOOL)lit
- {
- [super highlight:cellFrame inView:aView lit:lit];
-
- [self drawMark:cellFrame];
-
- return self;
- }
-
- - drawMark:(const NXRect *)cellFrame
- {
- NXRect rect;
- id idImage;
-
- if ([self isLeaf])
- {
- idImage = ([self state] || [self isHighlighted])
- ? [[self class] altMarkImage]
- : [[self class] markImage];
- [idImage getSize:&rect.size];
- rect.origin.x = NX_WIDTH(cellFrame) - rect.size.width - 5.0;
- rect.origin.y = NX_Y(cellFrame) + NX_HEIGHT(cellFrame)
- - ((NX_HEIGHT(cellFrame) - rect.size.height) / 2);
-
- if (fMarked)
- {
- [idImage composite:NX_SOVER toPoint:&rect.origin];
- }
- else
- {
- PSsetgray(([self state] || [self isHighlighted])
- ? NX_WHITE : NX_LTGRAY);
- rect.origin.y -= rect.size.height;
- NXRectFill(&rect);
- }
- }
-
- return self;
- }
-
- @end
-