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