/*---------------------------------------------------------------------
 * $Date: 2002/01/31 17:55:25 $             $Revision: 727.2 $
 *---------------------------------------------------------------------
 *
 *             Copyright (c) 1989-1996, Visual Edge Software Ltd.
 *
 * ALL  RIGHTS  RESERVED.  Permission  to  use,  copy,  modify,  and
 * distribute  this  software  and its documentation for any purpose
 * and  without  fee  is  hereby  granted,  provided  that the above
 * copyright  notice  appear  in  all  copies  and  that  both  that
 * copyright  notice and this permission notice appear in supporting
 * documentation,  and that  the name of Visual Edge Software not be
 * used  in advertising  or publicity  pertaining to distribution of
 * the software without specific, written prior permission. The year
 * included in the notice is the year of the creation of the work.
 *---------------------------------------------------------------------
 * Definition of the UIM/X interface base class "UxInterface",
 * C and C++ versions, and its subclass, "UxVisualInterface".  These
 * definitions are shared by all code generation options.
 *-------------------------------------------------------------------*/

#ifndef _UXINTERFACE_INCLUDED
#define _UXINTERFACE_INCLUDED

#ifdef __cplusplus

#include "UxBase.h"

class UxInterface : public UxBase
{
    public:
	UXINLINE UxInterface();
	virtual ~UxInterface();
	UXINLINE Boolean auto_destroy() const;

	static void UxDestroyContextCB(Widget, XtPointer, XtPointer);

    protected:
	UXINLINE void auto_destroy(Boolean value);
	Boolean auto_destroy_flag;
};

class UxVisualInterface : public UxInterface
{
    public:
	virtual swidget childSite (Environment *pEnv);
	virtual swidget UxChildSite (swidget sw);
	virtual void _set_x (Environment*, int);
	virtual int  _get_x (Environment*);
	virtual void _set_y (Environment*, int);
	virtual int  _get_y (Environment*);
	virtual void _set_width (Environment*, int);
	virtual int  _get_width (Environment*);
	virtual void _set_height (Environment*, int);
	virtual int  _get_height (Environment*);
	virtual void Manage (Environment *pEnv = NULL);
	virtual void Unmanage (Environment *pEnv = NULL);
	virtual swidget get_UxThis();
};

#define CPLUS_ADAPT_CONTEXT(CLASS) \
	static inline \
		CLASS* UxGetContext(CLASS*self) {return self;} \
	static inline\
		void* UxGetContext(swidget any) {return ::UxGetContext(any);}


/* Corba - to - C++ translation for method calls. */
#ifndef DESIGN_TIME
inline UxInterface::UxInterface(): auto_destroy_flag(False)
{
};

inline void UxInterface::auto_destroy(Boolean value)
{
	auto_destroy_flag = value;
}

inline Boolean UxInterface::auto_destroy() const
{
	return auto_destroy_flag;
}

inline int VisualInterface__get_x(swidget UxThis, Environment* pEnv)
{
	return ((UxVisualInterface*)UxGetContext(UxThis))->_get_x(pEnv);
}

inline void VisualInterface__set_x(swidget UxThis, Environment *pEnv, int value)
{
	((UxVisualInterface*)UxGetContext(UxThis))->_set_x(pEnv, value);
}

inline int VisualInterface__get_y(swidget UxThis, Environment* pEnv)
{
	return ((UxVisualInterface*)UxGetContext(UxThis))->_get_y(pEnv);
}

inline void VisualInterface__set_y(swidget UxThis, Environment *pEnv, int value)
{
	((UxVisualInterface*)UxGetContext(UxThis))->_set_y(pEnv, value);
}

inline int VisualInterface__get_width(swidget UxThis, Environment *pEnv)
{
	return ((UxVisualInterface*)UxGetContext(UxThis))->_get_width(pEnv);
}

inline void VisualInterface__set_width(swidget UxThis, Environment *pEnv,
				       int value)
{
	((UxVisualInterface*)UxGetContext(UxThis))->_set_width(pEnv, value);
}

inline int VisualInterface__get_height(swidget UxThis, Environment *pEnv)
{
	return ((UxVisualInterface*)UxGetContext(UxThis))->_get_height(pEnv);
}

