home *** CD-ROM | disk | FTP | other *** search
-
- #import "MyNXBrowserCell.h"
- #import "common.h"
-
- #define FIRST_COLUMN_START 5.0
- #define SECOND_COLUMN_START 45.0
-
- @implementation MyNXBrowserCell
-
- static id twoImage;
- static id eightImage;
- static id twelveImage;
- static id twentyfourImage;
- static NXSize imageSize; // All assumed to be same size
-
- /*=========================================================================
- * NAME : initTextCell:
- * DESCRIPTION : Initialize a cell.
- *=========================================================================*/
- - initTextCell:(const char *)aString
- {
- id bundle = [NXBundle bundleForClass:[self class]];
- char buf[MAXPATHLEN+1];
-
- [super initTextCell:aString];
-
- if (!twoImage) {
- if ([bundle getPath:buf forResource:"2" ofType:"tiff"]) {
- twoImage = [[NXImage alloc] initFromFile:buf];
- }
- [twoImage getSize:&imageSize];
- }
- if (!eightImage) {
- if ([bundle getPath:buf forResource:"8" ofType:"tiff"]) {
- eightImage = [[NXImage alloc] initFromFile:buf];
- }
- }
- if (!twelveImage) {
- if ([bundle getPath:buf forResource:"12" ofType:"tiff"]) {
- twelveImage = [[NXImage alloc] initFromFile:buf];
- }
- }
- if (!twentyfourImage) {
- if ([bundle getPath:buf forResource:"24" ofType:"tiff"]) {
- twentyfourImage = [[NXImage alloc] initFromFile:buf];
- }
- }
- return self;
- }
-
- /*=========================================================================
- * NAME : setTag:
- * DESCRIPTION : Sets the cell's integer tag.
- *=========================================================================*/
- - setTag:(int)aTag
- {
- tag = aTag;
- return self;
- }
-
- /*=========================================================================
- * NAME : tag
- * DESCRIPTION : Returns the cell's integer tag.
- *=========================================================================*/
- - (int)tag
- {
- return tag;
- }
-
- /*=========================================================================
- * NAME : setOwner:
- * DESCRIPTION : Set the owner attribute.
- *=========================================================================*/
- - setOwner:(NXAtom)theOwner
- {
- owner = theOwner;
- return self;
- }
-
- /*=========================================================================
- * NAME : owner
- * DESCRIPTION : Return the owner attribute.
- *=========================================================================*/
- - (NXAtom)owner
- {
- return owner;
- }
-
- /*=========================================================================
- * NAME : setDepth:
- * DESCRIPTION : Set the WindowDepthLimit attribute.
- *=========================================================================*/
- - setDepth:(int)theDepth;
- {
- depth = theDepth;
- switch (depth) {
- case USE_2_BIT:
- depthImage = twoImage;
- break;
- case USE_8_BIT:
- depthImage = eightImage;
- break;
- case USE_12_BIT:
- depthImage = twelveImage;
- break;
- case USE_24_BIT:
- depthImage = twentyfourImage;
- break;
- default:
- depthImage = nil;
- break;
- }
- return self;
- }
-
- /*=========================================================================
- * NAME : depth
- * DESCRIPTION : Return the WindowDepthLimit.
- *=========================================================================*/
- - (int)depth
- {
- return depth;
- }
-
- /*=========================================================================
- * NAME : setTestMode:
- * DESCRIPTION : Sets the test flag.
- *=========================================================================*/
- - setTestMode:(BOOL)flag
- {
- test = flag;
- return self;
- }
-
- /*=========================================================================
- * NAME : testMode
- * DESCRIPTION : Returns the state of the test mode flag.
- *=========================================================================*/
- - (BOOL)testMode
- {
- return test;
- }
-
- /*===========================================================================
- * NAME : - setFont:
- * DESCRIPTION : Set the cell font.
- *===========================================================================*/
- - setFont:fontObj
- {
- [super setFont:fontObj];
- NXTextFontInfo(support, &ascender, &descender, &lineHeight);
- return self;
- }
-
- /*===========================================================================
- * NAME : - drawInside:inView:
- * DESCRIPTION : Draw the custom cell.
- *===========================================================================*/
- - drawInside:(const NXRect *)cellFrame inView:controlView
- {
- NXPoint imageOrigin;
-
- [super drawInside:cellFrame inView:controlView];
-
- /* erase the cell */
- PSsetgray((cFlags1.state || cFlags1.highlighted) ? NX_WHITE : NX_LTGRAY);
- NXRectFill(cellFrame);
-
- /* draw the depth tiff */
- if (depthImage) {
- imageOrigin.x = FIRST_COLUMN_START;
- imageOrigin.y = NX_Y(cellFrame) + NX_HEIGHT(cellFrame) -
- (NX_HEIGHT(cellFrame) - imageSize.height) / 2.0;
- [depthImage composite:NX_SOVER toPoint:&imageOrigin];
- }
-
- /* draw the text */
- if (depth != USE_DEFAULT)
- PSsetgray(NX_BLACK);
- else
- PSsetgray(NX_DKGRAY);
- PSmoveto(NX_X(cellFrame) + SECOND_COLUMN_START,
- NX_Y(cellFrame) + lineHeight - descender);
- PSshow(contents);
-
- return self;
- }
-
- @end
-