mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 10:21:21 +00:00
[qwaq] Rework the hierarchy again
It doesn't work right now because View unconditionally sends refresh to its textContext, but textContext can be a draw buffer which does not respond to refresh. Still, these changes (notably the assignment chain in qwaq-group.r really pushed qfcc).
This commit is contained in:
parent
72f4b8ccb5
commit
877ad35a82
8 changed files with 34 additions and 30 deletions
|
@ -1,18 +1,21 @@
|
|||
#ifndef __qwaq_app_h
|
||||
#define __qwaq_app_h
|
||||
|
||||
#include <Object.h>
|
||||
|
||||
#include "event.h"
|
||||
#include "qwaq-group.h"
|
||||
|
||||
@class Screen;
|
||||
@class Group;
|
||||
|
||||
@interface QwaqApplication: Group
|
||||
@interface QwaqApplication: Object
|
||||
{
|
||||
qwaq_event_t event;
|
||||
qwaq_command endState;
|
||||
Screen *screen;
|
||||
|
||||
Group *objects;
|
||||
}
|
||||
-run;
|
||||
-draw;
|
||||
-handleEvent: (qwaq_event_t *) event;
|
||||
@end
|
||||
|
||||
|
|
|
@ -38,16 +38,17 @@ arp_end (void)
|
|||
init_pair (1, COLOR_WHITE, COLOR_BLUE);
|
||||
init_pair (2, COLOR_WHITE, COLOR_BLACK);
|
||||
|
||||
screen = [[Screen screen] retain];
|
||||
[self insert:screen];
|
||||
[screen setBackground: COLOR_PAIR (1)];
|
||||
Rect r = *[screen getRect];
|
||||
TextContext *screen = [TextContext screen];
|
||||
objects = [[Group alloc] initWithContext: screen];
|
||||
|
||||
[screen bkgd: COLOR_PAIR (1)];
|
||||
Rect r = { nil, [screen size] };
|
||||
r.offset.x = r.extent.width / 4;
|
||||
r.offset.y = r.extent.height / 4;
|
||||
r.extent.width /= 2;
|
||||
r.extent.height /= 2;
|
||||
Window *w;
|
||||
[self insert: w=[[Window windowWithRect: r] setBackground: COLOR_PAIR (2)]];
|
||||
[objects insert: w=[[Window windowWithRect: r] setBackground: COLOR_PAIR (2)]];
|
||||
//wprintf (w.window, "%d %d %d %d\n", r.offset.x, r.offset.y, r.extent.width, r.ylen);
|
||||
return self;
|
||||
}
|
||||
|
@ -70,14 +71,14 @@ arp_end (void)
|
|||
|
||||
-draw
|
||||
{
|
||||
[super draw];
|
||||
[objects draw];
|
||||
[TextContext refresh];
|
||||
return self;
|
||||
}
|
||||
|
||||
-handleEvent: (qwaq_event_t *) event
|
||||
{
|
||||
[screen handleEvent: event];
|
||||
[objects handleEvent: event];
|
||||
if (event.what == qe_key && event.key == '\x18') {
|
||||
event.what = qe_command;
|
||||
event.message.command = qc_exit;
|
||||
|
|
|
@ -31,8 +31,9 @@ typedef BOOL condition_func2 (id object, void *anObject, void *data);
|
|||
{
|
||||
Array *views;
|
||||
int focused;
|
||||
TextContext *buffer;
|
||||
id buffer; //FIXME id<TextContext> or sim
|
||||
}
|
||||
-initWithContext: (id) context; //FIXME id<TextContext> or sim
|
||||
-insert: (View *) view;
|
||||
-remove: (View *) view;
|
||||
@end
|
||||
|
|
|
@ -66,11 +66,16 @@
|
|||
@end
|
||||
|
||||
@implementation Group
|
||||
-init
|
||||
|
||||
-initWithContext: (id) context
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
textContext = context;
|
||||
absRect = rect = { nil, [textContext size] };
|
||||
printf ("\n\nsize:%d %d\n\n", rect.extent.width, rect.extent.height);
|
||||
buffer = [DrawBuffer buffer: rect.extent];
|
||||
views = [[Array array] retain];
|
||||
return self;
|
||||
}
|
||||
|
@ -92,6 +97,7 @@
|
|||
-insert: (View *) view
|
||||
{
|
||||
[views addObject: view];
|
||||
view.textContext = buffer;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -114,13 +120,8 @@ not_dont_draw (id aView, void *aGroup)
|
|||
{
|
||||
View *view = aView;
|
||||
Group *group = (Group *) aGroup;
|
||||
if (!(view.options & ofDontDraw)) {
|
||||
if (!view.textContext) {
|
||||
view.textContext = group.buffer;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
|
||||
return !(view.options & ofDontDraw);
|
||||
}
|
||||
|
||||
-draw
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
}
|
||||
+(Screen *) screen;
|
||||
-handleEvent: (qwaq_event_t *) event;
|
||||
-setBackground: (int) ch;
|
||||
@end
|
||||
|
||||
#endif//__qwaq_screen_h
|
||||
|
|
|
@ -29,20 +29,14 @@
|
|||
|
||||
-draw
|
||||
{
|
||||
update_panels ();
|
||||
[TextContext doupdate];
|
||||
return self;
|
||||
}
|
||||
|
||||
-redraw
|
||||
{
|
||||
[textContext refresh];
|
||||
return self;
|
||||
}
|
||||
|
||||
-setBackground: (int) ch
|
||||
{
|
||||
[textContext bkgd:ch];
|
||||
//update_panels ();
|
||||
[TextContext refresh];
|
||||
//[TextContext doupdate];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ enum {
|
|||
-(struct Rect_s *)getRect;
|
||||
-draw;
|
||||
-redraw;
|
||||
-handleEvent: (qwaq_event_t *) event;
|
||||
|
||||
- (void) refresh;
|
||||
- (void) mvprintf: (Point) pos, string fmt, ...;
|
||||
|
|
|
@ -126,5 +126,9 @@ updateScreenCursor (View *view)
|
|||
[textContext mvaddch: pos, ch];
|
||||
}
|
||||
|
||||
-handleEvent: (qwaq_event_t *) event
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue