Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef _TMACROX_H_
Toshihiro Shimizu 890ddd
#define _TMACROX_H_
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FUNCPROTO
Toshihiro Shimizu 890ddd
#define FUNCPROTO 0xFF
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
#include <xm xm.h=""></xm>
Toshihiro Shimizu 890ddd
#include <xm bulletinb.h=""></xm>
Toshihiro Shimizu 890ddd
#include <xm frame.h=""></xm>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tmacro.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*---------------------------------------------------------------------------*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if XtSpecificationRelease >= 5
Toshihiro Shimizu 890ddd
typedef int xargc_t;
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
typedef unsigned int xargc_t;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*---------------------------------------------------------------------------*/
Toshihiro Shimizu 890ddd
/* macro per la gestione delle liste di argomenti */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ARG_VARS(num) \
Toshihiro Shimizu 890ddd
	Cardinal TxArgN = 0; \
Toshihiro Shimizu 890ddd
	Arg TxArgs[num]
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_ARG(resource, value)                                     \
Toshihiro Shimizu 890ddd
	{                                                                   \
Toshihiro Shimizu 890ddd
		if (TxArgN >= sizeof(TxArgs) / sizeof(Arg)) {                   \
Toshihiro Shimizu 890ddd
			fprintf(stderr, "TX_ADD_ARG error in file %s at line %d\n", \
Toshihiro Shimizu 890ddd
					__FILE__, __LINE__);                                \
Toshihiro Shimizu 890ddd
			abort();                                                    \
Toshihiro Shimizu 890ddd
		}                                                               \
Toshihiro Shimizu 890ddd
		XtSetArg(TxArgs[TxArgN], resource, value);                      \
Toshihiro Shimizu 890ddd
		TxArgN++;                                                       \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_RESET_ARGS TxArgN = 0;
Toshihiro Shimizu 890ddd
#define TX_ARGS TxArgs, TxArgN
Toshihiro Shimizu 890ddd
#define TX_N_ARGS TxArgN
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*---------------------------------------------------------------------------*/
Toshihiro Shimizu 890ddd
/* macro per la gestione dei form */
Toshihiro Shimizu 890ddd
/* nota: l'attachment che e' widget o form a seconda che il widget ci sia o no
Toshihiro Shimizu 890ddd
   e' una correzione veloce per lesstif (linux) che scrive un warning,
Toshihiro Shimizu 890ddd
   ma andrebbe lasciato solo di tipo XmATTACH_WIDGET e corretto il codice
Toshihiro Shimizu 890ddd
   che usa la macro sbagliata
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
#define TX_ADD_LEFT_FORM(offset)                      \
Toshihiro Shimizu 890ddd
	{                                                 \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNleftAttachment, XmATTACH_FORM); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNleftOffset, offset)             \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_LEFT_WIDGET(widget, offset)                                       \
Toshihiro Shimizu 890ddd
	{                                                                            \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNleftAttachment, widget ? XmATTACH_WIDGET : XmATTACH_FORM); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNleftWidget, widget);                                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNleftOffset, offset)                                        \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_LEFT_OPPOSITE(widget, offset)                     \
Toshihiro Shimizu 890ddd
	{                                                            \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNleftWidget, widget);                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNleftOffset, offset)                        \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_RIGHT_FORM(offset)                      \
Toshihiro Shimizu 890ddd
	{                                                  \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNrightAttachment, XmATTACH_FORM); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNrightOffset, offset)             \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_RIGHT_WIDGET(widget, offset)                                       \
Toshihiro Shimizu 890ddd
	{                                                                             \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNrightAttachment, widget ? XmATTACH_WIDGET : XmATTACH_FORM); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNrightWidget, widget);                                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNrightOffset, offset)                                        \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_RIGHT_OPPOSITE(widget, offset)                     \
Toshihiro Shimizu 890ddd
	{                                                             \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNrightWidget, widget);                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNrightOffset, offset)                        \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_TOP_FORM(offset)                      \
Toshihiro Shimizu 890ddd
	{                                                \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNtopAttachment, XmATTACH_FORM); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNtopOffset, offset)             \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_TOP_WIDGET(widget, offset)                                       \
Toshihiro Shimizu 890ddd
	{                                                                           \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNtopAttachment, widget ? XmATTACH_WIDGET : XmATTACH_FORM); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNtopWidget, widget);                                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNtopOffset, offset)                                        \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_TOP_OPPOSITE(widget, offset)                     \
Toshihiro Shimizu 890ddd
	{                                                           \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNtopWidget, widget);                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNtopOffset, offset)                        \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_BOTTOM_FORM(offset)                      \
Toshihiro Shimizu 890ddd
	{                                                   \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNbottomAttachment, XmATTACH_FORM); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNbottomOffset, offset)             \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_BOTTOM_WIDGET(widget, offset)                                       \
Toshihiro Shimizu 890ddd
	{                                                                              \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNbottomAttachment, widget ? XmATTACH_WIDGET : XmATTACH_FORM); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNbottomWidget, widget);                                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNbottomOffset, offset)                                        \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_BOTTOM_OPPOSITE(widget, offset)                     \
Toshihiro Shimizu 890ddd
	{                                                              \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNbottomWidget, widget);                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ARG(XmNbottomOffset, offset)                        \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*---------------------------------------------------------------------------*/
Toshihiro Shimizu 890ddd
/* macro per actions e translations */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_ACTIONS(w, action_table)              \
Toshihiro Shimizu 890ddd
	XtAppAddActions(XtWidgetToApplicationContext(w), \
Toshihiro Shimizu 890ddd
					(action_table), XtNumber(action_table));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_OVERRIDE_TRANSLATIONS(w, translation_table) \
Toshihiro Shimizu 890ddd
	XtOverrideTranslations((w), XtParseTranslationTable(translation_table));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TX_ADD_ACTIONS_AND_TRANSLATIONS(w, action_table, translation_table) \
Toshihiro Shimizu 890ddd
	{                                                                       \
Toshihiro Shimizu 890ddd
		TX_ADD_ACTIONS((w), (action_table))                                 \
Toshihiro Shimizu 890ddd
		TX_OVERRIDE_TRANSLATIONS((w), (translation_table))                  \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif