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 */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
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 */
|
|
|
|
};
|
|
|
|
|
2004-03-24 07:02:06 -08:00
|
|
|
extern Display * caml_gr_display; /* The display connection */
|
|
|
|
extern int caml_gr_screen; /* The screen number */
|
|
|
|
extern Colormap caml_gr_colormap; /* The color map */
|
|
|
|
extern struct canvas caml_gr_window; /* The graphics window */
|
|
|
|
extern struct canvas caml_gr_bstore; /* The pixmap used for backing store */
|
|
|
|
extern int caml_gr_white, caml_gr_black; /* Black and white pixels for X */
|
|
|
|
extern int caml_gr_background; /* Background color for X
|
2001-07-12 06:00:55 -07:00
|
|
|
(used for CAML color -1) */
|
2004-03-24 07:02:06 -08:00
|
|
|
extern Bool caml_gr_display_modeflag; /* Display-mode flag */
|
|
|
|
extern Bool caml_gr_remember_modeflag; /* Remember-mode flag */
|
|
|
|
extern int caml_gr_x, caml_gr_y; /* Coordinates of the current point */
|
|
|
|
extern int caml_gr_color; /* Current *CAML* drawing color (can be -1) */
|
|
|
|
extern XFontStruct * caml_gr_font; /* Current font */
|
|
|
|
extern long caml_gr_selected_events; /* Events we are interested in */
|
2004-05-30 03:25:08 -07:00
|
|
|
extern Bool caml_gr_ignore_sigio; /* Whether to consume events on sigio */
|
1995-05-08 10:04:35 -07:00
|
|
|
|
2004-03-24 07:02:06 -08:00
|
|
|
extern Bool caml_gr_direct_rgb;
|
|
|
|
extern int caml_gr_byte_order;
|
|
|
|
extern int caml_gr_bitmap_unit;
|
|
|
|
extern int caml_gr_bits_per_pixel;
|
1999-02-19 09:08:27 -08:00
|
|
|
|
2004-03-24 07:02:06 -08:00
|
|
|
#define Wcvt(y) (caml_gr_window.h - 1 - (y))
|
|
|
|
#define Bcvt(y) (caml_gr_bstore.h - 1 - (y))
|
|
|
|
#define WtoB(y) ((y) + caml_gr_bstore.h - caml_gr_window.h)
|
|
|
|
#define BtoW(y) ((y) + caml_gr_window.h - caml_gr_bstore.h)
|
1995-05-08 10:04:35 -07:00
|
|
|
#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
|
2003-04-25 05:25:21 -07:00
|
|
|
#define DEFAULT_WINDOW_NAME "Caml graphics"
|
2001-07-31 06:15:36 -07:00
|
|
|
#define DEFAULT_SELECTED_EVENTS \
|
|
|
|
(ExposureMask | KeyPressMask | StructureNotifyMask)
|
1995-05-08 10:04:35 -07:00
|
|
|
#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
|
|
|
|
|
2004-03-24 07:02:06 -08:00
|
|
|
extern void caml_gr_fail(char *fmt, char *arg);
|
|
|
|
extern void caml_gr_check_open(void);
|
|
|
|
extern unsigned long caml_gr_pixel_rgb(int rgb);
|
|
|
|
extern int caml_gr_rgb_pixel(long unsigned int pixel);
|
|
|
|
extern void caml_gr_handle_event(XEvent *e);
|
|
|
|
extern void caml_gr_init_color_cache(void);
|
|
|
|
extern void caml_gr_init_direct_rgb_to_pixel(void);
|
|
|
|
extern value caml_gr_id_of_window( Window w );
|