2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
24 * $TOG: wwl.h /main/4 1998/04/17 11:46:09 mgreess $
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.
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.
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
47 // Widget Wrapper Library by:
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
54 #include <X11/Intrinsic.h>
58 #include "WXmString.h"
60 #include "WCallback.h"
65 # define _stringify(x) #x
67 # define _stringify(x) "x"
72 #ifndef _XtintrinsicP_h
73 typedef void (* XtProc)();
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; }
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); }
87 #define CASTRNAM (char*)
88 #define CASTVAL (void*)
94 #define DEFINE_ARG(rsc,typ,rnam) \
95 inline WArgList& rsc(typ val, WArgList& _w) const \
96 { return _w.Add (CASTRNAM rnam, CASTVAL val); }
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)
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
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)
118 #define DEFINE_INIT(class_name, base_name, class) \
120 inline class_name() {} \
121 /* Constructor with widget */ \
122 inline class_name (Widget w) : base_name (w) {} \
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, \
130 : base_name (father, c, name, args, card) {} \
132 inline class_name (const WComposite& father, \
134 ArgList args = NULL, \
136 : base_name (father, class, name, args, card) {} \
138 inline class_name (const WComposite& father, \
141 : base_name (father, class, name, args.Args(), args.NumArgs()) {} \
143 /* Managed Widget Constructors */ \
144 inline class_name (const WComposite& father, \
146 WidgetClass c = class, \
147 const char *name = _stringify(class_name), \
148 ArgList args = NULL, \
150 : base_name (father, automanage, c, name, args, card) {} \
152 inline class_name (const WComposite& father, \
155 ArgList args = NULL, \
157 : base_name (father, automanage, class, name, args, card) {} \
159 inline class_name (const WComposite& father, \
163 : base_name (father, automanage, class, name, args.Args(), \
166 inline class_name& operator=(const class_name& w) { \
172 #define DEFINE_POPUP_INIT(class_name, base_name, class) \
173 inline class_name (const WComposite& father, \
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, \
182 ArgList args = NULL, Cardinal card = 0) \
183 : base_name (father, popup, (WidgetClass)class, name, args, card) {} \
184 inline class_name (const WComposite& father, \
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); }
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) {}
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); }
210 #define NULLWidget ((Widget)0)