Tagged files with gromacs 3.0 header and added some license info
[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 3.0
11  * 
12  * Copyright (c) 1991-2001
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  * 
21  * If you want to redistribute modifications, please consider that
22  * scientific software is very special. Version control is crucial -
23  * bugs must be traceable. We will be happy to consider code for
24  * inclusion in the official distribution, but derived work must not
25  * be called official GROMACS. Details are found in the README & COPYING
26  * files - if they are missing, get the official version at www.gromacs.org.
27  * 
28  * To help us fund GROMACS development, we humbly ask that you cite
29  * the papers on the package - you can find them in the top README file.
30  * 
31  * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
32  * 
33  * And Hey:
34  * Giving Russians Opium May Alter Current Situation
35  */
36
37 #ifndef _xdlg_h
38 #define _xdlg_h
39
40 static char *SRCID_xdlg_h = "$Id$";
41 #ifdef HAVE_IDENT
42 #ident  "@(#) xdlg.h 1.3 9/29/92"
43 #endif /* HAVE_IDENT */
44
45 #include <xdlgitem.h>
46
47 #define DLG_SHOW         (1<<0)
48 #define DLG_HIDE         (1<<1)
49 #define DLG_SHOWANDHIDE  (DLG_SHOW | DLG_HIDE)
50 #define DLG_SYSTEMMODAL  (1<<2)
51 #define DLG_APPLMODAL    (1<<3)
52 #define DLG_HIDEONBUTTON (1<<4)
53 #define DLG_FREEONBUTTON (1<<5)
54
55 enum { DLG_SET, DLG_EXIT };
56
57 typedef void DlgCallback(t_x11 *x11,int dlg_mess,int item_id,
58                          char *set,void *data);
59 /* User function that can be called by the dialog box. All setting of
60  * check-boxes and radio-buttons etc., is done by the dialog manager,
61  * the user can let himself be informed about mouse activity also.
62  */
63
64 typedef struct {
65   t_x11         *x11;           /* All about X                          */
66   t_windata     win;            /* The position and size of the window  */
67   char          *title;         /* Window name                          */
68   Window        wDad;           /* The parent window                    */
69   unsigned int          xmax,ymax;      /* Dimensions of parent window          */
70   unsigned long         flags;          /* Flags for display                    */
71   unsigned long         fg,bg;          /* The colours                          */
72   bool          bPop;           /* Should we pop the mouse back         */
73   bool          bGrab;          /* Have we grabbed the mouse ?          */
74   int           nitem;          /* The number of items                  */
75   t_dlgitem     **dlgitem;      /* The array of item pointers           */
76   DlgCallback   *cb;            /* User call back function              */
77   void          *data;          /* User data                            */
78 } t_dlg;
79
80 /*****************************
81  *
82  * Routine to create the DLG structure, returns NULL on failure
83  * cb and data may be NULL.
84  *
85  ****************************/
86 t_dlg *CreateDlg(t_x11 *x11,Window Parent,char *title,
87                  int x0,int y0,int w,int h,int bw,unsigned long fg,unsigned long bg,
88                  DlgCallback *cb,void *data);
89
90 /*****************************
91  *
92  * Routine to add an item to the dialog box
93  * The pointer to the item is copied to the dlg struct,
94  * the item itself may not be freed until the dlg is done with
95  *
96  ****************************/
97 void AddDlgItem(t_dlg *dlg,t_dlgitem *new);
98
99 void AddDlgItems(t_dlg *dlg,int nitem,t_dlgitem *new[]);
100
101 /*****************************
102  *
103  * Routines to manipulate items on a dialog box
104  * They return TRUE on succes, FALSE otherwise
105  * FALSE will mean most of the time, that item id was not found
106  *
107  ****************************/
108 bool QueryDlgItemSize(t_dlg *dlg,t_id id,int *w,int *h);
109
110 bool QueryDlgItemPos(t_dlg *dlg,t_id id,int *x0,int *y0);
111
112 int QueryDlgItemX(t_dlg *dlg, t_id id);
113
114 int QueryDlgItemY(t_dlg *dlg, t_id id);
115
116 int QueryDlgItemW(t_dlg *dlg, t_id id);
117
118 int QueryDlgItemH(t_dlg *dlg, t_id id);
119
120 bool SetDlgItemSize(t_dlg *dlg,t_id id,int w,int h);
121
122 bool SetDlgItemPos(t_dlg *dlg,t_id id,int x0,int y0);
123
124 void SetDlgSize(t_dlg *dlg,int w,int h, bool bAutoPosition);
125
126 /*****************************
127  *
128  * Routines to extract information from the dlg proc
129  * after dlg is exec'ed
130  *
131  ****************************/
132 bool IsCBChecked(t_dlg *dlg,t_id id);
133
134 t_id RBSelected(t_dlg *dlg,int gid);
135
136 int  EditTextLen(t_dlg *dlg,t_id id);
137
138 char *EditText(t_dlg *dlg,t_id id);
139
140 /*****************************
141  *
142  * Routines to do internal things
143  *
144  ****************************/
145 t_dlgitem *FindWin(t_dlg *dlg, Window win);
146
147 t_dlgitem *FindItem(t_dlg *dlg, t_id id);
148
149 void HelpDlg(t_dlg *dlg);
150
151 void HelpNow(t_dlg *dlg, t_dlgitem *dlgitem);
152
153 void NoHelp(t_dlg *dlg);
154
155 /*****************************
156  *
157  * Exececute the dialog box procedure
158  * Returns when a button is pushed.
159  * return value is the ID of the button
160  *
161  ****************************/
162 void ShowDlg(t_dlg *dlg);
163
164 void HideDlg(t_dlg *dlg);
165
166 void FreeDlgItem(t_dlg *dlg, t_id id);
167
168 void FreeDlg(t_dlg *dlg);
169
170 #endif  /* _xdlg_h */