Add missing defines to PKG_CFLAGS
[gromacs.git] / src / ngmx / x11.h
blobac0f3bc0a77b9410270e2daadadafa79b35afe4e
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
39 #ifndef _x11_h
40 #define _x11_h
42 #include <stdio.h>
43 #include "typedefs.h"
44 #include "Xstuff.h"
46 /* These colours will be mapped to black on a monochrome screen */
47 extern unsigned long BLACK,BLUE,GREEN,CYAN,RED,BROWN,GREY,DARKGREY;
49 /* These colours will be mapped to white on a monochrome screen */
50 extern unsigned long LIGHTBLUE,LIGHTGREY,LIGHTGREEN,LIGHTCYAN,
51 LIGHTRED,VIOLET,YELLOW,WHITE;
53 typedef enum { ecbOK } ecbReturn;
55 #define CBARGS (struct t_x11 *x11,XEvent *event, Window w, void *data)
56 /* Callback function. Return FALSE to continue, TRUE to exit */
58 typedef struct t_x11 {
59 Display *disp;
60 XFontStruct *font;
61 GC gc;
62 Window root;
63 char *dispname;
64 FILE *console;
65 int screen,depth;
66 Colormap cmap;
67 unsigned long fg,bg;
68 char *title;
69 struct t_wlist *wlist;
70 void (*GetNamedColor)(struct t_x11 *x11,const char *name,unsigned long *col);
71 void (*MainLoop)(struct t_x11 *x11);
72 void (*RegisterCallback)(struct t_x11 *x11,Window w,Window Parent,
73 gmx_bool cb CBARGS, void *data);
74 void (*UnRegisterCallback)(struct t_x11 *x11, Window w);
75 void (*SetInputMask)(struct t_x11 *x11, Window w, unsigned long mask);
76 unsigned long (*GetInputMask)(struct t_x11 *x11, Window w);
77 void (*CleanUp)(struct t_x11 *x11);
78 void (*Flush)(struct t_x11 *x11);
79 } t_x11;
81 typedef gmx_bool CallBack CBARGS;
83 typedef struct t_wlist {
84 Window w; /* The window itself */
85 Window Parent; /* It's parent window */
86 CallBack *cb; /* Call back function */
87 unsigned long mask; /* Input mask */
88 void *data; /* User data struct */
89 struct t_wlist *next;
90 } t_wlist;
92 t_x11 *GetX11(int *argc, char *argv[]);
93 /* x11 is a struct / function-set that manages a number of windows.
94 * more or (presumably) less like Xt does, but since x11 uses only
95 * Xlib calls, it is *PORTABLE* software.
97 * The x11 struct is in principle Object Oriented, in that the functions
98 * are member of the struct. This makes the software a little more
99 * managable. Because of portability I decided not to use C++, even
100 * though it would be much nicer to work with in the X-Bizz.
102 * Here's the description of how to use the x11 struct
103 * 1. Call the GetX11 routine, with the argc and argv from your main.
104 * This will sort out the X-arguments on the command line and remove
105 * them from the command line. When the routine returns, only the
106 * application specific arguments should be left. Thi opens the
107 * display, selects a font, creates a Graphics Context and also sets
108 * the colours listed above in the global variables.
109 * 2. Call x11->RegisterCallback for each window you want to have
110 * managed by x11. You have to create a Callback routine for your
111 * application that handles *ONE* event at a time. The idea is that
112 * each window has it's own Callback which is not polluted by code
113 * for other windows, but it is of course entirely possible to have
114 * one Callback routine for a number of windows (eg. when you need
115 * to know something about your children).
116 * 3. Call x11->SetInputMask. This comes in place of the normal
117 * XSelectInput, because it enables x11 to manually decide which
118 * events are passed to the windows. With the x11->GetInputMask,
119 * x11->SetInputMask combination, a child window can temporarily
120 * disable mouse and keyboard input for it's parent, while allowing
121 * redraw events to pass through for instance. Hereby a simple way
122 * for creating application modal child windows is implemented.
123 * 4. Call x11->MainLoop. This will call every callback function as
124 * appropriate. When a window receives a message, that makes it decide
125 * to terminate it should call x11->UnRegisterCallback, in order to
126 * tell the x11 Manager that it does not want to receive any more
127 * events. It is up to the window to destroy itself. The MainLoop
128 * routine exits when there are no more windows to manage, i.e. when
129 * all routines have called UnRegisterCallback, OR when one Callback
130 * routine returns non-zero (TRUE).
131 * 5. Call x11->CleanUp. This closes the display, and frees all
132 * memory allocated by x11 before.
135 extern void GetNamedColor(t_x11 *x11,const char *name,unsigned long *col);
137 #endif /* _x11_h */