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_pulldown_c
= "$Id$";
38 static bool PDCallBack(t_x11
*x11
,XEvent
*event
,Window w
,void *data
)
43 pd
=(t_pulldown
*)data
;
47 XSetForeground(x11
->disp
,x11
->gc
,x11
->fg
);
48 XDrawLine(x11
->disp
,w
,x11
->gc
,0,y
-1,pd
->wd
.width
,y
-1);
49 for(i
=0; (i
<pd
->nmenu
); i
++)
50 XDrawString(x11
->disp
,pd
->wd
.self
,x11
->gc
,pd
->xpos
[i
],x11
->font
->ascent
,
51 pd
->title
[i
],strlen(pd
->title
[i
]));
56 for(nsel
=0; (pd
->xpos
[nsel
+1] < x
) && (nsel
< pd
->nmenu
-1); nsel
++);
58 x1
=max(0,min(pd_width(pd
)-menu_width(pd
->m
[nsel
]),pd
->xpos
[nsel
]));
59 show_menu(x11
,pd
->m
[nsel
],x1
,y
+1,FALSE
);
71 t_pulldown
*init_pd(t_x11
*x11
,Window Parent
,int width
,int height
,
72 unsigned long fg
,unsigned long bg
,
73 int nmenu
,int *nsub
,t_mentry
*ent
[],char **title
)
83 snew(pd
->xpos
,nmenu
+1);
85 for(i
=1; (i
<=nmenu
); i
++)
86 pd
->xpos
[i
]=20+pd
->xpos
[i
-1]+
87 XTextWidth(x11
->font
,title
[i
-1],strlen(title
[i
-1]));
88 if (pd
->xpos
[nmenu
] > width
)
89 printf("Menu too wide\n");
91 InitWin(&(pd
->wd
),0,0,width
,XTextHeight(x11
->font
)+2,0,"PullDown");
92 pd
->wd
.self
=XCreateSimpleWindow(x11
->disp
,Parent
,
94 pd
->wd
.width
,pd
->wd
.height
,
96 x11
->RegisterCallback(x11
,pd
->wd
.self
,Parent
,PDCallBack
,pd
);
97 x11
->SetInputMask(x11
,pd
->wd
.self
,ExposureMask
| ButtonPressMask
|
98 OwnerGrabButtonMask
| ButtonReleaseMask
);
99 XMapWindow(x11
->disp
,pd
->wd
.self
);
101 for(i
=0; (i
<nmenu
); i
++)
102 pd
->m
[i
]=init_menu(x11
,Parent
,fg
,bg
,nsub
[i
],ent
[i
],1);
107 void hide_pd(t_x11
*x11
,t_pulldown
*pd
)
110 hide_menu(x11
,pd
->m
[pd
->nsel
]);
114 void check_pd_item(t_pulldown
*pd
,int nreturn
,bool bStatus
)
118 for(i
=0; (i
<pd
->nmenu
); i
++)
119 check_menu_item(pd
->m
[i
],nreturn
,bStatus
);
122 void done_pd(t_x11
*x11
,t_pulldown
*pd
)
126 for(i
=0; (i
<pd
->nmenu
); i
++)
127 done_menu(x11
,pd
->m
[i
]);
128 x11
->UnRegisterCallback(x11
,pd
->wd
.self
);
133 int pd_width(t_pulldown
*pd
)
138 for(i
=0; (i
<pd
->nmenu
); i
++)
139 w
=max(w
,menu_width(pd
->m
[i
]));
140 w
=max(w
,pd
->xpos
[pd
->nmenu
]);
144 int pd_height(t_pulldown
*pd
)
149 for(i
=0; (i
<pd
->nmenu
); i
++)
150 h
=max(h
,menu_height(pd
->m
[i
]));