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,2013, 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
++)
71 wd
= &(bbox
->b
[i
].wd
);
75 XMoveWindow(x11
->disp
, wd
->self
, x0
, y0
);
76 XResizeWindow(x11
->disp
, wd
->self
, wd
->width
, wd
->height
);
81 static gmx_bool
BBCallBack(t_x11
*x11
, XEvent
*event
, Window w
, void *data
)
85 if (event
->type
== ConfigureNotify
)
87 bbox
= (t_butbox
*)data
;
88 bbox
->wd
.width
= event
->xconfigure
.width
;
89 bbox
->wd
.height
= event
->xconfigure
.height
;
95 static gmx_bool
VBCallBack(t_x11
*x11
, XEvent
*event
, Window w
, void *data
)
100 if (event
->type
== Expose
)
102 vbox
= (t_butbox
*)data
;
103 y0
= XTextHeight(x11
->font
)+2*AIR
+1;
104 XSetForeground(x11
->disp
, x11
->gc
, WHITE
);
105 XClearArea(x11
->disp
, vbox
->wd
.self
, 1, 1, vbox
->wd
.width
-2, y0
-1, False
);
106 TextInRect(x11
, vbox
->wd
.self
, vbox
->wd
.text
,
107 1, 1, vbox
->wd
.width
-2, y0
-1, eXLeft
, eYCenter
);
108 XDrawLine(x11
->disp
, vbox
->wd
.self
, x11
->gc
, 0, y0
, vbox
->wd
.width
, y0
);
109 XSetForeground(x11
->disp
, x11
->gc
, x11
->fg
);
114 void set_vbtime(t_x11
*x11
, t_butbox
*vbox
, char *text
)
116 sfree(vbox
->wd
.text
);
117 vbox
->wd
.text
= strdup(text
);
118 ExposeWin(x11
->disp
, vbox
->wd
.self
);
121 static gmx_bool
ButtonCallBack(t_x11
*x11
, XEvent
*event
, Window w
, void *data
)
127 but
= (t_mwbut
*)data
;
132 XSetForeground(x11
->disp
, x11
->gc
, WHITE
);
133 XDrawRoundRect(x11
->disp
, wd
->self
, x11
->gc
,
134 0, 0, wd
->width
-1, wd
->height
-1);
135 TextInWin(x11
, wd
, wd
->text
, eXCenter
, eYCenter
);
136 XSetForeground(x11
->disp
, x11
->gc
, x11
->fg
);
140 /* LightBorder(x11->disp,wd->self,WHITE);*/
141 XSetForeground(x11
->disp
, x11
->gc
, WHITE
);
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
);
147 /* LightBorder(x11->disp,wd->self,BLUE);*/
148 XSetForeground(x11
->disp
, x11
->gc
, BLUE
);
149 XDrawRoundRect(x11
->disp
, wd
->self
, x11
->gc
,
150 1, 1, wd
->width
-3, wd
->height
-3);
151 XSetForeground(x11
->disp
, x11
->gc
, x11
->fg
);
156 letter
.type
= ClientMessage
;
157 letter
.xclient
.display
= x11
->disp
;
158 letter
.xclient
.window
= wd
->Parent
;
159 letter
.xclient
.message_type
= 0;
160 letter
.xclient
.format
= 32;
161 letter
.xclient
.data
.l
[0] = but
->ID
;
162 letter
.xclient
.data
.l
[1] = (long)event
->xbutton
.button
;
163 XSendEvent(x11
->disp
, wd
->Parent
, True
, 0, &letter
);
171 t_butbox
*init_vbox(t_x11
*x11
, Window Parent
, Window SendTo
, unsigned long fg
, unsigned long bg
)
179 vb
->nbut
= IDNR
-IDBUTNR
-1;
180 snew(vb
->b
, vb
->nbut
);
183 y0
= XTextHeight(x11
->font
)+2*AIR
+2;
184 InitWin(&vb
->wd
, 0, 0, vb
->nbut
*(play_width
+AIR
)+AIR
,
185 y0
+play_height
+2*AIR
, 1, "VCR - Control");
186 vb
->wd
.self
= XCreateSimpleWindow(x11
->disp
, Parent
,
187 vb
->wd
.x
, vb
->wd
.y
, vb
->wd
.width
, vb
->wd
.height
,
188 vb
->wd
.bwidth
, WHITE
, BLACK
);
189 x11
->RegisterCallback(x11
, vb
->wd
.self
, Parent
, VBCallBack
, vb
);
190 x11
->SetInputMask(x11
, vb
->wd
.self
, ExposureMask
);
194 for (i
= 0; (i
< vb
->nbut
); i
++)
200 data
= &(rewind_bits
[0]);
209 data
= stop_ani_bits
;
212 fprintf(stderr
, "Invalid bitmap in init_vbox %d\n", ID
);
215 /* Rely on the fact that all bitmaps are equal size */
216 pm
= XCreatePixmapFromBitmapData(x11
->disp
, x11
->root
,
217 (char *)data
, play_width
, play_height
,
218 BLACK
, LIGHTGREY
, x11
->depth
);
220 vb
->b
[i
].wd
.Parent
= SendTo
;
222 XCreateSimpleWindow(x11
->disp
, vb
->wd
.self
,
223 x
, y0
+AIR
, play_width
, play_height
, 0, WHITE
, BLACK
);
224 XSetWindowBackgroundPixmap(x11
->disp
, vb
->b
[i
].wd
.self
, pm
);
226 x11
->RegisterCallback(x11
, vb
->b
[i
].wd
.self
, vb
->wd
.self
,
227 ButtonCallBack
, &(vb
->b
[i
]));
228 x11
->SetInputMask(x11
, vb
->b
[i
].wd
.self
,
229 ButtonPressMask
| StructureNotifyMask
);
236 void show_but(t_x11
*x11
, t_butbox
*bbox
)
238 XMapWindow(x11
->disp
, bbox
->wd
.self
);
239 XMapSubwindows(x11
->disp
, bbox
->wd
.self
);
242 void hide_but(t_x11
*x11
, t_butbox
*bbox
)
244 XUnmapWindow(x11
->disp
, bbox
->wd
.self
);
245 XUnmapSubwindows(x11
->disp
, bbox
->wd
.self
);
248 t_butbox
*init_bbox(t_x11
*x11
, Window Parent
, Window SendTo
,
249 int width
, unsigned long fg
, unsigned long bg
)
252 static const char *lbut
[IDBUTNR
] = {
253 "< X-Rotate >", "< Y-Rotate >", "< Z-Rotate >",
254 "< X-Move >", "< Y-Move >", "< Z-Move >", "< Scale >",
261 bbox
->nbut
= IDBUTNR
;
262 snew(bbox
->b
, bbox
->nbut
);
263 y0
= XTextHeight(x11
->font
)+2*(AIR
+BORDER
);
265 InitWin(&(bbox
->wd
), 0, 0, /*width,(y0+AIR)*IDBUTNR+AIR+2*BORDER,*/ 1, 1,
267 width
-= 2*AIR
+2*BORDER
;
268 bbox
->wd
.self
= XCreateSimpleWindow(x11
->disp
, Parent
,
269 bbox
->wd
.x
, bbox
->wd
.y
, bbox
->wd
.width
,
270 bbox
->wd
.height
, bbox
->wd
.bwidth
,
272 x11
->RegisterCallback(x11
, bbox
->wd
.self
, Parent
, BBCallBack
, bbox
);
273 x11
->SetInputMask(x11
, bbox
->wd
.self
, StructureNotifyMask
);
275 DrawOn
= bbox
->wd
.self
;
277 for (i
= 0; (i
< bbox
->nbut
); i
++)
280 InitWin(&but
->wd
, AIR
, h0
, width
, y0
, 1, lbut
[i
]);
282 but
->wd
.Parent
= SendTo
;
284 but
->wd
.self
= XCreateSimpleWindow(x11
->disp
, DrawOn
,
285 but
->wd
.x
, but
->wd
.y
,
286 but
->wd
.width
, but
->wd
.height
,
287 but
->wd
.bwidth
, bg
, bg
);
288 x11
->RegisterCallback(x11
, but
->wd
.self
, DrawOn
, ButtonCallBack
, but
);
289 x11
->SetInputMask(x11
, but
->wd
.self
, ExposureMask
| ButtonPressMask
|
295 void done_bbox(t_x11
*x11
, t_butbox
*bbox
)
299 for (i
= 0; (i
< bbox
->nbut
); i
++)
301 x11
->UnRegisterCallback(x11
, bbox
->b
[i
].wd
.self
);
303 x11
->UnRegisterCallback(x11
, bbox
->wd
.self
);