ftp.nice.ch/pub/next/tools/frontends/Gnuplot.I.bs.tar.gz#/Gnuplot/GnuplotSource/TicCell.m

This is TicCell.m in view mode; [Download] [Up]

/*
 *  Copyright (C) 1993  Robert Davis
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of Version 2, or any later version, of 
 *  the GNU General Public License as published by the Free Software 
 *  Foundation.
 */

static char RCSId[]="$Id: TicCell.m,v 1.4 1993/05/04 16:23:06 davis Exp $";


#import <appkit/Font.h>
#import <appkit/Text.h>		/* NXTextFontInfo()		*/
#import <dpsclient/wraps.h>
#import <strings.h>

#import "TicCell.h"
#import "TicObject.h"

#define VALUE_COLUMN_END 95.0
#define STRING_COLUMN_START 100.0
#define DIGITS_ACCURACY 5


@implementation TicCell

- drawInside:(const NXRect *)cellFrame inView:controlView
{
    float	stringWidth;
    NXRect	rectArray[2];
    char	valueString[100];

    sprintf (valueString, "%.*f", DIGITS_ACCURACY, [subObject doubleValue]);

    /*
     *  Find width of the string, which depends on the font, which
     *  depends on whether we're printing or drawing.
     */

    if (NXDrawingStatus == NX_DRAWING)
	stringWidth = [[[support screenFont] set] getWidthOf:valueString];
    else
	stringWidth = [[support set] getWidthOf:valueString];

    PSsetgray(cFlags1.highlighted ? NX_WHITE : NX_LTGRAY);     /* Erase cell */
    NXRectFill(cellFrame);


    PSsetgray(cFlags1.disabled? NX_DKGRAY : NX_BLACK);

    /*
     *  TicCells draw both the double value and the string value in
     *  the cell.  Here's the string value ("contents"):
     */

    PSmoveto(NX_X(cellFrame) + STRING_COLUMN_START,
    	     NX_Y(cellFrame) + lineHeight - descender);
    PSshow(contents);

    /*  ... and the double value:  */

    PSmoveto(NX_X(cellFrame) + VALUE_COLUMN_END - stringWidth,
	     NX_Y(cellFrame) + lineHeight - descender);
    PSshow(valueString);


    /*  Draw the two dark gray lines above and below the cell.  */

    PSsetgray(NX_DKGRAY);
    if (cFlags1.highlighted) {
	/*
	 *  Draw 1-pixel tall rectangles instead of lines (this is
	 *  faster than PSmoveto(); PSlineto()).
	 */
	NXSetRect(&(rectArray[0]), NX_X(cellFrame), NX_Y(cellFrame),
		  NX_WIDTH(cellFrame), 1.0);
	NXSetRect(&(rectArray[1]), NX_X(cellFrame), NX_MAXY(cellFrame) - 1.0,
		  NX_WIDTH(cellFrame), 1.0);

	/*
	 * Using NXRectFillList is faster than separate calls to
	 * NXRectFill.
	 */
	NXRectFillList(rectArray, 2);
    }

    return self;
}


// Shuts up the compiler about unused RCSId
- (const char *) rcsid
{
    return RCSId;
}


@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.