2 typedef unsigned int uint32;
4 typedef unsigned char uint8;
5 typedef unsigned short unichar_t;
9 em_symbol, em_zapfding, em_user, em_adobestandard =
13 typedef struct gimage {
15 typedef struct grect {
17 typedef struct gpoint {
24 gic_overspot = 2, gic_root = 1, gic_hidden = 0, gic_orlesser =
27 typedef struct ginput_context GIC;
29 sn_primary, sn_clipboard, sn_drag_and_drop, sn_max
31 typedef struct gwindow *GWindow;
32 typedef struct gdisplay GDisplay;
33 typedef struct gtimer GTimer;
34 typedef struct gevent {
37 -1, et_char, et_charup, et_mousemove, et_mousedown,
38 et_mouseup, et_crossing, et_focus, et_expose, et_visibility,
39 et_resize, et_timer, et_close, et_create, et_map,
40 et_destroy, et_selclear, et_drag, et_dragout, et_drop,
41 et_lastnativeevent = et_drop, et_controlevent, et_user
44 typedef enum cursor_types {
45 ct_default, ct_pointer, ct_backpointer, ct_hand, ct_question, ct_cross,
46 ct_4way, ct_text, ct_watch, ct_draganddrop, ct_invisible, ct_user,
49 typedef struct gwindow_attrs {
51 typedef struct gprinter_attrs {
54 gzf_pos = 1, gzf_size = 2
59 void (*init) (GDisplay *);
60 void (*term) (GDisplay *);
61 void *(*nativeDisplay) (GDisplay *);
62 void (*setDefaultIcon) (GWindow);
63 GWindow(*createTopWindow) (GDisplay *, GRect * pos,
64 int (*eh) (GWindow, GEvent *),
65 void *user_data, GWindowAttrs *);
66 GWindow(*createSubWindow) (GWindow, GRect * pos,
67 int (*eh) (GWindow, GEvent *),
68 void *user_data, GWindowAttrs *);
69 GWindow(*createPixmap) (GDisplay *, unsigned short width, unsigned short height);
70 GWindow(*createBitmap) (GDisplay *, unsigned short width, unsigned short height,
72 GCursor(*createCursor) (GWindow src, GWindow mask, Color fg, Color bg,
74 void (*destroyWindow) (GWindow);
75 void (*destroyCursor) (GDisplay *, GCursor);
76 int (*nativeWindowExists) (GDisplay *, void *native_window);
77 void (*setZoom) (GWindow, GRect * size, enum gzoom_flags flags);
78 void (*setWindowBorder) (GWindow, int width, Color);
79 int (*setDither) (GDisplay *, int);
80 void (*reparentWindow) (GWindow, GWindow, int, int);
81 void (*setVisible) (GWindow, int);
82 void (*move) (GWindow, int32, int32);
83 void (*trueMove) (GWindow, int32, int32);
84 void (*resize) (GWindow, int32, int32);
85 void (*moveResize) (GWindow, int32, int32, int32, int32);
86 void (*raise) (GWindow);
87 void (*raiseAbove) (GWindow, GWindow);
88 int (*isAbove) (GWindow, GWindow);
89 void (*lower) (GWindow);
90 void (*setWindowTitles) (GWindow, const unichar_t * title,
91 const unichar_t * icontitle);
92 void (*setWindowTitles8) (GWindow, const char *title,
93 const char *icontitle);
94 unichar_t *(*getWindowTitle) (GWindow);
95 char *(*getWindowTitle8) (GWindow);
96 void (*getPointerPos) (GWindow, GEvent *);
97 void (*setCursor) (GWindow, GCursor);
98 GCursor(*getCursor) (GWindow);
99 GWindow(*getRedirectWindow) (GDisplay * gd);
100 void (*translateCoordinates) (GWindow from, GWindow to, GPoint * pt);
101 void (*beep) (GDisplay *);
102 void (*flush) (GDisplay *);
103 void (*pushClip) (GWindow, GRect * rct, GRect * old);
104 void (*popClip) (GWindow, GRect * old);
105 void (*eventLoop) (GDisplay *);
106 void (*postEvent) (GEvent * e);
107 void (*postDragEvent) (GWindow w, GEvent * mouse, enum event_type et);
108 int (*requestDeviceEvents) (GWindow w, int devcnt,
110 GTimer *(*requestTimer) (GWindow w, int32 time_from_now,
111 int32 frequency, void *userdata);
112 void (*cancelTimer) (GTimer * timer);
113 int (*endJob) (GWindow w, int cancel);
115 typedef struct gpswindow {
117 typedef struct gpsdisplay {
118 struct displayfuncs *funcs;
120 extern void _GPSDraw_Image(GWindow, GImage *, GRect * src, int32 x, int32 y);
121 extern void _GPSDraw_TileImage(GWindow, GImage *, GRect * src, int32 x,
123 extern void _GPSDraw_ImageMagnified(GWindow, GImage *, GRect * src, int32 x,
124 int32 y, int32 width, int32 height);
125 extern void *_GPSDraw_LoadFontMetrics(GDisplay * gdisp,
127 extern struct font_data *_GPSDraw_ScaleFont(GDisplay * gdisp,
128 struct font_data *fd,
130 extern struct font_data *_GPSDraw_StylizeFont(GDisplay * gdisp,
131 struct font_data *fd,
133 static void PSDrawInit(GDisplay * gdisp)
136 static void PSDrawTerm(GDisplay * gdisp)
139 static void *PSDrawNativeDisplay(GDisplay * gdisp)
142 static void PSDrawSetDefaultIcon(GWindow icon)
145 static GWindow PSDrawCreateSubWindow(GWindow w, GRect * pos,
146 int (*eh) (GWindow, GEvent *),
147 void *user_data, GWindowAttrs * wattrs)
150 static GWindow PSDrawCreatePixmap(GDisplay * gdisp, unsigned short width, unsigned short height)
153 static GWindow PSDrawCreateBitmap(GDisplay * gdisp, unsigned short width, unsigned short height,
157 static GCursor PSDrawCreateCursor(GWindow src, GWindow mask, Color fg, Color bg,
161 static void PSSetZoom(GWindow w, GRect * r, enum gzoom_flags flags)
164 static void PSDestroyCursor(GDisplay * gdisp, GCursor ct)
167 static int PSNativeWindowExists(GDisplay * gdisp, void *native)
170 static void PSSetWindowBorder(GWindow w, int width, Color col)
173 static int PSSetDither(GDisplay * gdisp, int dither)
176 static void PSDrawReparentWindow(GWindow child, GWindow newparent, int x, int y)
179 static void PSDrawSetVisible(GWindow w, int vis)
182 static void PSDrawMove(GWindow w, int32 x, int32 y)
185 static void PSDrawResize(GWindow w, int32 width, int32 height)
188 static void PSDrawMoveResize(GWindow w, int32 x, int32 y, int32 width,
192 static void PSDrawRaise(GWindow w)
195 static void PSDrawRaiseAbove(GWindow w, GWindow below)
198 static int PSDrawIsAbove(GWindow w, GWindow below)
201 static void PSDrawLower(GWindow w)
204 static void PSDrawSetWindowTitles(GWindow w, const unichar_t * title,
205 const unichar_t * icontit)
208 static void PSDrawSetWindowTitles8(GWindow w, const char *title,
212 static void PSDrawGetPointerPosition(GWindow w, GEvent * ret)
215 static void PSDrawSetCursor(GWindow w, GCursor ct)
218 static GCursor PSDrawGetCursor(GWindow w)
221 static GWindow PSDrawGetRedirectWindow(GDisplay * gd)
224 static unichar_t *PSDrawGetWindowTitle(GWindow w)
227 static char *PSDrawGetWindowTitle8(GWindow w)
230 static void PSDrawTranslateCoordinates(GWindow _from, GWindow _to, GPoint * pt)
233 static void PSDrawScroll(GWindow w, GRect * rect, int32 hor, int32 vert)
236 static void PSDrawBeep(GDisplay * gdisp)
239 static void PSDrawFlush(GDisplay * gdisp)
242 static GIC *PSDrawCreateInputContext(GWindow w, enum gic_style def_style)
245 static void PSDrawSetGIC(GWindow w, GIC * gic, int x, int y)
248 static void PSDrawPointerUngrab(GDisplay * gdisp)
251 static void PSDrawPointerGrab(GWindow w)
254 static void PSDrawGrabSelection(GWindow w, enum selnames sel)
257 static void PSDrawAddSelectionType(GWindow w, enum selnames sel, char *type,
258 void *data, int32 len, int32 unitsize,
259 void *(*gendata) (void *, int32 * len),
260 void (*freedata) (void *))
263 static void *PSDrawRequestSelection(GWindow w, enum selnames sn, char *typename,
267 static int PSDrawSelectionHasType(GWindow w, enum selnames sn, char *typename)
270 static void PSDrawRequestExpose(GWindow gw, GRect * rect, int doclear)
273 static GTimer *PSDrawRequestTimer(GWindow w, int32 time_from_now,
274 int32 frequency, void *userdata)
277 static void PSDrawCancelTimer(GTimer * timer)
280 static void PSDrawSyncThread(GDisplay * gdisp, void (*func) (void *),
284 static void PSDrawForceUpdate(GWindow gw)
287 static void PSDrawSync(GDisplay * gdisp)
290 static void PSDrawSkipMouseMoveEvents(GWindow gw, GEvent * last)
293 static void PSDrawProcessPendingEvents(GDisplay * gdisp)
296 static void PSDrawProcessWindowEvents(GWindow gw)
299 static void PSDrawEventLoop(GDisplay * gd)
302 static void PSDrawPostEvent(GEvent * e)
305 static void PSDrawPostDragEvent(GWindow w, GEvent * mouse, enum event_type et)
308 static int PSDrawRequestDeviceEvents(GWindow w, int devcnt,
312 static GImage *_PSDraw_CopyScreenToImage(GWindow w, GRect * rect)
315 static void _PSDraw_Pixmap(GWindow _w, GWindow _pixmap, GRect * src, int32 x,
319 static void _PSDraw_TilePixmap(GWindow _w, GWindow _pixmap, GRect * src,
323 static void PSMyArc(GPSWindow ps, double cx, double cy, double radx,
324 double rady, double sa, double ta)
329 temp = ((int)((sa + 90) / 90)) * 90;
330 PSDoArc(ps, cx, cy, radx, rady, sa, ea < temp ? ea : temp);
334 static void PSDrawElipse(GPSWindow ps, GRect * rct, char *command)
336 float cx, cy, radx, rady;
338 PSMyArc(ps, cx, cy, radx, rady, 0, 360);
340 static void PSDrawPushClip(GWindow w, GRect * rct, GRect * old)
343 static void PSDrawPopClip(GWindow w, GRect * old)
346 static void PSDrawDrawLine(GWindow w, int32 x, int32 y, int32 xend, int32 yend,
350 static void PSDrawDrawArrowLine(GWindow w, int32 x, int32 y, int32 xend,
351 int32 yend, int16 arrows, Color col)
354 static void PSDrawDrawRect(GWindow w, GRect * rct, Color col)
357 static void PSDrawFillRect(GWindow w, GRect * rct, Color col)
360 static void PSDrawClear(GWindow w, GRect * rect)
363 static void PSDrawDrawCircle(GWindow w, GRect * rct, Color col)
366 static void PSDrawFillCircle(GWindow w, GRect * rct, Color col)
368 GPSWindow ps = (GPSWindow) w;
369 PSDrawElipse(ps, rct, "fill");
371 static void PSDrawDrawArc(GWindow w, GRect * rct, int32 sa, int32 ta, Color col)
374 static void PSDrawDrawPoly(GWindow w, GPoint * pt, int16 cnt, Color col)
377 static void PSDrawFillPoly(GWindow w, GPoint * pt, int16 cnt, Color col)
380 static void _GPSDraw_Text1(GWindow gw, struct font_data *fd, int32 x, int32 y,
381 char *txt, int32 cnt, FontMods * mods, Color col)
384 static void _GPSDraw_Text2(GWindow gw, struct font_data *fd, int32 x, int32 y,
385 GChar2b * txt, int32 cnt, FontMods * mods, Color col)
388 static GWindow GPSPrinterStartJob(GDisplay * gd, void *user_data,
389 GPrinterAttrs * attrs)
392 static void GPSPrinterNextPage(GWindow w)
395 static int GPSPrinterEndJob(GWindow w, int cancel)
398 static GWindow PSDrawCreateTopWindow(GDisplay * gdisp, GRect * pos,
399 int (*eh) (GWindow, GEvent *),
400 void *user_data, GWindowAttrs * wattrs)
403 static void PSDrawDestroyWindow(GWindow w)
409 PSDrawDrawCircle, PSDrawFillCircle, PSDrawDrawArc, PSDrawDrawPoly,
410 _GPSDraw_Image, _GPSDraw_TileImage,
411 _GPSDraw_ImageMagnified, _PSDraw_CopyScreenToImage, _PSDraw_Pixmap,
412 _PSDraw_TilePixmap, _GPSDraw_ScaleFont, _GPSDraw_StylizeFont,
413 _GPSDraw_LoadFontMetrics, _GPSDraw_Text1, _GPSDraw_Text2,
416 GDisplay *_GPSDraw_CreateDisplay()
419 gdisp->funcs = &psfuncs;