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-2013, 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)
55 real idb, bh, one = 1.0;
58 bw = std::max(1, bbox->wd.width-2*(AIR+BORDER));
60 bh = (bbox->wd.height-AIR*(bbox->nbut+1));
62 bh = std::max(bh, one);
66 for (i = 0; (i < bbox->nbut); i++)
68 wd = &(bbox->b[i].wd);
72 XMoveWindow(x11->disp, wd->self, x0, y0);
73 XResizeWindow(x11->disp, wd->self, wd->width, wd->height);
78 static bool BBCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
82 if (event->type == ConfigureNotify)
84 bbox = (t_butbox *)data;
85 bbox->wd.width = event->xconfigure.width;
86 bbox->wd.height = event->xconfigure.height;
92 static bool VBCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
97 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 bool ButtonCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
124 but = (t_mwbut *)data;
129 XSetForeground(x11->disp, x11->gc, WHITE);
130 XDrawRoundRect(x11->disp, wd->self, x11->gc,
131 0, 0, wd->width-1, wd->height-1);
132 TextInWin(x11, wd, wd->text, eXCenter, eYCenter);
133 XSetForeground(x11->disp, x11->gc, x11->fg);
137 /* LightBorder(x11->disp,wd->self,WHITE);*/
138 XSetForeground(x11->disp, x11->gc, WHITE);
139 XDrawRoundRect(x11->disp, wd->self, x11->gc,
140 1, 1, wd->width-3, wd->height-3);
141 XSetForeground(x11->disp, x11->gc, x11->fg);
144 /* LightBorder(x11->disp,wd->self,BLUE);*/
145 XSetForeground(x11->disp, x11->gc, BLUE);
146 XDrawRoundRect(x11->disp, wd->self, x11->gc,
147 1, 1, wd->width-3, wd->height-3);
148 XSetForeground(x11->disp, x11->gc, x11->fg);
153 letter.type = ClientMessage;
154 letter.xclient.display = x11->disp;
155 letter.xclient.window = wd->Parent;
156 letter.xclient.message_type = 0;
157 letter.xclient.format = 32;
158 letter.xclient.data.l[0] = but->ID;
159 letter.xclient.data.l[1] = (long)event->xbutton.button;
160 XSendEvent(x11->disp, wd->Parent, True, 0, &letter);
168 t_butbox *init_vbox(t_x11 *x11, Window Parent, Window SendTo, unsigned long fg, unsigned long bg)
176 vb->nbut = IDNR-IDBUTNR-1;
177 snew(vb->b, vb->nbut);
180 y0 = XTextHeight(x11->font)+2*AIR+2;
181 InitWin(&vb->wd, 0, 0, vb->nbut*(play_width+AIR)+AIR,
182 y0+play_height+2*AIR, 1, "VCR - Control");
183 vb->wd.self = XCreateSimpleWindow(x11->disp, Parent,
184 vb->wd.x, vb->wd.y, vb->wd.width, vb->wd.height,
185 vb->wd.bwidth, WHITE, BLACK);
186 x11->RegisterCallback(x11, vb->wd.self, Parent, VBCallBack, vb);
187 x11->SetInputMask(x11, vb->wd.self, ExposureMask);
191 for (i = 0; (i < vb->nbut); i++)
197 data = &(rewind_bits[0]);
206 data = stop_ani_bits;
209 fprintf(stderr, "Invalid bitmap in init_vbox %d\n", ID);
212 /* Rely on the fact that all bitmaps are equal size */
213 pm = XCreatePixmapFromBitmapData(x11->disp, x11->root,
214 (char *)data, play_width, play_height,
215 BLACK, LIGHTGREY, x11->depth);
217 vb->b[i].wd.Parent = SendTo;
219 XCreateSimpleWindow(x11->disp, vb->wd.self,
220 x, y0+AIR, play_width, play_height, 0, WHITE, BLACK);
221 XSetWindowBackgroundPixmap(x11->disp, vb->b[i].wd.self, pm);
223 x11->RegisterCallback(x11, vb->b[i].wd.self, vb->wd.self,
224 ButtonCallBack, &(vb->b[i]));
225 x11->SetInputMask(x11, vb->b[i].wd.self,
226 ButtonPressMask | StructureNotifyMask);
233 void show_but(t_x11 *x11, t_butbox *bbox)
235 XMapWindow(x11->disp, bbox->wd.self);
236 XMapSubwindows(x11->disp, bbox->wd.self);
239 void hide_but(t_x11 *x11, t_butbox *bbox)
241 XUnmapWindow(x11->disp, bbox->wd.self);
242 XUnmapSubwindows(x11->disp, bbox->wd.self);
245 t_butbox *init_bbox(t_x11 *x11, Window Parent, Window SendTo,
246 int width, unsigned long fg, unsigned long bg)
249 static const char *lbut[IDBUTNR] = {
250 "< X-Rotate >", "< Y-Rotate >", "< Z-Rotate >",
251 "< X-Move >", "< Y-Move >", "< Z-Move >", "< Scale >",
258 bbox->nbut = IDBUTNR;
259 snew(bbox->b, bbox->nbut);
260 y0 = XTextHeight(x11->font)+2*(AIR+BORDER);
262 InitWin(&(bbox->wd), 0, 0, /*width,(y0+AIR)*IDBUTNR+AIR+2*BORDER,*/ 1, 1,
264 width -= 2*AIR+2*BORDER;
265 bbox->wd.self = XCreateSimpleWindow(x11->disp, Parent,
266 bbox->wd.x, bbox->wd.y, bbox->wd.width,
267 bbox->wd.height, bbox->wd.bwidth,
269 x11->RegisterCallback(x11, bbox->wd.self, Parent, BBCallBack, bbox);
270 x11->SetInputMask(x11, bbox->wd.self, StructureNotifyMask);
272 DrawOn = bbox->wd.self;
274 for (i = 0; (i < bbox->nbut); i++)
277 InitWin(&but->wd, AIR, h0, width, y0, 1, lbut[i]);
279 but->wd.Parent = SendTo;
281 but->wd.self = XCreateSimpleWindow(x11->disp, DrawOn,
282 but->wd.x, but->wd.y,
283 but->wd.width, but->wd.height,
284 but->wd.bwidth, bg, bg);
285 x11->RegisterCallback(x11, but->wd.self, DrawOn, ButtonCallBack, but);
286 x11->SetInputMask(x11, but->wd.self, ExposureMask | ButtonPressMask |
292 void done_bbox(t_x11 *x11, t_butbox *bbox)
296 for (i = 0; (i < bbox->nbut); i++)
298 x11->UnRegisterCallback(x11, bbox->b[i].wd.self);
300 x11->UnRegisterCallback(x11, bbox->wd.self);