sym2num: don't hardcode path to cpp
[oweals/cde.git] / cde / programs / dtudcfonted / util.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* util.h 1.5 - Fujitsu source for CDEnext    96/09/18 13:59:22      */
24 /* $XConsortium: util.h /main/5 1996/09/19 19:42:11 cde-fuj $ */
25 /*
26  *  (c) Copyright 1995 FUJITSU LIMITED
27  *  This is source code modified by FUJITSU LIMITED under the Joint
28  *  Development Agreement for the CDEnext PST.
29  *  This is unpublished proprietary source code of FUJITSU LIMITED
30  */
31
32 #include <Xm/Xm.h>
33 #include <Xm/XmStrDefs.h>
34
35 #define MarginWidth 4
36 #define RowMarginWidth 11
37 #define MarginHeight 11
38 #define HeightSpace 4
39 #define MinimumSpace 4
40
41 /*****  Exclusive Set  *****/
42 typedef struct _ToggleButt {
43     Widget      w;
44     char *      label;
45     XtPointer   clientdata;
46     String      name;
47     XtArgVal    sensitive;
48     XtCallbackProc      cb;
49     XtArgVal    set;
50 } ToggleButt;
51
52 #define EXARGS( clientdata, name, sensitive, cb, set ){ \
53                 NULL, \
54     (char *)    "", \
55     (XtPointer) clientdata, \
56                 name, \
57     (XtArgVal)  sensitive, \
58     (XtCallbackProc)    cb, \
59     (XtArgVal)  set \
60 }
61
62 typedef struct _RadioButt {
63     String      label;
64     ToggleButt  *items;
65     int         items_cnt;
66     String      name;
67     Widget      w;
68     XtPointer   udata;
69 } RadioButt;
70
71
72 #define EXCLUSIVE(a) { 0, a, XtNumber(a), 0, 0, 0 }
73
74 #define ExclusiveItems          ToggleButt
75 #define Exclusive               RadioButt
76
77 #define SetItemLabel(b,n,l) (b)->items[(n)].label = (l)
78
79 /*****  PushButton Set  *****/
80
81 typedef struct _ButtonItems {
82         char *  label;
83         XtCallbackProc  cb;
84         XtPointer clientdata;
85         XtArgVal  mnemonic;
86         XtArgVal  sensitive;
87         XtArgVal  deflt;
88 } ButtonItems;
89
90 #define BTNARGS( cb, clientdata, mnumonic, sensitive, deflt ) { \
91         (char *) "", \
92         (XtCallbackProc) cb, \
93         (XtPointer) clientdata, \
94         (XtArgVal) mnumonic, \
95         (XtArgVal) sensitive, \
96         (XtArgVal) deflt \
97 }
98
99 typedef struct _Button {
100         Widget          *w;
101         ButtonItems     *items;
102         int             itemcnt;
103 } Button;
104
105 #define BUTTONS( items ) { 0, items, XtNumber(items) }
106
107 /*****  MenuButton Set  *****/
108
109 typedef struct _menuButtonItems {
110         char    *label;
111         char    mnemonic;
112         Widget  menu;
113 } menuButtonItems;
114
115 #define MENUBTNARGS( mnumonic ) { \
116         "",    \
117         mnumonic, \
118         NULL, \
119 }
120
121 typedef struct _MButton {
122         menuButtonItems *items;
123         int             itemcnt;
124 } MButton;
125
126 #define MBUTTONS(items) {items,XtNumber((items))}
127
128
129 /*****  NoticeButton Set  *****/
130
131 typedef struct _NoticeButton {
132         char    *label;
133         void    (*cb)();
134 } NoticeButton;
135
136 #define NBTNARGS( cb, clientdata, mnumonic, sensitive, deflt) { \
137         "",    \
138         cb,    \
139 }
140
141 typedef struct _NButton {
142         NoticeButton    *items;
143         int             itemcnt;
144 } NButton;
145
146 #define NBUTTONS(items) {items,XtNumber((items))}
147
148
149 /*****  TextField Set  *****/
150
151 typedef struct _TextField {
152         Widget  w1;
153         Widget  w2;
154         String  label;
155 } TextField;
156
157
158 /*****  Function Type  *****/
159
160 #define D_WARNING       XmDIALOG_WARNING
161 #define D_QUESTION      XmDIALOG_QUESTION
162 #define D_ERROR         XmDIALOG_ERROR
163 #define D_TEMPLATE      XmDIALOG_TEMPLATE
164 #define L_VERTICAL      XmVERTICAL
165 #define L_HORIZONTAL    XmHORIZONTAL
166
167
168 #ifdef  USE_MACRO
169 #define AddLeftAttachWidget( w, ref, offset ) XtVaSetValues( w, \
170         XmNleftAttachment, XmATTACH_WIDGET, \
171         XmNleftWidget, ref, \
172         XmNleftOffset, offset, \
173         0)
174
175 #define AddLeftAttachForm( w, offset ) XtVaSetValues( w, \
176         XmNleftAttachment, XmATTACH_FORM, \
177         XmNleftOffset, offset, \
178         0)
179
180 #define AddTopAttachWidget( w, ref, offset ) XtVaSetValues( w, \
181         XmNtopAttachment, XmATTACH_WIDGET, \
182         XmNtopWidget, ref, \
183         XmNtopOffset, offset, \
184         0)
185
186 #define AddTopAttachForm( w, offset ) XtVaSetValues( w, \
187         XmNtopAttachment, XmATTACH_FORM, \
188         XmNtopOffset, offset, \
189         0)
190
191 #define AddRightAttachWidget( w, ref, offset ) XtVaSetValues( w, \
192         XmNrightAttachment, XmATTACH_WIDGET, \
193         XmNrightWidget, ref, \
194         XmNrightOffset, offset, \
195         0)
196
197 #define AddRightAttachForm( w, offset ) XtVaSetValues( w, \
198         XmNrightAttachment, XmATTACH_FORM, \
199         XmNrightOffset, offset, \
200         0)
201
202 #define AddBottomAttachForm( w, offset ) XtVaSetValues( w, \
203         XmNbottomAttachment, XmATTACH_FORM, \
204         XmNbottomOffset, offset, \
205         0)
206 #endif  /* USE_MACRO */
207
208
209 extern Widget CreateDrawingArea(Widget owner,
210                                 String name,
211                                 int width,
212                                 int height,
213                                 void (*proc)(),
214                                 int val);
215 extern Widget CreateDialogAndButtons(Widget owner,
216                                      String name,
217                                      void (*delcb)(),
218                                      Button *btns,
219                                      int btns_cnt,
220                                      Widget *pop);
221 extern String GetTextFieldValue(TextField *textf);
222 extern Widget CreateTemplateDialog(Widget w,
223                                    char *message,
224                                    unsigned char type,
225                                    NButton *button,
226                                    String title,
227                                    Widget *pop);
228 extern Widget CreateScrollBase(Widget owner,
229                                String name,
230                                int min,
231                                int max,
232                                int val,
233                                int vcnt,
234                                void (*sbproc)());
235
236 Widget  CreateCaptionFrame(Widget owner,
237                            String name,
238                            String labelstr,
239                            int type,
240                            int thickness);
241 void    CreateTextField(Widget owner,
242                         String name,
243                         String labelstr,
244                         TextField *data,
245                         int maxlength);
246 void    CreateMenuButtons(Widget owner, Button *buttons, int buttons_cnt);
247 Widget  GuiInitialize(XtAppContext *app,
248                       String class_name,
249                       int *ac,
250                       String av[]);
251 void    AddLeftAttachWidget(Widget w, Widget ref, int offset);
252 void    AddLeftAttachForm(Widget w, int offset);
253 void    AddTopAttachWidget(Widget w, Widget ref, int offset);
254 void    AddTopAttachForm(Widget w, int offset);
255 void    AddRightAttachWidget(Widget w, Widget ref, int offset);
256 void    AddRightAttachForm(Widget w, int offset);
257 void    AddBottomAttachForm(Widget w, int offset);
258 void    PopupDialog(Widget w);
259 void    PopdownDialog(Widget w);
260 void    ForcePopdownDialog(Widget w);
261 void    SetLabelString(Widget w, String str);
262 void    SetFooterString(Widget w, String str);
263 void    PopupNotice(Widget owner,
264                     char *message,
265                     unsigned char type,
266                     NButton *button,
267                     Boolean do_format,
268                     String title);
269 void    AddDeleteProc(Widget w, void (*delcb)());
270 Widget  CreateMenuBarAndFooterMessageForm(Widget owner,
271                                           String name,
272                                           MButton *buttons,
273                                           int bcnt,
274                                           Widget *pop,
275                                           Widget *footer);
276 Widget  GetMenuWidget(MButton *buttons, int buttons_num);
277 Widget  CreateForm(Widget owner, String name);
278 Widget  CreateLabel(Widget owner, String name, String str);
279 Widget  CreateFrame(Widget owner,
280                     String name,
281                     int type,
282                     int thickness);
283 Widget  CreateRowColumn(Widget owner,
284                         String name,
285                         int layout,
286                         int space,
287                         int marginw,
288                         int marginh);
289 Widget  CreateScrollBar(Widget owner,
290                         String name,
291                         int height,
292                         int val,
293                         int min,
294                         int max,
295                         void (*proc)());
296