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>
55 #if !defined(linux) && !defined(CSRG_BASED)
58 #define name2(__n1,__n2) __paste2(__n1,__n2)
59 #define __paste2(__p1,__p2) __p1##__p2
63 #include "WXmString.h"
65 #include "WCallback.h"
70 # define _stringify(x) #x
72 # define _stringify(x) "x"
77 #ifndef _XtintrinsicP_h
78 typedef void (* XtProc)();
81 #if defined(linux) || defined(CSRG_BASED)
82 #define CASTRNAM (char*)
83 #define CASTVAL (void*)(size_t)
89 #define DEFINE_GETTER(rsc,typ,rnam) \
90 inline typ rsc() const \
91 { Arg a; typ __value; \
92 a.name = CASTRNAM rnam; a.value = (XtArgVal)&__value; \
93 _Get(a); return __value; }
95 #define DEFINE_SETTER(rsc,typ,rnam) \
96 inline void rsc(typ val) const \
97 { Arg a; a.name = CASTRNAM rnam; a.value = (XtArgVal)val; _Set(a); }
99 #define DEFINE_ARG(rsc,typ,rnam) \
100 inline WArgList& rsc(typ val, WArgList& _w) const \
101 { return _w.Add (CASTRNAM rnam, CASTVAL val); }
103 #define DEFINE_GETTER_SETTER(rsc,typ,rnam) \
104 DEFINE_GETTER(rsc,typ,rnam) \
105 DEFINE_SETTER(rsc,typ,rnam) \
106 DEFINE_ARG(rsc, typ,rnam)
109 /*----------------------------------------------------------------------
110 * This special macro is used to prevent the dangerous action of setting
111 * an arg using a WXmString. Since the member XmString of the WXmString
112 * gets deleted when the WXmString gets deleted, an implicit cast to a
113 * WXmString can cause a temporary to be created whose scope is undefined.
114 * By using this macro, we require an XmString to be explicitly created
115 * which can be freed when the arg list is no longer needed
118 #define DEFINE_STRING_GETSET(resource,rname) \
119 DEFINE_GETTER(resource,WXmString,rname) \
120 DEFINE_SETTER(resource,WXmString,rname) \
121 DEFINE_ARG(resource,XmString,rname)
123 #define DEFINE_INIT(class_name, base_name, class) \
125 inline class_name() {} \
126 /* Constructor with widget */ \
127 inline class_name (Widget w) : base_name (w) {} \
129 /* Unmanaged Widget Constructors */ \
130 inline class_name (const WComposite& father, \
131 WidgetClass c = class, \
132 const char *name = _stringify(class_name), \
133 ArgList args = NULL, \
135 : base_name (father, c, name, args, card) {} \
137 inline class_name (const WComposite& father, \
139 ArgList args = NULL, \
141 : base_name (father, class, name, args, card) {} \
143 inline class_name (const WComposite& father, \
146 : base_name (father, class, name, args.Args(), args.NumArgs()) {} \
148 /* Managed Widget Constructors */ \
149 inline class_name (const WComposite& father, \
151 WidgetClass c = class, \
152 const char *name = _stringify(class_name), \
153 ArgList args = NULL, \
155 : base_name (father, automanage, c, name, args, card) {} \
157 inline class_name (const WComposite& father, \
160 ArgList args = NULL, \
162 : base_name (father, automanage, class, name, args, card) {} \
164 inline class_name (const WComposite& father, \
168 : base_name (father, automanage, class, name, args.Args(), \
171 inline class_name& operator=(const class_name& w) { \
177 #define DEFINE_POPUP_INIT(class_name, base_name, class) \
178 inline class_name (const WComposite& father, \
180 WidgetClass c = (WidgetClass)class, \
181 const char *name = _stringify(class_name), \
182 ArgList args = NULL, Cardinal card = 0) \
183 : base_name (father, popup, c, name, args, card) {} \
184 inline class_name (const WComposite& father, \
187 ArgList args = NULL, Cardinal card = 0) \
188 : base_name (father, popup, (WidgetClass)class, name, args, card) {} \
189 inline class_name (const WComposite& father, \
193 : base_name (father, popup, (WidgetClass)class, name, args.Args(), args.NumArgs()) {} \
194 inline void Popup (XtGrabKind grab = XtGrabNone) \
195 { XtPopup(widget,grab); } \
196 inline void Popdown () { XtPopdown(widget); }
198 #define DEFINE_CINIT(class_name, base_name, class) \
199 inline class_name (Widget w) : base_name (w) {} \
200 inline class_name (WObject& o) : base_name (o) {}
203 #define DEFINE_CALLBACK(cb_name, cb_res) \
204 inline void name2(Add,cb_name) (XtCallbackProc proc, caddr_t closure = 0) const \
205 { XtAddCallback(widget, cb_res, proc, closure); } \
206 inline void name2(Remove,cb_name) (XtCallbackProc proc, caddr_t closure = 0) const \
207 { XtRemoveCallback(widget, cb_res, proc, closure); } \
208 inline void name2(Call,cb_name) (caddr_t call_data) const \
209 { XtCallCallbacks(widget, cb_res, call_data); } \
210 inline void name2(RemoveAll,cb_name) () const \
211 { XtRemoveAllCallbacks(widget, cb_res); } \
212 DEFINE_GETTER_SETTER (cb_name, XtCallbackList, cb_res) \
213 inline WCallback* name2(Set,cb_name) (WWL* obj, WWL_FUN fun, void* client=0) { return SetCallback (cb_res, obj, fun, client); }
215 #define NULLWidget ((Widget)0)