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
46 static gmx_bool
PDCallBack(t_x11
*x11
,XEvent
*event
,Window w
,void *data
)
51 pd
=(t_pulldown
*)data
;
55 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
56 XDrawLine(x11
->disp
,w
,x11
->gc
,0,y
-1,pd
->wd
.width
,y
-1);
57 for(i
=0; (i
<pd
->nmenu
); i
++)
58 XDrawString(x11
->disp
,pd
->wd
.self
,x11
->gc
,pd
->xpos
[i
],x11
->font
->ascent
,
59 pd
->title
[i
],strlen(pd
->title
[i
]));
64 for(nsel
=0; (pd
->xpos
[nsel
+1] < x
) && (nsel
< pd
->nmenu
-1); nsel
++);
66 x1
=max(0,min(pd_width(pd
)-menu_width(pd
->m
[nsel
]),pd
->xpos
[nsel
]));
67 show_menu(x11
,pd
->m
[nsel
],x1
,y
+1,FALSE
);
79 t_pulldown
*init_pd(t_x11
*x11
,Window Parent
,int width
,int height
,
80 unsigned long fg
,unsigned long bg
,
81 int nmenu
,int *nsub
,t_mentry
*ent
[],const char **title
)
91 snew(pd
->xpos
,nmenu
+1);
93 for(i
=1; (i
<=nmenu
); i
++)
94 pd
->xpos
[i
]=20+pd
->xpos
[i
-1]+
95 XTextWidth(x11
->font
,title
[i
-1],strlen(title
[i
-1]));
96 if (pd
->xpos
[nmenu
] > width
)
97 printf("Menu too wide\n");
99 InitWin(&(pd
->wd
),0,0,width
,XTextHeight(x11
->font
)+2,0,"PullDown");
100 pd
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,
102 pd
->wd
.width
,pd
->wd
.height
,
103 pd
->wd
.bwidth
,fg
,bg
);
104 x11
->RegisterCallback(x11
,pd
->wd
.self
,Parent
,PDCallBack
,pd
);
105 x11
->SetInputMask(x11
,pd
->wd
.self
,ExposureMask
| ButtonPressMask
|
106 OwnerGrabButtonMask
| ButtonReleaseMask
);
107 XMapWindow(x11
->disp
,pd
->wd
.self
);
109 for(i
=0; (i
<nmenu
); i
++)
110 pd
->m
[i
]=init_menu(x11
,Parent
,fg
,bg
,nsub
[i
],ent
[i
],1);
115 void hide_pd(t_x11
*x11
,t_pulldown
*pd
)
118 hide_menu(x11
,pd
->m
[pd
->nsel
]);
122 void check_pd_item(t_pulldown
*pd
,int nreturn
,gmx_bool bStatus
)
126 for(i
=0; (i
<pd
->nmenu
); i
++)
127 check_menu_item(pd
->m
[i
],nreturn
,bStatus
);
130 void done_pd(t_x11
*x11
,t_pulldown
*pd
)
134 for(i
=0; (i
<pd
->nmenu
); i
++)
135 done_menu(x11
,pd
->m
[i
]);
136 x11
->UnRegisterCallback(x11
,pd
->wd
.self
);
141 int pd_width(t_pulldown
*pd
)
146 for(i
=0; (i
<pd
->nmenu
); i
++)
147 w
=max(w
,menu_width(pd
->m
[i
]));
148 w
=max(w
,pd
->xpos
[pd
->nmenu
]);
152 int pd_height(t_pulldown
*pd
)
157 for(i
=0; (i
<pd
->nmenu
); i
++)
158 h
=max(h
,menu_height(pd
->m
[i
]));