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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [mw/] [src/] [include/] [XtoNX.h] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
#ifndef __XTONX_H
2
#define __XTONX_H
3
/*
4
 * Copyright (c) 2001 by Greg Haerr <greg@centurysoftware.com>
5
 *
6
 * XtoNX.h - X to Nano-X macro conversion header file
7
 *
8
 * Yes, this is a vain attempt at making things easier when
9
 * porting Xlib programs to Nano-X!
10
 */
11
 
12
#ifdef __cplusplus
13
extern "C" {
14
#endif
15
 
16
#define MWINCLUDECOLORS
17
#include "nano-X.h"
18
 
19
typedef GR_WINDOW_ID            Window;
20
typedef GR_WINDOW_ID            Pixmap;
21
typedef GR_GC_ID                GC;
22
typedef GR_FONT_ID              Font;
23
typedef GR_CURSOR_ID            Cursor;
24
typedef GR_REGION_ID            Region;
25
typedef unsigned long           Time;           /* change to GR_TIME*/
26
typedef GR_EVENT                XEvent;
27
typedef GR_FONT_INFO            XFontStruct;
28
typedef GR_POINT                XPoint;
29
typedef GR_RECT                 XRectangle;
30
 
31
/* static display structed initialized by XOpenDisplay()*/
32
typedef struct {
33
        GR_COORD display_width;
34
        GR_COORD display_height;
35
        int     display_bpp;
36
} Display;
37
 
38
/* kluge structs*/
39
#define XCharStruct             char
40
 
41
#define DisplayWidth(d,s)       (_display.display_width)
42
#define DisplayHeight(d,s)      (_display.display_height)
43
#define DefaultDepth(d,s)       (_display.display_bpp)
44
#define DefaultScreen(d)        0
45
#define RootWindow(d,s)         GR_ROOT_WINDOW_ID
46
#define BlackPixel(d,s)         BLACK
47
#define WhitePixel(d,s)         WHITE
48
#define False                   0
49
#define True                    1
50
 
51
#define None                    0
52
#define RectangleOut            MWRECT_OUT
53
#define RectangleIn             MWRECT_ALLIN
54
#define RectanglePart           MWRECT_PARTIN
55
 
56
/* events*/
57
#define EnterWindowMask         GR_EVENT_MASK_MOUSE_ENTER
58
#define LeaveWindowMask         GR_EVENT_MASK_MOUSE_EXIT
59
#define ButtonPressMask         GR_EVENT_MASK_BUTTON_DOWN
60
#define ButtonReleaseMask       GR_EVENT_MASK_BUTTON_UP
61
#define KeyPressMask            GR_EVENT_MASK_KEY_DOWN
62
#define KeyReleaseMask          GR_EVENT_MASK_KEY_UP
63
#define ExposureMask            GR_EVENT_MASK_EXPOSURE
64
#define SubstructureNotifyMask  GR_EVENT_MASK_CHLD_UPDATE
65
 
66
#define EnterNotify             GR_EVENT_TYPE_MOUSE_ENTER
67
#define LeaveNotify             GR_EVENT_TYPE_MOUSE_EXIT
68
#define ButtonPress             GR_EVENT_TYPE_BUTTON_DOWN
69
#define ButtonRelease           GR_EVENT_TYPE_BUTTON_UP
70
#define KeyPress                GR_EVENT_TYPE_KEY_DOWN
71
#define KeyRelease              GR_EVENT_TYPE_KEY_UP
72
#define Expose                  GR_EVENT_TYPE_EXPOSURE
73
#define ConfigureNotify         GR_EVENT_TYPE_CHLD_UPDATE
74
 
75
#define XCloseDisplay(d)                        GrClose()
76
#define XNextEvent(d,ep)                        GrGetNextEvent(ep)
77
#define XSelectInput(d,w,m)                     GrSelectEvents(w,m)
78
#define XFlush(d)                               GrFlush()
79
#define XSync(d,f)                              GrFlush()
80
 
81
/* graphics functions*/
82
#define XCreateSimpleWindow(d,p,x,y,w,h,bw,bordc,backc) \
83
                        GrNewWindow(p,x,y,w,h,bw,backc,bordc)
84
#define XCreateWindow(d,p,x,y,w,h,bw,depth,cl,vis,vm,attr) \
85
                        GrNewWindow(p,x,y,w,h,bw,WHITE,BLACK)
86
#define XCreatePixmapFromBitmapData(d,w,bm,W,H,f,b,depth) \
87
                        GrNewPixmapFromData(W,H,f,b,(void *)bm, \
88
                                GR_BMDATA_BYTEREVERSE|GR_BMDATA_BYTESWAP)
89
#define XCreateBitmapFromData(d,w,bm,W,H) \
90
                        GrNewPixmapFromData(W,H,WHITE,BLACK,(void *)bm, \
91
                                GR_BMDATA_BYTEREVERSE|GR_BMDATA_BYTESWAP)
92
#define XDestroyWindow(d,w)                     GrDestroyWindow(w)
93
#define XReparentWindow(d,w,p,x,y)              GrReparentWindow(w,p,x,y)
94
#define XMapWindow(d,w)                         GrMapWindow(w)
95
#define XUnmapWindow(d,w)                       GrUnmapWindow(w)
96
#define XClearWindow(d,w)                       GrClearArea(w,0,0,0,0,GR_FALSE)
97
#define XClearArea(d,w,X,Y,W,H,e)               GrClearArea(w,X,Y,W,H,e)
98
#define XRaiseWindow(d,w)                       GrRaiseWindow(w)
99
#define XLowerWindow(d,w)                       GrLowerWindow(w)
100
#define XMoveWindow(d,w,x,y)                    GrMoveWindow(w,x,y)
101
#define XResizeWindow(d,w,W,H)                  GrResizeWindow(w,W,H)
102
 
103
#define XCreateGC(d,a,b,c)                      GrNewGC()
104
#define XSetFunction(d,g,f)                     GrSetGCMode(g,f)
105
#define GXxor           GR_MODE_XOR
106
#define XSetForeground(d,g,c)                   GrSetGCForeground(g,c)
107
#define XSetWindowBackgroundPixmap(d,w,p) \
108
                        GrSetBackgroundPixmap(w,p,GR_BACKGROUND_TILE)
109
#define XSetWindowBackground(d,w,c)             GrSetWindowBackgroundColor(w,c)
110
#define XSetWindowBorderWidth(d,w,bw)           GrSetWindowBorderSize(w,bw)
111
#define XSetWindowBorder(d,w,c)                 GrSetWindowBorderColor(w,c)
112
#define XStoreName(d,w,n)                       GrSetWindowTitle(w,n)
113
#define XSetIconName(d,w,n)     /* nyi*/
114
#define XDrawLines(d,w,g,ar,cnt,B)              GrDrawLines(w,g,ar,cnt)
115
#define XFillRectangle(d,w,g,x,y,W,H)           GrFillRect(w,g,x,y,W,H)
116
#define XDrawString(d,w,g,x,y,s,c)      GrText(w,g,x,y,(void *)s,c,GR_TFASCII)
117
#define XSetFont(d,g,f)                         GrSetGCFont(g,f)
118
#define XLoadFont(d,f)                          GrCreateFont(0, 0, 0)
119
#define XDefineCursor(d,w,c)                    GrSetWindowCursor(w,c)
120
#define XUndefineCursor(d,w)                    GrSetWindowCursor(w,0)
121
 
122
#define XCreateRegion()                         GrNewRegion()
123
#define XUnionRectWithRegion(rect,sr,dr)        GrUnionRectWithRegion(dr,rect)  /* FIXME*/
124
#define XRectInRegion(r,x,y,w,h)                GrRectInRegion(r,x,y,w,h)
125
#define XSubtractRegion(sra,srb,dr)             GrSubtractRegion(dr,sra,srb)
126
#define XDestroyRegion(r)                       GrDestroyRegion(r)
127
 
128
#define XQueryTree(d,w,r,p,c,nc)                GrQueryTree(w,p,c,nc)
129
#define XFree(p)                                free(p)
130
 
131
/* client-statically declared functions*/
132
#define STATIC_FUNCTIONS                        \
133
static Display  _display;                       \
134
                                                \
135
Display *                                       \
136
XOpenDisplay(char *name)                        \
137
{                                               \
138
        GR_SCREEN_INFO  sinfo;                  \
139
                                                \
140
        if (GrOpen() < 0)                        \
141
                return NULL;                    \
142
                                                \
143
        GrGetScreenInfo(&sinfo);                \
144
        _display.display_width = sinfo.cols;    \
145
        _display.display_height = sinfo.rows;   \
146
        _display.display_bpp = sinfo.bpp;       \
147
                                                \
148
        return &_display;                       \
149
}                                               \
150
                                                \
151
int                                             \
152
XPending(Display *d)                            \
153
{                                               \
154
        GR_EVENT ev;                            \
155
                                                \
156
        GrFlush();                              \
157
        return GrPeekEvent(&ev);                \
158
}
159
 
160
#ifdef __cplusplus
161
} /* extern "C"*/
162
#endif
163
 
164
#endif /* __XTONX_H*/

powered by: WebSVN 2.1.0

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