changed reading hint
[gromacs/adressmacs.git] / src / ngmx / logo.c
blobfa60d6cddd44070e00a84f2eb7e11169b57ebd63
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_logo_c = "$Id$";
31 #include "sysstuff.h"
32 #include "Xstuff.h"
33 #include "xutil.h"
34 #include "smalloc.h"
35 #include "macros.h"
36 #include "copyrite.h"
37 #include "logo.h"
39 typedef struct {
40 int x,y,rad;
41 unsigned long *col;
42 } t_circle;
44 typedef struct {
45 char *text;
46 int y,h;
47 XFontStruct *fnt;
48 } t_mess;
50 void show_logo(t_x11 *x11,t_logo *logo)
52 XMapWindow(x11->disp,logo->wd.self);
53 XMapSubwindows(x11->disp,logo->wd.self);
56 void hide_logo(t_x11 *x11,t_logo *logo)
58 XUnmapWindow(x11->disp,logo->wd.self);
61 static bool LogoCallBack(t_x11 *x11,XEvent *event, Window w, void *data)
63 /* Assume window is 100x110 */
64 static bool bFirst=TRUE;
65 #define CSIZE 9
66 #define NSIZE 8
67 #define OSIZE 9
68 #define HSIZE 7
69 #define YOFFS 30
70 static t_circle c[] = {
71 { 10,YOFFS+12,CSIZE,&LIGHTGREEN },
72 { 20,YOFFS+22,CSIZE,&LIGHTGREEN },
73 { 20,YOFFS+34,OSIZE,&LIGHTRED },
74 { 30,YOFFS+12,NSIZE,&LIGHTCYAN },
75 { 30,YOFFS+ 2,HSIZE ,&WHITE },
76 { 40,YOFFS+22,CSIZE,&LIGHTGREEN },
77 { 40,YOFFS+34,CSIZE,&LIGHTGREEN },
78 { 50,YOFFS+12,CSIZE,&LIGHTGREEN },
79 { 50,YOFFS ,OSIZE,&LIGHTRED },
80 { 60,YOFFS+22,NSIZE,&LIGHTCYAN },
81 { 60,YOFFS+32,HSIZE, &WHITE },
82 { 70,YOFFS+12,CSIZE,&LIGHTGREEN },
83 { 80,YOFFS+22,CSIZE,&LIGHTGREEN },
84 { 80,YOFFS+34,OSIZE,&LIGHTRED },
85 { 90,YOFFS+12,NSIZE,&LIGHTCYAN },
86 { 90,YOFFS+ 2,HSIZE,&WHITE },
87 {100,YOFFS+22,CSIZE,&LIGHTGREEN }
89 static int lines[] = {
90 0,1, 1,2, 1,3, 3,4, 3,5, 5,6, 5,7, 7,8, 7,9,
91 9,10, 9,11, 11,12, 12,13, 12,14, 14,15, 14,16
93 #define COFFS 70
94 static t_mess Mess[] = {
95 { "GROMACS", 0, 20, NULL },
96 { NULL, 16, 9, NULL },
97 { "Copyright (c) 1991-1998", COFFS+ 2, 9, NULL },
98 { "Dept. of Biophysical Chemistry", COFFS+11, 9, NULL },
99 { "University of Groningen", COFFS+20, 9, NULL },
100 { "click to dismiss", COFFS+31, 8, NULL }
102 #define NMESS asize(Mess)
103 int i;
104 real wfac,hfac;
105 t_logo *logo;
106 t_windata *wd;
108 logo=(t_logo *)data;
109 wd=&(logo->wd);
110 if (bFirst) {
111 wfac=wd->width/110.0;
112 hfac=wd->height/110.0;
113 for(i=0; (i<asize(c)); i++) {
114 c[i].x *= wfac;
115 c[i].y *= hfac;
117 Mess[1].text=GromacsVersion();
118 for(i=0; (i<NMESS); i++) {
119 Mess[i].y *= hfac;
120 Mess[i].h *= hfac;
121 Mess[i].fnt = (i==0) ? logo->bigfont : (i==NMESS-1) ? x11->font :
122 logo->smallfont;
124 bFirst=FALSE;
126 switch (event->type) {
127 case Expose:
128 XSetForeground(x11->disp,x11->gc,WHITE);
129 XSetLineAttributes(x11->disp,x11->gc,3,LineSolid,CapNotLast,JoinRound);
130 for(i=0; (i<asize(lines)); i+=2) {
131 XDrawLine(x11->disp,wd->self,x11->gc,
132 c[lines[i]].x,c[lines[i]].y,c[lines[i+1]].x,c[lines[i+1]].y);
134 XSetLineAttributes(x11->disp,x11->gc,1,LineSolid,CapNotLast,JoinRound);
135 for(i=0; (i<asize(c)); i++) {
136 XSetForeground(x11->disp,x11->gc,*(c[i].col));
137 XFillCircle(x11->disp,wd->self,x11->gc,c[i].x,c[i].y,c[i].rad);
139 XSetForeground(x11->disp,x11->gc,BLACK);
140 XDrawRectangle(x11->disp,wd->self,x11->gc,2,2,wd->width-5,wd->height-5);
141 for(i=0; (i<asize(Mess)); i++)
142 SpecialTextInRect(x11,Mess[i].fnt,wd->self,Mess[i].text,
143 0,Mess[i].y,wd->width,Mess[i].h,
144 eXCenter,eYCenter);
145 XSetForeground(x11->disp,x11->gc,x11->fg);
146 break;
147 case ButtonPress:
148 hide_logo(x11,logo);
149 break;
150 default:
151 break;
154 return FALSE;
157 t_logo *init_logo(t_x11 *x11,Window parent)
159 static char *bfname[]= {
160 "-b&h-lucida-bold-i-normal-sans-34-240-100-100-p-215-iso8859-1",
161 "-b&h-lucida-bold-i-normal-sans-26-190-100-100-p-166-iso8859-1",
162 "lucidasans-bolditalic-24",
163 "lucidasans-italic-24",
164 "10x20",
165 "fixed"
167 #define NBF asize(bfname)
168 static char *sfname[]= {
169 "lucidasans-bold-18",
170 "10x20",
171 "fixed"
173 #define NSF asize(sfname)
174 int i;
175 unsigned long bg;
176 char *newcol;
177 t_logo *logo;
179 snew(logo,1);
180 InitWin(&logo->wd,0,0,360,270,1,"GROMACS");
181 bg=LIGHTGREY;
182 if ((newcol=getenv("LOGO"))!=NULL)
183 GetNamedColor(x11,newcol,&bg);
184 logo->wd.self=XCreateSimpleWindow(x11->disp,parent,
185 logo->wd.x, logo->wd.y,
186 logo->wd.width,logo->wd.height,
187 logo->wd.bwidth,WHITE,bg);
188 for (i=0,logo->bigfont=NULL; (i<NBF); i++)
189 if ((logo->bigfont=XLoadQueryFont(x11->disp,bfname[i]))!=NULL)
190 break;
191 if (i==NBF) {
192 perror(bfname[i-1]);
193 exit(1);
195 #ifdef DEBUG
196 fprintf(stderr,"Big Logofont: %s\n",bfname[i]);
197 #endif
198 for (i=0,logo->smallfont=NULL; (i<NSF); i++)
199 if ((logo->smallfont=XLoadQueryFont(x11->disp,sfname[i]))!=NULL)
200 break;
201 if (i==NSF) {
202 perror(sfname[i-1]);
203 exit(1);
205 #ifdef DEBUG
206 fprintf(stderr,"Small Logofont: %s\n",sfname[i]);
207 #endif
208 x11->RegisterCallback(x11,logo->wd.self,parent,LogoCallBack,logo);
209 x11->SetInputMask(x11,logo->wd.self,ButtonPressMask | ExposureMask);
211 return logo;
214 void done_logo(t_x11 *x11,t_logo *logo)
216 x11->UnRegisterCallback(x11,logo->wd.self);