4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Great Red Oystrich Makes All Chemists Sane
33 static char *SRCID_x11_h
= "$Id$";
36 #ident "@(#) x11.h 1.6 12/16/92"
37 #endif /* HAVE_IDENT */
43 /* These colours will be mapped to black on a monochrome screen */
44 extern unsigned long BLACK
,BLUE
,GREEN
,CYAN
,RED
,BROWN
,GREY
,DARKGREY
;
46 /* These colours will be mapped to white on a monochrome screen */
47 extern unsigned long LIGHTBLUE
,LIGHTGREY
,LIGHTGREEN
,LIGHTCYAN
,
48 LIGHTRED
,VIOLET
,YELLOW
,WHITE
;
50 typedef enum { ecbOK
} ecbReturn
;
52 #define CBARGS (struct t_x11 *x11,XEvent *event, Window w, void *data)
53 /* Callback function. Return FALSE to continue, TRUE to exit */
55 typedef struct t_x11
{
66 struct t_wlist
*wlist
;
67 void (*GetNamedColor
)(struct t_x11
*x11
,char *name
,unsigned long *col
);
68 void (*MainLoop
)(struct t_x11
*x11
);
69 void (*RegisterCallback
)(struct t_x11
*x11
,Window w
,Window Parent
,
70 bool cb CBARGS
, void *data
);
71 void (*UnRegisterCallback
)(struct t_x11
*x11
, Window w
);
72 void (*SetInputMask
)(struct t_x11
*x11
, Window w
, unsigned long mask
);
73 unsigned long (*GetInputMask
)(struct t_x11
*x11
, Window w
);
74 void (*CleanUp
)(struct t_x11
*x11
);
75 void (*Flush
)(struct t_x11
*x11
);
78 typedef bool CallBack CBARGS
;
80 typedef struct t_wlist
{
81 Window w
; /* The window itself */
82 Window Parent
; /* It's parent window */
83 CallBack
*cb
; /* Call back function */
84 unsigned long mask
; /* Input mask */
85 void *data
; /* User data struct */
89 t_x11
*GetX11(int *argc
, char *argv
[]);
90 /* x11 is a struct / function-set that manages a number of windows.
91 * more or (presumably) less like Xt does, but since x11 uses only
92 * Xlib calls, it is *PORTABLE* software.
94 * The x11 struct is in principle Object Oriented, in that the functions
95 * are member of the struct. This makes the software a little more
96 * managable. Because of portability I decided not to use C++, even
97 * though it would be much nicer to work with in the X-Bizz.
99 * Here's the description of how to use the x11 struct
100 * 1. Call the GetX11 routine, with the argc and argv from your main.
101 * This will sort out the X-arguments on the command line and remove
102 * them from the command line. When the routine returns, only the
103 * application specific arguments should be left. Thi opens the
104 * display, selects a font, creates a Graphics Context and also sets
105 * the colours listed above in the global variables.
106 * 2. Call x11->RegisterCallback for each window you want to have
107 * managed by x11. You have to create a Callback routine for your
108 * application that handles *ONE* event at a time. The idea is that
109 * each window has it's own Callback which is not polluted by code
110 * for other windows, but it is of course entirely possible to have
111 * one Callback routine for a number of windows (eg. when you need
112 * to know something about your children).
113 * 3. Call x11->SetInputMask. This comes in place of the normal
114 * XSelectInput, because it enables x11 to manually decide which
115 * events are passed to the windows. With the x11->GetInputMask,
116 * x11->SetInputMask combination, a child window can temporarily
117 * disable mouse and keyboard input for it's parent, while allowing
118 * redraw events to pass through for instance. Hereby a simple way
119 * for creating application modal child windows is implemented.
120 * 4. Call x11->MainLoop. This will call every callback function as
121 * appropriate. When a window receives a message, that makes it decide
122 * to terminate it should call x11->UnRegisterCallback, in order to
123 * tell the x11 Manager that it does not want to receive any more
124 * events. It is up to the window to destroy itself. The MainLoop
125 * routine exits when there are no more windows to manage, i.e. when
126 * all routines have called UnRegisterCallback, OR when one Callback
127 * routine returns non-zero (TRUE).
128 * 5. Call x11->CleanUp. This closes the display, and frees all
129 * memory allocated by x11 before.
132 extern void GetNamedColor(t_x11
*x11
,char *name
,unsigned long *col
);