2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
#include "KeypairView.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "Things.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
id keypairview_i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
@implementation KeypairView
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
initWithFrame:
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
- initWithFrame:(NSRect) frameRect
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
[super initWithFrame:frameRect];
|
|
|
|
keypairview_i = self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-calcViewSize
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect b;
|
|
|
|
NSPoint pt;
|
|
|
|
int count;
|
|
|
|
id ent;
|
|
|
|
|
|
|
|
ent =[map_i currentEntity];
|
|
|
|
count =[ent numPairs];
|
|
|
|
|
2010-09-11 11:30:01 +00:00
|
|
|
//XXX[[self superview] setFlipped: YES];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-11 11:30:01 +00:00
|
|
|
b =[[self superview] bounds];
|
2010-09-11 10:03:41 +00:00
|
|
|
b.size.height = LINEHEIGHT * count + SPACING;
|
|
|
|
[self setBounds:b];
|
2003-03-18 19:48:24 +00:00
|
|
|
pt.x = pt.y = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
[self scrollPoint:pt];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-drawSelf: (const NSRect *) rects:(int) rectCount
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
epair_t *pair;
|
|
|
|
int y;
|
|
|
|
|
2010-09-11 11:30:01 +00:00
|
|
|
PSsetgray(NSLightGray);
|
2010-09-11 10:03:41 +00:00
|
|
|
PSrectfill (0, 0, _bounds.size.width, _bounds.size.height);
|
|
|
|
|
2010-09-14 13:17:35 +00:00
|
|
|
[[NSFont systemFontOfSize: FONTSIZE] set];
|
2010-09-11 10:03:41 +00:00
|
|
|
PSrotate (0);
|
|
|
|
PSsetgray (0);
|
|
|
|
|
|
|
|
pair =[[map_i currentEntity] epairs];
|
2003-03-18 19:48:24 +00:00
|
|
|
y = _bounds.size.height - LINEHEIGHT;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (; pair; pair = pair->next) {
|
|
|
|
PSmoveto (SPACING, y);
|
|
|
|
PSshow (pair->key);
|
|
|
|
PSmoveto (100, y);
|
|
|
|
PSshow (pair->value);
|
2003-03-18 19:48:24 +00:00
|
|
|
y -= LINEHEIGHT;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
PSstroke ();
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(void) mouseDown:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint loc;
|
|
|
|
int i;
|
|
|
|
epair_t *p;
|
|
|
|
|
|
|
|
loc =[theEvent locationInWindow];
|
|
|
|
loc =[self convertPoint: loc fromView:NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
p =[[map_i currentEntity] epairs];
|
|
|
|
while (i) {
|
|
|
|
p = p->next;
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!p)
|
|
|
|
return;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
if (p)
|
2010-09-11 10:03:41 +00:00
|
|
|
[things_i setSelectedKey:p];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|