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_buttons_c
= "$Id$";
38 #include "stop_ani.bm"
43 static void move_bbox(t_x11
*x11
,t_butbox
*bbox
)
50 bw
=max(1,bbox
->wd
.width
-2*(AIR
+BORDER
));
52 bh
=(bbox
->wd
.height
-AIR
*(bbox
->nbut
+1));
58 for (i
=0; (i
<bbox
->nbut
); i
++) {
63 XMoveWindow(x11
->disp
,wd
->self
,x0
,y0
);
64 XResizeWindow(x11
->disp
,wd
->self
,wd
->width
,wd
->height
);
69 static bool BBCallBack(t_x11
*x11
,XEvent
*event
, Window w
,void *data
)
73 if (event
->type
==ConfigureNotify
) {
74 bbox
=(t_butbox
*)data
;
75 bbox
->wd
.width
=event
->xconfigure
.width
;
76 bbox
->wd
.height
=event
->xconfigure
.height
;
82 static bool VBCallBack(t_x11
*x11
,XEvent
*event
, Window w
,void *data
)
87 if (event
->type
==Expose
) {
88 vbox
=(t_butbox
*)data
;
89 y0
=XTextHeight(x11
->font
)+2*AIR
+1;
90 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
91 XClearArea(x11
->disp
,vbox
->wd
.self
,1,1,vbox
->wd
.width
-2,y0
-1,False
);
92 TextInRect(x11
,vbox
->wd
.self
,vbox
->wd
.text
,
93 1,1,vbox
->wd
.width
-2,y0
-1,eXLeft
,eYCenter
);
94 XDrawLine(x11
->disp
,vbox
->wd
.self
,x11
->gc
,0,y0
,vbox
->wd
.width
,y0
);
95 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
100 void set_vbtime(t_x11
*x11
,t_butbox
*vbox
,char *text
)
102 sfree(vbox
->wd
.text
);
103 vbox
->wd
.text
=strdup(text
);
104 ExposeWin(x11
->disp
,vbox
->wd
.self
);
107 static bool ButtonCallBack(t_x11
*x11
,XEvent
*event
, Window w
, void *data
)
115 switch(event
->type
) {
117 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
118 XDrawRoundRect(x11
->disp
, wd
->self
, x11
->gc
,
119 0,0,wd
->width
-1,wd
->height
-1);
120 TextInWin(x11
,wd
,wd
->text
,eXCenter
,eYCenter
);
121 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
125 /* LightBorder(x11->disp,wd->self,WHITE);*/
126 XSetForeground(x11
->disp
,x11
->gc
,WHITE
);
127 XDrawRoundRect(x11
->disp
, wd
->self
, x11
->gc
,
128 1,1,wd
->width
-3,wd
->height
-3);
129 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
132 /* LightBorder(x11->disp,wd->self,BLUE);*/
133 XSetForeground(x11
->disp
,x11
->gc
,BLUE
);
134 XDrawRoundRect(x11
->disp
, wd
->self
, x11
->gc
,
135 1,1,wd
->width
-3,wd
->height
-3);
136 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
141 letter
.type
=ClientMessage
;
142 letter
.xclient
.display
=x11
->disp
;
143 letter
.xclient
.window
=wd
->Parent
;
144 letter
.xclient
.message_type
=0;
145 letter
.xclient
.format
=32;
146 letter
.xclient
.data
.l
[0]=but
->ID
;
147 letter
.xclient
.data
.l
[1]=(long)event
->xbutton
.button
;
148 XSendEvent(x11
->disp
,wd
->Parent
,True
,0,&letter
);
156 t_butbox
*init_vbox(t_x11
*x11
,Window Parent
,Window SendTo
,unsigned long fg
,unsigned long bg
)
164 vb
->nbut
=IDNR
-IDBUTNR
-1;
165 snew(vb
->b
,vb
->nbut
);
168 y0
=XTextHeight(x11
->font
)+2*AIR
+2;
169 InitWin(&vb
->wd
,0,0,vb
->nbut
*(play_width
+AIR
)+AIR
,
170 y0
+play_height
+2*AIR
,1,"VCR - Control");
171 vb
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,
172 vb
->wd
.x
,vb
->wd
.y
,vb
->wd
.width
,vb
->wd
.height
,
173 vb
->wd
.bwidth
,WHITE
,BLACK
);
174 x11
->RegisterCallback(x11
,vb
->wd
.self
,Parent
,VBCallBack
,vb
);
175 x11
->SetInputMask(x11
,vb
->wd
.self
,ExposureMask
);
179 for(i
=0; (i
<vb
->nbut
); i
++) {
183 data
=&(rewind_bits
[0]);
195 fprintf(stderr
,"Invalid bitmap in init_vbox %d\n",ID
);
198 /* Rely on the fact that all bitmaps are equal size */
199 pm
=XCreatePixmapFromBitmapData(x11
->disp
,x11
->root
,
200 (char *)data
,play_width
,play_height
,
201 BLACK
,LIGHTGREY
,x11
->depth
);
203 vb
->b
[i
].wd
.Parent
=SendTo
;
205 XCreateSimpleWindow(x11
->disp
,vb
->wd
.self
,
206 x
,y0
+AIR
,play_width
,play_height
,0,WHITE
,BLACK
);
207 XSetWindowBackgroundPixmap(x11
->disp
,vb
->b
[i
].wd
.self
,pm
);
209 x11
->RegisterCallback(x11
,vb
->b
[i
].wd
.self
,vb
->wd
.self
,
210 ButtonCallBack
,&(vb
->b
[i
]));
211 x11
->SetInputMask(x11
,vb
->b
[i
].wd
.self
,
212 ButtonPressMask
| StructureNotifyMask
);
219 void show_but(t_x11
*x11
,t_butbox
*bbox
)
221 XMapWindow(x11
->disp
,bbox
->wd
.self
);
222 XMapSubwindows(x11
->disp
,bbox
->wd
.self
);
225 void hide_but(t_x11
*x11
,t_butbox
*bbox
)
227 XUnmapWindow(x11
->disp
,bbox
->wd
.self
);
228 XUnmapSubwindows(x11
->disp
,bbox
->wd
.self
);
231 t_butbox
*init_bbox(t_x11
*x11
,Window Parent
,Window SendTo
,
232 int width
,unsigned long fg
,unsigned long bg
)
235 static char *lbut
[IDBUTNR
] = {
236 "< X-Rotate >", "< Y-Rotate >", "< Z-Rotate >",
237 "< X-Move >", "< Y-Move >", "< Z-Move >", "< Scale >",
245 snew(bbox
->b
,bbox
->nbut
);
246 y0
=XTextHeight(x11
->font
)+2*(AIR
+BORDER
);
248 InitWin(&(bbox
->wd
),0,0,/*width,(y0+AIR)*IDBUTNR+AIR+2*BORDER,*/1,1,
250 width
-=2*AIR
+2*BORDER
;
251 bbox
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,
252 bbox
->wd
.x
,bbox
->wd
.y
,bbox
->wd
.width
,
253 bbox
->wd
.height
,bbox
->wd
.bwidth
,
255 x11
->RegisterCallback(x11
,bbox
->wd
.self
,Parent
,BBCallBack
,bbox
);
256 x11
->SetInputMask(x11
,bbox
->wd
.self
,StructureNotifyMask
);
258 DrawOn
=bbox
->wd
.self
;
260 for (i
=0; (i
<bbox
->nbut
); i
++) {
262 InitWin(&but
->wd
,AIR
,h0
,width
,y0
,1,lbut
[i
]);
264 but
->wd
.Parent
=SendTo
;
266 but
->wd
.self
=XCreateSimpleWindow(x11
->disp
,DrawOn
,
268 but
->wd
.width
,but
->wd
.height
,
269 but
->wd
.bwidth
,bg
,bg
);
270 x11
->RegisterCallback(x11
,but
->wd
.self
,DrawOn
,ButtonCallBack
,but
);
271 x11
->SetInputMask(x11
,but
->wd
.self
,ExposureMask
| ButtonPressMask
|
277 void done_bbox(t_x11
*x11
,t_butbox
*bbox
)
281 for(i
=0; (i
<bbox
->nbut
); i
++)
282 x11
->UnRegisterCallback(x11
,bbox
->b
[i
].wd
.self
);
283 x11
->UnRegisterCallback(x11
,bbox
->wd
.self
);