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_popup_c
= "$Id$";
39 bool ChildCallBack(t_x11
*x11
,XEvent
*event
, Window w
, void *data
)
46 child
=(t_child
*)data
;
49 switch (event
->type
) {
51 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
52 TextInRect(x11
,w
,m
->str
,16,0,wd
->width
-16-2,wd
->height
-2,
55 int y
=x11
->font
->ascent
;
56 XDrawLine(x11
->disp
,w
,x11
->gc
,2,(y
*2)/3,6,y
);
57 XDrawLine(x11
->disp
,w
,x11
->gc
,3,(y
*2)/3,7,y
);
58 XDrawLine(x11
->disp
,w
,x11
->gc
,7,y
,12,2);
62 LightBorder(x11
->disp
,w
,x11
->fg
);
65 LightBorder(x11
->disp
,w
,x11
->bg
);
68 letter
.type
=ClientMessage
;
69 letter
.xclient
.display
=x11
->disp
;
70 letter
.xclient
.window
=m
->send_to
? m
->send_to
: child
->Parent
;
71 letter
.xclient
.message_type
=0;
72 letter
.xclient
.format
=32;
73 letter
.xclient
.data
.l
[0]=m
->nreturn
;
74 XSendEvent(x11
->disp
,letter
.xclient
.window
,True
,0,&letter
);
82 bool MenuCallBack(t_x11
*x11
,XEvent
*event
, Window w
, void *data
)
89 /* Nothing to be done */
92 GrabOK(stderr
,XGrabPointer(x11
->disp
,m
->wd
.self
,True
,
93 ButtonReleaseMask
,GrabModeAsync
,
94 GrabModeAsync
,m
->wd
.self
,None
,CurrentTime
));
100 event
->xclient
.window
=m
->Parent
;
101 XSendEvent(x11
->disp
,m
->Parent
,True
,0,event
);
109 t_menu
*init_menu(t_x11
*x11
,Window Parent
,unsigned long fg
,unsigned long bg
,
110 int nent
,t_mentry ent
[],int ncol
)
112 int i
,mlen
,mht
,area
,ht
;
123 /* Calculate dimensions of the menu */
125 for(i
=0; (i
<nent
); i
++)
126 mlen
=max(mlen
,XTextWidth(x11
->font
,ent
[i
].str
,strlen(ent
[i
].str
)));
127 mht
=XTextHeight(x11
->font
);
128 /* Now we have the biggest single box, add a border of 2 pixels */
129 mlen
+=20; /* We need extra space at the left for checkmarks */
131 /* Calculate the area of the menu */
134 /* No the number of rows per column, only beyond 8 rows */
148 InitWin(&(m
->wd
),10,10,fcol
*mlen
,frows
*mht
,1,"Menu");
150 m
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,
152 m
->wd
.width
,m
->wd
.height
,
154 x11
->RegisterCallback(x11
,m
->wd
.self
,Parent
,MenuCallBack
,m
);
155 x11
->SetInputMask(x11
,m
->wd
.self
,ExposureMask
|
156 OwnerGrabButtonMask
| ButtonReleaseMask
);
158 for(j
=l
=0; (j
<fcol
); j
++)
159 for(k
=0; (k
<frows
) && (l
<nent
); k
++,l
++) {
164 InitWin(w
,j
*mlen
,k
*mht
,mlen
-2,mht
-2,1,NULL
);
165 w
->self
=XCreateSimpleWindow(x11
->disp
,m
->wd
.self
,
166 w
->x
,w
->y
,w
->width
,w
->height
,
168 x11
->RegisterCallback(x11
,w
->self
,m
->wd
.self
,
170 x11
->SetInputMask(x11
,w
->self
,
171 ButtonPressMask
| ButtonReleaseMask
|
172 OwnerGrabButtonMask
| ExposureMask
|
173 EnterWindowMask
| LeaveWindowMask
);
179 void show_menu(t_x11
*x11
,t_menu
*m
,int x
,int y
,bool bGrab
)
181 XMoveWindow(x11
->disp
,m
->wd
.self
,x
,y
);
183 XMapWindow(x11
->disp
,m
->wd
.self
);
184 XMapSubwindows(x11
->disp
,m
->wd
.self
);
187 void hide_menu(t_x11
*x11
,t_menu
*m
)
190 XUngrabPointer(x11
->disp
,CurrentTime
);
191 XUnmapWindow(x11
->disp
,m
->wd
.self
);
194 void check_menu_item(t_menu
*m
,int nreturn
,bool bStatus
)
198 for(i
=0; (i
<m
->nitem
); i
++)
199 if(m
->item
[i
].m
->nreturn
==nreturn
)
200 m
->item
[i
].m
->bChecked
=bStatus
;
203 void done_menu(t_x11
*x11
,t_menu
*m
)
207 for(i
=0; (i
<m
->nitem
); i
++)
208 x11
->UnRegisterCallback(x11
,m
->item
[i
].wd
.self
);
210 x11
->UnRegisterCallback(x11
,m
->wd
.self
);
214 int menu_width(t_menu
*m
)
219 int menu_height(t_menu
*m
)