mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
[qwaq] Clean things up in prep for button testing
This commit is contained in:
parent
23e6b49845
commit
19161ea80a
6 changed files with 38 additions and 66 deletions
|
@ -40,7 +40,7 @@ arp_end (void)
|
|||
init_pair (2, COLOR_WHITE, COLOR_BLACK);
|
||||
|
||||
TextContext *screen = [TextContext screen];
|
||||
objects = [[Group alloc] initWithContext: screen];
|
||||
objects = [[Group alloc] initWithContext: screen owner: nil];
|
||||
|
||||
[screen bkgd: COLOR_PAIR (1)];
|
||||
Rect r = { nil, [screen size] };
|
||||
|
|
|
@ -10,18 +10,21 @@
|
|||
|
||||
@interface Group : Object
|
||||
{
|
||||
View *owner;
|
||||
Array *views;
|
||||
View *mouse_grabbed;
|
||||
View *mouse_within;
|
||||
int focused;
|
||||
id<TextContext> context;
|
||||
}
|
||||
-initWithContext: (id<TextContext>) context;
|
||||
-initWithContext: (id<TextContext>) context owner: (View *) owner;
|
||||
-insert: (View *) view;
|
||||
-remove: (View *) view;
|
||||
-draw;
|
||||
-redraw;
|
||||
-handleEvent: (qwaq_event_t *) event;
|
||||
-(void) grabMouse;
|
||||
-(void) releaseMouse;
|
||||
@end
|
||||
|
||||
#endif//__qwaq_group_h
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
|
||||
@implementation Group
|
||||
|
||||
-initWithContext: (id<TextContext>) context
|
||||
-initWithContext: (id<TextContext>) context owner: (View *) owner
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
self.owner = owner;
|
||||
self.context = context;
|
||||
focused = -1;
|
||||
views = [[Array array] retain];
|
||||
return self;
|
||||
}
|
||||
|
@ -108,4 +110,17 @@ find_mouse_view(Group *group, Point pos)
|
|||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) grabMouse
|
||||
{
|
||||
mouse_grabbed = mouse_within;
|
||||
[owner grabMouse];
|
||||
}
|
||||
|
||||
-(void) releaseMouse
|
||||
{
|
||||
mouse_grabbed = mouse_within;
|
||||
[owner grabMouse];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -63,6 +63,8 @@ enum {
|
|||
-(Rect)rect;
|
||||
|
||||
-(int) containsPoint: (Point) point;
|
||||
-(void) grabMouse;
|
||||
-(void) releaseMouse;
|
||||
|
||||
-(int) options;
|
||||
|
||||
|
|
|
@ -105,6 +105,16 @@ updateScreenCursor (View *view)
|
|||
return rectContainsPoint (rect, point);
|
||||
}
|
||||
|
||||
-(void) grabMouse
|
||||
{
|
||||
[owner grabMouse];
|
||||
}
|
||||
|
||||
-(void) releaseMouse
|
||||
{
|
||||
[owner releaseMouse];
|
||||
}
|
||||
|
||||
- (void) forward: (SEL) sel : (@va_list) args
|
||||
{
|
||||
if (!textContext) {
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
textContext = [[TextContext alloc] initWithRect: rect];
|
||||
panel = create_panel ([(id)textContext window]);
|
||||
|
||||
objects = [[Group alloc] initWithContext: textContext owner: self];
|
||||
|
||||
buf = [DrawBuffer buffer: {3, 3}];
|
||||
[buf mvaddstr: {0, 0}, "XOX"];
|
||||
[buf mvaddstr: {0, 1}, "OXO"];
|
||||
|
@ -36,45 +38,13 @@
|
|||
|
||||
-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;
|
||||
}*/
|
||||
[objects handleEvent: event];
|
||||
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];*/
|
||||
[objects insert: view];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -102,35 +72,7 @@
|
|||
}
|
||||
[super draw];
|
||||
[(id)textContext border: box_sides, box_corners];
|
||||
Point pos = { 1, 1 };
|
||||
//for (int i = ACS_ULCORNER; i <= ACS_STERLING; i++) {
|
||||
for (int i = 32; i <= 127; i++) {
|
||||
int ch = acs_char (i);
|
||||
if (ch) {
|
||||
[self mvaddch: pos, ch];
|
||||
} else {
|
||||
[self mvaddch: pos, '.'];
|
||||
}
|
||||
if (++pos.x > 32) {
|
||||
pos.x = 1;
|
||||
if (++pos.y >= ylen) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
[textContext blitFromBuffer: buf to: makePoint (6, 3) from: [buf rect]];
|
||||
[self refresh];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(Rect *) getRect
|
||||
{
|
||||
return ▭
|
||||
}
|
||||
|
||||
-setOwner: owner
|
||||
{
|
||||
self.owner = owner;
|
||||
[objects draw];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue