4
* $Id: xbasic.h 685 2003-03-08 15:26:51Z travo $
6
* Declare the basic play engine for GIST.
9
/* Copyright (c) 2000. The Regents of the University of California.
10
All rights reserved. */
19
typedef struct XEngine XEngine;
23
/* --------------- Specific to XEngine ------------------- */
27
int width, height; /* of (virtual page) graphics window */
28
int wtop, htop; /* of actual top-level window */
29
int topMargin; /* height of top menu bar, if any */
30
int leftMargin; /* width of left menu bar, if any */
31
int x, y; /* position of graphics relative to win */
32
int dpi; /* resolution of X window (dots per inch, 75 or 100) */
35
/* if w!=win, this is animation mode */
37
int a_width, a_height; /* of animation Pixmap */
38
int a_x, a_y; /* where it goes on graphics window */
39
GpTransform swapped; /* transform for graphics window while
40
* in animation mode */
42
/* if non-zero, these handlers can deal with input events */
43
void (*HandleExpose)(Engine *engine, Drauing *drawing, int *xy);
44
void (*HandleClick)(Engine *e,int b,int md,int x,int y, unsigned long ms);
45
void (*HandleMotion)(Engine *e,int md,int x,int y);
46
void (*HandleKey)(Engine *e,int k,int md);
49
/* GxBasic creates the basic top level window for a GpBXEngine.
50
The window manager properties are filled in.
51
Use the DefaultTopSize macro to set the width and
52
height appropriate for a particular resolution (dpi).
53
DefaultTopSize is 6 inches (450 pixels at 75 dpi, 600 at 100 dpi). */
54
extern p_scr *GxBasic(char *name, char *display, int width, int height,
57
extern p_scr *g_connect(char *displayName);
58
extern void g_disconnect(p_scr *s);
60
extern int gx75width, gx100width; /* defaults are 450 and 600 pixels */
61
#define DefaultTopWidth(dpi) \
62
(gx75width<gx100width?((dpi)*gx100width)/100:gx100width)
63
extern int gx75height, gx100height; /* defaults are 450 and 600 pixels */
64
#define DefaultTopHeight(dpi) \
65
(gx75width<gx100width?((dpi)*gx100height)/100:gx100height)
66
#define PixelsPerNDC(dpi) ((dpi)/ONE_INCH)
68
/* GxEngine creates an XEngine and adds it to the list of GIST engines.
69
The top window will generally be smaller than the graphics
70
window created by GxEngine; specific engines are responsible for
71
scrolling of the graphics window relative to the top window, although
72
the initial location is passed in via (x, y). The size argument is
73
sizeof(XEngine), or sizeof some derived engine class. */
74
extern XEngine *GxEngine(p_scr *s, char *name, GpTransform *toPixels,
76
int topMargin, int leftMargin, long size);
78
/* GxInput sets optional event handlers, and calls XSelectInput with
79
the given eventMask. HandleExpose, if non-zero, will be called
80
instead of redrawing the Drauing associated with the Engine, which
81
is the default action. HandleResize, if non-zero, will be called
82
instead of the default resize action (which is to recenter the
83
graphics window). HandleOther, if non-zero, will be called for
84
keyboard, button, or other events not recogized by the default
86
extern int GxInput(Engine *engine,
87
void (*HandleExpose)(Engine *, Drauing *, int *),
88
void (*HandleClick)(Engine *,int,int,int,int,unsigned long),
89
void (*HandleMotion)(Engine *,int,int,int),
90
void (*HandleKey)(Engine *,int,int));
92
extern XEngine *GisXEngine(Engine *engine);
94
extern void GxExpose(Engine *engine, Drauing *drawing, int *xy);
95
extern void GxRecenter(XEngine *xEngine, int width, int height);
97
/* GxAnimate creates an offscreen pixmap for the specified region of
98
the window. Subsequent drawing takes place on the pixmap, not
99
on the graphics window. GxStrobe copies the pixmap to the screen,
100
optionally clearing it for the next frame of the animation.
101
The viewport should be large enough to cover everything that will
102
change as the animation proceeds, but no larger to get peak speed.
103
GxDirect restores the usual direct-to-screen drawing mode. */
104
extern int GxAnimate(Engine *engine, GpBox *viewport);
105
extern int GxStrobe(Engine *engine, int clear);
106
extern int GxDirect(Engine *engine);
108
extern int g_rgb_read(Engine *eng, GpColor *rgb, long *nx, long *ny);