3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Gyas ROwers Mature At Cryogenic Speed
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 #define CBARGS (struct t_x11 *x11, XEvent *event, Window w, void *data)
51 /* Callback function. Return false to continue, true to exit */
53 typedef struct t_x11 {
64 struct t_wlist *wlist;
65 void (*GetNamedColor)(struct t_x11 *x11, const char *name, unsigned long *col);
66 void (*MainLoop)(struct t_x11 *x11);
67 void (*RegisterCallback)(struct t_x11 *x11, Window w, Window Parent,
68 bool cb CBARGS, void *data);
69 void (*UnRegisterCallback)(struct t_x11 *x11, Window w);
70 void (*SetInputMask)(struct t_x11 *x11, Window w, unsigned long mask);
71 unsigned long (*GetInputMask)(struct t_x11 *x11, Window w);
72 void (*CleanUp)(struct t_x11 *x11);
73 void (*Flush)(struct t_x11 *x11);
76 typedef bool CallBack CBARGS;
78 typedef struct t_wlist {
79 Window w; /* The window itself */
80 Window Parent; /* It's parent window */
81 CallBack *cb; /* Call back function */
82 unsigned long mask; /* Input mask */
83 void *data; /* User data struct */
87 t_x11 *GetX11(int *argc, char *argv[]);
88 /* x11 is a struct / function-set that manages a number of windows.
89 * more or (presumably) less like Xt does, but since x11 uses only
90 * Xlib calls, it is *PORTABLE* software.
92 * The x11 struct is in principle Object Oriented, in that the functions
93 * are member of the struct. This makes the software a little more
94 * managable. Because of portability I decided not to use C++, even
95 * though it would be much nicer to work with in the X-Bizz.
97 * Here's the description of how to use the x11 struct
98 * 1. Call the GetX11 routine, with the argc and argv from your main.
99 * This will sort out the X-arguments on the command line and remove
100 * them from the command line. When the routine returns, only the
101 * application specific arguments should be left. Thi opens the
102 * display, selects a font, creates a Graphics Context and also sets
103 * the colours listed above in the global variables.
104 * 2. Call x11->RegisterCallback for each window you want to have
105 * managed by x11. You have to create a Callback routine for your
106 * application that handles *ONE* event at a time. The idea is that
107 * each window has it's own Callback which is not polluted by code
108 * for other windows, but it is of course entirely possible to have
109 * one Callback routine for a number of windows (eg. when you need
110 * to know something about your children).
111 * 3. Call x11->SetInputMask. This comes in place of the normal
112 * XSelectInput, because it enables x11 to manually decide which
113 * events are passed to the windows. With the x11->GetInputMask,
114 * x11->SetInputMask combination, a child window can temporarily
115 * disable mouse and keyboard input for it's parent, while allowing
116 * redraw events to pass through for instance. Hereby a simple way
117 * for creating application modal child windows is implemented.
118 * 4. Call x11->MainLoop. This will call every callback function as
119 * appropriate. When a window receives a message, that makes it decide
120 * to terminate it should call x11->UnRegisterCallback, in order to
121 * tell the x11 Manager that it does not want to receive any more
122 * events. It is up to the window to destroy itself. The MainLoop
123 * routine exits when there are no more windows to manage, i.e. when
124 * all routines have called UnRegisterCallback, OR when one Callback
125 * routine returns non-zero (true).
126 * 5. Call x11->CleanUp. This closes the display, and frees all
127 * memory allocated by x11 before.
130 extern void GetNamedColor(t_x11 *x11, const char *name, unsigned long *col);