2020-03-05 06:44:53 +00:00
|
|
|
#include <Array.h>
|
|
|
|
#include "event.h"
|
2020-03-19 02:32:44 +00:00
|
|
|
#include "qwaq-draw.h"
|
2020-03-19 02:04:02 +00:00
|
|
|
#include "qwaq-garray.h"
|
2020-03-05 06:44:53 +00:00
|
|
|
#include "qwaq-group.h"
|
2020-03-19 02:32:44 +00:00
|
|
|
#include "qwaq-view.h"
|
2020-03-05 06:44:53 +00:00
|
|
|
|
|
|
|
@implementation Group
|
2020-03-14 10:45:07 +00:00
|
|
|
|
2020-03-17 16:39:12 +00:00
|
|
|
-initWithContext: (id<TextContext>) context
|
2020-03-05 06:44:53 +00:00
|
|
|
{
|
|
|
|
if (!(self = [super init])) {
|
|
|
|
return nil;
|
|
|
|
}
|
2020-03-19 02:32:44 +00:00
|
|
|
self.context = context;
|
2020-03-05 15:32:09 +00:00
|
|
|
views = [[Array array] retain];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2020-03-05 06:44:53 +00:00
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
[views release];
|
|
|
|
}
|
|
|
|
|
|
|
|
-insert: (View *) view
|
|
|
|
{
|
2020-03-06 02:53:40 +00:00
|
|
|
[views addObject: view];
|
2020-03-19 02:32:44 +00:00
|
|
|
[view setContext: context];
|
2020-03-05 06:44:53 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-03-06 02:53:40 +00:00
|
|
|
static BOOL
|
|
|
|
not_dont_draw (id aView, void *aGroup)
|
|
|
|
{
|
|
|
|
View *view = aView;
|
|
|
|
Group *group = (Group *) aGroup;
|
2020-03-14 10:45:07 +00:00
|
|
|
|
2020-03-19 02:32:44 +00:00
|
|
|
return !([view options] & ofDontDraw);
|
2020-03-06 02:53:40 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 06:44:53 +00:00
|
|
|
-draw
|
|
|
|
{
|
2020-03-06 02:53:40 +00:00
|
|
|
[views makeObjectsPerformSelector: @selector(draw)
|
|
|
|
if: not_dont_draw
|
|
|
|
with: self];
|
2020-03-05 06:44:53 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2020-03-19 02:32:44 +00:00
|
|
|
-redraw
|
|
|
|
{
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2020-03-05 06:44:53 +00:00
|
|
|
-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
|