static void AddDlgItemGroups(t_dlg *dlg, int gridx, int gridy, t_dlgitemlist **grid, bool bAutoPosition) { t_dlgitemlist *item; int x1,y1,w1,h1; int x,y,dw,dh; float w,h; w=h=0; for(x=0; (x<gridx); x++) for(y=0; (y<gridy); y++) { item=&(grid[x][y]); if (item->nitem) { if (!item->list) { printf("Error: empty list with non-empty nitem (%d)\n",item->nitem); printf(" at grid point: %d,%d\n",x,y); printf(" with size: %dx%d\n",item->w,item->h); exit(1); } else { AddDlgItems(dlg,item->nitem,item->list); dw=item->w; dh=item->h; w=max(w,((float) QueryDlgItemW(dlg,item->list[0]->ID))/dw); h=max(h,((float) QueryDlgItemH(dlg,item->list[0]->ID))/dh); } } } w1=gridx*w; h1=gridy*h; SetDlgSize(dlg,w1,h1,bAutoPosition); #ifdef DEBUG printf("Dimensions of grid cell: %8.3f x %8.3f\n",w,h); printf("Dimensions of window: %d x %d\n",w1,h1); #endif for(x=0; (x<gridx); x++) for(y=0; (y<gridy); y++) { item=&(grid[x][y]); if (item->nitem) { x1=x*w; y1=y*h; w1=item->w*w; h1=item->h*h; #ifdef DEBUG printf("New size: %d x %d at %d, %d\n",w1,h1,x1,y1); #endif SetDlgItemSize(dlg,item->list[0]->ID,w1,h1); SetDlgItemPos(dlg,item->list[0]->ID,x1,y1); } } }
t_dlg *MessageBox(t_x11 *x11, Window Parent, char *title, int nlines, char *lines[], unsigned long Flags, DlgCallback *cb, void *data) { t_dlg *dlg; int width,nicon; int x,y,x0; unsigned long nFlag; unsigned long bg; /* Check flags for inconsistencies */ if (((Flags & MB_OK) && (Flags & MB_YES)) || ((Flags & MB_NO) && (Flags & MB_CANCEL)) || (!(Flags & MB_OK) && !(Flags & MB_YES))) { fprintf(stderr,"Invalid button selection in MessageBox\n"); exit(1); } nicon=0; if (Flags & MB_ICONSTOP) nicon++; if (Flags & MB_ICONINFORMATION) nicon++; if (Flags & MB_ICONEXCLAMATION) nicon++; if (Flags & MB_ICONGMX) nicon++; if (nicon > 1) gmx_fatal(FARGS,"More than one (%d) icon selected in MessageBox",nicon); /* Input seems ok */ bg=x11->bg; if (nicon > 0) { if (Flags & MB_ICONSTOP) SetIcon(stop_bits,stop_width,stop_height,RED,bg); if (Flags & MB_ICONINFORMATION) SetIcon(info_bits,info_width,info_height,BLUE,bg); if (Flags & MB_ICONEXCLAMATION) SetIcon(alert_bits,alert_width,alert_height,GREEN,bg); if (Flags & MB_ICONGMX) SetIcon(gromacs_bits,gromacs_width,gromacs_height,BLUE,bg); } dlg=CreateDlg(x11,Parent,title,0,0,0,0,3,x11->fg,bg,cb,data); x=2*OFFS_X; if (nicon > 0) { AddDlgItem(dlg,CreatePixmap (x11,XCreatePixmapFromBitmapData (x11->disp,dlg->win.self,icon_bits,icon_width,icon_height, icon_fg,icon_bg,x11->depth), ID_ICON,ID_BOX,2*OFFS_X,2*OFFS_Y,icon_width,icon_height,0)); x+=QueryDlgItemW(dlg,ID_ICON)+2*OFFS_X; } AddDlgItem(dlg,CreateStaticText(x11,nlines,lines,ID_TEXT,ID_BOX, x,2*OFFS_Y,0,0,0)); y=QueryDlgItemY(dlg,ID_TEXT)+QueryDlgItemH(dlg,ID_TEXT); if (nicon > 0) { int yi; yi=QueryDlgItemY(dlg,ID_ICON)+QueryDlgItemH(dlg,ID_ICON); if (yi > y) SetDlgItemPos(dlg,ID_TEXT,x,2*OFFS_Y+(yi-y)/2); else SetDlgItemPos(dlg,ID_ICON,2*OFFS_X,2*OFFS_Y+(y-yi)/2); y=max(y,yi); } x+=QueryDlgItemW(dlg,ID_TEXT)+2*OFFS_X; y+=2*OFFS_Y; width=(x-8*OFFS_X)/2; if (((Flags & MB_OKCANCEL) == MB_OKCANCEL) || ((Flags & MB_YESNO) == MB_YESNO)) x0=2*OFFS_X; else x0=(x-width)/2; #define CB(name,butx,id) AddDlgItem(dlg,CreateButton(x11,name,\ TRUE,id,ID_BOX,\ butx,y,width,0,0)) if (Flags & MB_OK) CB("OK",x0,MB_OK); if (Flags & MB_CANCEL) CB("Cancel",x/2+2*OFFS_X,MB_CANCEL); if (Flags & MB_YES) CB("Yes",x0,MB_YES); if (Flags & MB_NO) CB("No",x/2+2*OFFS_X,MB_NO); SetDlgSize(dlg,x,y+2*OFFS_Y+ QueryDlgItemH(dlg,(Flags & MB_OK) ? MB_OK : MB_YES),TRUE); if (Flags & MB_SYSTEMMODAL) nFlag=DLG_SYSTEMMODAL; else if (Flags & MB_APPLMODAL) nFlag=DLG_APPLMODAL; else nFlag=0; nFlag=nFlag | DLG_FREEONBUTTON; dlg->flags=nFlag; if (!(Flags & MB_DONTSHOW)) ShowDlg(dlg); return dlg; }