2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
#import "qedefs.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
NOTE: I am specifically not using cached image reps, because the data is also needed for texturing the views, and a cached rep would waste tons of space.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@implementation TextureView
|
|
|
|
|
|
|
|
- init
|
|
|
|
{
|
|
|
|
deselectIndex = -1;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- setParent:(id)from
|
|
|
|
{
|
|
|
|
parent_i = from;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)acceptsFirstMouse
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2001-02-12 09:20:26 +00:00
|
|
|
- drawSelf:(const NSRect *)rects :(int)rectCount
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int max;
|
|
|
|
id list_i;
|
|
|
|
texpal_t *t;
|
|
|
|
int x;
|
|
|
|
int y;
|
2001-02-12 09:20:26 +00:00
|
|
|
NSPoint p;
|
|
|
|
NSRect r;
|
2001-02-09 01:52:44 +00:00
|
|
|
int selected;
|
|
|
|
|
|
|
|
selected = [parent_i getSelectedTexture];
|
|
|
|
list_i = [parent_i getList];
|
|
|
|
PSselectfont("Helvetica-Medium",FONTSIZE);
|
|
|
|
PSrotate(0);
|
|
|
|
|
2001-02-12 09:20:26 +00:00
|
|
|
PSsetgray(NSLightGray);
|
2001-02-09 01:52:44 +00:00
|
|
|
PSrectfill(rects->origin.x, rects->origin.y,
|
|
|
|
rects->size.width, rects->size.height);
|
|
|
|
|
|
|
|
if (!list_i) // WADfile didn't init
|
|
|
|
return self;
|
|
|
|
|
|
|
|
if (deselectIndex != -1)
|
|
|
|
{
|
2001-02-12 09:20:26 +00:00
|
|
|
t = [list_i elementAtIndex:deselectIndex];
|
2001-02-09 01:52:44 +00:00
|
|
|
r = t->r;
|
|
|
|
r.origin.x -= TEX_INDENT;
|
|
|
|
r.origin.y -= TEX_INDENT;
|
|
|
|
r.size.width += TEX_INDENT*2;
|
|
|
|
r.size.height += TEX_INDENT*2;
|
|
|
|
|
2001-02-12 09:20:26 +00:00
|
|
|
PSsetgray(NSGrayComponent(NSGray));
|
2001-02-09 01:52:44 +00:00
|
|
|
PSrectfill(r.origin.x, r.origin.y,
|
|
|
|
r.size.width, r.size.height);
|
|
|
|
p = t->r.origin;
|
|
|
|
p.y += TEX_SPACING;
|
2001-02-12 09:20:26 +00:00
|
|
|
[t->image drawAtPoint:p];
|
2001-02-09 01:52:44 +00:00
|
|
|
PSsetgray(0);
|
|
|
|
x = t->r.origin.x;
|
|
|
|
y = t->r.origin.y + 7;
|
|
|
|
PSmoveto(x,y);
|
|
|
|
PSshow(t->name);
|
|
|
|
PSstroke();
|
|
|
|
deselectIndex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
max = [list_i count];
|
|
|
|
PSsetgray(0);
|
|
|
|
|
|
|
|
for (i = 0;i < max; i++)
|
|
|
|
{
|
2001-02-12 09:20:26 +00:00
|
|
|
t = [list_i elementAtIndex:i];
|
2001-02-09 01:52:44 +00:00
|
|
|
r = t->r;
|
|
|
|
r.origin.x -= TEX_INDENT/2;
|
|
|
|
r.size.width += TEX_INDENT;
|
|
|
|
r.origin.y += 4;
|
2001-02-12 09:20:26 +00:00
|
|
|
if (NSIntersectsRect(rects[0],r) == YES &&
|
2001-02-09 01:52:44 +00:00
|
|
|
t->display)
|
|
|
|
{
|
|
|
|
if (selected == i)
|
|
|
|
{
|
|
|
|
PSsetgray(1);
|
|
|
|
PSrectfill(r.origin.x,r.origin.y,
|
|
|
|
r.size.width,r.size.height);
|
|
|
|
PSsetrgbcolor(1,0,0);
|
|
|
|
PSrectstroke(r.origin.x, r.origin.y,
|
|
|
|
r.size.width, r.size.height);
|
|
|
|
PSsetgray(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
p = t->r.origin;
|
|
|
|
p.y += TEX_SPACING;
|
2001-02-12 09:20:26 +00:00
|
|
|
[t->image drawAtPoint:p];
|
2001-02-09 01:52:44 +00:00
|
|
|
x = t->r.origin.x;
|
|
|
|
y = t->r.origin.y + 7;
|
|
|
|
PSmoveto(x,y);
|
|
|
|
PSshow(t->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PSstroke();
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- deselect
|
|
|
|
{
|
|
|
|
deselectIndex = [parent_i getSelectedTexture];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2001-02-12 09:20:26 +00:00
|
|
|
- mouseDown:(NSEvent *)theEvent
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
2001-02-12 09:20:26 +00:00
|
|
|
NSPoint loc;
|
2001-02-09 01:52:44 +00:00
|
|
|
int i;
|
|
|
|
int max;
|
|
|
|
int oldwindowmask;
|
|
|
|
texpal_t *t;
|
|
|
|
id list;
|
2001-02-12 09:20:26 +00:00
|
|
|
NSRect r;
|
2001-02-09 01:52:44 +00:00
|
|
|
|
2001-02-12 09:20:26 +00:00
|
|
|
oldwindowmask = [[self window] addToEventMask:NSLeftMouseDraggedMask];
|
|
|
|
loc = [theEvent locationInWindow];
|
|
|
|
[self convertPoint:loc fromView:NULL];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
list = [parent_i getList];
|
|
|
|
max = [list count];
|
|
|
|
for (i = 0;i < max; i++)
|
|
|
|
{
|
2001-02-12 09:20:26 +00:00
|
|
|
t = [list elementAtIndex:i];
|
2001-02-09 01:52:44 +00:00
|
|
|
r = t->r;
|
2001-02-12 09:20:26 +00:00
|
|
|
if (NSPointInRect(loc,r) == YES)
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
[self deselect];
|
|
|
|
[parent_i setSelectedTexture:i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-12 09:20:26 +00:00
|
|
|
[[self window] setEventMask:oldwindowmask];
|
2001-02-09 01:52:44 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|