1 /***********************************************************************/
5 /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../../LICENSE. */
12 /***********************************************************************/
14 /* $Id: libgraph.h 6350 2004-05-30 10:25:08Z xleroy $ */
18 #include <X11/Xutil.h>
22 int w, h; /* Dimensions of the drawable */
23 Drawable win; /* The drawable itself */
24 GC gc; /* The associated graphics context */
27 extern Display * caml_gr_display; /* The display connection */
28 extern int caml_gr_screen; /* The screen number */
29 extern Colormap caml_gr_colormap; /* The color map */
30 extern struct canvas caml_gr_window; /* The graphics window */
31 extern struct canvas caml_gr_bstore; /* The pixmap used for backing store */
32 extern int caml_gr_white, caml_gr_black; /* Black and white pixels for X */
33 extern int caml_gr_background; /* Background color for X
34 (used for CAML color -1) */
35 extern Bool caml_gr_display_modeflag; /* Display-mode flag */
36 extern Bool caml_gr_remember_modeflag; /* Remember-mode flag */
37 extern int caml_gr_x, caml_gr_y; /* Coordinates of the current point */
38 extern int caml_gr_color; /* Current *CAML* drawing color (can be -1) */
39 extern XFontStruct * caml_gr_font; /* Current font */
40 extern long caml_gr_selected_events; /* Events we are interested in */
41 extern Bool caml_gr_ignore_sigio; /* Whether to consume events on sigio */
43 extern Bool caml_gr_direct_rgb;
44 extern int caml_gr_byte_order;
45 extern int caml_gr_bitmap_unit;
46 extern int caml_gr_bits_per_pixel;
48 #define Wcvt(y) (caml_gr_window.h - 1 - (y))
49 #define Bcvt(y) (caml_gr_bstore.h - 1 - (y))
50 #define WtoB(y) ((y) + caml_gr_bstore.h - caml_gr_window.h)
51 #define BtoW(y) ((y) + caml_gr_window.h - caml_gr_bstore.h)
52 #define min(a,b) ((a) < (b) ? (a) : (b))
53 #define max(a,b) ((a) > (b) ? (a) : (b))
55 #define DEFAULT_SCREEN_WIDTH 600
56 #define DEFAULT_SCREEN_HEIGHT 450
57 #define BORDER_WIDTH 2
58 #define DEFAULT_WINDOW_NAME "Caml graphics"
59 #define DEFAULT_SELECTED_EVENTS \
60 (ExposureMask | KeyPressMask | StructureNotifyMask)
61 #define DEFAULT_FONT "fixed"
62 #define SIZE_QUEUE 256
64 /* To handle events asynchronously */
67 #define EVENT_SIGNAL SIGIO
70 #define USE_INTERVAL_TIMER
71 #define EVENT_SIGNAL SIGALRM
74 #define EVENT_SIGNAL SIGALRM
78 extern void caml_gr_fail(char *fmt, char *arg);
79 extern void caml_gr_check_open(void);
80 extern unsigned long caml_gr_pixel_rgb(int rgb);
81 extern int caml_gr_rgb_pixel(long unsigned int pixel);
82 extern void caml_gr_handle_event(XEvent *e);
83 extern void caml_gr_init_color_cache(void);
84 extern void caml_gr_init_direct_rgb_to_pixel(void);
85 extern value caml_gr_id_of_window( Window w );