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
48 int CheckWin(Window win
,const char *file
, int line
)
55 { BadAlloc
, "Bad Alloc" },
56 { BadColor
, "Bad Color" },
57 { BadCursor
, "Bad Cursor"},
58 { BadMatch
, "Bad Match" },
59 { BadPixmap
, "Bad Pixmap"},
60 { BadValue
, "Bad Value" },
61 { BadWindow
, "Bad Window"}
63 #define NERR (sizeof(winerr)/sizeof(winerr[0]))
66 for(i
=0; (i
<NERR
); i
++)
67 if (win
==winerr
[i
].n
) {
68 fprintf(stderr
,"%s",winerr
[i
].s
);
71 if (i
==NERR
) return 1;
73 fprintf(stderr
," in file %s, line %d\n",file
,line
);
77 void LightBorder(Display
*disp
, Window win
, unsigned long color
)
79 XSetWindowAttributes attributes
;
81 attributes
.border_pixel
= color
;
82 XChangeWindowAttributes(disp
,win
,CWBorderPixel
,&attributes
);
85 void SpecialTextInRect(t_x11
*x11
,XFontStruct
*font
,Drawable win
,
86 const char *s
,int x
,int y
,int width
,int height
,
93 XSetFont(x11
->disp
,x11
->gc
,font
->fid
);
99 fw
=XTextWidth(f
,s
,strlen(s
));
118 y0
=y
+height
-f
->descent
;
122 y0
=y
+(height
-fh
)/2+f
->ascent
;
125 XDrawString(x11
->disp
,win
,x11
->gc
,x0
,y0
,s
,strlen(s
));
127 XSetFont(x11
->disp
,x11
->gc
,x11
->font
->fid
);
130 void TextInRect(t_x11
*x11
,Drawable win
,
131 const char *s
,int x
,int y
,int width
,int height
,
134 SpecialTextInRect(x11
,NULL
,win
,s
,x
,y
,width
,height
,eX
,eY
);
137 void TextInWin(t_x11
*x11
, t_windata
*win
,
138 const char *s
, eXPos eX
, eYPos eY
)
140 TextInRect(x11
,win
->self
,s
,0,0,win
->width
,win
->height
,eX
,eY
);
143 void InitWin(t_windata
*win
, int x0
,int y0
, int w
, int h
, int bw
, const char *text
)
155 win
->text
=strdup(text
);
159 printf("%s: %d x %d at %d, %d\n",text
,w
,h
,x0
,y0
);
163 void FreeWin(Display
*disp
, t_windata
*win
)
168 XFreeCursor(disp
,win
->cursor
);
171 void ExposeWin(Display
*disp
,Window win
)
176 event
.xexpose
.send_event
=True
;
177 event
.xexpose
.window
= win
;
180 event
.xexpose
.width
=1000;
181 event
.xexpose
.height
=1000;
182 event
.xexpose
.count
= 0;
183 XSendEvent(disp
,win
,False
,ExposureMask
,&event
);
186 void XDrawRoundRect(Display
*disp
, Window win
, GC gc
,
187 int x
, int y
, int w
, int h
)
189 #define RAD (OFFS_X/2)
190 #define SetPoint(pn,x0,y0) pn.x=x0; pn.y=y0
192 if ((w
<10) || (h
<10))
193 XDrawRectangle(disp
,win
,gc
,x
,y
,w
,h
);
197 SetPoint(p
[0],x
+RAD
,y
);
198 SetPoint(p
[1],w
-2*RAD
,0);
199 SetPoint(p
[2],RAD
,RAD
);
200 SetPoint(p
[3],0,h
-2*RAD
);
201 SetPoint(p
[4],-RAD
,RAD
);
202 SetPoint(p
[5],2*RAD
-w
,0);
203 SetPoint(p
[6],-RAD
,-RAD
);
204 SetPoint(p
[7],0,2*RAD
-h
);
205 SetPoint(p
[8],RAD
,-RAD
);
206 XDrawLines(disp
,win
,gc
,p
,9,CoordModePrevious
);
210 void RoundRectWin(Display
*disp
, GC gc
, t_windata
*win
,
211 int offsx
, int offsy
,unsigned long color
)
213 XSetLineAttributes(disp
,gc
,1,LineOnOffDash
,CapButt
,JoinRound
);
214 XSetForeground(disp
,gc
,color
);
215 XDrawRoundRect(disp
,win
->self
,gc
,offsx
,offsy
,
216 win
->width
-2*offsx
-1,win
->height
-2*offsy
-1);
217 XSetLineAttributes(disp
,gc
,1,LineSolid
,CapButt
,JoinRound
);
220 void RectWin(Display
*disp
, GC gc
, t_windata
*win
, unsigned long color
)
222 int bw
=1; /*2*w.bwidth;*/
224 XSetForeground(disp
,gc
,color
);
225 XDrawRoundRect(disp
,win
->self
,gc
,0,0,win
->width
-bw
,win
->height
-bw
);
228 typedef struct t_mpos
{
233 static t_mpos
*mpos
=NULL
;
235 void PushMouse(Display
*disp
, Window dest
, int x
, int y
)
244 XQueryPointer(disp
,DefaultRootWindow(disp
),&root
,&child
,&root_x
,&root_y
,
245 &win_x
,&win_y
,&keybut
);
250 XWarpPointer(disp
,None
,dest
,0,0,0,0,x
,y
);
252 fprintf(stderr
,"Pushmouse %d, %d\n",x
,y
);
256 void PopMouse(Display
*disp
)
263 XWarpPointer(disp
,None
,DefaultRootWindow(disp
),0,0,0,0,old
->x
,old
->y
);
265 fprintf(stderr
,"Popmouse %d, %d\n",old
->x
,old
->y
);
271 gmx_bool
HelpPressed(XEvent
*event
)
275 XComposeStatus compose
;
278 (void)XLookupString(&(event
->xkey
),buf
,BUFSIZE
,&keysym
,&compose
);
280 return (keysym
== XK_F1
);
283 gmx_bool
GrabOK(FILE *out
, int err
)
288 case GrabNotViewable
:
289 fprintf(out
,"GrabNotViewable\n"); break;
291 fprintf(out
,"AlreadyGrabbed\n"); break;
293 fprintf(out
,"GrabFrozen\n"); break;
294 case GrabInvalidTime
:
295 fprintf(out
,"GrabInvalidTime\n"); break;