OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [demos/] [nanox/] [demo2.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#define MWINCLUDECOLORS
2
#include <stdio.h>
3
#include "nano-X.h"
4
 
5
#include <signal.h>
6
 
7
int
8
main(int ac,char **av)
9
{
10
        GR_WINDOW_ID    w, w2;
11
        GR_GC_ID        gc;
12
        GR_EVENT        event;
13
        GR_WM_PROPERTIES props;
14
 
15
        if (GrOpen() < 0) {
16
                printf("Can't open graphics\n");
17
                exit(1);
18
        }
19
 
20
        /* pass errors through main loop*/
21
        GrSetErrorHandler(NULL);
22
 
23
#define WIDTH   320
24
#define HEIGHT  240
25
        w = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 20, WIDTH, HEIGHT,
26
                0, GREEN, BLACK);
27
 
28
        w2 = GrNewWindow(w, 20, 20, 40, 40, 0, WHITE, BLACK);
29
 
30
        props.flags = GR_WM_FLAGS_PROPS | GR_WM_FLAGS_TITLE;
31
        props.props = GR_WM_PROPS_NOBACKGROUND;
32
        props.title = "Nano-X Demo2";
33
        GrSetWMProperties(w, &props);
34
 
35
        gc = GrNewGC();
36
 
37
        GrSelectEvents(w, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ
38
                | GR_EVENT_MASK_BUTTON_DOWN
39
                | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP);
40
        GrMapWindow(w);
41
        GrSetFocus(w);
42
        /* serious bug here: when wm running, w2 is mapped anyway!!*/
43
        /*GrMapWindow(w2);*/
44
 
45
        for (;;) {
46
                /*GR_EVENT_KEYSTROKE *kev;*/
47
 
48
                GrGetNextEvent(&event);
49
                switch (event.type) {
50
                case GR_EVENT_TYPE_EXPOSURE:
51
                        GrSetGCForeground(gc,GrGetSysColor(GR_COLOR_APPWINDOW));
52
                        GrFillRect(w, gc, event.exposure.x, event.exposure.y,
53
                                event.exposure.width, event.exposure.height);
54
                        GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPTEXT));
55
                        GrSetGCUseBackground(gc, GR_FALSE);
56
                        GrText(w, gc, 10, 30, "Hello World", -1, GR_TFASCII);
57
GrRect(w, gc, 5, 5, 300, 60);
58
                        break;
59
                case GR_EVENT_TYPE_CLOSE_REQ:
60
                        GrClose();
61
                        exit(0);
62
                        break;
63
                case GR_EVENT_TYPE_ERROR:
64
                        printf("\7demo2: Error (%s) ", event.error.name);
65
                        printf(nxErrorStrings[event.error.code],event.error.id);
66
                        break;
67
#if 0
68
                case GR_EVENT_TYPE_BUTTON_DOWN:
69
                        /* test server error on bad syscall*/
70
                        GrMapWindow(w2);
71
                        GrMoveWindow(GR_ROOT_WINDOW_ID, 0, 0);
72
                        { GR_SCREEN_INFO sinfo; GrGetScreenInfo(&sinfo); }
73
                        break;
74
#endif
75
#if 0
76
                case GR_EVENT_TYPE_KEY_DOWN:
77
                        kev = (GR_EVENT_KEYSTROKE *)&event;
78
                        printf("DOWN %d (%04x) %04x\n",
79
                                kev->ch, kev->ch, kev->modifiers);
80
                        break;
81
                case GR_EVENT_TYPE_KEY_UP:
82
                        kev = (GR_EVENT_KEYSTROKE *)&event;
83
                        printf("UP %d (%04x) %04x\n",
84
                                kev->ch, kev->ch, kev->modifiers);
85
                        break;
86
#endif
87
                }
88
        }
89
 
90
        GrClose();
91
        return 0;
92
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.