mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-11 15:51:36 +00:00
2f3ca9d9e4
I think I've finally figured out what I want the core hierarchy to be. Right now, it's just the two classes: View and Window (derived from View). Window has a Group, and Group is just a collection of Views that it manages. QwaqApplication is just an object but like a Window, it has a Group of views. View Window has a Group Group contains Views QwaqApplication has a group More work needs to be done on drawing and event handling, but things are working again.
81 lines
1.3 KiB
R
81 lines
1.3 KiB
R
#include <Array.h>
|
|
#include "event.h"
|
|
#include "qwaq-draw.h"
|
|
#include "qwaq-garray.h"
|
|
#include "qwaq-group.h"
|
|
#include "qwaq-view.h"
|
|
|
|
@implementation Group
|
|
|
|
-initWithContext: (id<TextContext>) context
|
|
{
|
|
if (!(self = [super init])) {
|
|
return nil;
|
|
}
|
|
self.context = context;
|
|
views = [[Array array] retain];
|
|
return self;
|
|
}
|
|
|
|
-(void)dealloc
|
|
{
|
|
[views release];
|
|
}
|
|
|
|
-insert: (View *) view
|
|
{
|
|
[views addObject: view];
|
|
[view setContext: context];
|
|
return self;
|
|
}
|
|
|
|
-remove: (View *) view
|
|
{
|
|
int index = [views indexOfObject: view];
|
|
if (index != NotFound) {
|
|
if (focused == index) {
|
|
focused = -1;
|
|
} else if (focused > index) {
|
|
focused--;
|
|
}
|
|
[views removeObjectAtIndex: index];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
static BOOL
|
|
not_dont_draw (id aView, void *aGroup)
|
|
{
|
|
View *view = aView;
|
|
Group *group = (Group *) aGroup;
|
|
|
|
return !([view options] & ofDontDraw);
|
|
}
|
|
|
|
-draw
|
|
{
|
|
[views makeObjectsPerformSelector: @selector(draw)
|
|
if: not_dont_draw
|
|
with: self];
|
|
return self;
|
|
}
|
|
|
|
-redraw
|
|
{
|
|
return self;
|
|
}
|
|
|
|
-handleEvent: (qwaq_event_t *) event
|
|
{
|
|
if (event.what & qe_focused) {
|
|
if (focused >= 0) {
|
|
[[views objectAtIndex:focused] handleEvent: event];
|
|
}
|
|
} else if (event.what & qe_positional) {
|
|
} else {
|
|
// broadcast
|
|
[views makeObjectsPerformSelector: @selector(draw) withObject: event];
|
|
}
|
|
return self;
|
|
}
|
|
@end
|