inline void VisualInterface__set_height(swidget UxThis, Environment *pEnv,
					int value)
{
	((UxVisualInterface*)UxGetContext(UxThis))->_set_height(pEnv, value);
}

inline void VisualInterface_Manage(swidget UxThis, Environment *pEnv)
{
	((UxVisualInterface*)UxGetContext(UxThis))->Manage(pEnv);
}

inline void VisualInterface_Unmanage(swidget UxThis, Environment *pEnv)
{
	((UxVisualInterface*)UxGetContext(UxThis))->Unmanage(pEnv);
}

#endif /* ! DESIGN_TIME */
#endif /* __cplusplus */


#if !defined(__cplusplus) || defined (DESIGN_TIME)
/* C interface to the base class. */

#  define VisualInterface__get_x( UxThis, pEnv ) \
	((int(*)UXPROTO((swidget,Environment*)))UxMethodLookup(UxThis, UxVisualInterface__get_x_Id, UxVisualInterface__get_x_Name)) \
		( UxThis, pEnv )

#  define VisualInterface__set_x( UxThis, pEnv, value ) \
	((void(*)UXPROTO((swidget,Environment*,int)))UxMethodLookup(UxThis, UxVisualInterface__set_x_Id, UxVisualInterface__set_x_Name)) \
		( UxThis, pEnv, value )

#  define VisualInterface__get_y( UxThis, pEnv ) \
	((int(*)UXPROTO((swidget,Environment*)))UxMethodLookup(UxThis, UxVisualInterface__get_y_Id, UxVisualInterface__get_y_Name)) \
		( UxThis, pEnv )

#  define VisualInterface__set_y( UxThis, pEnv, value ) \
	((void(*)UXPROTO((swidget,Environment*,int)))UxMethodLookup(UxThis, UxVisualInterface__set_y_Id, UxVisualInterface__set_y_Name)) \
		( UxThis, pEnv, value )

#  define VisualInterface__get_width( UxThis, pEnv ) \
	((int(*)UXPROTO((swidget,Environment*)))UxMethodLookup(UxThis, UxVisualInterface__get_width_Id, UxVisualInterface__get_width_Name)) \
		( UxThis, pEnv )

#  define VisualInterface__set_width( UxThis, pEnv, value ) \
	((void(*)UXPROTO((swidget,Environment*,int)))UxMethodLookup(UxThis, UxVisualInterface__set_width_Id, UxVisualInterface__set_width_Name)) \
		( UxThis, pEnv, value )

#  define VisualInterface__get_height( UxThis, pEnv ) \
	((int(*)UXPROTO((swidget,Environment*)))UxMethodLookup(UxThis, UxVisualInterface__get_height_Id, UxVisualInterface__get_height_Name)) \
		( UxThis, pEnv )

#  define VisualInterface__set_height( UxThis, pEnv, value ) \
	((void(*)UXPROTO((swidget,Environment*,int)))UxMethodLookup(UxThis, UxVisualInterface__set_height_Id, UxVisualInterface__set_height_Name)) \
		( UxThis, pEnv, value )

#  define VisualInterface_Manage( UxThis, pEnv ) \
	do {\
		swidget _sw_ = UxThis;\
		((void(*)UXPROTO((swidget,Environment *)))UxMethodLookup(_sw_, UxVisualInterface_Manage_Id, UxVisualInterface_Manage_Name)) \
			( _sw_, pEnv ); \
	} while (0)


#  define VisualInterface_Unmanage( UxThis, pEnv ) \
	do {\
		swidget _sw_ = UxThis;\
		((void(*)UXPROTO((swidget,Environment *)))UxMethodLookup(_sw_, UxVisualInterface_Unmanage_Id, UxVisualInterface_Unmanage_Name)) \
			( _sw_, pEnv ); \
	} while (0)

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

  extern int	UxVisualInterface__get_x_Id;
  extern char*	UxVisualInterface__get_x_Name;
  extern int	UxVisualInterface__get_y_Id;
  extern char*	UxVisualInterface__get_y_Name;
  extern int	UxVisualInterface__set_x_Id;
  extern char*	UxVisualInterface__set_x_Name;
  extern int	UxVisualInterface__set_y_Id;
  extern char*	UxVisualInterface__set_y_Name;
  extern int	UxVisualInterface__get_width_Id;
  extern char*	UxVisualInterface__get_width_Name;
  extern int	UxVisualInterface__set_width_Id;
  extern char*	UxVisualInterface__set_width_Name;
  extern int	UxVisualInterface__get_height_Id;
  extern char*	UxVisualInterface__get_height_Name;
  extern int	UxVisualInterface__set_height_Id;
  extern char*	UxVisualInterface__set_height_Name;
  extern int	UxVisualInterface_Manage_Id;
  extern char*	UxVisualInterface_Manage_Name;
  extern int	UxVisualInterface_Unmanage_Id;
  extern char*	UxVisualInterface_Unmanage_Name;

  /*
   * This is used to get a class ID for each top-level interface class.
   * It ensures that the interface base class is registered.
   */
