Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / wwl / include / WWL / wwl.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 librararies 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 /*
24  * $TOG: wwl.h /main/4 1998/04/17 11:46:09 mgreess $
25  *
26  * Copyright (c) 1991 HaL Computer Systems, Inc.  All rights reserved.
27  * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28  * States.  Use of a copyright notice is precautionary only and does not
29  * imply publication or disclosure.
30  * 
31  * This software contains confidential information and trade secrets of HaL
32  * Computer Systems, Inc.  Use, disclosure, or reproduction is prohibited
33  * without the prior express written permission of HaL Computer Systems, Inc.
34  * 
35  *                         RESTRICTED RIGHTS LEGEND
36  * Use, duplication, or disclosure by the Government is subject to
37  * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38  * Technical Data and Computer Software clause at DFARS 252.227-7013.
39  *                        HaL Computer Systems, Inc.
40  *                  1315 Dell Avenue, Campbell, CA  95008
41  * 
42  */
43
44 #ifndef wwl_h
45 #define wwl_h
46
47 // Widget Wrapper Library by:
48 //
49 //    ___    0  Jean-Daniel Fekete            uucp  : jdf@lri.lri.fr
50 //   /   \  /   LRI - Bat 490                 bitnet: jdf@FRLRI61.bitnet
51 //  /   _/ /    Universite de Paris-Sud       voice : +33 (1) 69 41 65 91
52 // /__   \/     F-91405 ORSAY Cedex                   +33 (1) 69 41 66 29
53
54 #include <X11/Intrinsic.h>
55 #include <generic.h>
56
57 #include <Xm/Xm.h>
58 #include "WXmString.h"
59
60 #include "WCallback.h"
61 #include "WTimeOut.h"
62 #include "WArgList.h"
63
64 #ifdef __STDC__
65 # define _stringify(x)  #x
66 #else
67 # define _stringify(x)  "x"
68 #endif
69
70 class WComposite;
71
72 #ifndef _XtintrinsicP_h
73  typedef void   (* XtProc)();
74 #endif
75
76 #define DEFINE_GETTER(rsc,typ,rnam) \
77 inline typ rsc() const \
78 { Arg a; typ __value; \
79   a.name = rnam; a.value = (XtArgVal)&__value; \
80   _Get(a); return __value; }
81
82 #define DEFINE_SETTER(rsc,typ,rnam) \
83 inline void rsc(typ val) const \
84 { Arg a; a.name = rnam; a.value = (XtArgVal)val; _Set(a); }
85
86 #if defined(linux)
87 #define CASTRNAM (char*)
88 #define CASTVAL  (void*)
89 #else
90 #define CASTRNAM
91 #define CASTVAL
92 #endif
93
94 #define DEFINE_ARG(rsc,typ,rnam) \
95 inline WArgList& rsc(typ val, WArgList& _w) const \
96 { return _w.Add (CASTRNAM rnam, CASTVAL val); }
97
98 #define DEFINE_GETTER_SETTER(rsc,typ,rnam) \
99         DEFINE_GETTER(rsc,typ,rnam) \
100         DEFINE_SETTER(rsc,typ,rnam) \
101         DEFINE_ARG(rsc, typ,rnam)
102
103
104 /*----------------------------------------------------------------------
105  * This special macro is used to prevent the dangerous action of setting
106  * an arg using a WXmString.  Since the member XmString of the WXmString
107  * gets deleted when the WXmString gets deleted, an implicit cast to a
108  * WXmString can cause a temporary to be created whose scope is undefined.
109  * By using this macro, we require an XmString to be explicitly created
110  * which can be freed when the arg list is no longer needed
111  */
112
113 #define DEFINE_STRING_GETSET(resource,rname)    \
114         DEFINE_GETTER(resource,WXmString,rname) \
115         DEFINE_SETTER(resource,WXmString,rname) \
116         DEFINE_ARG(resource,XmString,rname)
117
118 #define DEFINE_INIT(class_name, base_name, class) \
119  \
120 inline  class_name() {} \
121 /* Constructor with widget */ \
122 inline  class_name (Widget w) : base_name (w) {} \
123  \
124 /* Unmanaged Widget Constructors */     \
125 inline  class_name (const WComposite&   father,                 \
126                     WidgetClass         c       = class,        \
127                     const char          *name   = _stringify(class_name), \
128                     ArgList             args    = NULL,         \
129                     Cardinal            card    = 0)            \
130         : base_name (father, c, name, args, card) {}            \
131  \
132 inline  class_name (const WComposite&   father,                 \
133                     const char          *name,                  \
134                     ArgList             args = NULL,            \
135                     Cardinal            card = 0)               \
136         : base_name (father, class, name, args, card) {}        \
137  \
138 inline  class_name (const WComposite&   father,                 \
139                     const char          *name,                  \
140                     WArgList            args)                   \
141         : base_name (father, class, name, args.Args(), args.NumArgs()) {} \
142  \
143 /* Managed Widget Constructors */ \
144 inline  class_name (const WComposite&   father,                 \
145                     int                 automanage,             \
146                     WidgetClass         c       = class,        \
147                     const char          *name   = _stringify(class_name), \
148                     ArgList             args    = NULL,         \
149                     Cardinal            card    = 0)            \
150         : base_name (father, automanage, c, name, args, card) {} \
151  \
152 inline  class_name (const WComposite&   father,                 \
153                     const char          *name,                  \
154                     int                 automanage,             \
155                     ArgList             args = NULL,            \
156                     Cardinal            card = 0)               \
157         : base_name (father, automanage, class, name, args, card) {} \
158  \
159 inline  class_name (const WComposite&   father,                 \
160                     const char          *name,                  \
161                     int                 automanage,             \
162                     WArgList            args)                   \
163         : base_name (father, automanage, class, name, args.Args(), \
164                      args.NumArgs()) {} \
165  \
166 inline  class_name& operator=(const class_name& w) { \
167                        widget = w.widget; \
168                        return *this; \
169                     } \
170
171
172 #define DEFINE_POPUP_INIT(class_name, base_name, class)                   \
173 inline  class_name (const WComposite& father,                     \
174                     Boolean popup,                                \
175                     WidgetClass c = (WidgetClass)class,           \
176                     const char *name = _stringify(class_name),    \
177                     ArgList args = NULL, Cardinal card = 0)       \
178                 : base_name (father, popup, c, name, args, card) {}       \
179 inline  class_name (const WComposite& father,                     \
180                     Boolean popup,                                \
181                     const char *name,                             \
182                     ArgList args = NULL, Cardinal card = 0)       \
183                 : base_name (father, popup, (WidgetClass)class, name, args, card) {} \
184 inline  class_name (const WComposite& father,                     \
185                     Boolean popup,                                \
186                     const char *name,                             \
187                     WArgList args)                                \
188                 : base_name (father, popup, (WidgetClass)class, name, args.Args(), args.NumArgs()) {} \
189 inline  void Popup (XtGrabKind grab = XtGrabNone)                 \
190                 { XtPopup(widget,grab); }                         \
191 inline  void Popdown () { XtPopdown(widget); }
192
193 #define DEFINE_CINIT(class_name, base_name, class)                \
194 inline  class_name (Widget w) : base_name (w) {}                  \
195 inline  class_name (WObject& o) : base_name (o) {}
196
197
198 #define DEFINE_CALLBACK(cb_name, cb_res)                              \
199 inline  void    name2(Add,cb_name) (XtCallbackProc proc, caddr_t closure = 0) const \
200                 { XtAddCallback(widget, cb_res, proc, closure); }     \
201 inline  void    name2(Remove,cb_name) (XtCallbackProc proc, caddr_t closure = 0) const \
202                 { XtRemoveCallback(widget, cb_res, proc, closure); }     \
203 inline  void    name2(Call,cb_name) (caddr_t call_data) const \
204                 { XtCallCallbacks(widget, cb_res, call_data); }     \
205 inline  void    name2(RemoveAll,cb_name) () const \
206                 { XtRemoveAllCallbacks(widget, cb_res); } \
207         DEFINE_GETTER_SETTER (cb_name, XtCallbackList, cb_res) \
208 inline  WCallback*      name2(Set,cb_name) (WWL* obj, WWL_FUN fun, void* client=0) { return SetCallback (cb_res, obj, fun, client); }
209
210 #define NULLWidget      ((Widget)0)
211
212 #endif