Annotation of Examples/AppKit/ScrollDoodScroll/RulerView.m, revision 1.1

1.1     ! root        1: // RulerView.m
        !             2: // By Jayson Adams, NeXT Developer Support Team
        !             3: // Modified for 3.0 by Ali Ozer, May '92
        !             4: // You may freely copy, distribute and reuse the code in this example.
        !             5: // NeXT disclaims any warranty of any kind, expressed or implied, as to its
        !             6: // fitness for any particular use.
        !             7: 
        !             8: #import <dpsclient/psops.h>
        !             9: #import <math.h>
        !            10: 
        !            11: #import "RulerView.h"
        !            12: 
        !            13: @implementation RulerView
        !            14: 
        !            15: #define INCH_MARK_LENGTH (NX_HEIGHT(&bounds) * 0.75)
        !            16: #define HALFINCH_MARK_LENGTH (NX_HEIGHT(&bounds) * 0.5)
        !            17: #define QUARTERINCH_MARK_LENGTH (NX_HEIGHT(&bounds) * 0.25)
        !            18: 
        !            19: - drawSelf:(const NXRect *)rects :(int)rectCount
        !            20: {
        !            21:     NXCoord start = floor(NX_X(rects) / 72.0) * 72.0;
        !            22:     NXCoord end = ceil(NX_MAXX(rects) / 72.0) * 72.0;
        !            23: 
        !            24:     PSsetgray (NX_LTGRAY);
        !            25:     NXRectFill (rects);
        !            26:     
        !            27:     PSmoveto (start, 1.0);
        !            28:     PSlineto (end, 1.0);
        !            29:     while (start <= end) {
        !            30:        // Userpaths would really help out here. Exercise for the reader...
        !            31:        PSmoveto (start, 0.0);
        !            32:        PSrlineto (0.0, INCH_MARK_LENGTH);
        !            33:        PSmoveto (start + 36.0, 0.0);
        !            34:        PSrlineto (0.0, HALFINCH_MARK_LENGTH);
        !            35:        PSmoveto (start + 18.0, 0.0);
        !            36:        PSrlineto (0.0, QUARTERINCH_MARK_LENGTH);
        !            37:        PSmoveto (start + 54.0, 0.0);
        !            38:        PSrlineto (0.0, QUARTERINCH_MARK_LENGTH);
        !            39:        start += 72.0;
        !            40:     }
        !            41: 
        !            42:     PSsetlinewidth (0.0);
        !            43:     PSsetgray (NX_BLACK);
        !            44:     PSstroke();
        !            45: 
        !            46:     return self;
        !            47: }
        !            48: 
        !            49: @end

unix.superglobalmegacorp.com

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