[comp.windows.x] Easy XtSetArg

doyle@infonode.ingr.com (Doyle Davidson) (05/04/91)

Here is a set of macros that I use to make XtSetArg life easier.
There is an assertion to make sure that you don't exceed the array size.
It works for both C and C++.

Enjoy!

Doyle
---------------------------------- cut here -----------------------
/*
 *
 * Author:	Doyle C. Davidson
 *		Intergraph Corporation
 *		One Madison Industrial Park
 *		Huntsville, Al.  35894-0001
 *
 * My macros for using XtSetArg easily:
 * Usage:
 *	
 *	blah()
 *	{
 *	DeclareArgs(2);
 *		...
 *		FirstArg(XmNx, 100);
 *		NextArg(XmNy, 80);
 *		button = XmCreatePushButton(parent, name, Args, ArgCount);
 *	}
 */

#define ArgCount	_fooArgCount
#define Args		_fooArgList
#define ArgCountMax     _fooArgCountMax

#define DeclareArgs(n)  Arg Args[n]; int ArgCountMax = n; int ArgCount

#define FirstArg(name, val) \
	{ XtSetArg(Args[0], (name), (val)); ArgCount=1;}
#define NextArg(name, val) \
	{ assert(ArgCount < ArgCountMax); \
	  XtSetArg(Args[ArgCount], (name), (val)); ArgCount++;}
---------------------------------- end here -----------------------
------------------------------------------------------------------
Doyle C. Davidson              |
Intergraph Corp.               |  These comments are...
Workstation Graphics Standards |
1 Madison Industrial Park      |
Huntsville, AL 35806           |
(205) 730-2000                 |         X-clusively my own.
                               |
..!uunet!ingr!doyle            |
------------------------------------------------------------------