]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/win32caml/libgraph.h
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / win32caml / libgraph.h
1 /***********************************************************************/
2 /*                                                                     */
3 /*                           Objective Caml                            */
4 /*                                                                     */
5 /*            Jacob Navia, after Xavier Leroy                          */
6 /*                                                                     */
7 /*  Copyright 2001 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.     */
11 /*                                                                     */
12 /***********************************************************************/
13
14 /* $Id: libgraph.h 5029 2002-07-23 14:12:03Z doligez $ */
15
16 #include <stdio.h>
17 #include <windows.h>
18
19 struct canvas {
20   int w, h;                     /* Dimensions of the drawable */
21   HWND win;                     /* The drawable itself */
22   HDC gc;                        /* The associated graphics context */
23 };
24
25 extern HWND grdisplay;     /* The display connection */
26 //extern int grscreen;            /* The screen number */
27 //extern Colormap grcolormap;     /* The color map */
28 //extern struct canvas grwindow;  /* The graphics window */
29 //extern struct canvas grbstore;  /* The pixmap used for backing store */
30 //extern int grwhite, grblack;    /* Black and white pixels for X */
31 //extern int grbackground;        /* Background color for X
32 //                                   (used for CAML color -1) */
33 extern COLORREF grbackground;
34 extern BOOL grdisplay_mode;     /* Display-mode flag */
35 extern BOOL grremember_mode;    /* Remember-mode flag */
36 extern int grx, gry;            /* Coordinates of the current point */
37 extern int grcolor;             /* Current *CAML* drawing color (can be -1) */
38 extern HFONT * grfont;          /* Current font */
39
40 extern BOOL direct_rgb;
41 extern int byte_order;
42 extern int bitmap_unit;
43 extern int bits_per_pixel;
44
45 #define Wcvt(y) (grwindow.height - 1 - (y))
46 #define Bcvt(y) (grwindow.height - 1 - (y))
47 #define WtoB(y) ((y) + WindowRect.bottom - grwindow.h)
48 //#define BtoW(y) ((y) + WindowRect.bottom - grbstore.h)
49
50 #define DEFAULT_SCREEN_WIDTH 1024
51 #define DEFAULT_SCREEN_HEIGHT 768
52 #define BORDER_WIDTH 2
53 #define WINDOW_NAME "Caml graphics"
54 #define ICON_NAME "Caml graphics"
55 #define DEFAULT_EVENT_MASK \
56           (ExposureMask | KeyPressMask | StructureNotifyMask)
57 #define DEFAULT_FONT "fixed"
58 #define SIZE_QUEUE 256
59
60 /* To handle events asynchronously */
61 #ifdef HAS_ASYNC_IO
62 #define USE_ASYNC_IO
63 #define EVENT_SIGNAL SIGIO
64 #else
65 #ifdef HAS_SETITIMER
66 #define USE_INTERVAL_TIMER
67 #define EVENT_SIGNAL SIGALRM
68 #else
69 #define USE_ALARM
70 #define EVENT_SIGNAL SIGALRM
71 #endif
72 #endif
73
74 void gr_fail(char *fmt, char *arg);
75 void gr_check_open(void);
76 unsigned long gr_pixel_rgb(int rgb);
77 int gr_rgb_pixel(long unsigned int pixel);
78 void gr_enqueue_char(unsigned char c);
79 void gr_init_color_cache(void);
80
81 // Windows specific definitions
82 extern RECT WindowRect;
83 extern int grCurrentColor;
84
85 typedef struct tagWindow {
86         HDC gc;
87         HDC gcBitmap;
88         HWND hwnd;
89         HBRUSH CurrentBrush;
90         HPEN CurrentPen;
91         DWORD CurrentColor;
92         int width;
93         int height;
94         int grx;
95         int gry;
96         HBITMAP hBitmap;
97         HFONT CurrentFont;
98         int CurrentFontSize;
99         HDC tempDC; // For image operations;
100 } GR_WINDOW;
101
102 extern GR_WINDOW grwindow;
103 HFONT CreationFont(char *name);
104 extern int MouseLbuttonDown,MouseMbuttonDown,MouseRbuttonDown;
105 extern HANDLE EventHandle;
106 extern int InspectMessages;
107 extern MSG msg;
108