minor fixes in ditribution files
[gromacs/qmmm-gamess-us.git] / src / ngmx / logo.c
blobe93ed7ab882a488a1743087092dc969c1b9a565d
1 /*
2 *
3 * This source code is part of
4 *
5 * G R O M A C S
6 *
7 * GROningen MAchine for Chemical Simulations
8 *
9 * VERSION 3.2.0
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
32 * And Hey:
33 * Gyas ROwers Mature At Cryogenic Speed
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
39 #include "sysstuff.h"
40 #include "xutil.h"
41 #include "Xstuff.h"
42 #include "smalloc.h"
43 #include "macros.h"
44 #include "copyrite.h"
45 #include "logo.h"
47 typedef struct {
48 int x,y,rad;
49 unsigned long *col;
50 } t_circle;
52 typedef struct {
53 const char *text;
54 int y,h;
55 XFontStruct *fnt;
56 } t_mess;
58 void show_logo(t_x11 *x11,t_logo *logo)
60 XMapWindow(x11->disp,logo->wd.self);
61 XMapSubwindows(x11->disp,logo->wd.self);
64 void hide_logo(t_x11 *x11,t_logo *logo)
66 XUnmapWindow(x11->disp,logo->wd.self);
69 static bool LogoCallBack(t_x11 *x11,XEvent *event, Window w, void *data)
71 /* Assume window is 100x110 */
72 static bool bFirst=TRUE;
73 #define CSIZE 9
74 #define NSIZE 8
75 #define OSIZE 9
76 #define HSIZE 7
77 #define YOFFS 30
78 static t_circle c[] = {
79 { 10,YOFFS+12,CSIZE,&LIGHTGREEN },
80 { 20,YOFFS+22,CSIZE,&LIGHTGREEN },
81 { 20,YOFFS+34,OSIZE,&LIGHTRED },
82 { 30,YOFFS+12,NSIZE,&LIGHTCYAN },
83 { 30,YOFFS+ 2,HSIZE ,&WHITE },
84 { 40,YOFFS+22,CSIZE,&LIGHTGREEN },
85 { 40,YOFFS+34,CSIZE,&LIGHTGREEN },
86 { 50,YOFFS+12,CSIZE,&LIGHTGREEN },
87 { 50,YOFFS ,OSIZE,&LIGHTRED },
88 { 60,YOFFS+22,NSIZE,&LIGHTCYAN },
89 { 60,YOFFS+32,HSIZE, &WHITE },
90 { 70,YOFFS+12,CSIZE,&LIGHTGREEN },
91 { 80,YOFFS+22,CSIZE,&LIGHTGREEN },
92 { 80,YOFFS+34,OSIZE,&LIGHTRED },
93 { 90,YOFFS+12,NSIZE,&LIGHTCYAN },
94 { 90,YOFFS+ 2,HSIZE,&WHITE },
95 {100,YOFFS+22,CSIZE,&LIGHTGREEN }
97 static int lines[] = {
98 0,1, 1,2, 1,3, 3,4, 3,5, 5,6, 5,7, 7,8, 7,9,
99 9,10, 9,11, 11,12, 12,13, 12,14, 14,15, 14,16
101 #define COFFS 70
102 static t_mess Mess[] = {
103 { "GROMACS", 0, 20, NULL },
104 { NULL, 16, 9, NULL },
105 { "Copyright (c) 1991-2004", COFFS+ 2, 9, NULL },
106 { "D.v.d.Spoel, E.Lindahl, B.Hess", COFFS+11, 9, NULL },
107 { "& Groningen University ", COFFS+20, 9, NULL },
108 { "click to dismiss", COFFS+31, 8, NULL }
110 #define NMESS asize(Mess)
111 int i;
112 real wfac,hfac;
113 t_logo *logo;
114 t_windata *wd;
116 logo=(t_logo *)data;
117 wd=&(logo->wd);
118 if (bFirst) {
119 wfac=wd->width/110.0;
120 hfac=wd->height/110.0;
121 for(i=0; (i<asize(c)); i++) {
122 c[i].x *= wfac;
123 c[i].y *= hfac;
125 Mess[1].text=GromacsVersion();
126 for(i=0; (i<NMESS); i++) {
127 Mess[i].y *= hfac;
128 Mess[i].h *= hfac;
129 Mess[i].fnt = (i==0) ? logo->bigfont : (i==NMESS-1) ? x11->font :
130 logo->smallfont;
132 bFirst=FALSE;
134 switch (event->type) {
135 case Expose:
136 XSetForeground(x11->disp,x11->gc,WHITE);
137 XSetLineAttributes(x11->disp,x11->gc,3,LineSolid,CapNotLast,JoinRound);
138 for(i=0; (i<asize(lines)); i+=2) {
139 XDrawLine(x11->disp,wd->self,x11->gc,
140 c[lines[i]].x,c[lines[i]].y,c[lines[i+1]].x,c[lines[i+1]].y);
142 XSetLineAttributes(x11->disp,x11->gc,1,LineSolid,CapNotLast,JoinRound);
143 for(i=0; (i<asize(c)); i++) {
144 XSetForeground(x11->disp,x11->gc,*(c[i].col));
145 XFillCircle(x11->disp,wd->self,x11->gc,c[i].x,c[i].y,c[i].rad);
147 XSetForeground(x11->disp,x11->gc,BLACK);
148 XDrawRectangle(x11->disp,wd->self,x11->gc,2,2,wd->width-5,wd->height-5);
149 for(i=0; (i<asize(Mess)); i++)
150 SpecialTextInRect(x11,Mess[i].fnt,wd->self,Mess[i].text,
151 0,Mess[i].y,wd->width,Mess[i].h,
152 eXCenter,eYCenter);
153 XSetForeground(x11->disp,x11->gc,x11->fg);
154 break;
155 case ButtonPress:
156 hide_logo(x11,logo);
157 break;
158 default:
159 break;
162 return FALSE;
165 t_logo *init_logo(t_x11 *x11,Window parent)
167 static const char *bfname[]= {
168 "-b&h-lucida-bold-i-normal-sans-34-240-100-100-p-215-iso8859-1",
169 "-b&h-lucida-bold-i-normal-sans-26-190-100-100-p-166-iso8859-1",
170 "lucidasans-bolditalic-24",
171 "lucidasans-italic-24",
172 "10x20",
173 "fixed"
175 #define NBF asize(bfname)
176 static const char *sfname[]= {
177 "lucidasans-bold-18",
178 "10x20",
179 "fixed"
181 #define NSF asize(sfname)
182 int i;
183 unsigned long bg;
184 char *newcol;
185 t_logo *logo;
187 snew(logo,1);
188 InitWin(&logo->wd,0,0,360,270,1,"GROMACS");
189 bg=LIGHTGREY;
190 if ((newcol=getenv("LOGO"))!=NULL)
191 GetNamedColor(x11,newcol,&bg);
192 logo->wd.self=XCreateSimpleWindow(x11->disp,parent,
193 logo->wd.x, logo->wd.y,
194 logo->wd.width,logo->wd.height,
195 logo->wd.bwidth,WHITE,bg);
196 for (i=0,logo->bigfont=NULL; (i<NBF); i++)
197 if ((logo->bigfont=XLoadQueryFont(x11->disp,bfname[i]))!=NULL)
198 break;
199 if (i==NBF) {
200 perror(bfname[i-1]);
201 exit(1);
203 #ifdef DEBUG
204 fprintf(stderr,"Big Logofont: %s\n",bfname[i]);
205 #endif
206 for (i=0,logo->smallfont=NULL; (i<NSF); i++)
207 if ((logo->smallfont=XLoadQueryFont(x11->disp,sfname[i]))!=NULL)
208 break;
209 if (i==NSF) {
210 perror(sfname[i-1]);
211 exit(1);
213 #ifdef DEBUG
214 fprintf(stderr,"Small Logofont: %s\n",sfname[i]);
215 #endif
216 x11->RegisterCallback(x11,logo->wd.self,parent,LogoCallBack,logo);
217 x11->SetInputMask(x11,logo->wd.self,ButtonPressMask | ExposureMask);
219 return logo;
222 void done_logo(t_x11 *x11,t_logo *logo)
224 x11->UnRegisterCallback(x11,logo->wd.self);