mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-11 07:42:18 +00:00
c377b324a1
Things are finally doing something again, and getting closer to having a moveable window.
113 lines
1.9 KiB
R
113 lines
1.9 KiB
R
#include <Array.h>
|
|
|
|
#include "event.h"
|
|
#include "qwaq-curses.h"
|
|
#include "qwaq-window.h"
|
|
#include "qwaq-view.h"
|
|
|
|
@implementation Window
|
|
|
|
+windowWithRect: (Rect) rect
|
|
{
|
|
return [[[self alloc] initWithRect: rect] autorelease];
|
|
}
|
|
|
|
-initWithRect: (Rect) rect
|
|
{
|
|
if (!(self = [super init])) {
|
|
return nil;
|
|
}
|
|
views = [[Array array] retain];
|
|
self.rect = rect;
|
|
window = create_window (xpos, ypos, xlen, ylen);
|
|
panel = create_panel (window);
|
|
return self;
|
|
}
|
|
|
|
-handleEvent: (qwaq_event_t *) event
|
|
{
|
|
/* switch (event.what) {
|
|
case qe_mouse:
|
|
mvwprintf(window, 0, 3, "%2d %2d %08x",
|
|
event.mouse.x, event.mouse.y, event.mouse.buttons);
|
|
[self redraw];
|
|
point.x = event.mouse.x;
|
|
point.y = event.mouse.y;
|
|
for (int i = [views count]; i--> 0; ) {
|
|
View *v = [views objectAtIndex: i];
|
|
if (rectContainsPoint (&v.absRect, &point)) {
|
|
[v handleEvent: event];
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case qe_key:
|
|
case qe_command:
|
|
if (focusedView) {
|
|
[focusedView handleEvent: event];
|
|
for (int i = [views count];
|
|
event.what != qe_none && i--> 0; ) {
|
|
View *v = [views objectAtIndex: i];
|
|
[v handleEvent: event];
|
|
}
|
|
}
|
|
break;
|
|
case qe_none:
|
|
break;
|
|
}*/
|
|
return self;
|
|
}
|
|
|
|
-addView: (View *) view
|
|
{
|
|
/* [views addObject: view];
|
|
view.absRect.xpos = view.rect.xpos + rect.xpos;
|
|
view.absRect.ypos = view.rect.ypos + rect.ypos;
|
|
view.window = window;
|
|
[view setOwner: self];*/
|
|
return self;
|
|
}
|
|
|
|
-setBackground: (int) ch
|
|
{
|
|
wbkgd (window, ch);
|
|
return self;
|
|
}
|
|
|
|
-draw
|
|
{
|
|
int x = 0, y = 0;
|
|
for (int i = ACS_ULCORNER; i <= ACS_STERLING; i++) {
|
|
int ch = acs_char (i);
|
|
if (ch) {
|
|
mvwaddch (window, x, y, ch);
|
|
} else {
|
|
mvwaddch (window, x, y, '.');
|
|
}
|
|
if (++x >= xlen) {
|
|
x = 0;
|
|
if (++y >= ylen) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
[views makeObjectsPerformSelector: @selector (draw)];
|
|
return self;
|
|
}
|
|
|
|
-(Rect *) getRect
|
|
{
|
|
return ▭
|
|
}
|
|
|
|
-setOwner: owner
|
|
{
|
|
self.owner = owner;
|
|
return self;
|
|
}
|
|
|
|
-redraw
|
|
{
|
|
return [owner redraw];
|
|
}
|
|
@end
|