2 * $TOG: wwl.h /main/4 1998/04/17 11:46:09 mgreess $
4 * Copyright (c) 1991 HaL Computer Systems, Inc. All rights reserved.
5 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
9 * This software contains confidential information and trade secrets of HaL
10 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
11 * without the prior express written permission of HaL Computer Systems, Inc.
13 * RESTRICTED RIGHTS LEGEND
14 * Use, duplication, or disclosure by the Government is subject to
15 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
16 * Technical Data and Computer Software clause at DFARS 252.227-7013.
17 * HaL Computer Systems, Inc.
18 * 1315 Dell Avenue, Campbell, CA 95008
25 // Widget Wrapper Library by:
27 // ___ 0 Jean-Daniel Fekete uucp : jdf@lri.lri.fr
28 // / \ / LRI - Bat 490 bitnet: jdf@FRLRI61.bitnet
29 // / _/ / Universite de Paris-Sud voice : +33 (1) 69 41 65 91
30 // /__ \/ F-91405 ORSAY Cedex +33 (1) 69 41 66 29
32 #include <X11/Intrinsic.h>
36 #include "WXmString.h"
38 #include "WCallback.h"
43 # define _stringify(x) #x
45 # define _stringify(x) "x"
50 #ifndef _XtintrinsicP_h
51 typedef void (* XtProc)();
54 #define DEFINE_GETTER(rsc,typ,rnam) \
55 inline typ rsc() const \
56 { Arg a; typ __value; \
57 a.name = rnam; a.value = (XtArgVal)&__value; \
58 _Get(a); return __value; }
60 #define DEFINE_SETTER(rsc,typ,rnam) \
61 inline void rsc(typ val) const \
62 { Arg a; a.name = rnam; a.value = (XtArgVal)val; _Set(a); }
65 #define CASTRNAM (char*)
66 #define CASTVAL (void*)
72 #define DEFINE_ARG(rsc,typ,rnam) \
73 inline WArgList& rsc(typ val, WArgList& _w) const \
74 { return _w.Add (CASTRNAM rnam, CASTVAL val); }
76 #define DEFINE_GETTER_SETTER(rsc,typ,rnam) \
77 DEFINE_GETTER(rsc,typ,rnam) \
78 DEFINE_SETTER(rsc,typ,rnam) \
79 DEFINE_ARG(rsc, typ,rnam)
82 /*----------------------------------------------------------------------
83 * This special macro is used to prevent the dangerous action of setting
84 * an arg using a WXmString. Since the member XmString of the WXmString
85 * gets deleted when the WXmString gets deleted, an implicit cast to a
86 * WXmString can cause a temporary to be created whose scope is undefined.
87 * By using this macro, we require an XmString to be explicitly created
88 * which can be freed when the arg list is no longer needed
91 #define DEFINE_STRING_GETSET(resource,rname) \
92 DEFINE_GETTER(resource,WXmString,rname) \
93 DEFINE_SETTER(resource,WXmString,rname) \
94 DEFINE_ARG(resource,XmString,rname)
96 #define DEFINE_INIT(class_name, base_name, class) \
98 inline class_name() {} \
99 /* Constructor with widget */ \
100 inline class_name (Widget w) : base_name (w) {} \
102 /* Unmanaged Widget Constructors */ \
103 inline class_name (const WComposite& father, \
104 WidgetClass c = class, \
105 const char *name = _stringify(class_name), \
106 ArgList args = NULL, \
108 : base_name (father, c, name, args, card) {} \
110 inline class_name (const WComposite& father, \
112 ArgList args = NULL, \
114 : base_name (father, class, name, args, card) {} \
116 inline class_name (const WComposite& father, \
119 : base_name (father, class, name, args.Args(), args.NumArgs()) {} \
121 /* Managed Widget Constructors */ \
122 inline class_name (const WComposite& father, \
124 WidgetClass c = class, \
125 const char *name = _stringify(class_name), \
126 ArgList args = NULL, \
128 : base_name (father, automanage, c, name, args, card) {} \
130 inline class_name (const WComposite& father, \
133 ArgList args = NULL, \
135 : base_name (father, automanage, class, name, args, card) {} \
137 inline class_name (const WComposite& father, \
141 : base_name (father, automanage, class, name, args.Args(), \
144 inline class_name& operator=(const class_name& w) { \
150 #define DEFINE_POPUP_INIT(class_name, base_name, class) \
151 inline class_name (const WComposite& father, \
153 WidgetClass c = (WidgetClass)class, \
154 const char *name = _stringify(class_name), \
155 ArgList args = NULL, Cardinal card = 0) \
156 : base_name (father, popup, c, name, args, card) {} \
157 inline class_name (const WComposite& father, \
160 ArgList args = NULL, Cardinal card = 0) \
161 : base_name (father, popup, (WidgetClass)class, name, args, card) {} \
162 inline class_name (const WComposite& father, \
166 : base_name (father, popup, (WidgetClass)class, name, args.Args(), args.NumArgs()) {} \
167 inline void Popup (XtGrabKind grab = XtGrabNone) \
168 { XtPopup(widget,grab); } \
169 inline void Popdown () { XtPopdown(widget); }
171 #define DEFINE_CINIT(class_name, base_name, class) \
172 inline class_name (Widget w) : base_name (w) {} \
173 inline class_name (WObject& o) : base_name (o) {}
176 #define DEFINE_CALLBACK(cb_name, cb_res) \
177 inline void name2(Add,cb_name) (XtCallbackProc proc, caddr_t closure = 0) const \
178 { XtAddCallback(widget, cb_res, proc, closure); } \
179 inline void name2(Remove,cb_name) (XtCallbackProc proc, caddr_t closure = 0) const \
180 { XtRemoveCallback(widget, cb_res, proc, closure); } \
181 inline void name2(Call,cb_name) (caddr_t call_data) const \
182 { XtCallCallbacks(widget, cb_res, call_data); } \
183 inline void name2(RemoveAll,cb_name) () const \
184 { XtRemoveAllCallbacks(widget, cb_res); } \
185 DEFINE_GETTER_SETTER (cb_name, XtCallbackList, cb_res) \
186 inline WCallback* name2(Set,cb_name) (WWL* obj, WWL_FUN fun, void* client=0) { return SetCallback (cb_res, obj, fun, client); }
188 #define NULLWidget ((Widget)0)