Adjust more copyright headers
[alexxy/gromacs.git] / src / programs / view / xdlg.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team.
6  * Copyright (c) 2013, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37
38 #ifndef _xdlg_h
39 #define _xdlg_h
40
41 #include "xdlgitem.h"
42
43 #define DLG_SHOW         (1<<0)
44 #define DLG_HIDE         (1<<1)
45 #define DLG_SHOWANDHIDE  (DLG_SHOW | DLG_HIDE)
46 #define DLG_SYSTEMMODAL  (1<<2)
47 #define DLG_APPLMODAL    (1<<3)
48 #define DLG_HIDEONBUTTON (1<<4)
49 #define DLG_FREEONBUTTON (1<<5)
50
51 enum {
52     DLG_SET, DLG_EXIT
53 };
54
55 typedef void DlgCallback (t_x11 *x11, int dlg_mess, int item_id,
56                           char *set, void *data);
57 /* User function that can be called by the dialog box. All setting of
58  * check-boxes and radio-buttons etc., is done by the dialog manager,
59  * the user can let himself be informed about mouse activity also.
60  */
61
62 typedef struct {
63     t_x11                *x11;        /* All about X                */
64     t_windata             win;        /* The position and size of the window    */
65     char                 *title;      /* Window name                */
66     Window                wDad;       /* The parent window          */
67     unsigned int          xmax, ymax; /* Dimensions of parent window        */
68     unsigned long         flags;      /* Flags for display          */
69     unsigned long         fg, bg;     /* The colours                */
70     bool                  bPop;       /* Should we pop the mouse back   */
71     bool                  bGrab;      /* Have we grabbed the mouse ?        */
72     int                   nitem;      /* The number of items            */
73     t_dlgitem           **dlgitem;    /* The array of item pointers         */
74     DlgCallback          *cb;         /* User call back function                */
75     void                 *data;       /* User data                              */
76 } t_dlg;
77
78 /*****************************
79  *
80  * Routine to create the DLG structure, returns NULL on failure
81  * cb and data may be NULL.
82  *
83  ****************************/
84 t_dlg *CreateDlg(t_x11 *x11, Window Parent, const char *title,
85                  int x0, int y0, int w, int h, int bw,
86                  DlgCallback *cb, void *data);
87
88 /*****************************
89  *
90  * Routine to add an item to the dialog box
91  * The pointer to the item is copied to the dlg struct,
92  * the item itself may not be freed until the dlg is done with
93  *
94  ****************************/
95 void AddDlgItem(t_dlg *dlg, t_dlgitem *item);
96
97 void AddDlgItems(t_dlg *dlg, int nitem, t_dlgitem *item[]);
98
99 /*****************************
100  *
101  * Routines to manipulate items on a dialog box
102  * They return true on succes, false otherwise
103  * false will mean most of the time, that item id was not found
104  *
105  ****************************/
106 bool QueryDlgItemSize(t_dlg *dlg, t_id id, int *w, int *h);
107
108 bool QueryDlgItemPos(t_dlg *dlg, t_id id, int *x0, int *y0);
109
110 int QueryDlgItemX(t_dlg *dlg, t_id id);
111
112 int QueryDlgItemY(t_dlg *dlg, t_id id);
113
114 int QueryDlgItemW(t_dlg *dlg, t_id id);
115
116 int QueryDlgItemH(t_dlg *dlg, t_id id);
117
118 bool SetDlgItemSize(t_dlg *dlg, t_id id, int w, int h);
119
120 bool SetDlgItemPos(t_dlg *dlg, t_id id, int x0, int y0);
121
122 void SetDlgSize(t_dlg *dlg, int w, int h, bool bAutoPosition);
123
124 /*****************************
125  *
126  * Routines to extract information from the dlg proc
127  * after dlg is exec'ed
128  *
129  ****************************/
130 bool IsCBChecked(t_dlg *dlg, t_id id);
131
132 t_id RBSelected(t_dlg *dlg, int gid);
133
134 int  EditTextLen(t_dlg *dlg, t_id id);
135
136 char *EditText(t_dlg *dlg, t_id id);
137
138 /*****************************
139  *
140  * Routines to do internal things
141  *
142  ****************************/
143 t_dlgitem *FindWin(t_dlg *dlg, Window win);
144
145 t_dlgitem *FindItem(t_dlg *dlg, t_id id);
146
147 void HelpDlg(t_dlg *dlg);
148
149 void HelpNow(t_dlg *dlg, t_dlgitem *dlgitem);
150
151 void NoHelp(t_dlg *dlg);
152
153 /*****************************
154  *
155  * Exececute the dialog box procedure
156  * Returns when a button is pushed.
157  * return value is the ID of the button
158  *
159  ****************************/
160 void ShowDlg(t_dlg *dlg);
161
162 void HideDlg(t_dlg *dlg);
163
164 void FreeDlgItem(t_dlg *dlg, t_id id);
165
166 void FreeDlg(t_dlg *dlg);
167
168 #endif  /* _xdlg_h */