From: ianhogg@milli.cs.umn.edu (Ian J. Hogg)
Newsgroups: comp.windows.x.motif
Subject: XmVaCreate<Widget>
Date: 10 Jan 93 18:45:43 GMT
Article-I.D.: news2.C0nIs9.GM7
Organization: University of Minnesota, Minneapolis, CSci dept.

Someone posted a request the other day if OSF has created XmVaCreate versions
for all the XmCreate functions?  Since it doesn't look like those are in 1.2
and plenty of us are stuck with 1.1 for a while anyways, I decided to do it
myself.  This posting contains a shar archive of XmVa.h and XmVa.c.  XmVa.h
contains prototypes for XmVaCreate<Widget> and XmVaCreateManaged<Widget> for
every <Widget> contained in an XmCreate<Widget>.  The already existing 
XmVaCreateSimple<Widget>'s are not included.  One thing that does suck though,
XmVa.c contains the functions for all widget types.  It should probably be
split into one file per widget type to avoid having to link every widget
into your executable if you call only one XmVaCreate<Widget>.  I didn't worry
about it for now because my application uses pretty much every widget and we
use shared libs.

The file is simple enough that I didn't include a Makefile.  If enough people
think this is useful, I will clean it up and put it on export.


#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	XmVa.c
#	XmVa.h
# This archive created: Sun Jan 10 12:33:25 1993
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'XmVa.c'
then
	echo shar: "will not over-write existing file 'XmVa.c'"
else
cat << \SHAR_EOF > 'XmVa.c'
static char sccs_id[] = "@(#) 1.1 XmVa.c";

/*------------------------------------------------------------------------------
 * DESCRIPTION:
 *
 * Source code to create XmVaCreate<Widget> and XmVaCreateManaged<Widget>
 * for all Motif XmCreate convienence functions.
 *
 * Author: Ian J Hogg
 */
#include <stdarg.h>
#include <X11/Intrinsic.h>
#include <X11/ResourceI.h>
#include <X11/VarargsI.h>
#include <Xm/Xm.h>
#include <Xm/ArrowB.h>
#include <Xm/ArrowBG.h>
#include <Xm/BulletinB.h>
#include <Xm/CascadeB.h>
#include <Xm/CascadeBG.h>
#include <Xm/Command.h>
#include <Xm/DialogS.h>
#include <Xm/DrawingA.h>
#include <Xm/DrawnB.h>
#include <Xm/FileSB.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xm/Label.h>
#include <Xm/LabelG.h>
#include <Xm/List.h>
#include <Xm/MainW.h>
#include <Xm/MenuShell.h>
#include <Xm/MessageB.h>
#include <Xm/PanedW.h>
#include <Xm/PushB.h>
#include <Xm/PushBG.h>
#include <Xm/RowColumn.h>
#include <Xm/Scale.h>
#include <Xm/ScrollBar.h>
#include <Xm/ScrolledW.h>
#include <Xm/SelectioB.h>
#include <Xm/Separator.h>
#include <Xm/SeparatoG.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>

#include <XmVa.h>

#define VA_CREATE(WIDGET) \
Widget _XmVaCreate##WIDGET(Widget parent, String name, va_list var)	\
{ 									\
    va_list var2; 							\
    ArgList args;							\
    int     total_count, typed_count; 					\
    Cardinal nargs;							\
    Widget  w; 								\
            								\
    var2 = var; 							\
    _XtCountVaList(var2, &total_count, &typed_count); 			\
	 								\
    var2 = var;								\
    _XtVaToArgList(NULL, var2, total_count, &args, &nargs);		\
									\
    w = XmCreate##WIDGET(parent, name, args, nargs);			\
									\
    XtFree((XtPointer) args);						\
    return w;								\
}									\
    									\
Widget XmVaCreate##WIDGET(Widget parent, String name, ...)		\
{									\
    va_list var;							\
    Widget  w;								\
									\
    va_start(var, name);						\
    w = _XmVaCreate##WIDGET(parent, name, var);				\
    va_end(var);							\
									\
    return w;								\
}									\
									\
Widget XmVaCreateManaged##WIDGET(Widget parent, String name, ...)	\
{									\
    va_list var;							\
    Widget  w;								\
									\
    va_start(var, name);						\
    w = _XmVaCreate##WIDGET(parent, name, var);				\
    va_end(var);							\
									\
    if (w)								\
	XtManageChild(w);						\
									\
    return w;								\
}

