4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
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
27 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_nleg_c = "$Id$";
45 static t_atomcolor ac[] = {
46 { "O", &LIGHTRED, { 1, 0, 0 } },
47 { "N", &LIGHTCYAN, { 0, 0, 1 } },
48 { "NA", &LIGHTGREY, { 0.6,0.6,0.6 } },
49 { "S", &YELLOW, { 1, 1, 0 } },
50 { "C", &LIGHTGREEN, { 0, 1, 0 } },
51 { "CL", &VIOLET, { 1, 0, 1 } },
52 { "F", &LIGHTGREY, { 0.6,0.6,0.6 } },
53 { "Z", &LIGHTGREY, { 0.6,0.6,0.6 } },
54 { "P", &LIGHTBLUE, { 0.4,0.4,1.0 } },
55 { "H", &WHITE, { 0.8,0.8,0.8 } },
56 { "C2", &GREEN, { 0.8,0.2,0.2 } },
57 { "BE1", &VIOLET, { 0.8,0.2,0.2 } },
58 { "W6R", &VIOLET, { 0.8,0.2,0.2 } },
59 { "W5R", &LIGHTGREY, { 0.8,0.2,0.2 } },
63 int search_ac(char *type)
65 int i,nb,mij,best,besti;
70 for(i=0; (i<NAC); i++) {
71 mij=min((int)strlen(type),(int)strlen(ac[i].tp));
72 for(nb=0; (nb<mij); nb++)
73 if (type[nb] != ac[i].tp[nb])
84 unsigned long Type2Color(char *type)
93 t_rgb *Type2RGB(char *type)
102 void DrawLegend(t_x11 *x11,t_windata *Win)
106 static char *lab[NLAB] = { "C", "O", "H", "S", "N", "P" };
107 int i,i0,dh,dw,w,y,x1,x0;
111 XClearWindow(x11->disp, Win->self);
113 h_2=Win->height/(2.0*NLAB/COLS);
117 for (i=0; (i<NLAB); i++) {
119 x0=(i / (NLAB/COLS))*(Win->width/COLS)+AIR;
121 cind=Type2Color(lab[i]);
122 XSetForeground(x11->disp,x11->gc,cind);
124 XFillRectangle (x11->disp,Win->self,x11->gc,x0,y-dh,2*dw,2*dh);
125 XSetForeground(x11->disp,x11->gc,WHITE);
126 TextInRect(x11,Win->self,lab[i],x1,y-dh,w-x1,2*dh,
129 XSetForeground(x11->disp,x11->gc,x11->fg);
132 static bool LegWCallBack(t_x11 *x11,XEvent *event, Window w, void *data)
136 lw=(t_legendwin *)data;
137 switch(event->type) {
139 DrawLegend(x11,&lw->wd);
147 t_legendwin *init_legw(t_x11 *x11,Window Parent,
148 int x,int y,int width,int height,
149 unsigned long fg,unsigned long bg)
154 InitWin(&lw->wd,x,y,width,height,1,"Legend Window");
155 lw->wd.self=XCreateSimpleWindow(x11->disp,Parent,x,y,1,1,1,fg,bg);
156 x11->RegisterCallback(x11,lw->wd.self,Parent,LegWCallBack,lw);
157 x11->SetInputMask(x11,lw->wd.self,ExposureMask);
162 void map_legw(t_x11 *x11,t_legendwin *lw)
164 XMapWindow(x11->disp,lw->wd.self);
168 void done_legw(t_x11 *x11,t_legendwin *lw)
170 x11->UnRegisterCallback(x11,lw->wd.self);