4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_xmb_c
= "$Id$";
51 static bmchar
*icon_bits
=NULL
;
52 static int icon_width
=0;
53 static int icon_height
=0;
54 static unsigned long icon_fg
=0;
55 static unsigned long icon_bg
=0;
57 void SetIcon(unsigned char *bits
, int w
, int h
, unsigned long fg
, unsigned long bg
)
59 icon_bits
=(bmchar
*)bits
;
66 t_dlg
*MessageBox(t_x11
*x11
, Window Parent
, char *title
,
67 int nlines
, char *lines
[], unsigned long Flags
,
68 DlgCallback
*cb
, void *data
)
76 /* Check flags for inconsistencies */
77 if (((Flags
& MB_OK
) && (Flags
& MB_YES
)) ||
78 ((Flags
& MB_NO
) && (Flags
& MB_CANCEL
)) ||
79 (!(Flags
& MB_OK
) && !(Flags
& MB_YES
))) {
80 fprintf(stderr
,"Invalid button selection in MessageBox\n");
84 if (Flags
& MB_ICONSTOP
) nicon
++;
85 if (Flags
& MB_ICONINFORMATION
) nicon
++;
86 if (Flags
& MB_ICONEXCLAMATION
) nicon
++;
87 if (Flags
& MB_ICONGMX
) nicon
++;
89 fatal_error(0,"More than one (%d) icon selected in MessageBox",nicon
);
93 if (Flags
& MB_ICONSTOP
)
94 SetIcon(stop_bits
,stop_width
,stop_height
,RED
,bg
);
95 if (Flags
& MB_ICONINFORMATION
)
96 SetIcon(info_bits
,info_width
,info_height
,BLUE
,bg
);
97 if (Flags
& MB_ICONEXCLAMATION
)
98 SetIcon(alert_bits
,alert_width
,alert_height
,GREEN
,bg
);
99 if (Flags
& MB_ICONGMX
)
100 SetIcon(gromacs_bits
,gromacs_width
,gromacs_height
,BLUE
,bg
);
103 dlg
=CreateDlg(x11
,Parent
,title
,0,0,0,0,3,x11
->fg
,bg
,cb
,data
);
106 AddDlgItem(dlg
,CreatePixmap
107 (x11
,XCreatePixmapFromBitmapData
108 (x11
->disp
,dlg
->win
.self
,icon_bits
,icon_width
,icon_height
,
109 icon_fg
,icon_bg
,x11
->depth
),
110 ID_ICON
,ID_BOX
,2*OFFS_X
,2*OFFS_Y
,icon_width
,icon_height
,0));
111 x
+=QueryDlgItemW(dlg
,ID_ICON
)+2*OFFS_X
;
114 AddDlgItem(dlg
,CreateStaticText(x11
,nlines
,lines
,ID_TEXT
,ID_BOX
,
117 y
=QueryDlgItemY(dlg
,ID_TEXT
)+QueryDlgItemH(dlg
,ID_TEXT
);
120 yi
=QueryDlgItemY(dlg
,ID_ICON
)+QueryDlgItemH(dlg
,ID_ICON
);
122 SetDlgItemPos(dlg
,ID_TEXT
,x
,2*OFFS_Y
+(yi
-y
)/2);
124 SetDlgItemPos(dlg
,ID_ICON
,2*OFFS_X
,2*OFFS_Y
+(y
-yi
)/2);
127 x
+=QueryDlgItemW(dlg
,ID_TEXT
)+2*OFFS_X
;
129 width
=(x
-8*OFFS_X
)/2;
131 if (((Flags
& MB_OKCANCEL
) == MB_OKCANCEL
) ||
132 ((Flags
& MB_YESNO
) == MB_YESNO
))
137 #define CB(name,butx,id) AddDlgItem(dlg,CreateButton(x11,name,\
140 if (Flags
& MB_OK
) CB("OK",x0
,MB_OK
);
141 if (Flags
& MB_CANCEL
) CB("Cancel",x
/2+2*OFFS_X
,MB_CANCEL
);
142 if (Flags
& MB_YES
) CB("Yes",x0
,MB_YES
);
143 if (Flags
& MB_NO
) CB("No",x
/2+2*OFFS_X
,MB_NO
);
145 SetDlgSize(dlg
,x
,y
+2*OFFS_Y
+
146 QueryDlgItemH(dlg
,(Flags
& MB_OK
) ? MB_OK
: MB_YES
),TRUE
);
148 if (Flags
& MB_SYSTEMMODAL
)
149 nFlag
=DLG_SYSTEMMODAL
;
150 else if (Flags
& MB_APPLMODAL
)
154 nFlag
=nFlag
| DLG_FREEONBUTTON
;
157 if (!(Flags
& MB_DONTSHOW
))