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
58 static void ApplCallback(t_x11 *x11, int dlg_mess, int item_id,
70 fprintf(stderr, "item_id: %d (%s)\n", item_id, set);
71 if (gmx_strcasecmp(set, "OK") == 0)
75 "xterm -geometry +100+100 -n %s"
76 " -title \"GROMACS: %s\" -e nice %s ",
77 data->name[data->nAppl],
78 data->name[data->nAppl],
79 data->name[data->nAppl]);
80 for (i = 0; (i < dlg->nitem); i++)
82 item = dlg->dlgitem[i];
86 strcat(doit, item->set);
90 if (item->u.checkbox.bChecked)
92 strcat(doit, item->set);
97 if (strlen(item->u.edittext.buf) > 0)
99 strcat(doit, item->set);
101 strcat(doit, item->u.edittext.buf);
106 fprintf(stderr, "Type: %d\n", item->type);
110 fprintf(stderr, "Going to exec: '%s'\n", doit);
113 printf("Warning-- No calls to system(3) supported on this platform.");
114 printf("Warning-- Skipping execution of 'system(\"%s\")'.", buf);
121 else if (gmx_strcasecmp(set, "Cancel") == 0)
128 static void Callback(t_x11 *x11, int dlg_mess, int item_id,
129 char *set, void *dta)
131 t_data *data = (t_data *)dta;
133 if (item_id == data->nopt)
135 fprintf(stderr, "Doei...\n");
140 fprintf(stderr, "%d: %s\n", item_id, data->description[item_id]);
141 if (data->nAppl != -1)
145 data->nAppl = item_id;
146 data->appl = ReadDlg(x11, 0, data->name[item_id],
147 BLACK, LIGHTGREY, data->dlgfile[item_id],
148 50, 50, FALSE, FALSE, ApplCallback, data);
153 static void read_opts(t_data *data)
156 char fn[STRLEN], buf[STRLEN];
159 sprintf(fn, "xstat.dat");
161 fscanf(in, "%d", &n);
163 snew(data->name, data->nopt);
164 snew(data->description, data->nopt);
165 snew(data->dlgfile, data->nopt);
167 for (i = 0; (i < data->nopt); i++)
169 ReadQuoteString(fn, in, buf);
170 data->name[i] = strdup(buf);
171 ReadQuoteString(fn, in, buf);
172 data->description[i] = strdup(buf);
173 ReadQuoteString(fn, in, buf);
174 data->dlgfile[i] = strdup(buf);
179 static void add_opts(t_x11 *x11, t_data *data)
185 for (i = 0; (i < data->nopt); i++)
187 but = CreateButton(x11, data->description[i], FALSE,
189 OFFS_X, y0, 0, 0, 1);
190 AddDlgItem(data->dlg, but);
191 y0 += but->win.height+OFFS_Y;
193 but = CreateButton(x11, "Quit", TRUE, (t_id)data->nopt, (t_id)0,
194 OFFS_X, y0, 0, 0, 1);
195 AddDlgItem(data->dlg, but);
196 y0 += but->win.height+OFFS_Y;
199 for (i = 0; (i <= data->nopt); i++)
201 w = max(w, QueryDlgItemW(data->dlg, i));
204 for (i = 0; (i <= data->nopt); i++)
206 SetDlgItemSize(data->dlg, i, w, 0);
208 SetDlgSize(data->dlg, w+2*OFFS_X, y0, TRUE);
212 main(int argc, char *argv[])
217 /* Initiate X and data */
218 if ((x11 = GetX11(&argc, argv)) == NULL)
220 fprintf(stderr, "Can't open DISPLAY\n");
224 data.dlg = CreateDlg(x11, 0, argv[0], 0, 0, 0, 0, 0, BLACK, LIGHTGREY, Callback, &data);
225 add_opts(x11, &data);