2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
49 static gmx_bool
PDCallBack(t_x11
*x11
,XEvent
*event
,Window w
,void *data
)
54 pd
=(t_pulldown
*)data
;
58 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
59 XDrawLine(x11
->disp
,w
,x11
->gc
,0,y
-1,pd
->wd
.width
,y
-1);
60 for(i
=0; (i
<pd
->nmenu
); i
++)
61 XDrawString(x11
->disp
,pd
->wd
.self
,x11
->gc
,pd
->xpos
[i
],x11
->font
->ascent
,
62 pd
->title
[i
],strlen(pd
->title
[i
]));
67 for(nsel
=0; (pd
->xpos
[nsel
+1] < x
) && (nsel
< pd
->nmenu
-1); nsel
++);
69 x1
=max(0,min(pd_width(pd
)-menu_width(pd
->m
[nsel
]),pd
->xpos
[nsel
]));
70 show_menu(x11
,pd
->m
[nsel
],x1
,y
+1,FALSE
);
82 t_pulldown
*init_pd(t_x11
*x11
,Window Parent
,int width
,int height
,
83 unsigned long fg
,unsigned long bg
,
84 int nmenu
,int *nsub
,t_mentry
*ent
[],const char **title
)
94 snew(pd
->xpos
,nmenu
+1);
96 for(i
=1; (i
<=nmenu
); i
++)
97 pd
->xpos
[i
]=20+pd
->xpos
[i
-1]+
98 XTextWidth(x11
->font
,title
[i
-1],strlen(title
[i
-1]));
99 if (pd
->xpos
[nmenu
] > width
)
100 printf("Menu too wide\n");
102 InitWin(&(pd
->wd
),0,0,width
,XTextHeight(x11
->font
)+2,0,"PullDown");
103 pd
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,
105 pd
->wd
.width
,pd
->wd
.height
,
106 pd
->wd
.bwidth
,fg
,bg
);
107 x11
->RegisterCallback(x11
,pd
->wd
.self
,Parent
,PDCallBack
,pd
);
108 x11
->SetInputMask(x11
,pd
->wd
.self
,ExposureMask
| ButtonPressMask
|
109 OwnerGrabButtonMask
| ButtonReleaseMask
);
110 XMapWindow(x11
->disp
,pd
->wd
.self
);
112 for(i
=0; (i
<nmenu
); i
++)
113 pd
->m
[i
]=init_menu(x11
,Parent
,fg
,bg
,nsub
[i
],ent
[i
],1);
118 void hide_pd(t_x11
*x11
,t_pulldown
*pd
)
121 hide_menu(x11
,pd
->m
[pd
->nsel
]);
125 void check_pd_item(t_pulldown
*pd
,int nreturn
,gmx_bool bStatus
)
129 for(i
=0; (i
<pd
->nmenu
); i
++)
130 check_menu_item(pd
->m
[i
],nreturn
,bStatus
);
133 void done_pd(t_x11
*x11
,t_pulldown
*pd
)
137 for(i
=0; (i
<pd
->nmenu
); i
++)
138 done_menu(x11
,pd
->m
[i
]);
139 x11
->UnRegisterCallback(x11
,pd
->wd
.self
);
144 int pd_width(t_pulldown
*pd
)
149 for(i
=0; (i
<pd
->nmenu
); i
++)
150 w
=max(w
,menu_width(pd
->m
[i
]));
151 w
=max(w
,pd
->xpos
[pd
->nmenu
]);
155 int pd_height(t_pulldown
*pd
)
160 for(i
=0; (i
<pd
->nmenu
); i
++)
161 h
=max(h
,menu_height(pd
->m
[i
]));