786669838b055464833b20b6b4fdd3415e41e4fd
[alexxy/gromacs.git] / src / ngmx / xdlgitem.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 _xdlgitem_h
31 #define _xdlgitem_h
32
33 static char *SRCID_xdlgitem_h = "$Id$";
34
35 #ifdef HAVE_IDENT
36 #ident  "@(#) xdlgitem.h 1.4 9/29/92"
37 #endif /* HAVE_IDENT */
38
39 #include <typedefs.h>
40 #include <Xstuff.h>
41 #include <xutil.h>
42 #include <x11.h>
43
44 #define XCARET  2
45
46 enum { 
47   ITEMOK, RBPRESSED, BNPRESSED, CBPRESSED, ETCHANGED, HELPPRESSED, ENTERPRESSED
48 };
49
50 typedef int t_id;
51
52 typedef struct {
53   bool bDefault;        /* This is the default button */
54 } t_button;
55
56 typedef struct {
57   bool bSelect;         /* Is this rb selected ? */
58 } t_radiobutton;
59
60 typedef struct {
61   bool bChecked;        /* Is this cb checked ? */
62 } t_checkbox;
63
64 typedef struct {
65   Pixmap pm;            /* The pixmap bits */
66 } t_pixmap;
67
68 typedef struct {
69   int  nlines;
70   char **lines;
71 } t_statictext;
72
73 typedef struct {
74   int  buflen,strbegin; /* Length of the screen buf and begin of string  */
75   int  pos/*,len*/;     /* Current length of the string and pos of caret */
76                         /* Pos is relative to strbegin, and is the pos   */
77                         /* in the window.                                */
78   bool bChanged;
79   char *buf;
80 } t_edittext;
81
82 typedef struct {
83   int  nitems;
84   t_id *item;
85 } t_groupbox;
86
87 typedef enum {
88   edlgBN, edlgRB, edlgGB, edlgCB, edlgPM, edlgST, edlgET, edlgNR
89 } edlgitem;
90
91 typedef struct t_dlgitem {
92   t_windata     win;
93   t_id          ID,GroupID;
94   bool          bUseMon;
95   char          *set,*get,*help;
96   edlgitem      type;
97   int           (*WndProc)(t_x11 *x11,struct t_dlgitem *dlgitem,XEvent *event);
98   union {
99     t_button      button;
100     t_radiobutton radiobutton;
101     t_groupbox    groupbox;
102     t_checkbox    checkbox;
103     t_pixmap      pixmap;
104     t_statictext  statictext;
105     t_edittext    edittext;
106   } u;
107 } t_dlgitem;
108
109 /*****************************
110  *
111  * Routines to create dialog items, all items have an id
112  * which you can use to extract info. It is possible to have
113  * multiple items with the same id but it may then not be possible
114  * to extract information.
115  * All routines take the position relative to the parent dlg
116  * and the size and border width.
117  * If the width and height are set to zero initially, they will
118  * be calculated and set by the routine. With the dlgitem manipulation
119  * routines listed below, the application can then move the items around
120  * on the dlg box, and if wished resize them.
121  *
122  ****************************/
123 extern t_dlgitem *CreateButton(t_x11 *x11, char *szLab,bool bDef,
124                                t_id id,t_id groupid,
125                                int x0,int y0,int w,int h,int bw);
126
127 extern t_dlgitem *CreateRadioButton(t_x11 *x11,
128                                     char *szLab,bool bSet,t_id id,
129                                     t_id groupid,
130                                     int x0,int y0,int w,int h,int bw);
131
132 extern t_dlgitem *CreateGroupBox(t_x11 *x11,char *szLab,t_id id,
133                                  int nitems, t_id items[],
134                                  int x0,int y0,int w,int h,int bw);
135
136 extern t_dlgitem *CreateCheckBox(t_x11 *x11,char *szLab,
137                                  bool bCheckedInitial,
138                                  t_id id,t_id groupid,
139                                  int x0,int y0,int w,int h,int bw);
140
141 extern t_dlgitem *CreatePixmap(t_x11 *x11,Pixmap pm,t_id id,t_id groupid,
142                                int x0,int y0,int w,int h,int bw);
143
144 extern t_dlgitem *CreateStaticText(t_x11 *x11,
145                                    int nlines,char **lines,t_id id,
146                                    t_id groupid,
147                                    int x0,int y0,int w,int h,int bw);
148
149 extern t_dlgitem *CreateEditText(t_x11 *x11,char *title, 
150                                  int screenbuf,char *buf, t_id id,t_id groupid,
151                                  int x0,int y0,int w,int h,int bw);
152
153 extern void SetDlgitemOpts(t_dlgitem *dlgitem,bool bUseMon,
154                            char *set, char *get, char *help);
155
156 #endif  /* _xdlgitem_h */