mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[qwaq] Get Window working
It even draws a border around itself.
This commit is contained in:
parent
f18e3c3ad7
commit
ad4cde15b5
7 changed files with 46 additions and 28 deletions
|
@ -2,10 +2,11 @@
|
|||
#define __qwaq_app_h
|
||||
|
||||
#include "event.h"
|
||||
#include "qwaq-group.h"
|
||||
|
||||
@class Screen;
|
||||
|
||||
@interface QwaqApplication: Object
|
||||
@interface QwaqApplication: Group
|
||||
{
|
||||
qwaq_event_t event;
|
||||
qwaq_command endState;
|
||||
|
|
|
@ -33,32 +33,28 @@ arp_end (void)
|
|||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
initialize ();
|
||||
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];
|
||||
[screen printf:"%d %d %d %d\n",
|
||||
r.offset.x, r.offset.y, r.extent.width, r.extent.height];
|
||||
r.offset.x = r.extent.width / 4;
|
||||
r.offset.y = r.extent.height / 4;
|
||||
r.extent.width /= 2;
|
||||
r.extent.height /= 2;
|
||||
[screen printf:"%d %d %d %d\n",
|
||||
r.offset.x, r.offset.y, r.extent.width, r.extent.height];
|
||||
[screen printf:"%d\n", acs_char(ACS_HLINE)];
|
||||
[screen addch: acs_char(ACS_HLINE) atX:4 Y:4];
|
||||
Window *w;
|
||||
//[screen add: w=[[Window windowWithRect: r] setBackground: COLOR_PAIR (2)]];
|
||||
[self 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);
|
||||
[screen redraw];
|
||||
return self;
|
||||
}
|
||||
|
||||
-run
|
||||
{
|
||||
[screen draw];
|
||||
[self draw];
|
||||
do {
|
||||
arp_start ();
|
||||
|
||||
|
|
|
@ -12,6 +12,15 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-initWithRect: (Rect) rect
|
||||
{
|
||||
if (!(self = [super initWithRect: rect])) {
|
||||
return nil;
|
||||
}
|
||||
views = [[Array array] retain];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
[views release];
|
||||
|
|
|
@ -10,12 +10,11 @@
|
|||
|
||||
-init
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
if (!(self = [super initWithRect:getwrect (stdscr)])) {
|
||||
return nil;
|
||||
}
|
||||
window = stdscr;
|
||||
scrollok (window, 1);
|
||||
rect = getwrect (window);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -28,7 +27,7 @@
|
|||
-handleEvent: (qwaq_event_t *) event
|
||||
{
|
||||
if (event.what & qe_mouse) {
|
||||
[self printf:"%04x %2d %2d %d %08x\r", event.what, event.mouse.x, event.mouse.y, event.mouse.click, event.mouse.buttons];
|
||||
[self printf:"%04x %2d %2d %d %08x \r", event.what, event.mouse.x, event.mouse.y, event.mouse.click, event.mouse.buttons];
|
||||
[self redraw];
|
||||
}
|
||||
return self;
|
||||
|
@ -61,13 +60,9 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (Rect *) getRect
|
||||
{
|
||||
return ▭
|
||||
}
|
||||
|
||||
-setOwner: owner
|
||||
{
|
||||
self.owner = owner;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@ rectContainsPoint (Rect *rect, Point *point)
|
|||
|
||||
@implementation View
|
||||
|
||||
-init
|
||||
{
|
||||
return [super init];
|
||||
}
|
||||
|
||||
-initWithRect: (Rect) rect
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
|
|
|
@ -13,13 +13,9 @@
|
|||
@interface Window: Group
|
||||
{
|
||||
Point point; // FIXME can't be local :(
|
||||
Array *views;
|
||||
View *focusedView;
|
||||
struct window_s *window;
|
||||
struct panel_s *panel;
|
||||
}
|
||||
+windowWithRect: (Rect) rect;
|
||||
-addView: (View *) view;
|
||||
-setBackground: (int) ch;
|
||||
@end
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
views = [[Array array] retain];
|
||||
self.rect = rect;
|
||||
window = create_window (xpos, ypos, xlen, ylen);
|
||||
panel = create_panel (window);
|
||||
|
@ -76,22 +75,39 @@
|
|||
|
||||
-draw
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
for (int i = ACS_ULCORNER; i <= ACS_STERLING; i++) {
|
||||
static box_sides_t box_sides = {
|
||||
ACS_VLINE, ACS_VLINE,
|
||||
ACS_HLINE, ACS_HLINE,
|
||||
};
|
||||
static box_corners_t box_corners = {
|
||||
ACS_ULCORNER, ACS_URCORNER,
|
||||
ACS_LLCORNER, ACS_LRCORNER,
|
||||
};
|
||||
if (box_sides.ls == ACS_VLINE) {
|
||||
int *foo = &box_sides.ls;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
foo[i] = acs_char (foo[i]);
|
||||
}
|
||||
}
|
||||
[super draw];
|
||||
int x = 1, y = 1;
|
||||
wborder (window, box_sides, box_corners);
|
||||
//for (int i = ACS_ULCORNER; i <= ACS_STERLING; i++) {
|
||||
for (int i = 32; i <= 127; i++) {
|
||||
int ch = acs_char (i);
|
||||
if (ch) {
|
||||
mvwaddch (window, x, y, ch);
|
||||
} else {
|
||||
mvwaddch (window, x, y, '.');
|
||||
}
|
||||
if (++x >= xlen) {
|
||||
x = 0;
|
||||
if (++x > 32) {
|
||||
x = 1;
|
||||
if (++y >= ylen) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
[views makeObjectsPerformSelector: @selector (draw)];
|
||||
wrefresh (window);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue