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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [include/] [microwin/] [nano-X.h] - Blame information for rev 539

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

Line No. Rev Author Line
1 27 unneback
#ifndef _NANO_X_H
2
#define _NANO_X_H
3
/* Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com>
4
 * Copyright (c) 2000 Alex Holden <alex@linuxhacker.org>
5
 * Copyright (c) 1991 David I. Bell
6
 * Permission is granted to use, distribute, or modify this source,
7
 * provided that this copyright notice remains intact.
8
 *
9
 * Nano-X public definition header file:  user applications should
10
 * include only this header file.
11
 */
12
#ifdef __cplusplus
13
extern "C" {
14
#endif
15
 
16
#ifdef __ECOS
17
#include <cyg/kernel/kapi.h>
18
#endif
19
 
20
#include "mwtypes.h"                    /* exported engine MW* types*/
21
 
22
/*
23
 * The following typedefs are inherited from the Microwindows
24
 * engine layer.
25
 */
26
typedef MWCOORD         GR_COORD;       /* coordinate value */
27
typedef MWCOORD         GR_SIZE;        /* size value */
28
typedef MWCOLORVAL      GR_COLOR;       /* full color value */
29
typedef MWPIXELVAL      GR_PIXELVAL;    /* hw pixel value*/
30
typedef MWIMAGEBITS     GR_BITMAP;      /* bitmap unit */
31
typedef MWUCHAR         GR_CHAR;        /* filename, window title */
32
typedef MWKEY           GR_KEY;         /* keystroke value*/
33
typedef MWSCANCODE      GR_SCANCODE;    /* oem keystroke scancode value*/
34
typedef MWKEYMOD        GR_KEYMOD;      /* keystroke modifiers*/
35
typedef MWSCREENINFO    GR_SCREEN_INFO; /* screen information*/
36
typedef MWWINDOWFBINFO  GR_WINDOW_FB_INFO; /* direct client-mapped window info*/
37
typedef MWFONTINFO      GR_FONT_INFO;   /* font information*/
38
typedef MWIMAGEINFO     GR_IMAGE_INFO;  /* image information*/
39
typedef MWIMAGEHDR      GR_IMAGE_HDR;   /* multicolor image representation*/
40
typedef MWLOGFONT       GR_LOGFONT;     /* logical font descriptor*/
41
typedef MWPALENTRY      GR_PALENTRY;    /* palette entry*/
42
typedef MWPOINT         GR_POINT;       /* definition of a point*/
43
typedef MWTIMEOUT       GR_TIMEOUT;     /* timeout value */
44
typedef MWFONTLIST      GR_FONTLIST;    /* list of fonts */
45
typedef MWKBINFO        GR_KBINFO;      /* keyboard information  */
46
 
47
/* Basic typedefs. */
48
typedef int             GR_COUNT;       /* number of items */
49
typedef unsigned char   GR_CHAR_WIDTH;  /* width of character */
50
typedef unsigned int    GR_ID;          /* resource ids */
51
typedef GR_ID           GR_DRAW_ID;     /* drawable id */
52
typedef GR_DRAW_ID      GR_WINDOW_ID;   /* window or pixmap id */
53
typedef GR_ID           GR_GC_ID;       /* graphics context id */
54
typedef GR_ID           GR_REGION_ID;   /* region id */
55
typedef GR_ID           GR_FONT_ID;     /* font id */
56
typedef GR_ID           GR_IMAGE_ID;    /* image id */
57
typedef GR_ID           GR_TIMER_ID;    /* timer id */
58
typedef GR_ID           GR_CURSOR_ID;   /* cursor id */
59
typedef unsigned short  GR_BOOL;        /* boolean value */
60
typedef int             GR_ERROR;       /* error types*/
61
typedef int             GR_EVENT_TYPE;  /* event types */
62
typedef int             GR_UPDATE_TYPE; /* window update types */
63
typedef unsigned long   GR_EVENT_MASK;  /* event masks */
64
typedef char            GR_FUNC_NAME[25];/* function name */
65
typedef unsigned long   GR_WM_PROPS;    /* window property flags */
66
typedef unsigned long   GR_SERIALNO;    /* Selection request ID number */
67
typedef unsigned short  GR_MIMETYPE;    /* Index into mime type list */
68
typedef unsigned long   GR_LENGTH;      /* Length of a block of data */
69
typedef unsigned int    GR_BUTTON;      /* mouse button value*/
70
 
71
/* Nano-X rectangle, different from MWRECT*/
72
typedef struct {
73
        GR_COORD x;
74
        GR_COORD y;
75
        GR_SIZE  width;
76
        GR_SIZE  height;
77
} GR_RECT;
78
 
79
/* The root window id. */
80
#define GR_ROOT_WINDOW_ID       ((GR_WINDOW_ID) 1)
81
 
82
/* GR_COLOR color constructor*/
83
#define GR_RGB(r,g,b)           MWRGB(r,g,b)
84
 
85
/* Drawing modes for GrSetGCMode*/
86
#define GR_MODE_COPY            MWMODE_COPY             /* src*/
87
#define GR_MODE_SET             MWMODE_COPY             /* obsolete, use GR_MODE_COPY*/
88
#define GR_MODE_XOR             MWMODE_XOR              /* src ^ dst*/
89
#define GR_MODE_OR              MWMODE_OR               /* src | dst*/
90
#define GR_MODE_AND             MWMODE_AND              /* src & dst*/
91
#define GR_MODE_CLEAR           MWMODE_CLEAR            /* 0*/
92
#define GR_MODE_SETTO1          MWMODE_SETTO1           /* 11111111*/ /* will be GR_MODE_SET*/
93
#define GR_MODE_EQUIV           MWMODE_EQUIV            /* ~(src ^ dst)*/
94
#define GR_MODE_NOR             MWMODE_NOR              /* ~(src | dst)*/
95
#define GR_MODE_NAND            MWMODE_NAND             /* ~(src & dst)*/
96
#define GR_MODE_INVERT          MWMODE_INVERT           /* ~dst*/
97
#define GR_MODE_COPYINVERTED    MWMODE_COPYINVERTED     /* ~src*/
98
#define GR_MODE_ORINVERTED      MWMODE_ORINVERTED       /* ~src | dst*/
99
#define GR_MODE_ANDINVERTED     MWMODE_ANDINVERTED      /* ~src & dst*/
100
#define GR_MODE_ORREVERSE       MWMODE_ORREVERSE        /* src | ~dst*/
101
#define GR_MODE_ANDREVERSE      MWMODE_ANDREVERSE       /* src & ~dst*/
102
#define GR_MODE_NOOP            MWMODE_NOOP             /* dst*/
103
 
104
#define GR_MODE_DRAWMASK        0x00FF
105
#define GR_MODE_EXCLUDECHILDREN 0x0100          /* exclude children on clip*/
106
 
107
/* builtin font std names*/
108
#define GR_FONT_SYSTEM_VAR      MWFONT_SYSTEM_VAR
109
#define GR_FONT_GUI_VAR         MWFONT_GUI_VAR
110
#define GR_FONT_OEM_FIXED       MWFONT_OEM_FIXED
111
#define GR_FONT_SYSTEM_FIXED    MWFONT_SYSTEM_FIXED
112
 
113
/* GrText/GrGetTextSize encoding flags*/
114
#define GR_TFASCII              MWTF_ASCII
115
#define GR_TFUTF8               MWTF_UTF8
116
#define GR_TFUC16               MWTF_UC16
117
#define GR_TFUC32               MWTF_UC32
118
#define GR_TFPACKMASK           MWTF_PACKMASK
119
 
120
/* GrText alignment flags*/
121
#define GR_TFTOP                MWTF_TOP
122
#define GR_TFBASELINE           MWTF_BASELINE
123
#define GR_TFBOTTOM             MWTF_BOTTOM
124
 
125
/* GrSetFontAttr flags*/
126
#define GR_TFKERNING            MWTF_KERNING
127
#define GR_TFANTIALIAS          MWTF_ANTIALIAS
128
#define GR_TFUNDERLINE          MWTF_UNDERLINE
129
 
130
/* GrArc, GrArcAngle types*/
131
#define GR_ARC          MWARC           /* arc only*/
132
#define GR_ARCOUTLINE   MWARCOUTLINE    /* arc + outline*/
133
#define GR_PIE          MWPIE           /* pie (filled)*/
134
 
135
/* Booleans */
136
#define GR_FALSE                0
137
#define GR_TRUE                 1
138
 
139
/* Loadable Image support definition */
140
#define GR_IMAGE_MAX_SIZE       (-1)
141
 
142
/* Button flags */
143
#define GR_BUTTON_R             MWBUTTON_R      /* right button*/
144
#define GR_BUTTON_M             MWBUTTON_M      /* middle button*/
145
#define GR_BUTTON_L             MWBUTTON_L      /* left button */
146
#define GR_BUTTON_ANY           (MWBUTTON_R|MWBUTTON_M|MWBUTTON_L) /* any*/
147
 
148
/* GrSetBackgroundPixmap flags */
149
#define GR_BACKGROUND_TILE      0        /* Tile across the window */
150
#define GR_BACKGROUND_CENTER    1       /* Draw in center of window */
151
#define GR_BACKGROUND_TOPLEFT   2       /* Draw at top left of window */
152
#define GR_BACKGROUND_STRETCH   4       /* Stretch image to fit window*/
153
#define GR_BACKGROUND_TRANS     8       /* Don't fill in gaps */
154
 
155
/* GrNewPixmapFromData flags*/
156
#define GR_BMDATA_BYTEREVERSE   01      /* byte-reverse bitmap data*/
157
#define GR_BMDATA_BYTESWAP      02      /* byte-swap bitmap data*/
158
 
159
#if 0 /* don't define unimp'd flags*/
160
/* Window property flags */
161
#define GR_WM_PROP_NORESIZE     0x04    /* don't let user resize window */
162
#define GR_WM_PROP_NOICONISE    0x08    /* don't let user iconise window */
163
#define GR_WM_PROP_NOWINMENU    0x10    /* don't display a window menu button */
164
#define GR_WM_PROP_NOROLLUP     0x20    /* don't let user roll window up */
165
#define GR_WM_PROP_ONTOP        0x200   /* try to keep window always on top */
166
#define GR_WM_PROP_STICKY       0x400   /* keep window after desktop change */
167
#define GR_WM_PROP_DND          0x2000  /* accept drag and drop icons */
168
#endif
169
 
170
/* Window properties*/
171
#define GR_WM_PROPS_NOBACKGROUND 0x00000001L/* Don't draw window background*/
172
#define GR_WM_PROPS_NOFOCUS      0x00000002L /* Don't set focus to this window*/
173
#define GR_WM_PROPS_NOMOVE       0x00000004L /* Don't let user move window*/
174
#define GR_WM_PROPS_NORAISE      0x00000008L /* Don't let user raise window*/
175
#define GR_WM_PROPS_NODECORATE   0x00000010L /* Don't redecorate window*/
176
#define GR_WM_PROPS_NOAUTOMOVE   0x00000020L /* Don't move window on 1st map*/
177
#define GR_WM_PROPS_NOAUTORESIZE 0x00000040L /* Don't resize window on 1st map*/
178
 
179
/* default decoration style*/
180
#define GR_WM_PROPS_APPWINDOW   0x00000000L /* Leave appearance to WM*/
181
#define GR_WM_PROPS_APPMASK     0xF0000000L /* Appearance mask*/
182
#define GR_WM_PROPS_BORDER      0x80000000L /* Single line border*/
183
#define GR_WM_PROPS_APPFRAME    0x40000000L /* 3D app frame (overrides border)*/
184
#define GR_WM_PROPS_CAPTION     0x20000000L /* Title bar*/
185
#define GR_WM_PROPS_CLOSEBOX    0x10000000L /* Close box*/
186
#define GR_WM_PROPS_MAXIMIZE    0x08000000L /* Application is maximized*/
187
 
188
/* Flags for indicating valid bits in GrSetWMProperties call*/
189
#define GR_WM_FLAGS_PROPS       0x0001  /* Properties*/
190
#define GR_WM_FLAGS_TITLE       0x0002  /* Title*/
191
#define GR_WM_FLAGS_BACKGROUND  0x0004  /* Background color*/
192
#define GR_WM_FLAGS_BORDERSIZE  0x0008  /* Border size*/
193
#define GR_WM_FLAGS_BORDERCOLOR 0x0010  /* Border color*/
194
 
195
/* Window manager properties used by the Gr[GS]etWMProperties calls. */
196
/* NOTE: this struct must be hand-packed to a DWORD boundary for nxproto.h*/
197
typedef struct {
198
  GR_WM_PROPS flags;            /* Which properties valid in struct for set*/
199
  GR_WM_PROPS props;            /* Window property bits*/
200
  GR_CHAR *title;               /* Window title*/
201
  GR_COLOR background;          /* Window background color*/
202
  GR_SIZE bordersize;           /* Window border size*/
203
  GR_COLOR bordercolor;         /* Window border color*/
204
} GR_WM_PROPERTIES;
205
 
206
/* Window properties returned by the GrGetWindowInfo call. */
207
typedef struct {
208
  GR_WINDOW_ID wid;             /* window id (or 0 if no such window) */
209
  GR_WINDOW_ID parent;          /* parent window id */
210
  GR_WINDOW_ID child;           /* first child window id (or 0) */
211
  GR_WINDOW_ID sibling;         /* next sibling window id (or 0) */
212
  GR_BOOL inputonly;            /* TRUE if window is input only */
213
  GR_BOOL mapped;               /* TRUE if window is mapped */
214
  GR_COUNT unmapcount;          /* reasons why window is unmapped */
215
  GR_COORD x;                   /* absolute x position of window */
216
  GR_COORD y;                   /* absolute y position of window */
217
  GR_SIZE width;                /* width of window */
218
  GR_SIZE height;               /* height of window */
219
  GR_SIZE bordersize;           /* size of border */
220
  GR_COLOR bordercolor;         /* color of border */
221
  GR_COLOR background;          /* background color */
222
  GR_EVENT_MASK eventmask;      /* current event mask for this client */
223
  GR_WM_PROPS props;            /* window properties */
224
  GR_CURSOR_ID cursor;          /* cursor id*/
225
  unsigned long processid;      /* process id of owner*/
226
} GR_WINDOW_INFO;
227
 
228
/* Graphics context properties returned by the GrGetGCInfo call. */
229
typedef struct {
230
  GR_GC_ID gcid;                /* GC id (or 0 if no such GC) */
231
  int mode;                     /* drawing mode */
232
  GR_REGION_ID region;          /* user region */
233
  int xoff;                     /* x offset of user region*/
234
  int yoff;                     /* y offset of user region*/
235
  GR_FONT_ID font;              /* font number */
236
  GR_COLOR foreground;          /* foreground color */
237
  GR_COLOR background;          /* background color */
238
  GR_BOOL usebackground;        /* use background in bitmaps */
239
} GR_GC_INFO;
240
 
241
/* color palette*/
242
typedef struct {
243
  GR_COUNT count;               /* # valid entries*/
244
  GR_PALENTRY palette[256];     /* palette*/
245
} GR_PALETTE;
246
 
247
/* Error codes */
248
#define GR_ERROR_BAD_WINDOW_ID          1
249
#define GR_ERROR_BAD_GC_ID              2
250
#define GR_ERROR_BAD_CURSOR_SIZE        3
251
#define GR_ERROR_MALLOC_FAILED          4
252
#define GR_ERROR_BAD_WINDOW_SIZE        5
253
#define GR_ERROR_KEYBOARD_ERROR         6
254
#define GR_ERROR_MOUSE_ERROR            7
255
#define GR_ERROR_INPUT_ONLY_WINDOW      8
256
#define GR_ERROR_ILLEGAL_ON_ROOT_WINDOW 9
257
#define GR_ERROR_TOO_MUCH_CLIPPING      10
258
#define GR_ERROR_SCREEN_ERROR           11
259
#define GR_ERROR_UNMAPPED_FOCUS_WINDOW  12
260
#define GR_ERROR_BAD_DRAWING_MODE       13
261
 
262
/* Event types.
263
 * Mouse motion is generated for every motion of the mouse, and is used to
264
 * track the entire history of the mouse (many events and lots of overhead).
265
 * Mouse position ignores the history of the motion, and only reports the
266
 * latest position of the mouse by only queuing the latest such event for
267
 * any single client (good for rubber-banding).
268
 */
269
#define GR_EVENT_TYPE_ERROR             (-1)
270
#define GR_EVENT_TYPE_NONE              0
271
#define GR_EVENT_TYPE_EXPOSURE          1
272
#define GR_EVENT_TYPE_BUTTON_DOWN       2
273
#define GR_EVENT_TYPE_BUTTON_UP         3
274
#define GR_EVENT_TYPE_MOUSE_ENTER       4
275
#define GR_EVENT_TYPE_MOUSE_EXIT        5
276
#define GR_EVENT_TYPE_MOUSE_MOTION      6
277
#define GR_EVENT_TYPE_MOUSE_POSITION    7
278
#define GR_EVENT_TYPE_KEY_DOWN          8
279
#define GR_EVENT_TYPE_KEY_UP            9
280
#define GR_EVENT_TYPE_FOCUS_IN          10
281
#define GR_EVENT_TYPE_FOCUS_OUT         11
282
#define GR_EVENT_TYPE_FDINPUT           12
283
#define GR_EVENT_TYPE_UPDATE            13
284
#define GR_EVENT_TYPE_CHLD_UPDATE       14
285
#define GR_EVENT_TYPE_CLOSE_REQ         15
286
#define GR_EVENT_TYPE_TIMEOUT           16
287
#define GR_EVENT_TYPE_SCREENSAVER       17
288
#define GR_EVENT_TYPE_CLIENT_DATA_REQ   18
289
#define GR_EVENT_TYPE_CLIENT_DATA       19
290
#define GR_EVENT_TYPE_SELECTION_CHANGED 20
291
#define GR_EVENT_TYPE_TIMER             21
292
#define GR_EVENT_TYPE_PORTRAIT_CHANGED  22
293
 
294
/* Event masks */
295
#define GR_EVENTMASK(n)                 (((GR_EVENT_MASK) 1) << (n))
296
 
297
#define GR_EVENT_MASK_NONE              GR_EVENTMASK(GR_EVENT_TYPE_NONE)
298
#define GR_EVENT_MASK_ERROR             0x80000000L
299
#define GR_EVENT_MASK_EXPOSURE          GR_EVENTMASK(GR_EVENT_TYPE_EXPOSURE)
300
#define GR_EVENT_MASK_BUTTON_DOWN       GR_EVENTMASK(GR_EVENT_TYPE_BUTTON_DOWN)
301
#define GR_EVENT_MASK_BUTTON_UP         GR_EVENTMASK(GR_EVENT_TYPE_BUTTON_UP)
302
#define GR_EVENT_MASK_MOUSE_ENTER       GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_ENTER)
303
#define GR_EVENT_MASK_MOUSE_EXIT        GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_EXIT)
304
#define GR_EVENT_MASK_MOUSE_MOTION      GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_MOTION)
305
#define GR_EVENT_MASK_MOUSE_POSITION    GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_POSITION)
306
#define GR_EVENT_MASK_KEY_DOWN          GR_EVENTMASK(GR_EVENT_TYPE_KEY_DOWN)
307
#define GR_EVENT_MASK_KEY_UP            GR_EVENTMASK(GR_EVENT_TYPE_KEY_UP)
308
#define GR_EVENT_MASK_FOCUS_IN          GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_IN)
309
#define GR_EVENT_MASK_FOCUS_OUT         GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_OUT)
310
#define GR_EVENT_MASK_FDINPUT           GR_EVENTMASK(GR_EVENT_TYPE_FDINPUT)
311
#define GR_EVENT_MASK_UPDATE            GR_EVENTMASK(GR_EVENT_TYPE_UPDATE)
312
#define GR_EVENT_MASK_CHLD_UPDATE       GR_EVENTMASK(GR_EVENT_TYPE_CHLD_UPDATE)
313
#define GR_EVENT_MASK_CLOSE_REQ         GR_EVENTMASK(GR_EVENT_TYPE_CLOSE_REQ)
314
#define GR_EVENT_MASK_TIMEOUT           GR_EVENTMASK(GR_EVENT_TYPE_TIMEOUT)
315
#define GR_EVENT_MASK_SCREENSAVER       GR_EVENTMASK(GR_EVENT_TYPE_SCREENSAVER)
316
#define GR_EVENT_MASK_CLIENT_DATA_REQ   GR_EVENTMASK(GR_EVENT_TYPE_CLIENT_DATA_REQ)
317
#define GR_EVENT_MASK_CLIENT_DATA       GR_EVENTMASK(GR_EVENT_TYPE_CLIENT_DATA)
318
#define GR_EVENT_MASK_SELECTION_CHANGED GR_EVENTMASK(GR_EVENT_TYPE_SELECTION_CHANGED)
319
#define GR_EVENT_MASK_TIMER             GR_EVENTMASK(GR_EVENT_TYPE_TIMER)
320
#define GR_EVENT_MASK_PORTRAIT_CHANGED  GR_EVENTMASK(GR_EVENT_TYPE_PORTRAIT_CHANGED)
321
#define GR_EVENT_MASK_ALL               ((GR_EVENT_MASK) -1L)
322
 
323
/* update event types */
324
#define GR_UPDATE_MAP           1
325
#define GR_UPDATE_UNMAP         2
326
#define GR_UPDATE_MOVE          3
327
#define GR_UPDATE_SIZE          4
328
#define GR_UPDATE_UNMAPTEMP     5       /* unmap during window move/resize*/
329
#define GR_UPDATE_ACTIVATE      6       /* toplevel window [de]activate*/
330
#define GR_UPDATE_DESTROY       7
331
 
332
/* Event for errors detected by the server.
333
 * These events are not delivered to GrGetNextEvent, but instead call
334
 * the user supplied error handling function.  Only the first one of
335
 * these errors at a time is saved for delivery to the client since
336
 * there is not much to be done about errors anyway except complain
337
 * and exit.
338
 */
339
typedef struct {
340
  GR_EVENT_TYPE type;           /* event type */
341
  GR_FUNC_NAME name;            /* function name which failed */
342
  GR_ERROR code;                /* error code */
343
  GR_ID id;                     /* resource id (maybe useless) */
344
} GR_EVENT_ERROR;
345
 
346
/* Event for a mouse button pressed down or released. */
347
typedef struct {
348
  GR_EVENT_TYPE type;           /* event type */
349
  GR_WINDOW_ID wid;             /* window id event delivered to */
350
  GR_WINDOW_ID subwid;          /* sub-window id (pointer was in) */
351
  GR_COORD rootx;               /* root window x coordinate */
352
  GR_COORD rooty;               /* root window y coordinate */
353
  GR_COORD x;                   /* window x coordinate of mouse */
354
  GR_COORD y;                   /* window y coordinate of mouse */
355
  GR_BUTTON buttons;            /* current state of all buttons */
356
  GR_BUTTON changebuttons;      /* buttons which went down or up */
357
  GR_KEYMOD modifiers;          /* modifiers (MWKMOD_SHIFT, etc)*/
358
  GR_TIMEOUT time;              /* tickcount time value*/
359
} GR_EVENT_BUTTON;
360
 
361
/* Event for a keystroke typed for the window with has focus. */
362
typedef struct {
363
  GR_EVENT_TYPE type;           /* event type */
364
  GR_WINDOW_ID wid;             /* window id event delived to */
365
  GR_WINDOW_ID subwid;          /* sub-window id (pointer was in) */
366
  GR_COORD rootx;               /* root window x coordinate */
367
  GR_COORD rooty;               /* root window y coordinate */
368
  GR_COORD x;                   /* window x coordinate of mouse */
369
  GR_COORD y;                   /* window y coordinate of mouse */
370
  GR_BUTTON buttons;            /* current state of buttons */
371
  GR_KEYMOD modifiers;          /* modifiers (MWKMOD_SHIFT, etc)*/
372
  GR_KEY ch;                    /* 16-bit unicode key value, MWKEY_xxx */
373
  GR_SCANCODE scancode;         /* OEM scancode value if available*/
374
} GR_EVENT_KEYSTROKE;
375
 
376
/* Event for exposure for a region of a window. */
377
typedef struct {
378
  GR_EVENT_TYPE type;           /* event type */
379
  GR_WINDOW_ID wid;             /* window id */
380
  GR_COORD x;                   /* window x coordinate of exposure */
381
  GR_COORD y;                   /* window y coordinate of exposure */
382
  GR_SIZE width;                /* width of exposure */
383
  GR_SIZE height;               /* height of exposure */
384
} GR_EVENT_EXPOSURE;
385
 
386
/* General events for focus in or focus out for a window, or mouse enter
387
 * or mouse exit from a window, or window unmapping or mapping, etc.
388
 * Server portrait mode changes are also sent using this event to
389
 * all windows that request it.
390
 */
391
typedef struct {
392
  GR_EVENT_TYPE type;           /* event type */
393
  GR_WINDOW_ID wid;             /* window id */
394
  GR_WINDOW_ID otherid;         /* new/old focus id for focus events*/
395
} GR_EVENT_GENERAL;
396
 
397
/* Events for mouse motion or mouse position. */
398
typedef struct {
399
  GR_EVENT_TYPE type;           /* event type */
400
  GR_WINDOW_ID wid;             /* window id event delivered to */
401
  GR_WINDOW_ID subwid;          /* sub-window id (pointer was in) */
402
  GR_COORD rootx;               /* root window x coordinate */
403
  GR_COORD rooty;               /* root window y coordinate */
404
  GR_COORD x;                   /* window x coordinate of mouse */
405
  GR_COORD y;                   /* window y coordinate of mouse */
406
  GR_BUTTON buttons;            /* current state of buttons */
407
  GR_KEYMOD modifiers;          /* modifiers (MWKMOD_SHIFT, etc)*/
408
} GR_EVENT_MOUSE;
409
 
410
/* GrRegisterInput event*/
411
typedef struct {
412
  GR_EVENT_TYPE type;           /* event type */
413
  int           fd;             /* input fd*/
414
} GR_EVENT_FDINPUT;
415
 
416
/* GR_EVENT_TYPE_UPDATE */
417
typedef struct {
418
  GR_EVENT_TYPE type;           /* event type */
419
  GR_WINDOW_ID wid;             /* select window id*/
420
  GR_WINDOW_ID subwid;          /* update window id (=wid for UPDATE event)*/
421
  GR_COORD x;                   /* new window x coordinate */
422
  GR_COORD y;                   /* new window y coordinate */
423
  GR_SIZE width;                /* new width */
424
  GR_SIZE height;               /* new height */
425
  GR_UPDATE_TYPE utype;         /* update_type */
426
} GR_EVENT_UPDATE;
427
 
428
/* GR_EVENT_TYPE_SCREENSAVER */
429
typedef struct {
430
  GR_EVENT_TYPE type;           /* event type */
431
  GR_BOOL activate;             /* true = activate, false = deactivate */
432
} GR_EVENT_SCREENSAVER;
433
 
434
/* GR_EVENT_TYPE_CLIENT_DATA_REQ */
435
typedef struct {
436
  GR_EVENT_TYPE type;           /* event type */
437
  GR_WINDOW_ID wid;             /* ID of requested window */
438
  GR_WINDOW_ID rid;             /* ID of window to send data to */
439
  GR_SERIALNO serial;           /* Serial number of transaction */
440
  GR_MIMETYPE mimetype;         /* Type to supply data as */
441
} GR_EVENT_CLIENT_DATA_REQ;
442
 
443
/* GR_EVENT_TYPE_CLIENT_DATA */
444
typedef struct {
445
  GR_EVENT_TYPE type;           /* event type */
446
  GR_WINDOW_ID wid;             /* ID of window data is destined for */
447
  GR_WINDOW_ID rid;             /* ID of window data is from */
448
  GR_SERIALNO serial;           /* Serial number of transaction */
449
  unsigned long len;            /* Total length of data */
450
  unsigned long datalen;        /* Length of following data */
451
  void *data;                   /* Pointer to data (filled in on client side) */
452
} GR_EVENT_CLIENT_DATA;
453
 
454
/* GR_EVENT_TYPE_SELECTION_CHANGED */
455
typedef struct {
456
  GR_EVENT_TYPE type;           /* event type */
457
  GR_WINDOW_ID new_owner;       /* ID of new selection owner */
458
} GR_EVENT_SELECTION_CHANGED;
459
 
460
/* GR_EVENT_TYPE_TIMER */
461
typedef struct {
462
  GR_EVENT_TYPE  type;          /* event type, GR_EVENT_TYPE_TIMER */
463
  GR_WINDOW_ID   wid;           /* ID of window timer is destined for */
464
  GR_TIMER_ID    tid;           /* ID of expired timer */
465
} GR_EVENT_TIMER;
466
 
467
/*
468
 * Union of all possible event structures.
469
 * This is the structure returned by the GrGetNextEvent and similar routines.
470
 */
471
typedef union {
472
  GR_EVENT_TYPE type;                   /* event type */
473
  GR_EVENT_ERROR error;                 /* error event */
474
  GR_EVENT_GENERAL general;             /* general window events */
475
  GR_EVENT_BUTTON button;               /* button events */
476
  GR_EVENT_KEYSTROKE keystroke;         /* keystroke events */
477
  GR_EVENT_EXPOSURE exposure;           /* exposure events */
478
  GR_EVENT_MOUSE mouse;                 /* mouse motion events */
479
  GR_EVENT_FDINPUT fdinput;             /* fd input events*/
480
  GR_EVENT_UPDATE update;               /* window update events */
481
  GR_EVENT_SCREENSAVER screensaver;     /* Screen saver events */
482
  GR_EVENT_CLIENT_DATA_REQ clientdatareq; /* Request for client data events */
483
  GR_EVENT_CLIENT_DATA clientdata;      /* Client data events */
484
  GR_EVENT_SELECTION_CHANGED selectionchanged; /* Selection owner changed */
485
  GR_EVENT_TIMER timer;
486
} GR_EVENT;
487
 
488
typedef void (*GR_FNCALLBACKEVENT)(GR_EVENT *);
489
 
490
/* Pixel packings within words. */
491
#define GR_BITMAPBITS   (sizeof(GR_BITMAP) * 8)
492
#define GR_ZEROBITS     ((GR_BITMAP) 0x0000)
493
#define GR_ONEBITS      ((GR_BITMAP) 0xffff)
494
#define GR_FIRSTBIT     ((GR_BITMAP) 0x8000)
495
#define GR_LASTBIT      ((GR_BITMAP) 0x0001)
496
#define GR_BITVALUE(n)  ((GR_BITMAP) (((GR_BITMAP) 1) << (n)))
497
#define GR_SHIFTBIT(m)  ((GR_BITMAP) ((m) << 1))
498
#define GR_NEXTBIT(m)   ((GR_BITMAP) ((m) >> 1))
499
#define GR_TESTBIT(m)   (((m) & GR_FIRSTBIT) != 0)
500
 
501
/* Size of bitmaps. */
502
#define GR_BITMAP_SIZE(width, height)   ((height) * \
503
  (((width) + sizeof(GR_BITMAP) * 8 - 1) / (sizeof(GR_BITMAP) * 8)))
504
 
505
#define GR_MAX_BITMAP_SIZE \
506
  GR_BITMAP_SIZE(MWMAX_CURSOR_SIZE, MWMAX_CURSOR_SIZE)
507
 
508
/* GrGetSysColor colors*/
509
/* desktop background*/
510
#define GR_COLOR_DESKTOP           0
511
 
512
/* caption colors*/
513
#define GR_COLOR_ACTIVECAPTION     1
514
#define GR_COLOR_ACTIVECAPTIONTEXT 2
515
#define GR_COLOR_INACTIVECAPTION   3
516
#define GR_COLOR_INACTIVECAPTIONTEXT 4
517
 
518
/* 3d border shades*/
519
#define GR_COLOR_WINDOWFRAME       5
520
#define GR_COLOR_BTNSHADOW         6
521
#define GR_COLOR_3DLIGHT           7
522
#define GR_COLOR_BTNHIGHLIGHT      8
523
 
524
/* top level application window backgrounds/text*/
525
#define GR_COLOR_APPWINDOW         9
526
#define GR_COLOR_APPTEXT           10
527
 
528
/* button control backgrounds/text (usually same as app window colors)*/
529
#define GR_COLOR_BTNFACE           11
530
#define GR_COLOR_BTNTEXT           12
531
 
532
/* edit/listbox control backgrounds/text, selected highlights*/
533
#define GR_COLOR_WINDOW            13
534
#define GR_COLOR_WINDOWTEXT        14
535
#define GR_COLOR_HIGHLIGHT         15
536
#define GR_COLOR_HIGHLIGHTTEXT     16
537
#define GR_COLOR_GRAYTEXT          17
538
 
539
/* menu backgrounds/text*/
540
#define GR_COLOR_MENUTEXT          18
541
#define GR_COLOR_MENU              19
542
 
543
/* Error strings per error number*/
544
#define GR_ERROR_STRINGS                \
545
        "",                             \
546
        "Bad window id: %d\n",          \
547
        "Bad graphics context: %d\n",   \
548
        "Bad cursor size\n",            \
549
        "Out of server memory\n",       \
550
        "Bad window size: %d\n",        \
551
        "Keyboard error\n",             \
552
        "Mouse error\n",                \
553
        "Input only window: %d\n",      \
554
        "Illegal on root window: %d\n", \
555
        "Clipping overflow\n",          \
556
        "Screen error\n",               \
557
        "Unmapped focus window: %d\n",  \
558
        "Bad drawing mode gc: %d\n"
559
 
560
extern char *nxErrorStrings[];
561
 
562
/* Public graphics routines. */
563
void            GrFlush(void);
564
int             GrOpen(void);
565
void            GrClose(void);
566
void            GrDelay(GR_TIMEOUT msecs);
567
void            GrGetScreenInfo(GR_SCREEN_INFO *sip);
568
GR_COLOR        GrGetSysColor(int index);
569
GR_WINDOW_ID    GrNewWindow(GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
570
                        GR_SIZE width, GR_SIZE height, GR_SIZE bordersize,
571
                        GR_COLOR background, GR_COLOR bordercolor);
572
GR_WINDOW_ID    GrNewPixmap(GR_SIZE width, GR_SIZE height, void * addr);
573
GR_WINDOW_ID    GrNewInputWindow(GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
574
                                GR_SIZE width, GR_SIZE height);
575
void            GrDestroyWindow(GR_WINDOW_ID wid);
576
GR_GC_ID        GrNewGC(void);
577
GR_GC_ID        GrCopyGC(GR_GC_ID gc);
578
void            GrGetGCInfo(GR_GC_ID gc, GR_GC_INFO *gcip);
579
void            GrDestroyGC(GR_GC_ID gc);
580
GR_REGION_ID    GrNewRegion(void);
581
GR_REGION_ID    GrNewPolygonRegion(int mode, GR_COUNT count, GR_POINT *points);
582
void            GrDestroyRegion(GR_REGION_ID region);
583
void            GrUnionRectWithRegion(GR_REGION_ID region, GR_RECT *rect);
584
void            GrUnionRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
585
                        GR_REGION_ID src_rgn2);
586
void            GrIntersectRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
587
                        GR_REGION_ID src_rgn2);
588
void            GrSubtractRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
589
                        GR_REGION_ID src_rgn2);
590
void            GrXorRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
591
                        GR_REGION_ID src_rgn2);
592
void            GrSetGCRegion(GR_GC_ID gc, GR_REGION_ID region);
593
void            GrSetGCClipOrigin(GR_GC_ID gc, int x, int y);
594
GR_BOOL         GrPointInRegion(GR_REGION_ID region, GR_COORD x, GR_COORD y);
595
int             GrRectInRegion(GR_REGION_ID region, GR_COORD x, GR_COORD y,
596
                        GR_COORD w, GR_COORD h);
597
GR_BOOL         GrEmptyRegion(GR_REGION_ID region);
598
GR_BOOL         GrEqualRegion(GR_REGION_ID rgn1, GR_REGION_ID rgn2);
599
void            GrOffsetRegion(GR_REGION_ID region, GR_SIZE dx, GR_SIZE dy);
600
int             GrGetRegionBox(GR_REGION_ID region, GR_RECT *rect);
601
void            GrMapWindow(GR_WINDOW_ID wid);
602
void            GrUnmapWindow(GR_WINDOW_ID wid);
603
void            GrRaiseWindow(GR_WINDOW_ID wid);
604
void            GrLowerWindow(GR_WINDOW_ID wid);
605
void            GrMoveWindow(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y);
606
void            GrResizeWindow(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height);
607
void            GrReparentWindow(GR_WINDOW_ID wid, GR_WINDOW_ID pwid,
608
                        GR_COORD x, GR_COORD y);
609
void            GrGetWindowInfo(GR_WINDOW_ID wid, GR_WINDOW_INFO *infoptr);
610
void            GrSetWMProperties(GR_WINDOW_ID wid, GR_WM_PROPERTIES *props);
611
void            GrGetWMProperties(GR_WINDOW_ID wid, GR_WM_PROPERTIES *props);
612
GR_FONT_ID      GrCreateFont(GR_CHAR *name, GR_COORD height,
613
                        GR_LOGFONT *plogfont);
614
void            GrGetFontList(GR_FONTLIST ***fonts, int *numfonts);
615
void            GrFreeFontList(GR_FONTLIST ***fonts, int num);
616
void            GrSetFontSize(GR_FONT_ID fontid, GR_COORD size);
617
void            GrSetFontRotation(GR_FONT_ID fontid, int tenthsdegrees);
618
void            GrSetFontAttr(GR_FONT_ID fontid, int setflags, int clrflags);
619
void            GrDestroyFont(GR_FONT_ID fontid);
620
void            GrGetFontInfo(GR_FONT_ID font, GR_FONT_INFO *fip);
621
GR_WINDOW_ID    GrGetFocus(void);
622
void            GrSetFocus(GR_WINDOW_ID wid);
623
void            GrClearArea(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y, GR_SIZE width,
624
                        GR_SIZE height, GR_BOOL exposeflag);
625
void            GrSelectEvents(GR_WINDOW_ID wid, GR_EVENT_MASK eventmask);
626
void            GrGetNextEvent(GR_EVENT *ep);
627
void            GrGetNextEventTimeout(GR_EVENT *ep, GR_TIMEOUT timeout);
628
void            GrCheckNextEvent(GR_EVENT *ep);
629
int             GrPeekEvent(GR_EVENT *ep);
630
void            GrPeekWaitEvent(GR_EVENT *ep);
631
void            GrLine(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x1, GR_COORD y1,
632
                        GR_COORD x2, GR_COORD y2);
633
void            GrPoint(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y);
634
void            GrPoints(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
635
                        GR_POINT *pointtable);
636
void            GrRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
637
                        GR_SIZE width, GR_SIZE height);
638
void            GrFillRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
639
                        GR_SIZE width, GR_SIZE height);
640
void            GrPoly(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
641
                        GR_POINT *pointtable);
642
void            GrFillPoly(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
643
                        GR_POINT *pointtable);
644
void            GrEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
645
                        GR_SIZE rx, GR_SIZE ry);
646
void            GrFillEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
647
                        GR_COORD y, GR_SIZE rx, GR_SIZE ry);
648
void            GrArc(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
649
                        GR_SIZE rx, GR_SIZE ry, GR_COORD ax, GR_COORD ay,
650
                        GR_COORD bx, GR_COORD by, int type);
651
void            GrArcAngle(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
652
                        GR_SIZE rx, GR_SIZE ry, GR_COORD angle1,
653
                        GR_COORD angle2, int type); /* floating point required*/
654
void            GrSetGCForeground(GR_GC_ID gc, GR_COLOR foreground);
655
void            GrSetGCBackground(GR_GC_ID gc, GR_COLOR background);
656
void            GrSetGCUseBackground(GR_GC_ID gc, GR_BOOL flag);
657
void            GrSetGCMode(GR_GC_ID gc, int mode);
658
void            GrSetGCFont(GR_GC_ID gc, GR_FONT_ID font);
659
void            GrGetGCTextSize(GR_GC_ID gc, void *str, int count, int flags,
660
                        GR_SIZE *retwidth, GR_SIZE *retheight,GR_SIZE *retbase);
661
void            GrReadArea(GR_DRAW_ID id, GR_COORD x, GR_COORD y, GR_SIZE width,
662
                        GR_SIZE height, GR_PIXELVAL *pixels);
663
void            GrArea(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
664
                        GR_SIZE width,GR_SIZE height,void *pixels,int pixtype);
665
void            GrCopyArea(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
666
                        GR_SIZE width, GR_SIZE height, GR_DRAW_ID srcid,
667
                        GR_COORD srcx, GR_COORD srcy, int op);
668
void            GrBitmap(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
669
                        GR_SIZE width, GR_SIZE height, GR_BITMAP *imagebits);
670
void            GrDrawImageBits(GR_DRAW_ID id,GR_GC_ID gc,GR_COORD x,GR_COORD y,
671
                        GR_IMAGE_HDR *pimage);
672
void            GrDrawImageFromFile(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
673
                        GR_COORD y, GR_SIZE width, GR_SIZE height,
674
                        char *path, int flags);
675
GR_IMAGE_ID     GrLoadImageFromFile(char *path, int flags);
676
void            GrDrawImageFromBuffer(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
677
                        GR_COORD y, GR_SIZE width, GR_SIZE height,
678
                        void *buffer, int size, int flags);
679
GR_IMAGE_ID     GrLoadImageFromBuffer(void *buffer, int size, int flags);
680
void            GrDrawImageToFit(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
681
                        GR_COORD y, GR_SIZE width, GR_SIZE height,
682
                        GR_IMAGE_ID imageid);
683
void            GrFreeImage(GR_IMAGE_ID id);
684
void            GrGetImageInfo(GR_IMAGE_ID id, GR_IMAGE_INFO *iip);
685
void            GrText(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
686
                        void *str, GR_COUNT count, int flags);
687
GR_CURSOR_ID    GrNewCursor(GR_SIZE width, GR_SIZE height, GR_COORD hotx,
688
                        GR_COORD hoty, GR_COLOR foreground, GR_COLOR background,
689
                        GR_BITMAP *fgbitmap, GR_BITMAP *bgbitmap);
690
void            GrDestroyCursor(GR_CURSOR_ID cid);
691
void            GrSetWindowCursor(GR_WINDOW_ID wid, GR_CURSOR_ID cid);
692
void            GrMoveCursor(GR_COORD x, GR_COORD y);
693
void            GrGetSystemPalette(GR_PALETTE *pal);
694
void            GrSetSystemPalette(GR_COUNT first, GR_PALETTE *pal);
695
void            GrFindColor(GR_COLOR c, GR_PIXELVAL *retpixel);
696
void            GrReqShmCmds(long shmsize);
697
void            GrInjectPointerEvent(MWCOORD x, MWCOORD y,
698
                        int button, int visible);
699
void            GrInjectKeyboardEvent(GR_WINDOW_ID wid, GR_KEY keyvalue,
700
                        GR_KEYMOD modifiers, GR_SCANCODE scancode,
701
                        GR_BOOL pressed);
702
void            GrCloseWindow(GR_WINDOW_ID wid);
703
void            GrKillWindow(GR_WINDOW_ID wid);
704
void            GrSetScreenSaverTimeout(GR_TIMEOUT timeout);
705
void            GrSetSelectionOwner(GR_WINDOW_ID wid, GR_CHAR *typelist);
706
GR_WINDOW_ID    GrGetSelectionOwner(GR_CHAR **typelist);
707
void            GrRequestClientData(GR_WINDOW_ID wid, GR_WINDOW_ID rid,
708
                        GR_SERIALNO serial, GR_MIMETYPE mimetype);
709
void            GrSendClientData(GR_WINDOW_ID wid, GR_WINDOW_ID did,
710
                        GR_SERIALNO serial, GR_LENGTH len, GR_LENGTH thislen,
711
                        void *data);
712
void            GrBell(void);
713
void            GrSetBackgroundPixmap(GR_WINDOW_ID wid, GR_WINDOW_ID pixmap,
714
                        int flags);
715
void            GrQueryTree(GR_WINDOW_ID wid, GR_WINDOW_ID *parentid, GR_WINDOW_ID **children,
716
                        GR_COUNT *nchildren);
717
GR_TIMER_ID     GrCreateTimer(GR_WINDOW_ID wid, GR_TIMEOUT period);
718
void            GrDestroyTimer(GR_TIMER_ID tid);
719
void            GrSetPortraitMode(int portraitmode);
720
 
721
void            GrRegisterInput(int fd);
722
void            GrUnregisterInput(int fd);
723
void            GrMainLoop(GR_FNCALLBACKEVENT fncb);
724
GR_FNCALLBACKEVENT GrSetErrorHandler(GR_FNCALLBACKEVENT fncb);
725
void            GrDefaultErrorHandler(GR_EVENT *ep);
726
 