VA_CREATE(ArrowButton)
VA_CREATE(ArrowButtonGadget)
VA_CREATE(BulletinBoard)
VA_CREATE(BulletinBoardDialog)
VA_CREATE(CascadeButton)
VA_CREATE(CascadeButtonGadget)
VA_CREATE(Command)
VA_CREATE(DialogShell)
VA_CREATE(DrawingArea)
VA_CREATE(DrawnButton)
VA_CREATE(ErrorDialog)
VA_CREATE(FileSelectionBox)
VA_CREATE(FileSelectionDialog)
VA_CREATE(Form)
VA_CREATE(FormDialog)
VA_CREATE(Frame)
VA_CREATE(InformationDialog)
VA_CREATE(Label)
VA_CREATE(LabelGadget)
VA_CREATE(List)
VA_CREATE(MainWindow)
VA_CREATE(MenuBar)
VA_CREATE(MenuShell)
VA_CREATE(MessageBox)
VA_CREATE(MessageDialog)
VA_CREATE(OptionMenu)
VA_CREATE(PanedWindow)
VA_CREATE(PopupMenu)
VA_CREATE(PromptDialog)
VA_CREATE(PulldownMenu)
VA_CREATE(PushButton)
VA_CREATE(PushButtonGadget)
VA_CREATE(QuestionDialog)
VA_CREATE(RadioBox)
VA_CREATE(RowColumn)
VA_CREATE(Scale)
VA_CREATE(ScrollBar)
VA_CREATE(ScrolledList)
VA_CREATE(ScrolledText)
VA_CREATE(ScrolledWindow)
VA_CREATE(SelectionBox)
VA_CREATE(SelectionDialog)
VA_CREATE(Separator)
VA_CREATE(SeparatorGadget)
VA_CREATE(Text)
VA_CREATE(TextField)
VA_CREATE(ToggleButton)
VA_CREATE(ToggleButtonGadget)
VA_CREATE(WarningDialog)
VA_CREATE(WorkArea)
VA_CREATE(WorkingDialog)
SHAR_EOF
fi
if test -f 'XmVa.h'
then
	echo shar: "will not over-write existing file 'XmVa.h'"
else
cat << \SHAR_EOF > 'XmVa.h'
/*------------------------------------------------------------------------------
 * @(#) 1.1 XmVa.h
 *
 * DESCRIPTION:
 *
 * Prototypes for XmVaCreate<Widget> and XmVaCreateManaged<Widget>
 *
 * Author: Ian J Hogg
 */
#ifndef XmVa_h
#define XmVa_h

#ifdef __cplusplus
extern "C" {
#endif

#define VA_DECLARE(WIDGET) \
extern Widget XmVaCreate##WIDGET(Widget parent, char *name, ...); \
extern Widget XmVaCreateManaged##WIDGET(Widget parent, char *name, ...);

VA_DECLARE(ArrowButton)
VA_DECLARE(ArrowButtonGadget)
VA_DECLARE(BulletinBoard)
VA_DECLARE(BulletinBoardDialog)
VA_DECLARE(CascadeButton)
VA_DECLARE(CascadeButtonGadget)
VA_DECLARE(Command)
VA_DECLARE(DialogShell)
VA_DECLARE(DrawingArea)
VA_DECLARE(DrawnButton)
VA_DECLARE(ErrorDialog)
VA_DECLARE(FileSelectionBox)
VA_DECLARE(FileSelectionDialog)
VA_DECLARE(Form)
VA_DECLARE(FormDialog)
VA_DECLARE(Frame)
VA_DECLARE(InformationDialog)
VA_DECLARE(Label)
VA_DECLARE(LabelGadget)
VA_DECLARE(List)
VA_DECLARE(MainWindow)
VA_DECLARE(MenuBar)
VA_DECLARE(MenuShell)
VA_DECLARE(MessageBox)
VA_DECLARE(MessageDialog)
VA_DECLARE(OptionMenu)
VA_DECLARE(PanedWindow)
VA_DECLARE(PopupMenu)
VA_DECLARE(PromptDialog)
VA_DECLARE(PulldownMenu)
VA_DECLARE(PushButton)
VA_DECLARE(PushButtonGadget)
VA_DECLARE(QuestionDialog)
VA_DECLARE(RadioBox)
VA_DECLARE(RowColumn)
VA_DECLARE(Scale)
VA_DECLARE(ScrollBar)
VA_DECLARE(ScrolledList)
VA_DECLARE(ScrolledText)
VA_DECLARE(ScrolledWindow)
VA_DECLARE(SelectionBox)
VA_DECLARE(SelectionDialog)
VA_DECLARE(Separator)
VA_DECLARE(SeparatorGadget)
VA_DECLARE(Text)
VA_DECLARE(TextField)
VA_DECLARE(ToggleButton)
VA_DECLARE(ToggleButtonGadget)
VA_DECLARE(WarningDialog)
VA_DECLARE(WorkArea)
VA_DECLARE(WorkingDialog)

#ifdef __cplusplus
}
#endif
#endif
SHAR_EOF
fi
exit 0
#	End of shell archive
--
===============================================================================
Ian Hogg						ianhogg@cs.umn.edu
                                                        (612) 424-6332