Moved ngmx to C++, renamed it to view.
[alexxy/gromacs.git] / src / programs / view / xdlg.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 _xdlg_h
37 #define _xdlg_h
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 {
50     DLG_SET, DLG_EXIT
51 };
52
53 typedef void DlgCallback (t_x11 *x11, int dlg_mess, int item_id,
54                           char *set, void *data);
55 /* User function that can be called by the dialog box. All setting of
56  * check-boxes and radio-buttons etc., is done by the dialog manager,
57  * the user can let himself be informed about mouse activity also.
58  */
59
60 typedef struct {
61     t_x11                *x11;        /* All about X                */
62     t_windata             win;        /* The position and size of the window    */
63     char                 *title;      /* Window name                */
64     Window                wDad;       /* The parent window          */
65     unsigned int          xmax, ymax; /* Dimensions of parent window        */
66     unsigned long         flags;      /* Flags for display          */
67     unsigned long         fg, bg;     /* The colours                */
68     bool                  bPop;       /* Should we pop the mouse back   */
69     bool                  bGrab;      /* Have we grabbed the mouse ?        */
70     int                   nitem;      /* The number of items            */
71     t_dlgitem           **dlgitem;    /* The array of item pointers         */
72     DlgCallback          *cb;         /* User call back function                */
73     void                 *data;       /* User data                              */
74 } t_dlg;
75
76 /*****************************
77  *
78  * Routine to create the DLG structure, returns NULL on failure
79  * cb and data may be NULL.
80  *
81  ****************************/
82 t_dlg *CreateDlg(t_x11 *x11, Window Parent, const char *title,
83                  int x0, int y0, int w, int h, int bw,
84                  DlgCallback *cb, void *data);
85
86 /*****************************
87  *
88  * Routine to add an item to the dialog box
89  * The pointer to the item is copied to the dlg struct,
90  * the item itself may not be freed until the dlg is done with
91  *
92  ****************************/
93 void AddDlgItem(t_dlg *dlg, t_dlgitem *item);
94
95 void AddDlgItems(t_dlg *dlg, int nitem, t_dlgitem *item[]);
96
97 /*****************************
98  *
99  * Routines to manipulate items on a dialog box
100  * They return true on succes, false otherwise
101  * false will mean most of the time, that item id was not found
102  *
103  ****************************/
104 bool QueryDlgItemSize(t_dlg *dlg, t_id id, int *w, int *h);
105
106 bool QueryDlgItemPos(t_dlg *dlg, t_id id, int *x0, int *y0);
107
108 int QueryDlgItemX(t_dlg *dlg, t_id id);
109
110 int QueryDlgItemY(t_dlg *dlg, t_id id);
111
112 int QueryDlgItemW(t_dlg *dlg, t_id id);
113
114 int QueryDlgItemH(t_dlg *dlg, t_id id);
115
116 bool SetDlgItemSize(t_dlg *dlg, t_id id, int w, int h);
117
118 bool SetDlgItemPos(t_dlg *dlg, t_id id, int x0, int y0);
119
120 void SetDlgSize(t_dlg *dlg, int w, int h, bool bAutoPosition);
121
122 /*****************************
123  *
124  * Routines to extract information from the dlg proc
125  * after dlg is exec'ed
126  *
127  ****************************/
128 bool IsCBChecked(t_dlg *dlg, t_id id);
129
130 t_id RBSelected(t_dlg *dlg, int gid);
131
132 int  EditTextLen(t_dlg *dlg, t_id id);
133
134 char *EditText(t_dlg *dlg, t_id id);
135
136 /*****************************
137  *
138  * Routines to do internal things
139  *
140  ****************************/
141 t_dlgitem *FindWin(t_dlg *dlg, Window win);
142
143 t_dlgitem *FindItem(t_dlg *dlg, t_id id);
144
145 void HelpDlg(t_dlg *dlg);
146
147 void HelpNow(t_dlg *dlg, t_dlgitem *dlgitem);
148
149 void NoHelp(t_dlg *dlg);
150
151 /*****************************
152  *
153  * Exececute the dialog box procedure
154  * Returns when a button is pushed.
155  * return value is the ID of the button
156  *
157  ****************************/
158 void ShowDlg(t_dlg *dlg);
159
160 void HideDlg(t_dlg *dlg);
161
162 void FreeDlgItem(t_dlg *dlg, t_id id);
163
164 void FreeDlg(t_dlg *dlg);
165
166 #endif  /* _xdlg_h */