90eb590a226594819aff3d8e141bba9aba7587f5
[alexxy/gromacs.git] / src / ngmx / xdlg.h
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
11  * 
12  * Copyright (c) 1991-1999
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
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)
20  * 
21  * Also check out our WWW page:
22  * http://md.chem.rug.nl/~gmx
23  * or e-mail to:
24  * gromacs@chem.rug.nl
25  * 
26  * And Hey:
27  * Great Red Oystrich Makes All Chemists Sane
28  */
29
30 #ifndef _xdlg_h
31 #define _xdlg_h
32
33 static char *SRCID_xdlg_h = "$Id$";
34
35 #ifdef HAVE_IDENT
36 #ident  "@(#) xdlg.h 1.3 9/29/92"
37 #endif /* HAVE_IDENT */
38
39 #include <xdlgitem.h>
40
41 #define DLG_SHOW         (1<<0)
42 #define DLG_HIDE         (1<<1)
43 #define DLG_SHOWANDHIDE  (DLG_SHOW | DLG_HIDE)
44 #define DLG_SYSTEMMODAL  (1<<2)
45 #define DLG_APPLMODAL    (1<<3)
46 #define DLG_HIDEONBUTTON (1<<4)
47 #define DLG_FREEONBUTTON (1<<5)
48
49 enum { DLG_SET, DLG_EXIT };
50
51 typedef void DlgCallback(t_x11 *x11,int dlg_mess,int item_id,
52                          char *set,void *data);
53 /* User function that can be called by the dialog box. All setting of
54  * check-boxes and radio-buttons etc., is done by the dialog manager,
55  * the user can let himself be informed about mouse activity also.
56  */
57
58 typedef struct {
59   t_x11         *x11;           /* All about X                          */
60   t_windata     win;            /* The position and size of the window  */
61   char          *title;         /* Window name                          */
62   Window        wDad;           /* The parent window                    */
63   unsigned int          xmax,ymax;      /* Dimensions of parent window          */
64   unsigned long         flags;          /* Flags for display                    */
65   unsigned long         fg,bg;          /* The colours                          */
66   bool          bPop;           /* Should we pop the mouse back         */
67   bool          bGrab;          /* Have we grabbed the mouse ?          */
68   int           nitem;          /* The number of items                  */
69   t_dlgitem     **dlgitem;      /* The array of item pointers           */
70   DlgCallback   *cb;            /* User call back function              */
71   void          *data;          /* User data                            */
72 } t_dlg;
73
74 /*****************************
75  *
76  * Routine to create the DLG structure, returns NULL on failure
77  * cb and data may be NULL.
78  *
79  ****************************/
80 t_dlg *CreateDlg(t_x11 *x11,Window Parent,char *title,
81                  int x0,int y0,int w,int h,int bw,unsigned long fg,unsigned long bg,
82                  DlgCallback *cb,void *data);
83
84 /*****************************
85  *
86  * Routine to add an item to the dialog box
87  * The pointer to the item is copied to the dlg struct,
88  * the item itself may not be freed until the dlg is done with
89  *
90  ****************************/
91 void AddDlgItem(t_dlg *dlg,t_dlgitem *new);
92
93 void AddDlgItems(t_dlg *dlg,int nitem,t_dlgitem *new[]);
94
95 /*****************************
96  *
97  * Routines to manipulate items on a dialog box
98  * They return TRUE on succes, FALSE otherwise
99  * FALSE will mean most of the time, that item id was not found
100  *
101  ****************************/
102 bool QueryDlgItemSize(t_dlg *dlg,t_id id,int *w,int *h);
103
104 bool QueryDlgItemPos(t_dlg *dlg,t_id id,int *x0,int *y0);
105
106 int QueryDlgItemX(t_dlg *dlg, t_id id);
107
108 int QueryDlgItemY(t_dlg *dlg, t_id id);
109
110 int QueryDlgItemW(t_dlg *dlg, t_id id);
111
112 int QueryDlgItemH(t_dlg *dlg, t_id id);
113
114 bool SetDlgItemSize(t_dlg *dlg,t_id id,int w,int h);
115
116 bool SetDlgItemPos(t_dlg *dlg,t_id id,int x0,int y0);
117
118 void SetDlgSize(t_dlg *dlg,int w,int h, bool bAutoPosition);
119
120 /*****************************
121  *
122  * Routines to extract information from the dlg proc
123  * after dlg is exec'ed
124  *
125  ****************************/
126 bool IsCBChecked(t_dlg *dlg,t_id id);
127
128 t_id RBSelected(t_dlg *dlg,int gid);
129
130 int  EditTextLen(t_dlg *dlg,t_id id);
131
132 char *EditText(t_dlg *dlg,t_id id);
133
134 /*****************************
135  *
136  * Routines to do internal things
137  *
138  ****************************/
139 t_dlgitem *FindWin(t_dlg *dlg, Window win);
140
141 t_dlgitem *FindItem(t_dlg *dlg, t_id id);
142
143 void HelpDlg(t_dlg *dlg);
144
145 void HelpNow(t_dlg *dlg, t_dlgitem *dlgitem);
146
147 void NoHelp(t_dlg *dlg);
148
149 /*****************************
150  *
151  * Exececute the dialog box procedure
152  * Returns when a button is pushed.
153  * return value is the ID of the button
154  *
155  ****************************/
156 void ShowDlg(t_dlg *dlg);
157
158 void HideDlg(t_dlg *dlg);
159
160 void FreeDlgItem(t_dlg *dlg, t_id id);
161
162 void FreeDlg(t_dlg *dlg);
163
164 #endif  /* _xdlg_h */