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 #include "stop_ani.bm"
51 static void move_bbox(t_x11
*x11
,t_butbox
*bbox
)
58 bw
=max(1,bbox
->wd
.width
-2*(AIR
+BORDER
));
60 bh
=(bbox
->wd
.height
-AIR
*(bbox
->nbut
+1));
66 for (i
=0; (i
<bbox
->nbut
); i
++) {
71 XMoveWindow(x11
->disp
,wd
->self
,x0
,y0
);
72 XResizeWindow(x11
->disp
,wd
->self
,wd
->width
,wd
->height
);
77 static bool BBCallBack(t_x11
*x11
,XEvent
*event
, Window w
,void *data
)
81 if (event
->type
==ConfigureNotify
) {
82 bbox
=(t_butbox
*)data
;
83 bbox
->wd
.width
=event
->xconfigure
.width
;
84 bbox
->wd
.height
=event
->xconfigure
.height
;
90 static bool VBCallBack(t_x11
*x11
,XEvent
*event
, Window w
,void *data
)
95 if (event
->type
==Expose
) {
96 vbox
=(t_butbox
*)data
;
97 y0
=XTextHeight(x11
->font
)+2*AIR
+1;
98 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
99 XClearArea(x11
->disp
,vbox
->wd
.self
,1,1,vbox
->wd
.width
-2,y0
-1,False
);
100 TextInRect(x11
,vbox
->wd
.self
,vbox
->wd
.text
,
101 1,1,vbox
->wd
.width
-2,y0
-1,eXLeft
,eYCenter
);
102 XDrawLine(x11
->disp
,vbox
->wd
.self
,x11
->gc
,0,y0
,vbox
->wd
.width
,y0
);
103 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
108 void set_vbtime(t_x11
*x11
,t_butbox
*vbox
,char *text
)
110 sfree(vbox
->wd
.text
);
111 vbox
->wd
.text
=strdup(text
);
112 ExposeWin(x11
->disp
,vbox
->wd
.self
);
115 static bool ButtonCallBack(t_x11
*x11
,XEvent
*event
, Window w
, void *data
)
123 switch(event
->type
) {
125 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
126 XDrawRoundRect(x11
->disp
, wd
->self
, x11
->gc
,
127 0,0,wd
->width
-1,wd
->height
-1);
128 TextInWin(x11
,wd
,wd
->text
,eXCenter
,eYCenter
);
129 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
133 /* LightBorder(x11->disp,wd->self,WHITE);*/
134 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
135 XDrawRoundRect(x11
->disp
, wd
->self
, x11
->gc
,
136 1,1,wd
->width
-3,wd
->height
-3);
137 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
140 /* LightBorder(x11->disp,wd->self,BLUE);*/
141 XSetForeground(x11
->disp
,x11
->gc
,BLUE
);
142 XDrawRoundRect(x11
->disp
, wd
->self
, x11
->gc
,
143 1,1,wd
->width
-3,wd
->height
-3);
144 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
149 letter
.type
=ClientMessage
;
150 letter
.xclient
.display
=x11
->disp
;
151 letter
.xclient
.window
=wd
->Parent
;
152 letter
.xclient
.message_type
=0;
153 letter
.xclient
.format
=32;
154 letter
.xclient
.data
.l
[0]=but
->ID
;
155 letter
.xclient
.data
.l
[1]=(long)event
->xbutton
.button
;
156 XSendEvent(x11
->disp
,wd
->Parent
,True
,0,&letter
);
164 t_butbox
*init_vbox(t_x11
*x11
,Window Parent
,Window SendTo
,unsigned long fg
,unsigned long bg
)
172 vb
->nbut
=IDNR
-IDBUTNR
-1;
173 snew(vb
->b
,vb
->nbut
);
176 y0
=XTextHeight(x11
->font
)+2*AIR
+2;
177 InitWin(&vb
->wd
,0,0,vb
->nbut
*(play_width
+AIR
)+AIR
,
178 y0
+play_height
+2*AIR
,1,"VCR - Control");
179 vb
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,
180 vb
->wd
.x
,vb
->wd
.y
,vb
->wd
.width
,vb
->wd
.height
,
181 vb
->wd
.bwidth
,WHITE
,BLACK
);
182 x11
->RegisterCallback(x11
,vb
->wd
.self
,Parent
,VBCallBack
,vb
);
183 x11
->SetInputMask(x11
,vb
->wd
.self
,ExposureMask
);
187 for(i
=0; (i
<vb
->nbut
); i
++) {
191 data
=&(rewind_bits
[0]);
203 fprintf(stderr
,"Invalid bitmap in init_vbox %d\n",ID
);
206 /* Rely on the fact that all bitmaps are equal size */
207 pm
=XCreatePixmapFromBitmapData(x11
->disp
,x11
->root
,
208 (char *)data
,play_width
,play_height
,
209 BLACK
,LIGHTGREY
,x11
->depth
);
211 vb
->b
[i
].wd
.Parent
=SendTo
;
213 XCreateSimpleWindow(x11
->disp
,vb
->wd
.self
,
214 x
,y0
+AIR
,play_width
,play_height
,0,WHITE
,BLACK
);
215 XSetWindowBackgroundPixmap(x11
->disp
,vb
->b
[i
].wd
.self
,pm
);
217 x11
->RegisterCallback(x11
,vb
->b
[i
].wd
.self
,vb
->wd
.self
,
218 ButtonCallBack
,&(vb
->b
[i
]));
219 x11
->SetInputMask(x11
,vb
->b
[i
].wd
.self
,
220 ButtonPressMask
| StructureNotifyMask
);
227 void show_but(t_x11
*x11
,t_butbox
*bbox
)
229 XMapWindow(x11
->disp
,bbox
->wd
.self
);
230 XMapSubwindows(x11
->disp
,bbox
->wd
.self
);
233 void hide_but(t_x11
*x11
,t_butbox
*bbox
)
235 XUnmapWindow(x11
->disp
,bbox
->wd
.self
);
236 XUnmapSubwindows(x11
->disp
,bbox
->wd
.self
);
239 t_butbox
*init_bbox(t_x11
*x11
,Window Parent
,Window SendTo
,
240 int width
,unsigned long fg
,unsigned long bg
)
243 static const char *lbut
[IDBUTNR
] = {
244 "< X-Rotate >", "< Y-Rotate >", "< Z-Rotate >",
245 "< X-Move >", "< Y-Move >", "< Z-Move >", "< Scale >",
253 snew(bbox
->b
,bbox
->nbut
);
254 y0
=XTextHeight(x11
->font
)+2*(AIR
+BORDER
);
256 InitWin(&(bbox
->wd
),0,0,/*width,(y0+AIR)*IDBUTNR+AIR+2*BORDER,*/1,1,
258 width
-=2*AIR
+2*BORDER
;
259 bbox
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,
260 bbox
->wd
.x
,bbox
->wd
.y
,bbox
->wd
.width
,
261 bbox
->wd
.height
,bbox
->wd
.bwidth
,
263 x11
->RegisterCallback(x11
,bbox
->wd
.self
,Parent
,BBCallBack
,bbox
);
264 x11
->SetInputMask(x11
,bbox
->wd
.self
,StructureNotifyMask
);
266 DrawOn
=bbox
->wd
.self
;
268 for (i
=0; (i
<bbox
->nbut
); i
++) {
270 InitWin(&but
->wd
,AIR
,h0
,width
,y0
,1,lbut
[i
]);
272 but
->wd
.Parent
=SendTo
;
274 but
->wd
.self
=XCreateSimpleWindow(x11
->disp
,DrawOn
,
276 but
->wd
.width
,but
->wd
.height
,
277 but
->wd
.bwidth
,bg
,bg
);
278 x11
->RegisterCallback(x11
,but
->wd
.self
,DrawOn
,ButtonCallBack
,but
);
279 x11
->SetInputMask(x11
,but
->wd
.self
,ExposureMask
| ButtonPressMask
|
285 void done_bbox(t_x11
*x11
,t_butbox
*bbox
)
289 for(i
=0; (i
<bbox
->nbut
); i
++)
290 x11
->UnRegisterCallback(x11
,bbox
->b
[i
].wd
.self
);
291 x11
->UnRegisterCallback(x11
,bbox
->wd
.self
);