727
/* passive library entry points - available with client/server only*/
728
void            GrPrepareSelect(int *maxfd,void *rfdset);
729
void            GrServiceSelect(void *rfdset, GR_FNCALLBACKEVENT fncb);
730
 
731
/* nxutil.c - utility routines*/
732
GR_WINDOW_ID    GrNewWindowEx(GR_WM_PROPS props, GR_CHAR *title,
733
                        GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
734
                        GR_SIZE width, GR_SIZE height, GR_COLOR background);
735
void            GrDrawLines(GR_DRAW_ID w, GR_GC_ID gc, GR_POINT *points,
736
                        GR_COUNT count);
737
GR_BITMAP *     GrNewBitmapFromData(GR_SIZE width, GR_SIZE height, GR_SIZE bits_width,
738
                        GR_SIZE bits_height, void *bits, int flags);
739
GR_WINDOW_ID    GrNewPixmapFromData(GR_SIZE width, GR_SIZE height,
740
                        GR_COLOR foreground, GR_COLOR background, void * bits,
741
                        int flags);
742
 
743
/* direct client-side framebuffer mapping routines*/
744
unsigned char * GrOpenClientFramebuffer(void);
745
void            GrCloseClientFramebuffer(void);
746
void            GrGetWindowFBInfo(GR_WINDOW_ID wid, GR_WINDOW_FB_INFO *fbinfo);
747
 
748
/* retrofit - no longer used*/
749
GR_CURSOR_ID    GrSetCursor(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height,
750
                        GR_COORD hotx, GR_COORD hoty, GR_COLOR foreground,
751
                        GR_COLOR background, GR_BITMAP *fbbitmap,
752
                        GR_BITMAP *bgbitmap);
753
#define GrSetBorderColor                GrSetWindowBorderColor  /* retrofit*/
754
#define GrClearWindow(wid,exposeflag)   GrClearArea(wid,0,0,0,0,exposeflag) /* retrofit*/
755
 
756
/* useful function macros*/
757
#define GrSetWindowBackgroundColor(wid,color) \
758
                {       GR_WM_PROPERTIES props; \
759
                        props.flags = GR_WM_FLAGS_BACKGROUND; \
760
                        props.background = color; \
761
                        GrSetWMProperties(wid, &props); \
762
                }
763
#define GrSetWindowBorderSize(wid,width) \
764
                {       GR_WM_PROPERTIES props; \
765
                        props.flags = GR_WM_FLAGS_BORDERSIZE; \
766
                        props.bordersize = width; \
767
                        GrSetWMProperties(wid, &props); \
768
                }
769
#define GrSetWindowBorderColor(wid,color) \
770
                {       GR_WM_PROPERTIES props; \
771
                        props.flags = GR_WM_FLAGS_BORDERCOLOR; \
772
                        props.bordercolor = color; \
773
                        GrSetWMProperties(wid, &props); \
774
                }
775
#define GrSetWindowTitle(wid,name) \
776
                {       GR_WM_PROPERTIES props; \
777
                        props.flags = GR_WM_FLAGS_TITLE; \
778
                        props.title = (GR_CHAR *)name; \
779
                        GrSetWMProperties(wid, &props); \
780
                }
781
 
782
#ifdef __cplusplus
783
}
784
#endif
785
 
786
/* RTEMS requires rtems_main()*/
787
#if __rtems__
788
#define main    rtems_main
789
#endif
790
 
791
/* client side event queue (client.c local)*/
792
typedef struct event_list EVENT_LIST;
793
struct event_list {
794
        EVENT_LIST *    next;
795
        GR_EVENT        event;
796
};
797
 
798
/* queued request buffer (nxproto.c local)*/
799
typedef struct {
800
        unsigned char *bufptr;          /* next unused buffer location*/
801
        unsigned char *bufmax;          /* max buffer location*/
802
        unsigned char *buffer;          /* request buffer*/
803
} REQBUF;
804
 
805
#ifdef __ECOS
806
#include <sys/select.h>
807
/*
808
 * In a single process, multi-threaded environment, we need to keep
809
 * all static data of shared code in a structure, with a pointer to
810
 * the structure to be stored in thread-local storage
811
 */
812
typedef struct {                                // Init to:
813
    int                 _nxSocket;              //  -1
814
    int                 _storedevent;           // 0
815
    GR_EVENT            _storedevent_data;      // no init(0)
816
    int                 _regfdmax;              // -1
817
    fd_set              _regfdset;              // FD_ZERO
818
    GR_FNCALLBACKEVENT  _GrErrorFunc;           // GrDefaultErrorHandler
819
    REQBUF              _reqbuf;
820
    EVENT_LIST          *_evlist;
821
} ecos_nanox_client_data;
822
 
823
extern int     ecos_nanox_client_data_index;
824
 
825
#define ACCESS_PER_THREAD_DATA()                                        \
826
    ecos_nanox_client_data *data = (ecos_nanox_client_data*)            \
827
        cyg_thread_get_data((cyg_ucount32)ecos_nanox_client_data_index);
828
 
829
#define INIT_PER_THREAD_DATA()                                                  \
830
    {                                                                           \
831
        ecos_nanox_client_data *dptr = malloc(sizeof(ecos_nanox_client_data));  \
832
        ecos_nanox_client_data_index = data;                                    \
833
        dptr->_nxSocket = -1;                                                   \
834
        dptr->_storedevent = 0;                                                 \
835
        dptr->_regfdmax = -1;                                                   \
836
        FD_ZERO(&dptr->_regfdset);                                              \
837
        dptr->_GrErrorFunc = GrDefaultErrorHandler;                             \
838
        dptr->_reqbuf.bufptr = NULL;                                            \
839
        dptr->_reqbuf.bufmax = NULL;                                            \
840
        dptr->_reqbuf.buffer = NULL;                                            \
841
        dptr->_evlist = NULL;                                                   \
842
        cyg_thread_set_data(ecos_nanox_client_data_index,(CYG_ADDRWORD)dptr);   \
843
    }
844
 
845
#define nxSocket                (data->_nxSocket)
846
#define storedevent             (data->_storedevent)
847
#define storedevent_data        (data->_storedevent_data)
848
#define regfdmax                (data->_regfdmax)
849
#define regfdset                (data->_regfdset)
850
#define ErrorFunc               (data->_GrErrorFunc)
851
#define reqbuf                  (data->_reqbuf)
852
#define evlist                  (data->_evlist)
853
 
854
#else
855
#define ACCESS_PER_THREAD_DATA()
856
#endif
857
 
858
#endif /* _NANO_X_H*/

powered by: WebSVN 2.1.0

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