File:  [NeXTSTEP 3.3 examples] / Examples / AppKit / ScrollDoodScroll / RulerView.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:40 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

// RulerView.m
// By Jayson Adams, NeXT Developer Support Team
// Modified for 3.0 by Ali Ozer, May '92
// You may freely copy, distribute and reuse the code in this example.
// NeXT disclaims any warranty of any kind, expressed or implied, as to its
// fitness for any particular use.

#import <dpsclient/psops.h>
#import <math.h>

#import "RulerView.h"

@implementation RulerView

#define INCH_MARK_LENGTH (NX_HEIGHT(&bounds) * 0.75)
#define HALFINCH_MARK_LENGTH (NX_HEIGHT(&bounds) * 0.5)
#define QUARTERINCH_MARK_LENGTH (NX_HEIGHT(&bounds) * 0.25)

- drawSelf:(const NXRect *)rects :(int)rectCount
{
    NXCoord start = floor(NX_X(rects) / 72.0) * 72.0;
    NXCoord end = ceil(NX_MAXX(rects) / 72.0) * 72.0;

    PSsetgray (NX_LTGRAY);
    NXRectFill (rects);
    
    PSmoveto (start, 1.0);
    PSlineto (end, 1.0);
    while (start <= end) {
    	// Userpaths would really help out here. Exercise for the reader...
	PSmoveto (start, 0.0);
	PSrlineto (0.0, INCH_MARK_LENGTH);
	PSmoveto (start + 36.0, 0.0);
	PSrlineto (0.0, HALFINCH_MARK_LENGTH);
	PSmoveto (start + 18.0, 0.0);
	PSrlineto (0.0, QUARTERINCH_MARK_LENGTH);
	PSmoveto (start + 54.0, 0.0);
	PSrlineto (0.0, QUARTERINCH_MARK_LENGTH);
	start += 72.0;
    }

    PSsetlinewidth (0.0);
    PSsetgray (NX_BLACK);
    PSstroke();

    return self;
}

@end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.