4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-2001
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
34 * Giving Russians Opium May Alter Current Situation
36 static char *SRCID_buttons_c = "$Id$";
44 #include "stop_ani.bm"
49 static void move_bbox(t_x11 *x11,t_butbox *bbox)
56 bw=max(1,bbox->wd.width-2*(AIR+BORDER));
58 bh=(bbox->wd.height-AIR*(bbox->nbut+1));
64 for (i=0; (i<bbox->nbut); i++) {
69 XMoveWindow(x11->disp,wd->self,x0,y0);
70 XResizeWindow(x11->disp,wd->self,wd->width,wd->height);
75 static bool BBCallBack(t_x11 *x11,XEvent *event, Window w,void *data)
79 if (event->type==ConfigureNotify) {
80 bbox=(t_butbox *)data;
81 bbox->wd.width=event->xconfigure.width;
82 bbox->wd.height=event->xconfigure.height;
88 static bool VBCallBack(t_x11 *x11,XEvent *event, Window w,void *data)
93 if (event->type==Expose) {
94 vbox=(t_butbox *)data;
95 y0=XTextHeight(x11->font)+2*AIR+1;
96 XSetForeground(x11->disp,x11->gc,WHITE);
97 XClearArea(x11->disp,vbox->wd.self,1,1,vbox->wd.width-2,y0-1,False);
98 TextInRect(x11,vbox->wd.self,vbox->wd.text,
99 1,1,vbox->wd.width-2,y0-1,eXLeft,eYCenter);
100 XDrawLine(x11->disp,vbox->wd.self,x11->gc,0,y0,vbox->wd.width,y0);
101 XSetForeground(x11->disp,x11->gc,x11->fg);
106 void set_vbtime(t_x11 *x11,t_butbox *vbox,char *text)
108 sfree(vbox->wd.text);
109 vbox->wd.text=strdup(text);
110 ExposeWin(x11->disp,vbox->wd.self);
113 static bool ButtonCallBack(t_x11 *x11,XEvent *event, Window w, void *data)
121 switch(event->type) {
123 XSetForeground(x11->disp,x11->gc,WHITE);
124 XDrawRoundRect(x11->disp, wd->self, x11->gc,
125 0,0,wd->width-1,wd->height-1);
126 TextInWin(x11,wd,wd->text,eXCenter,eYCenter);
127 XSetForeground(x11->disp,x11->gc,x11->fg);
131 /* LightBorder(x11->disp,wd->self,WHITE);*/
132 XSetForeground(x11->disp,x11->gc,WHITE);
133 XDrawRoundRect(x11->disp, wd->self, x11->gc,
134 1,1,wd->width-3,wd->height-3);
135 XSetForeground(x11->disp,x11->gc,x11->fg);
138 /* LightBorder(x11->disp,wd->self,BLUE);*/
139 XSetForeground(x11->disp,x11->gc,BLUE);
140 XDrawRoundRect(x11->disp, wd->self, x11->gc,
141 1,1,wd->width-3,wd->height-3);
142 XSetForeground(x11->disp,x11->gc,x11->fg);
147 letter.type=ClientMessage;
148 letter.xclient.display=x11->disp;
149 letter.xclient.window=wd->Parent;
150 letter.xclient.message_type=0;
151 letter.xclient.format=32;
152 letter.xclient.data.l[0]=but->ID;
153 letter.xclient.data.l[1]=(long)event->xbutton.button;
154 XSendEvent(x11->disp,wd->Parent,True,0,&letter);
162 t_butbox *init_vbox(t_x11 *x11,Window Parent,Window SendTo,unsigned long fg,unsigned long bg)
170 vb->nbut=IDNR-IDBUTNR-1;
171 snew(vb->b,vb->nbut);
174 y0=XTextHeight(x11->font)+2*AIR+2;
175 InitWin(&vb->wd,0,0,vb->nbut*(play_width+AIR)+AIR,
176 y0+play_height+2*AIR,1,"VCR - Control");
177 vb->wd.self=XCreateSimpleWindow(x11->disp,Parent,
178 vb->wd.x,vb->wd.y,vb->wd.width,vb->wd.height,
179 vb->wd.bwidth,WHITE,BLACK);
180 x11->RegisterCallback(x11,vb->wd.self,Parent,VBCallBack,vb);
181 x11->SetInputMask(x11,vb->wd.self,ExposureMask);
185 for(i=0; (i<vb->nbut); i++) {
189 data=&(rewind_bits[0]);
201 fprintf(stderr,"Invalid bitmap in init_vbox %d\n",ID);
204 /* Rely on the fact that all bitmaps are equal size */
205 pm=XCreatePixmapFromBitmapData(x11->disp,x11->root,
206 (char *)data,play_width,play_height,
207 BLACK,LIGHTGREY,x11->depth);
209 vb->b[i].wd.Parent=SendTo;
211 XCreateSimpleWindow(x11->disp,vb->wd.self,
212 x,y0+AIR,play_width,play_height,0,WHITE,BLACK);
213 XSetWindowBackgroundPixmap(x11->disp,vb->b[i].wd.self,pm);
215 x11->RegisterCallback(x11,vb->b[i].wd.self,vb->wd.self,
216 ButtonCallBack,&(vb->b[i]));
217 x11->SetInputMask(x11,vb->b[i].wd.self,
218 ButtonPressMask | StructureNotifyMask);
225 void show_but(t_x11 *x11,t_butbox *bbox)
227 XMapWindow(x11->disp,bbox->wd.self);
228 XMapSubwindows(x11->disp,bbox->wd.self);
231 void hide_but(t_x11 *x11,t_butbox *bbox)
233 XUnmapWindow(x11->disp,bbox->wd.self);
234 XUnmapSubwindows(x11->disp,bbox->wd.self);
237 t_butbox *init_bbox(t_x11 *x11,Window Parent,Window SendTo,
238 int width,unsigned long fg,unsigned long bg)
241 static char *lbut[IDBUTNR] = {
242 "< X-Rotate >", "< Y-Rotate >", "< Z-Rotate >",
243 "< X-Move >", "< Y-Move >", "< Z-Move >", "< Scale >",
251 snew(bbox->b,bbox->nbut);
252 y0=XTextHeight(x11->font)+2*(AIR+BORDER);
254 InitWin(&(bbox->wd),0,0,/*width,(y0+AIR)*IDBUTNR+AIR+2*BORDER,*/1,1,
256 width-=2*AIR+2*BORDER;
257 bbox->wd.self=XCreateSimpleWindow(x11->disp,Parent,
258 bbox->wd.x,bbox->wd.y,bbox->wd.width,
259 bbox->wd.height,bbox->wd.bwidth,
261 x11->RegisterCallback(x11,bbox->wd.self,Parent,BBCallBack,bbox);
262 x11->SetInputMask(x11,bbox->wd.self,StructureNotifyMask);
264 DrawOn=bbox->wd.self;
266 for (i=0; (i<bbox->nbut); i++) {
268 InitWin(&but->wd,AIR,h0,width,y0,1,lbut[i]);
270 but->wd.Parent=SendTo;
272 but->wd.self=XCreateSimpleWindow(x11->disp,DrawOn,
274 but->wd.width,but->wd.height,
275 but->wd.bwidth,bg,bg);
276 x11->RegisterCallback(x11,but->wd.self,DrawOn,ButtonCallBack,but);
277 x11->SetInputMask(x11,but->wd.self,ExposureMask | ButtonPressMask |
283 void done_bbox(t_x11 *x11,t_butbox *bbox)
287 for(i=0; (i<bbox->nbut); i++)
288 x11->UnRegisterCallback(x11,bbox->b[i].wd.self);
289 x11->UnRegisterCallback(x11,bbox->wd.self);