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 #include "stop_ani.bm"
54 static void move_bbox(t_x11 *x11,t_butbox *bbox)
61 bw=max(1,bbox->wd.width-2*(AIR+BORDER));
63 bh=(bbox->wd.height-AIR*(bbox->nbut+1));
69 for (i=0; (i<bbox->nbut); i++) {
74 XMoveWindow(x11->disp,wd->self,x0,y0);
75 XResizeWindow(x11->disp,wd->self,wd->width,wd->height);
80 static gmx_bool BBCallBack(t_x11 *x11,XEvent *event, Window w,void *data)
84 if (event->type==ConfigureNotify) {
85 bbox=(t_butbox *)data;
86 bbox->wd.width=event->xconfigure.width;
87 bbox->wd.height=event->xconfigure.height;
93 static gmx_bool VBCallBack(t_x11 *x11,XEvent *event, Window w,void *data)
98 if (event->type==Expose) {
99 vbox=(t_butbox *)data;
100 y0=XTextHeight(x11->font)+2*AIR+1;
101 XSetForeground(x11->disp,x11->gc,WHITE);
102 XClearArea(x11->disp,vbox->wd.self,1,1,vbox->wd.width-2,y0-1,False);
103 TextInRect(x11,vbox->wd.self,vbox->wd.text,
104 1,1,vbox->wd.width-2,y0-1,eXLeft,eYCenter);
105 XDrawLine(x11->disp,vbox->wd.self,x11->gc,0,y0,vbox->wd.width,y0);
106 XSetForeground(x11->disp,x11->gc,x11->fg);
111 void set_vbtime(t_x11 *x11,t_butbox *vbox,char *text)
113 sfree(vbox->wd.text);
114 vbox->wd.text=strdup(text);
115 ExposeWin(x11->disp,vbox->wd.self);
118 static gmx_bool ButtonCallBack(t_x11 *x11,XEvent *event, Window w, void *data)
126 switch(event->type) {
128 XSetForeground(x11->disp,x11->gc,WHITE);
129 XDrawRoundRect(x11->disp, wd->self, x11->gc,
130 0,0,wd->width-1,wd->height-1);
131 TextInWin(x11,wd,wd->text,eXCenter,eYCenter);
132 XSetForeground(x11->disp,x11->gc,x11->fg);
136 /* LightBorder(x11->disp,wd->self,WHITE);*/
137 XSetForeground(x11->disp,x11->gc,WHITE);
138 XDrawRoundRect(x11->disp, wd->self, x11->gc,
139 1,1,wd->width-3,wd->height-3);
140 XSetForeground(x11->disp,x11->gc,x11->fg);
143 /* LightBorder(x11->disp,wd->self,BLUE);*/
144 XSetForeground(x11->disp,x11->gc,BLUE);
145 XDrawRoundRect(x11->disp, wd->self, x11->gc,
146 1,1,wd->width-3,wd->height-3);
147 XSetForeground(x11->disp,x11->gc,x11->fg);
152 letter.type=ClientMessage;
153 letter.xclient.display=x11->disp;
154 letter.xclient.window=wd->Parent;
155 letter.xclient.message_type=0;
156 letter.xclient.format=32;
157 letter.xclient.data.l[0]=but->ID;
158 letter.xclient.data.l[1]=(long)event->xbutton.button;
159 XSendEvent(x11->disp,wd->Parent,True,0,&letter);
167 t_butbox *init_vbox(t_x11 *x11,Window Parent,Window SendTo,unsigned long fg,unsigned long bg)
175 vb->nbut=IDNR-IDBUTNR-1;
176 snew(vb->b,vb->nbut);
179 y0=XTextHeight(x11->font)+2*AIR+2;
180 InitWin(&vb->wd,0,0,vb->nbut*(play_width+AIR)+AIR,
181 y0+play_height+2*AIR,1,"VCR - Control");
182 vb->wd.self=XCreateSimpleWindow(x11->disp,Parent,
183 vb->wd.x,vb->wd.y,vb->wd.width,vb->wd.height,
184 vb->wd.bwidth,WHITE,BLACK);
185 x11->RegisterCallback(x11,vb->wd.self,Parent,VBCallBack,vb);
186 x11->SetInputMask(x11,vb->wd.self,ExposureMask);
190 for(i=0; (i<vb->nbut); i++) {
194 data=&(rewind_bits[0]);
206 fprintf(stderr,"Invalid bitmap in init_vbox %d\n",ID);
209 /* Rely on the fact that all bitmaps are equal size */
210 pm=XCreatePixmapFromBitmapData(x11->disp,x11->root,
211 (char *)data,play_width,play_height,
212 BLACK,LIGHTGREY,x11->depth);
214 vb->b[i].wd.Parent=SendTo;
216 XCreateSimpleWindow(x11->disp,vb->wd.self,
217 x,y0+AIR,play_width,play_height,0,WHITE,BLACK);
218 XSetWindowBackgroundPixmap(x11->disp,vb->b[i].wd.self,pm);
220 x11->RegisterCallback(x11,vb->b[i].wd.self,vb->wd.self,
221 ButtonCallBack,&(vb->b[i]));
222 x11->SetInputMask(x11,vb->b[i].wd.self,
223 ButtonPressMask | StructureNotifyMask);
230 void show_but(t_x11 *x11,t_butbox *bbox)
232 XMapWindow(x11->disp,bbox->wd.self);
233 XMapSubwindows(x11->disp,bbox->wd.self);
236 void hide_but(t_x11 *x11,t_butbox *bbox)
238 XUnmapWindow(x11->disp,bbox->wd.self);
239 XUnmapSubwindows(x11->disp,bbox->wd.self);
242 t_butbox *init_bbox(t_x11 *x11,Window Parent,Window SendTo,
243 int width,unsigned long fg,unsigned long bg)
246 static const char *lbut[IDBUTNR] = {
247 "< X-Rotate >", "< Y-Rotate >", "< Z-Rotate >",
248 "< X-Move >", "< Y-Move >", "< Z-Move >", "< Scale >",
256 snew(bbox->b,bbox->nbut);
257 y0=XTextHeight(x11->font)+2*(AIR+BORDER);
259 InitWin(&(bbox->wd),0,0,/*width,(y0+AIR)*IDBUTNR+AIR+2*BORDER,*/1,1,
261 width-=2*AIR+2*BORDER;
262 bbox->wd.self=XCreateSimpleWindow(x11->disp,Parent,
263 bbox->wd.x,bbox->wd.y,bbox->wd.width,
264 bbox->wd.height,bbox->wd.bwidth,
266 x11->RegisterCallback(x11,bbox->wd.self,Parent,BBCallBack,bbox);
267 x11->SetInputMask(x11,bbox->wd.self,StructureNotifyMask);
269 DrawOn=bbox->wd.self;
271 for (i=0; (i<bbox->nbut); i++) {
273 InitWin(&but->wd,AIR,h0,width,y0,1,lbut[i]);
275 but->wd.Parent=SendTo;
277 but->wd.self=XCreateSimpleWindow(x11->disp,DrawOn,
279 but->wd.width,but->wd.height,
280 but->wd.bwidth,bg,bg);
281 x11->RegisterCallback(x11,but->wd.self,DrawOn,ButtonCallBack,but);
282 x11->SetInputMask(x11,but->wd.self,ExposureMask | ButtonPressMask |
288 void done_bbox(t_x11 *x11,t_butbox *bbox)
292 for(i=0; (i<bbox->nbut); i++)
293 x11->UnRegisterCallback(x11,bbox->b[i].wd.self);
294 x11->UnRegisterCallback(x11,bbox->wd.self);