4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-2001
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
34 * Good gRace! Old Maple Actually Chews Slate
36 static char *SRCID_xmb_c = "$Id$";
57 static bmchar *icon_bits=NULL;
58 static int icon_width=0;
59 static int icon_height=0;
60 static unsigned long icon_fg=0;
61 static unsigned long icon_bg=0;
63 void SetIcon(unsigned char *bits, int w, int h, unsigned long fg, unsigned long bg)
65 icon_bits=(bmchar *)bits;
72 t_dlg *MessageBox(t_x11 *x11, Window Parent, char *title,
73 int nlines, char *lines[], unsigned long Flags,
74 DlgCallback *cb, void *data)
82 /* Check flags for inconsistencies */
83 if (((Flags & MB_OK) && (Flags & MB_YES)) ||
84 ((Flags & MB_NO) && (Flags & MB_CANCEL)) ||
85 (!(Flags & MB_OK) && !(Flags & MB_YES))) {
86 fprintf(stderr,"Invalid button selection in MessageBox\n");
90 if (Flags & MB_ICONSTOP) nicon++;
91 if (Flags & MB_ICONINFORMATION) nicon++;
92 if (Flags & MB_ICONEXCLAMATION) nicon++;
93 if (Flags & MB_ICONGMX) nicon++;
95 fatal_error(0,"More than one (%d) icon selected in MessageBox",nicon);
99 if (Flags & MB_ICONSTOP)
100 SetIcon(stop_bits,stop_width,stop_height,RED,bg);
101 if (Flags & MB_ICONINFORMATION)
102 SetIcon(info_bits,info_width,info_height,BLUE,bg);
103 if (Flags & MB_ICONEXCLAMATION)
104 SetIcon(alert_bits,alert_width,alert_height,GREEN,bg);
105 if (Flags & MB_ICONGMX)
106 SetIcon(gromacs_bits,gromacs_width,gromacs_height,BLUE,bg);
109 dlg=CreateDlg(x11,Parent,title,0,0,0,0,3,x11->fg,bg,cb,data);
112 AddDlgItem(dlg,CreatePixmap
113 (x11,XCreatePixmapFromBitmapData
114 (x11->disp,dlg->win.self,icon_bits,icon_width,icon_height,
115 icon_fg,icon_bg,x11->depth),
116 ID_ICON,ID_BOX,2*OFFS_X,2*OFFS_Y,icon_width,icon_height,0));
117 x+=QueryDlgItemW(dlg,ID_ICON)+2*OFFS_X;
120 AddDlgItem(dlg,CreateStaticText(x11,nlines,lines,ID_TEXT,ID_BOX,
123 y=QueryDlgItemY(dlg,ID_TEXT)+QueryDlgItemH(dlg,ID_TEXT);
126 yi=QueryDlgItemY(dlg,ID_ICON)+QueryDlgItemH(dlg,ID_ICON);
128 SetDlgItemPos(dlg,ID_TEXT,x,2*OFFS_Y+(yi-y)/2);
130 SetDlgItemPos(dlg,ID_ICON,2*OFFS_X,2*OFFS_Y+(y-yi)/2);
133 x+=QueryDlgItemW(dlg,ID_TEXT)+2*OFFS_X;
135 width=(x-8*OFFS_X)/2;
137 if (((Flags & MB_OKCANCEL) == MB_OKCANCEL) ||
138 ((Flags & MB_YESNO) == MB_YESNO))
143 #define CB(name,butx,id) AddDlgItem(dlg,CreateButton(x11,name,\
146 if (Flags & MB_OK) CB("OK",x0,MB_OK);
147 if (Flags & MB_CANCEL) CB("Cancel",x/2+2*OFFS_X,MB_CANCEL);
148 if (Flags & MB_YES) CB("Yes",x0,MB_YES);
149 if (Flags & MB_NO) CB("No",x/2+2*OFFS_X,MB_NO);
151 SetDlgSize(dlg,x,y+2*OFFS_Y+
152 QueryDlgItemH(dlg,(Flags & MB_OK) ? MB_OK : MB_YES),TRUE);
154 if (Flags & MB_SYSTEMMODAL)
155 nFlag=DLG_SYSTEMMODAL;
156 else if (Flags & MB_APPLMODAL)
160 nFlag=nFlag | DLG_FREEONBUTTON;
163 if (!(Flags & MB_DONTSHOW))