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
49 #include "gmx_fatal.h"
59 static bmchar *icon_bits=NULL;
60 static int icon_width=0;
61 static int icon_height=0;
62 static unsigned long icon_fg=0;
63 static unsigned long icon_bg=0;
65 void SetIcon(unsigned char *bits, int w, int h, unsigned long fg, unsigned long bg)
67 icon_bits=(bmchar *)bits;
74 t_dlg *MessageBox(t_x11 *x11, Window Parent, const char *title,
75 int nlines, char ** lines, unsigned long Flags,
76 DlgCallback *cb, void *data)
84 /* Check flags for inconsistencies */
85 if (((Flags & MB_OK) && (Flags & MB_YES)) ||
86 ((Flags & MB_NO) && (Flags & MB_CANCEL)) ||
87 (!(Flags & MB_OK) && !(Flags & MB_YES))) {
88 fprintf(stderr,"Invalid button selection in MessageBox\n");
92 if (Flags & MB_ICONSTOP) nicon++;
93 if (Flags & MB_ICONINFORMATION) nicon++;
94 if (Flags & MB_ICONEXCLAMATION) nicon++;
95 if (Flags & MB_ICONGMX) nicon++;
97 gmx_fatal(FARGS,"More than one (%d) icon selected in MessageBox",nicon);
101 if (Flags & MB_ICONSTOP)
102 SetIcon(stop_bits,stop_width,stop_height,RED,bg);
103 if (Flags & MB_ICONINFORMATION)
104 SetIcon(info_bits,info_width,info_height,BLUE,bg);
105 if (Flags & MB_ICONEXCLAMATION)
106 SetIcon(alert_bits,alert_width,alert_height,GREEN,bg);
107 if (Flags & MB_ICONGMX)
108 SetIcon(gromacs_bits,gromacs_width,gromacs_height,BLUE,bg);
111 dlg=CreateDlg(x11,Parent,title,0,0,0,0,3,x11->fg,bg,cb,data);
114 AddDlgItem(dlg,CreatePixmap
115 (x11,XCreatePixmapFromBitmapData
116 (x11->disp,dlg->win.self,icon_bits,icon_width,icon_height,
117 icon_fg,icon_bg,x11->depth),
118 ID_ICON,ID_BOX,2*OFFS_X,2*OFFS_Y,icon_width,icon_height,0));
119 x+=QueryDlgItemW(dlg,ID_ICON)+2*OFFS_X;
122 AddDlgItem(dlg,CreateStaticText(x11,nlines,lines,ID_TEXT,ID_BOX,
125 y=QueryDlgItemY(dlg,ID_TEXT)+QueryDlgItemH(dlg,ID_TEXT);
128 yi=QueryDlgItemY(dlg,ID_ICON)+QueryDlgItemH(dlg,ID_ICON);
130 SetDlgItemPos(dlg,ID_TEXT,x,2*OFFS_Y+(yi-y)/2);
132 SetDlgItemPos(dlg,ID_ICON,2*OFFS_X,2*OFFS_Y+(y-yi)/2);
135 x+=QueryDlgItemW(dlg,ID_TEXT)+2*OFFS_X;
137 width=(x-8*OFFS_X)/2;
139 if (((Flags & MB_OKCANCEL) == MB_OKCANCEL) ||
140 ((Flags & MB_YESNO) == MB_YESNO))
145 #define CB(name,butx,id) AddDlgItem(dlg,CreateButton(x11,name,\
148 if (Flags & MB_OK) CB("OK",x0,MB_OK);
149 if (Flags & MB_CANCEL) CB("Cancel",x/2+2*OFFS_X,MB_CANCEL);
150 if (Flags & MB_YES) CB("Yes",x0,MB_YES);
151 if (Flags & MB_NO) CB("No",x/2+2*OFFS_X,MB_NO);
153 SetDlgSize(dlg,x,y+2*OFFS_Y+
154 QueryDlgItemH(dlg,(Flags & MB_OK) ? MB_OK : MB_YES),TRUE);
156 if (Flags & MB_SYSTEMMODAL)
157 nFlag=DLG_SYSTEMMODAL;
158 else if (Flags & MB_APPLMODAL)
162 nFlag=nFlag | DLG_FREEONBUTTON;
165 if (!(Flags & MB_DONTSHOW))