1 #import <Foundation/Foundation.h> 2 #import <AppKit/AppKit.h> 3 4 #import "Document.h" 5 #import "BTree.h" 6 7 // #define PIECE_WIDTH 48 // must be even 8 // #define PIECE_HEIGHT 40 // must be even 9 10 // used to be constant 11 #define PIECE_WIDTH piece_width // must be even 12 #define PIECE_HEIGHT piece_height // must be even 13 14 #define PIECE_WIDTH_SMALL 48 // must be even 15 #define PIECE_HEIGHT_SMALL 40 // must be even 16 17 #define PIECE_WIDTH_MEDIUM 64 // must be even 18 #define PIECE_HEIGHT_MEDIUM 52 // must be even 19 20 #define PIECE_WIDTH_LARGE 80 // must be even 21 #define PIECE_HEIGHT_LARGE 64 // must be even 22 23 // #define BOUNDARY 16 24 // #define OFFS 8 25 26 #define BOUNDARY_SMALL 16 27 #define OFFS_SMALL 8 28 29 #define BOUNDARY_MEDIUM 20 30 #define OFFS_MEDIUM 10 31 32 #define BOUNDARY_LARGE 24 33 #define OFFS_LARGE 12 34 35 #define BOUNDARY \ 36 (piece_width==PIECE_WIDTH_SMALL ? BOUNDARY_SMALL : \ 37 (piece_width==PIECE_WIDTH_MEDIUM ? BOUNDARY_MEDIUM : BOUNDARY_LARGE)) 38 39 #define OFFS \ 40 (piece_width==PIECE_WIDTH_SMALL ? OFFS_SMALL : \ 41 (piece_width==PIECE_WIDTH_MEDIUM ? OFFS_MEDIUM : OFFS_LARGE)) 42 43 44 #define RADSQ ((float)(BOUNDARY*BOUNDARY/4)) 45 46 #define PIECE_BD_WIDTH (2*BOUNDARY+PIECE_WIDTH) 47 #define PIECE_BD_HEIGHT (2*BOUNDARY+PIECE_HEIGHT) 48 49 #define DIM_MAX 32 50 #define DIM_MIN 3 51 52 typedef enum { 53 INNER = -1, 54 BORDER, 55 OUTER 56 } BTYPE; 57 58 typedef enum { 59 EXTERIOR, 60 LEFTIN, LEFTOUT, 61 RIGHTIN, RIGHTOUT, 62 LOWERIN, LOWEROUT, 63 UPPERIN, UPPEROUT, 64 CENTER 65 } PTYPE; 66 67 @interface PieceView : NSView 68 { 69 Document *doc; 70 71 NSImage *image, *complete; 72 73 BTree *cluster; 74 int x, y, px, py; 75 BTYPE left, right, upper, lower; 76 int padleft, padright, padupper, padlower; 77 78 NSBezierPath *clip, *boundary; 79 80 int tag; 81 int done; 82 83 int piece_width, piece_height; 84 } 85 86 + (id *)checkCluster:(BTree *)theCluster 87 dimX:(int)dimx 88 dimY:(int)dimy; 89 90 + (BTree *)doJoin:(BTree *)cluster and:(BTree *)ccluster 91 all:(NSMutableArray *)allClusters; 92 93 - (id)initWithImage:(NSImage *)theImage 94 dimX:(int)dimx 95 dimY:(int)dimy 96 loc:(NSPoint)theLoc 97 posX:(int)posx outOf:(int)px 98 posY:(int)posy outOf:(int)py 99 left:(BTYPE)bleft 100 right:(BTYPE)bright 101 upper:(BTYPE)bupper 102 lower:(BTYPE)blower; 103 104 - setCluster:(BTree *)theCluster; 105 - (BTree *)cluster; 106 107 - setDocument:(Document *)theDocument; 108 - (Document *)document; 109 110 - (int)setDone:(int)dflag; 111 112 - (void)drawRect:(NSRect)aRect; 113 - (void)outline:(float *)delta; 114 115 - (void)showInvalid; 116 117 - (void)bbox:(NSRect *)bbox; 118 119 - (void)shiftView:(float *)delta; 120 121 - (BTYPE)left; 122 - (BTYPE)right; 123 - (BTYPE)upper; 124 - (BTYPE)lower; 125 126 - (int)tag; 127 128 - (int)x; 129 - (int)y; 130 131 - (PTYPE)classifyPoint:(NSPoint)pt; 132 133 134 - (void)extractFromCluster; 135 - (void)splitCluster; 136 137 - (void)mouseDown:(NSEvent *)theEvent; 138 - (void)rightMouseDown:(NSEvent *)theEvent; 139 140 - (NSString *)toString; 141 142 143 @end 144 145 146 147