Redefine the default boolean type to gmx_bool.
[alexxy/gromacs.git] / src / ngmx / popup.h
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.
14
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.
19  * 
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.
26  * 
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.
29  * 
30  * For more info, check our website at http://www.gromacs.org
31  * 
32  * And Hey:
33  * Gyas ROwers Mature At Cryogenic Speed
34  */
35
36 #ifndef _popup_h
37 #define _popup_h
38
39 #include "x11.h"
40 #include "xutil.h"
41
42 typedef struct {
43   Window send_to;       /* Window to send messages to                   */
44   int    nreturn;       /* Value returned when entry is selected        */
45   gmx_bool   bChecked;  /* Indicate whether menu item is check-marked   */
46   const char *str;      /* Text for menu entry                          */
47 } t_mentry;
48
49 typedef struct {
50   t_windata wd;         /* The window struct                            */
51   t_mentry  *m;         /* The menu entry                               */
52   Window    Parent;     /* Parent window id                             */
53 } t_child;
54
55 typedef struct {
56   t_windata wd;         /* The window struct                            */
57   Window    Parent;     /* The parent of the menu                       */
58   int       nitem;      /* The number of menu items                     */
59   t_child   *item;      /* Array of child windows                       */
60   gmx_bool      bGrabbed;   /* Did this menu grab the pointer?              */
61 } t_menu;
62
63 extern t_menu *init_menu(t_x11 *x11,Window Parent,unsigned long fg,unsigned long bg,
64                          int nent,t_mentry ent[],int ncol);
65 /* This routine will create a popup menu. It will create a
66  * a base window, and child windows for all the items.
67  * If ncol != 0 then ncol columns of items will be created; 
68  * otherwise the routine will try to evenly space the menu, eg. if there
69  * are 20 items then the menu will be 2x10 entries, depending on the
70  * string lengths.
71  * !!!
72  * !!! Do not destroy the ent structure while using this menu
73  * !!!
74  * The routine will create the windows but not map them. That is, this
75  * routine can be called once at the beginning of a program. When a menu
76  * has to be shown, call show_menu. 
77  */
78
79 extern void show_menu(t_x11 *x11,t_menu *m,int x, int y,gmx_bool bGrab);
80 /* Show the menu in m at (x,y) 
81  * This will popup the menu, and when a button is released in the 
82  * menu send a ClientMessage to the Parent window of the menu
83  * specifying the selected menu item in xclient.data.l[0].
84  * bGrab specifies whether or not to grab the pointer.
85  */
86
87 extern void hide_menu(t_x11 *x11,t_menu *m);
88 /* Unmaps the window for m, hides the window */
89
90 extern void check_menu_item(t_menu *m,int nreturn,gmx_bool bStatus);
91 /* Set the bChecked field in the menu item with return code
92  * nreturn to bStatus. This function must always be called when
93  * the bChecked flag has to changed.
94  */
95
96 extern void done_menu(t_x11 *x11,t_menu *m);
97 /* This routine destroys the menu m, and unregisters it with x11 */
98
99 extern int menu_width(t_menu *m);
100 /* Return the width of the window */
101
102 extern int menu_height(t_menu *m);
103 /* Return the height of the window */
104
105 #endif  /* _popup_h */