/*************************************
** DOUG Added void for better prototyping 
****************************************/
  int	UxNewInterfaceClassId (void);

#ifdef __cplusplus
}  /* Close scope of 'extern "C"' declaration. */
#endif /* __cplusplus */

/*----------------------------------------------------------------------
 * Generated code uses these macros when setting component properties.
 *----------------------------------------------------------------------*/

/* Horrible patch for sun4's cc incapacity to concatenate strings. */

#if defined(sun4)
#       define UXCONCAT(a,b) UxConcatStrings(a,b)
#else
#       define UXCONCAT(a,b) a b
#endif /* sun4 */

/* CORBA1 */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#		define UxPUT_PROPERTY_CORBA1(sw, propname, valType, value) \
 		((void (*)(swidget, Environment *, valType)) \
			UxMethodLookup((sw), -1, "_set_" # propname)) \
			(sw, &UxEnv, (value))
#	else /* (__STDC__) || (UX_INTERPRETER) */
#		define UxPUT_PROPERTY_CORBA1(sw, propname, valType, value) \
 		((void (*)()) UxMethodLookup((sw), -1, UXCONCAT("_set_","propname"))) \
        		(sw, &UxEnv, (value))
#	endif /* (__STDC__) || (UX_INTERPRETER) */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#		define UxPUT_CHILDPROPERTY_CORBA1(parent, child, propname, valType, value) \
 		((void (*)(swidget, Environment *, swidget, valType)) \
			UxMethodLookup((parent), -1, "_set_" # propname)) \
			(parent, &UxEnv, child, (value))
#	else /* (__STDC__) || (UX_INTERPRETER) */
#		define UxPUT_CHILDPROPERTY_CORBA1(parent, child, propname, valType, value) \
 		((void (*)()) UxMethodLookup((parent), -1, UXCONCAT("_set_","propname"))) \
        		(parent, &UxEnv, child, (value))
#	endif /* (__STDC__) || (UX_INTERPRETER) */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#	define UxPUT_CALLBACK_CORBA1(sw, cbName, cbVal, clientData) \
 	((void (*)(swidget, Environment *, XtCallbackProc, void *)) \
		UxMethodLookup((sw), -1, cbName)) \
      		((sw), &UxEnv, (cbVal), (clientData)) 
#	else
#	define UxPUT_CALLBACK_CORBA1(sw, cbName, cbVal, clientData) \
        ((void (*)()) \
                UxMethodLookup((sw), -1, cbName)) \
                ((sw), &UxEnv, (cbVal), (clientData))
#	endif /* (__STDC__) || (UX_INTERPRETER) */

/* CORBA2 */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#		define UxPUT_PROPERTY_CORBA2(sw, propname, valType, value) \
 		((void (*)(swidget, valType, Environment *)) \
			UxMethodLookup((sw), -1, "_set_" # propname)) \
			(sw, (value), &UxEnv)
#	else /* (__STDC__) || (UX_INTERPRETER) */
#		define UxPUT_PROPERTY_CORBA2(sw, propname, valType, value) \
 		((void (*)()) UxMethodLookup((sw), -1, UXCONCAT("_set_","propname"))) \
        		(sw, (value), &UxEnv)
#	endif /* (__STDC__) || (UX_INTERPRETER) */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#		define UxPUT_CHILDPROPERTY_CORBA2(parent, child, propname, valType, value) \
 		((void (*)(swidget, swidget, valType, Environment *)) \
			UxMethodLookup((parent), -1, "_set_" # propname)) \
			(parent, child, (value), &UxEnv)
#	else /* (__STDC__) || (UX_INTERPRETER) */
#		define UxPUT_CHILDPROPERTY_CORBA2(parent, child, propname, valType, value) \
 		((void (*)()) UxMethodLookup((parent), -1, UXCONCAT("_set_","propname"))) \
        		(parent, child, (value), &UxEnv)
#	endif /* (__STDC__) || (UX_INTERPRETER) */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#	define UxPUT_CALLBACK_CORBA2(sw, cbName, cbVal, clientData) \
 	((void (*)(swidget, XtCallbackProc, void *, Environment *)) \
		UxMethodLookup((sw), -1, cbName)) \
      		((sw), (cbVal), (clientData), &UxEnv) 
#	else
#	define UxPUT_CALLBACK_CORBA2(sw, cbName, cbVal, clientData) \
        ((void (*)()) \
                UxMethodLookup((sw), -1, cbName)) \
                ((sw), (cbVal), (clientData), &UxEnv)
#	endif /* (__STDC__) || (UX_INTERPRETER) */

/* CORBANONE */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#		define UxPUT_PROPERTY_CORBANONE(sw, propname, valType, value) \
 		((void (*)(swidget, valType)) \
			UxMethodLookup((sw), -1, "_set_" # propname)) \
			(sw, (value))
#	else /* (__STDC__) || (UX_INTERPRETER) */
#		define UxPUT_PROPERTY_CORBANONE(sw, propname, valType, value) \
 		((void (*)()) UxMethodLookup((sw), -1, UXCONCAT("_set_","propname"))) \
        		(sw, (value))
#	endif /* (__STDC__) || (UX_INTERPRETER) */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#		define UxPUT_CHILDPROPERTY_CORBANONE(parent, child, propname, valType, value) \
 		((void (*)(swidget, swidget, valType)) \
			UxMethodLookup((parent), -1, "_set_" # propname)) \
			(parent, child, (value))
#	else /* (__STDC__) || (UX_INTERPRETER) */
#		define UxPUT_CHILDPROPERTY_CORBANONE(parent, child, propname, valType, value) \
 		((void (*)()) UxMethodLookup((parent), -1, UXCONCAT("_set_","propname"))) \
        		(parent, child, (value))
#	endif /* (__STDC__) || (UX_INTERPRETER) */

#	if defined(__STDC__) || defined(UX_INTERPRETER)
#	define UxPUT_CALLBACK_CORBANONE(sw, cbName, cbVal, clientData) \
 	((void (*)(swidget, XtCallbackProc, void *)) \
		UxMethodLookup((sw), -1, cbName)) \
      		((sw), (cbVal), (clientData)) 
#	else
#	define UxPUT_CALLBACK_CORBANONE(sw, cbName, cbVal, clientData) \
        ((void (*)()) \
                UxMethodLookup((sw), -1, cbName)) \
                ((sw), (cbVal), (clientData))
#	endif /* (__STDC__) || (UX_INTERPRETER) */

/* Backwards compatability */
#define UxPUT_PROPERTY(sw, propname, valType, value) \
	UxPUT_PROPERTY_CORBA1(sw, propname, valType, value)
#define UxPUT_CHILDPROPERTY(parent, child, propname, valType, value) \
	UxPUT_CHILDPROPERTY_CORBA1(parent, child, propname, valType, value)
#define UxPUT_CALLBACK(sw, cbName, cbVal, clientData) \
	UxPUT_CALLBACK_CORBA1(sw, cbName, cbVal, clientData)

#endif /* !__cplusplus || DESIGN_TIME */

/* Backwards compatibility */
#define _UxCInterface		UxVisualInterface
#define Interface__get_x	VisualInterface__get_x
#define Interface__set_x	VisualInterface__set_x
#define Interface__get_y	VisualInterface__get_y
#define Interface__set_y	VisualInterface__set_y
#define Interface__get_width	VisualInterface__get_width
#define Interface__set_width	VisualInterface__set_width
#define Interface__get_height	VisualInterface__get_height
#define Interface__set_height	VisualInterface__set_height
#define Interface_UxManage	VisualInterface_Manage
#define Interface_UxUnmanage	VisualInterface_Unmanage

#endif /* _UXINTERFACE_INCLUDED */
