mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-03 01:51:02 +00:00
[qwaq] Clean up the hierarchy
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.
This commit is contained in:
parent
b16093a533
commit
2f3ca9d9e4
7 changed files with 57 additions and 29 deletions
|
@ -4,6 +4,7 @@ int fence;
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "qwaq-app.h"
|
#include "qwaq-app.h"
|
||||||
#include "qwaq-curses.h"
|
#include "qwaq-curses.h"
|
||||||
|
#include "qwaq-group.h"
|
||||||
#include "qwaq-window.h"
|
#include "qwaq-window.h"
|
||||||
#include "qwaq-screen.h"
|
#include "qwaq-screen.h"
|
||||||
#include "qwaq-view.h"
|
#include "qwaq-view.h"
|
||||||
|
|
|
@ -1,17 +1,25 @@
|
||||||
#ifndef __qwaq_group_h
|
#ifndef __qwaq_group_h
|
||||||
#define __qwaq_group_h
|
#define __qwaq_group_h
|
||||||
|
|
||||||
#include "qwaq-view.h"
|
#include <Array.h>
|
||||||
|
|
||||||
@interface Group : View
|
#include "event.h"
|
||||||
|
#include "qwaq-draw.h"
|
||||||
|
|
||||||
|
@class View;
|
||||||
|
|
||||||
|
@interface Group : Object
|
||||||
{
|
{
|
||||||
Array *views;
|
Array *views;
|
||||||
int focused;
|
int focused;
|
||||||
id<TextContext> buffer;
|
id<TextContext> context;
|
||||||
}
|
}
|
||||||
-initWithContext: (id<TextContext>) context;
|
-initWithContext: (id<TextContext>) context;
|
||||||
-insert: (View *) view;
|
-insert: (View *) view;
|
||||||
-remove: (View *) view;
|
-remove: (View *) view;
|
||||||
|
-draw;
|
||||||
|
-redraw;
|
||||||
|
-handleEvent: (qwaq_event_t *) event;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif//__qwaq_group_h
|
#endif//__qwaq_group_h
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include <Array.h>
|
#include <Array.h>
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
#include "qwaq-draw.h"
|
||||||
#include "qwaq-garray.h"
|
#include "qwaq-garray.h"
|
||||||
#include "qwaq-group.h"
|
#include "qwaq-group.h"
|
||||||
|
#include "qwaq-view.h"
|
||||||
|
|
||||||
@implementation Group
|
@implementation Group
|
||||||
|
|
||||||
|
@ -10,18 +12,7 @@
|
||||||
if (!(self = [super init])) {
|
if (!(self = [super init])) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
textContext = context;
|
self.context = context;
|
||||||
absRect = rect = { nil, [textContext size] };
|
|
||||||
buffer = [DrawBuffer buffer: rect.extent];
|
|
||||||
views = [[Array array] retain];
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
-initWithRect: (Rect) rect
|
|
||||||
{
|
|
||||||
if (!(self = [super initWithRect: rect])) {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
views = [[Array array] retain];
|
views = [[Array array] retain];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +25,7 @@
|
||||||
-insert: (View *) view
|
-insert: (View *) view
|
||||||
{
|
{
|
||||||
[views addObject: view];
|
[views addObject: view];
|
||||||
view.textContext = buffer;
|
[view setContext: context];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +49,7 @@ not_dont_draw (id aView, void *aGroup)
|
||||||
View *view = aView;
|
View *view = aView;
|
||||||
Group *group = (Group *) aGroup;
|
Group *group = (Group *) aGroup;
|
||||||
|
|
||||||
return !(view.options & ofDontDraw);
|
return !([view options] & ofDontDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
-draw
|
-draw
|
||||||
|
@ -69,9 +60,13 @@ not_dont_draw (id aView, void *aGroup)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-redraw
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
-handleEvent: (qwaq_event_t *) event
|
-handleEvent: (qwaq_event_t *) event
|
||||||
{
|
{
|
||||||
[super handleEvent: event];
|
|
||||||
if (event.what & qe_focused) {
|
if (event.what & qe_focused) {
|
||||||
if (focused >= 0) {
|
if (focused >= 0) {
|
||||||
[[views objectAtIndex:focused] handleEvent: event];
|
[[views objectAtIndex:focused] handleEvent: event];
|
||||||
|
|
|
@ -53,12 +53,19 @@ enum {
|
||||||
}
|
}
|
||||||
-initWithRect: (Rect) rect;
|
-initWithRect: (Rect) rect;
|
||||||
- (void) dealloc;
|
- (void) dealloc;
|
||||||
|
|
||||||
-setOwner: (Group *) owner;
|
-setOwner: (Group *) owner;
|
||||||
-(struct Rect_s *)getRect;
|
|
||||||
|
-(struct Rect_s *)rect;
|
||||||
|
|
||||||
|
-(int) options;
|
||||||
|
|
||||||
|
-setContext: (id<TextContext>) context;
|
||||||
-draw;
|
-draw;
|
||||||
-redraw;
|
-redraw;
|
||||||
-handleEvent: (qwaq_event_t *) event;
|
-handleEvent: (qwaq_event_t *) event;
|
||||||
|
|
||||||
|
|
||||||
- (void) refresh;
|
- (void) refresh;
|
||||||
- (void) mvprintf: (Point) pos, string fmt, ...;
|
- (void) mvprintf: (Point) pos, string fmt, ...;
|
||||||
- (void) mvvprintf: (Point) pos, string fmt, @va_list args;
|
- (void) mvvprintf: (Point) pos, string fmt, @va_list args;
|
||||||
|
|
|
@ -27,6 +27,17 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- setContext: (id<TextContext>) context
|
||||||
|
{
|
||||||
|
textContext = context;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int) options
|
||||||
|
{
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
updateScreenCursor (View *view)
|
updateScreenCursor (View *view)
|
||||||
{
|
{
|
||||||
|
@ -84,7 +95,7 @@ updateScreenCursor (View *view)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (Rect *) getRect
|
- (Rect *) rect
|
||||||
{
|
{
|
||||||
return ▭
|
return ▭
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
||||||
@class Array;
|
@class Group;
|
||||||
|
|
||||||
#include "qwaq-draw.h"
|
#include "qwaq-draw.h"
|
||||||
#include "qwaq-rect.h"
|
#include "qwaq-rect.h"
|
||||||
#include "qwaq-view.h"
|
#include "qwaq-view.h"
|
||||||
#include "qwaq-group.h"
|
|
||||||
|
|
||||||
@interface Window: Group
|
@interface Window: View
|
||||||
{
|
{
|
||||||
Point point; // FIXME can't be local :(
|
|
||||||
struct panel_s *panel;
|
struct panel_s *panel;
|
||||||
|
Group *objects;
|
||||||
|
Point point; // FIXME can't be local :(
|
||||||
DrawBuffer *buf;
|
DrawBuffer *buf;
|
||||||
}
|
}
|
||||||
+windowWithRect: (Rect) rect;
|
+windowWithRect: (Rect) rect;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "qwaq-curses.h"
|
#include "qwaq-curses.h"
|
||||||
|
#include "qwaq-group.h"
|
||||||
#include "qwaq-window.h"
|
#include "qwaq-window.h"
|
||||||
#include "qwaq-view.h"
|
#include "qwaq-view.h"
|
||||||
|
|
||||||
|
@ -18,9 +19,9 @@
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
self.rect = rect;
|
self.rect = rect;
|
||||||
buffer = [[TextContext alloc] initWithRect: rect];
|
textContext = [[TextContext alloc] initWithRect: rect];
|
||||||
textContext = buffer;
|
panel = create_panel ([(id)textContext window]);
|
||||||
panel = create_panel ([(id)buffer window]);
|
|
||||||
buf = [DrawBuffer buffer: {3, 3}];
|
buf = [DrawBuffer buffer: {3, 3}];
|
||||||
[buf mvaddstr: {0, 0}, "XOX"];
|
[buf mvaddstr: {0, 0}, "XOX"];
|
||||||
[buf mvaddstr: {0, 1}, "OXO"];
|
[buf mvaddstr: {0, 1}, "OXO"];
|
||||||
|
@ -28,6 +29,11 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-setContext: (id<TextContext>) context
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
-handleEvent: (qwaq_event_t *) event
|
-handleEvent: (qwaq_event_t *) event
|
||||||
{
|
{
|
||||||
/* switch (event.what) {
|
/* switch (event.what) {
|
||||||
|
@ -74,7 +80,7 @@
|
||||||
|
|
||||||
-setBackground: (int) ch
|
-setBackground: (int) ch
|
||||||
{
|
{
|
||||||
[(id)buffer bkgd: ch];
|
[(id)textContext bkgd: ch];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +101,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[super draw];
|
[super draw];
|
||||||
[(id)buffer border: box_sides, box_corners];
|
[(id)textContext border: box_sides, box_corners];
|
||||||
Point pos = { 1, 1 };
|
Point pos = { 1, 1 };
|
||||||
//for (int i = ACS_ULCORNER; i <= ACS_STERLING; i++) {
|
//for (int i = ACS_ULCORNER; i <= ACS_STERLING; i++) {
|
||||||
for (int i = 32; i <= 127; i++) {
|
for (int i = 32; i <= 127; i++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue