1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1998-11-09 09:00:41 -08:00
|
|
|
/* en Automatique. Distributed only by permission. */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-05-08 10:04:35 -07:00
|
|
|
#include <stdio.h>
|
1997-03-21 06:23:00 -08:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
1995-05-08 10:04:35 -07:00
|
|
|
#include <mlvalues.h>
|
|
|
|
|
|
|
|
struct canvas {
|
|
|
|
int w, h; /* Dimensions of the drawable */
|
|
|
|
Drawable win; /* The drawable itself */
|
|
|
|
GC gc; /* The associated graphics context */
|
|
|
|
};
|
|
|
|
|
1996-09-03 01:25:04 -07:00
|
|
|
extern Display * grdisplay; /* The display connection */
|
1998-05-25 02:17:22 -07:00
|
|
|
extern int grscreen; /* The screen number */
|
|
|
|
extern Colormap grcolormap; /* The color map */
|
|
|
|
extern struct canvas grwindow; /* The graphics window */
|
|
|
|
extern struct canvas grbstore; /* The pixmap used for backing store */
|
|
|
|
extern int grwhite, grblack; /* Black and white pixels */
|
|
|
|
extern int grx, gry; /* Coordinates of the current point */
|
|
|
|
extern unsigned long grcolor; /* Current drawing color */
|
1995-05-08 10:04:35 -07:00
|
|
|
extern XFontStruct * grfont; /* Current font */
|
|
|
|
|
1999-02-19 09:08:27 -08:00
|
|
|
extern Bool direct_rgb;
|
|
|
|
extern int byte_order;
|
|
|
|
extern int bitmap_unit;
|
|
|
|
extern int bits_per_pixel;
|
|
|
|
|
1995-05-08 10:04:35 -07:00
|
|
|
#define Wcvt(y) (grwindow.h - 1 - (y))
|
|
|
|
#define Bcvt(y) (grbstore.h - 1 - (y))
|
|
|
|
#define WtoB(y) ((y) + grbstore.h - grwindow.h)
|
|
|
|
#define min(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
#define max(a,b) ((a) > (b) ? (a) : (b))
|
|
|
|
|
|
|
|
#define DEFAULT_SCREEN_WIDTH 600
|
|
|
|
#define DEFAULT_SCREEN_HEIGHT 450
|
|
|
|
#define BORDER_WIDTH 2
|
1998-11-09 09:00:41 -08:00
|
|
|
#define WINDOW_NAME "Caml graphics"
|
|
|
|
#define ICON_NAME "Caml graphics"
|
1995-05-08 10:04:35 -07:00
|
|
|
#define DEFAULT_EVENT_MASK \
|
|
|
|
(ExposureMask | KeyPressMask | StructureNotifyMask)
|
|
|
|
#define DEFAULT_FONT "fixed"
|
|
|
|
#define SIZE_QUEUE 256
|
|
|
|
|
|
|
|
/* To handle events asynchronously */
|
|
|
|
#ifdef HAS_ASYNC_IO
|
|
|
|
#define USE_ASYNC_IO
|
|
|
|
#define EVENT_SIGNAL SIGIO
|
|
|
|
#else
|
|
|
|
#ifdef HAS_SETITIMER
|
|
|
|
#define USE_INTERVAL_TIMER
|
|
|
|
#define EVENT_SIGNAL SIGALRM
|
|
|
|
#else
|
|
|
|
#define USE_ALARM
|
|
|
|
#define EVENT_SIGNAL SIGALRM
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
void gr_fail(char *fmt, char *arg);
|
|
|
|
void gr_check_open(void);
|
|
|
|
unsigned long gr_pixel_rgb(int rgb);
|
|
|
|
int gr_rgb_pixel(long unsigned int pixel);
|
|
|
|
void gr_handle_simple_event(XEvent *e);
|
|
|
|
void gr_enqueue_char(unsigned char c);
|
|
|
|
void gr_init_color_cache(void);
|