2 typedef unsigned int uint32;
4 typedef unsigned short uint16;
5 typedef unsigned char uint8;
6 typedef uint16 unichar_t;
9 -1, em_iso8859_1, em_iso8859_2, em_iso8859_3, em_iso8859_4,
10 em_iso8859_5, em_iso8859_6, em_iso8859_7, em_iso8859_8,
11 em_iso8859_9, em_iso8859_10, em_iso8859_11, em_iso8859_13,
12 em_iso8859_14, em_iso8859_15, em_koi8_r, em_jis201, em_win, em_mac,
13 em_symbol, em_zapfding, em_user, em_adobestandard =
14 em_user, em_jis208, em_jis212, em_ksc5601, em_gb2312, em_big5,
15 em_big5hkscs, em_johab, em_unicode, em_unicode4, em_gb18030, em_max,
16 em_first2byte = em_jis208, em_last94x94 = em_gb2312
19 typedef struct gimage {
21 typedef struct grect {
23 typedef struct gpoint {
30 gic_overspot = 2, gic_root = 1, gic_hidden = 0, gic_orlesser =
33 typedef struct ginput_context GIC;
35 sn_primary, sn_clipboard, sn_drag_and_drop, sn_max
37 typedef struct gwindow *GWindow;
38 typedef struct gdisplay GDisplay;
39 typedef struct gtimer GTimer;
40 typedef struct gevent {
43 -1, et_char, et_charup, et_mousemove, et_mousedown,
44 et_mouseup, et_crossing, et_focus, et_expose, et_visibility,
45 et_resize, et_timer, et_close, et_create, et_map,
46 et_destroy, et_selclear, et_drag, et_dragout, et_drop,
47 et_lastnativeevent = et_drop, et_controlevent, et_user
50 typedef enum cursor_types {
51 ct_default, ct_pointer, ct_backpointer, ct_hand, ct_question, ct_cross,
52 ct_4way, ct_text, ct_watch, ct_draganddrop, ct_invisible, ct_user,
55 typedef struct gwindow_attrs {
57 typedef struct gprinter_attrs {
60 gzf_pos = 1, gzf_size = 2
65 void (*init) (GDisplay *);
66 void (*term) (GDisplay *);
67 void *(*nativeDisplay) (GDisplay *);
68 void (*setDefaultIcon) (GWindow);
69 GWindow(*createTopWindow) (GDisplay *, GRect * pos,
70 int (*eh) (GWindow, GEvent *),
71 void *user_data, GWindowAttrs *);
72 GWindow(*createSubWindow) (GWindow, GRect * pos,
73 int (*eh) (GWindow, GEvent *),
74 void *user_data, GWindowAttrs *);
75 GWindow(*createPixmap) (GDisplay *, uint16 width, uint16 height);
76 GWindow(*createBitmap) (GDisplay *, uint16 width, uint16 height,
78 GCursor(*createCursor) (GWindow src, GWindow mask, Color fg, Color bg,
80 void (*destroyWindow) (GWindow);
81 void (*destroyCursor) (GDisplay *, GCursor);
82 int (*nativeWindowExists) (GDisplay *, void *native_window);
83 void (*setZoom) (GWindow, GRect * size, enum gzoom_flags flags);
84 void (*setWindowBorder) (GWindow, int width, Color);
85 int (*setDither) (GDisplay *, int);
86 void (*reparentWindow) (GWindow, GWindow, int, int);
87 void (*setVisible) (GWindow, int);
88 void (*move) (GWindow, int32, int32);
89 void (*trueMove) (GWindow, int32, int32);
90 void (*resize) (GWindow, int32, int32);
91 void (*moveResize) (GWindow, int32, int32, int32, int32);
92 void (*raise) (GWindow);
93 void (*raiseAbove) (GWindow, GWindow);
94 int (*isAbove) (GWindow, GWindow);
95 void (*lower) (GWindow);
96 void (*setWindowTitles) (GWindow, const unichar_t * title,
97 const unichar_t * icontitle);
98 void (*setWindowTitles8) (GWindow, const char *title,
99 const char *icontitle);
100 unichar_t *(*getWindowTitle) (GWindow);
101 char *(*getWindowTitle8) (GWindow);
102 void (*getPointerPos) (GWindow, GEvent *);
103 void (*setCursor) (GWindow, GCursor);
104 GCursor(*getCursor) (GWindow);
105 GWindow(*getRedirectWindow) (GDisplay * gd);
106 void (*translateCoordinates) (GWindow from, GWindow to, GPoint * pt);
107 void (*beep) (GDisplay *);
108 void (*flush) (GDisplay *);
109 void (*pushClip) (GWindow, GRect * rct, GRect * old);
110 void (*popClip) (GWindow, GRect * old);
111 void (*eventLoop) (GDisplay *);
112 void (*postEvent) (GEvent * e);
113 void (*postDragEvent) (GWindow w, GEvent * mouse, enum event_type et);
114 int (*requestDeviceEvents) (GWindow w, int devcnt,
115 struct gdeveventmask * de);
116 GTimer *(*requestTimer) (GWindow w, int32 time_from_now,
117 int32 frequency, void *userdata);
118 void (*cancelTimer) (GTimer * timer);
119 int (*endJob) (GWindow w, int cancel);
121 typedef struct gpswindow {
123 typedef struct gpsdisplay {
124 struct displayfuncs *funcs;
126 extern void _GPSDraw_Image(GWindow, GImage *, GRect * src, int32 x, int32 y);
127 extern void _GPSDraw_TileImage(GWindow, GImage *, GRect * src, int32 x,
129 extern void _GPSDraw_ImageMagnified(GWindow, GImage *, GRect * src, int32 x,
130 int32 y, int32 width, int32 height);
131 extern void *_GPSDraw_LoadFontMetrics(GDisplay * gdisp, struct font_data *fd);
132 extern struct font_data *_GPSDraw_ScaleFont(GDisplay * gdisp,
133 struct font_data *fd,
135 extern struct font_data *_GPSDraw_StylizeFont(GDisplay * gdisp,
136 struct font_data *fd,
138 static void PSDrawInit(GDisplay * gdisp)
141 static void PSDrawTerm(GDisplay * gdisp)
144 static void *PSDrawNativeDisplay(GDisplay * gdisp)
147 static void PSDrawSetDefaultIcon(GWindow icon)
150 static GWindow PSDrawCreateSubWindow(GWindow w, GRect * pos,
151 int (*eh) (GWindow, GEvent *),
152 void *user_data, GWindowAttrs * wattrs)
155 static GWindow PSDrawCreatePixmap(GDisplay * gdisp, uint16 width, uint16 height)
158 static GWindow PSDrawCreateBitmap(GDisplay * gdisp, uint16 width, uint16 height,
162 static GCursor PSDrawCreateCursor(GWindow src, GWindow mask, Color fg, Color bg,
166 static void PSSetZoom(GWindow w, GRect * r, enum gzoom_flags flags)
169 static void PSDestroyCursor(GDisplay * gdisp, GCursor ct)
172 static int PSNativeWindowExists(GDisplay * gdisp, void *native)
175 static void PSSetWindowBorder(GWindow w, int width, Color col)
178 static int PSSetDither(GDisplay * gdisp, int dither)
181 static void PSDrawReparentWindow(GWindow child, GWindow newparent, int x, int y)
184 static void PSDrawSetVisible(GWindow w, int vis)
187 static void PSDrawMove(GWindow w, int32 x, int32 y)
190 static void PSDrawResize(GWindow w, int32 width, int32 height)
193 static void PSDrawMoveResize(GWindow w, int32 x, int32 y, int32 width,
197 static void PSDrawRaise(GWindow w)
200 static void PSDrawRaiseAbove(GWindow w, GWindow below)
203 static int PSDrawIsAbove(GWindow w, GWindow below)
206 static void PSDrawLower(GWindow w)
209 static void PSDrawSetWindowTitles(GWindow w, const unichar_t * title,
210 const unichar_t * icontit)
213 static void PSDrawSetWindowTitles8(GWindow w, const char *title,
217 static void PSDrawGetPointerPosition(GWindow w, GEvent * ret)
220 static void PSDrawSetCursor(GWindow w, GCursor ct)
223 static GCursor PSDrawGetCursor(GWindow w)
226 static GWindow PSDrawGetRedirectWindow(GDisplay * gd)
229 static unichar_t *PSDrawGetWindowTitle(GWindow w)
232 static char *PSDrawGetWindowTitle8(GWindow w)
235 static void PSDrawTranslateCoordinates(GWindow _from, GWindow _to, GPoint * pt)
238 static void PSDrawScroll(GWindow w, GRect * rect, int32 hor, int32 vert)
241 static void PSDrawBeep(GDisplay * gdisp)
244 static void PSDrawFlush(GDisplay * gdisp)
247 static GIC *PSDrawCreateInputContext(GWindow w, enum gic_style def_style)
250 static void PSDrawSetGIC(GWindow w, GIC * gic, int x, int y)
253 static void PSDrawPointerUngrab(GDisplay * gdisp)
256 static void PSDrawPointerGrab(GWindow w)
259 static void PSDrawGrabSelection(GWindow w, enum selnames sel)
262 static void PSDrawAddSelectionType(GWindow w, enum selnames sel, char *type,
263 void *data, int32 len, int32 unitsize,
264 void *(*gendata) (void *, int32 * len),
265 void (*freedata) (void *))
268 static void *PSDrawRequestSelection(GWindow w, enum selnames sn, char *typename,
272 static int PSDrawSelectionHasType(GWindow w, enum selnames sn, char *typename)
275 static void PSDrawRequestExpose(GWindow gw, GRect * rect, int doclear)
278 static GTimer *PSDrawRequestTimer(GWindow w, int32 time_from_now,
279 int32 frequency, void *userdata)
282 static void PSDrawCancelTimer(GTimer * timer)
285 static void PSDrawSyncThread(GDisplay * gdisp, void (*func) (void *),
289 static void PSDrawForceUpdate(GWindow gw)
292 static void PSDrawSync(GDisplay * gdisp)
295 static void PSDrawSkipMouseMoveEvents(GWindow gw, GEvent * last)
298 static void PSDrawProcessPendingEvents(GDisplay * gdisp)
301 static void PSDrawProcessWindowEvents(GWindow gw)
304 static void PSDrawEventLoop(GDisplay * gd)
307 static void PSDrawPostEvent(GEvent * e)
310 static void PSDrawPostDragEvent(GWindow w, GEvent * mouse, enum event_type et)
313 static int PSDrawRequestDeviceEvents(GWindow w, int devcnt,
314 struct gdeveventmask *de)
317 static GImage *_PSDraw_CopyScreenToImage(GWindow w, GRect * rect)
320 static void _PSDraw_Pixmap(GWindow _w, GWindow _pixmap, GRect * src, int32 x,
324 static void _PSDraw_TilePixmap(GWindow _w, GWindow _pixmap, GRect * src,
328 static void PSMyArc(GPSWindow ps, double cx, double cy, double radx,
329 double rady, double sa, double ta)
334 temp = ((int)((sa + 90) / 90)) * 90;
335 PSDoArc(ps, cx, cy, radx, rady, sa, ea < temp ? ea : temp);
339 static void PSDrawElipse(GPSWindow ps, GRect * rct, char *command)
341 float cx, cy, radx, rady;
343 PSMyArc(ps, cx, cy, radx, rady, 0, 360);
345 static void PSDrawPushClip(GWindow w, GRect * rct, GRect * old)
348 static void PSDrawPopClip(GWindow w, GRect * old)
351 static void PSDrawDrawLine(GWindow w, int32 x, int32 y, int32 xend, int32 yend,
355 static void PSDrawDrawArrowLine(GWindow w, int32 x, int32 y, int32 xend,
356 int32 yend, int16 arrows, Color col)
359 static void PSDrawDrawRect(GWindow w, GRect * rct, Color col)
362 static void PSDrawFillRect(GWindow w, GRect * rct, Color col)
365 static void PSDrawClear(GWindow w, GRect * rect)
368 static void PSDrawDrawCircle(GWindow w, GRect * rct, Color col)
371 static void PSDrawFillCircle(GWindow w, GRect * rct, Color col)
373 GPSWindow ps = (GPSWindow) w;
374 PSDrawElipse(ps, rct, "fill");
376 static void PSDrawDrawArc(GWindow w, GRect * rct, int32 sa, int32 ta, Color col)
379 static void PSDrawDrawPoly(GWindow w, GPoint * pt, int16 cnt, Color col)
382 static void PSDrawFillPoly(GWindow w, GPoint * pt, int16 cnt, Color col)
385 static void _GPSDraw_Text1(GWindow gw, struct font_data *fd, int32 x, int32 y,
386 char *txt, int32 cnt, FontMods * mods, Color col)
389 static void _GPSDraw_Text2(GWindow gw, struct font_data *fd, int32 x, int32 y,
390 GChar2b * txt, int32 cnt, FontMods * mods, Color col)
393 static GWindow GPSPrinterStartJob(GDisplay * gd, void *user_data,
394 GPrinterAttrs * attrs)
397 static void GPSPrinterNextPage(GWindow w)
400 static int GPSPrinterEndJob(GWindow w, int cancel)
403 static GWindow PSDrawCreateTopWindow(GDisplay * gdisp, GRect * pos,
404 int (*eh) (GWindow, GEvent *),
405 void *user_data, GWindowAttrs * wattrs)
408 static void PSDrawDestroyWindow(GWindow w)
411 static struct displayfuncs psfuncs = {
412 PSDrawInit, PSDrawTerm, PSDrawNativeDisplay, PSDrawSetDefaultIcon,
413 PSDrawCreateTopWindow, PSDrawCreateSubWindow, PSDrawCreatePixmap,
414 PSDrawCreateBitmap, PSDrawCreateCursor, PSDrawDestroyWindow,
415 PSDestroyCursor, PSNativeWindowExists, PSSetZoom, PSSetWindowBorder,
416 PSSetDither, PSDrawReparentWindow, PSDrawSetVisible, PSDrawMove,
417 PSDrawMove, PSDrawResize, PSDrawMoveResize, PSDrawRaise,
418 PSDrawRaiseAbove, PSDrawIsAbove, PSDrawLower, PSDrawSetWindowTitles,
419 PSDrawSetWindowTitles8, PSDrawGetWindowTitle, PSDrawGetWindowTitle8,
420 PSDrawGetPointerPosition, PSDrawSetCursor, PSDrawGetCursor,
421 PSDrawGetRedirectWindow, PSDrawTranslateCoordinates, PSDrawBeep,
422 PSDrawFlush, PSDrawPushClip, PSDrawPopClip, PSDrawClear,
423 PSDrawDrawLine, PSDrawDrawArrowLine, PSDrawDrawRect, PSDrawFillRect,
424 PSDrawDrawCircle, PSDrawFillCircle, PSDrawDrawArc, PSDrawDrawPoly,
425 PSDrawFillPoly, PSDrawScroll, _GPSDraw_Image, _GPSDraw_TileImage,
426 _GPSDraw_ImageMagnified, _PSDraw_CopyScreenToImage, _PSDraw_Pixmap,
427 _PSDraw_TilePixmap, _GPSDraw_ScaleFont, _GPSDraw_StylizeFont,
428 _GPSDraw_LoadFontMetrics, _GPSDraw_Text1, _GPSDraw_Text2,
429 PSDrawCreateInputContext, PSDrawSetGIC, PSDrawGrabSelection,
430 PSDrawAddSelectionType, PSDrawRequestSelection,
431 PSDrawSelectionHasType, PSDrawPointerUngrab, PSDrawPointerGrab,
432 PSDrawRequestExpose, PSDrawForceUpdate, PSDrawSync,
433 PSDrawSkipMouseMoveEvents, PSDrawProcessPendingEvents,
434 PSDrawProcessWindowEvents, PSDrawProcessPendingEvents,
435 PSDrawEventLoop, PSDrawPostEvent, PSDrawPostDragEvent,
436 PSDrawRequestDeviceEvents, PSDrawRequestTimer, PSDrawCancelTimer,
437 PSDrawSyncThread, GPSPrinterStartJob, GPSPrinterNextPage,
440 GDisplay *_GPSDraw_CreateDisplay()
443 gdisp->funcs = &psfuncs;