//	Zinc Application Framework - M_WIN.HPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#if !defined(M_WIN_HPP)
#define M_WIN_HPP
#include <z_win.hpp>
#include "m_utils.hpp"

extern "C"
{
#include _MwmUtil_
#include _DialogS_
#include _DrawP_
#include _FrameP_
#include _ManagerP_
#include _MainWP_
#include _BulletinBP_
#include _ScrollWP_
#include _ShellP_
#include _PrimitiveP_
#include _AtomMgr_
#include _Protocols_
#include <X11/cursorfont.h>
}

// ----- MtfWindowShell widget definition -----------------------------------

#define MtfWindowShell OSWindowShell
#define MtfWindowShellIndex (TopLevelShellIndex + 1)

struct MtfWindowShellClassPart
{
	XtPointer reserved;
};

struct MtfWindowShellClassRec
{
	CoreClassPart coreClassPart;
	CompositeClassPart compositeClassPart;
	ShellClassPart shellClassPart;
	WMShellClassPart wmClassPart;
	VendorShellClassPart vendorClassPart;
	TopLevelShellClassPart topLevelClassPart;
	MtfWindowShellClassPart mtfWindowShellClassPart;
};

struct MtfWindowShellPart
{
	int borderSize;
	bool borderSizeInitialized;
	int titleSize;
	bool titleSizeInitialized;
};

struct MtfWindowShell
{
	CorePart core;
	CompositePart composite;
	ShellPart shell;
	WMShellPart wm;
	VendorShellPart vendor;
	TopLevelShellPart topLevel;
	MtfWindowShellPart mtfWindowShellPart;

	static MtfWindowShellClassRec classRecord;
	static XmOffsetPtr offsets;

	// Actions that map to Zinc functionality.
	static void callback(MtfWindowShell *mtfObject, ZafWindow *window, XEvent *xEvent, Boolean *);
	static void classInitialize();
	static void delete_window(MtfWindowShell *mtfObject, ZafWindow *window, XtPointer);
};

#define BorderSize(mtfShell) XmField(mtfShell, MtfWindowShell::offsets, \
	MtfWindowShell, borderSize, int)
#define BorderSizeInitialized(mtfShell) XmField(mtfShell, MtfWindowShell::offsets, \
	MtfWindowShell, borderSizeInitialized, bool)
#define TitleSize(mtfShell) XmField(mtfShell, MtfWindowShell::offsets, \
	MtfWindowShell, titleSize, int)
#define TitleSizeInitialized(mtfShell) XmField(mtfShell, MtfWindowShell::offsets, \
	MtfWindowShell, titleSizeInitialized, bool)

// ----- MtfWindowFrame widget definition -----------------------------------

#define MtfWindowFrame OSWindowFrame
#define MtfWindowFrameIndex (XmBulletinBoardIndex + 1)

struct MtfWindowFrameClassPart
{
	XtPointer reserved;
};

struct MtfWindowFrameClassRec
{
	CoreClassPart coreClassPart;
	CompositeClassPart compositeClassPart;
	ConstraintClassPart constraintClassPart;
	XmManagerClassPart managerClassPart;
	XmBulletinBoardClassPart bulletin_boardClassPart;
	MtfWindowFrameClassPart mtfWindowFrameClassPart;
};

struct MtfWindowFramePart
{
	unsigned char shadow_type;
};

struct MtfWindowFrame
{
	CorePart core;
	CompositePart composite;
	ConstraintPart constraint;
	XmManagerPart manager;
	XmBulletinBoardPart bulletin_board;
	MtfWindowFramePart mtfWindowFramePart;

	static MtfWindowFrameClassRec classRecord;
	static XmOffsetPtr offsets;
	static XtActionsRec action[];
	static char translations[];

	// Actions that map to Zinc functionality.
	static void classInitialize();
	static void expose(MtfWindowFrame *mtfObject, XEvent *xEvent, Region xRegion);
	static void help(MtfWindowFrame *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->Event(L_HELP); }
	static void initialize(MtfWindowFrame *request, MtfWindowFrame *init, ArgList argList, Cardinal *nparams);
	static void resize(MtfWindowFrame *mtfObject);

	// General purpose functions.
	static ZafWindow *GetZincObject(MtfWindowFrame *mtfObject)
		{ return ((ZafWindow *)mtfObject->manager.user_data); }
	static MtfWindowFrame *GetMotifWidget(OSWindowID screenID)
		{ return ((MtfWindowFrame *)screenID); }
	void OverrideTranslations(void);
};

#define Shadow_Type(mtfFrame) XmField(mtfFrame, MtfWindowFrame::offsets, \
	MtfWindowFrame, shadow_type, unsigned char)

// ----- MtfWindowClient widget definition ----------------------------------

#define MtfWindowClient OSWindowClient
#define MtfWindowClientIndex (XmBulletinBoardIndex + 1)

struct MtfWindowClientClassPart
{
	XtPointer reserved;
};

struct MtfWindowClientClassRec
{
	CoreClassPart coreClassPart;
	CompositeClassPart compositeClassPart;
	ConstraintClassPart constraintClassPart;
	XmManagerClassPart managerClassPart;
	XmBulletinBoardClassPart bulletin_boardClassPart;
	MtfWindowClientClassPart mtfWindowClientClassPart;
};

struct MtfWindowClientPart
{
};

struct MtfWindowClient
{
	CorePart core;
	CompositePart composite;
	ConstraintPart constraint;
	XmManagerPart manager;
	XmBulletinBoardPart bulletin_board;
	MtfWindowClientPart mtfWindowClientPart;

	static MtfWindowClientClassRec classRecord;
	static XmOffsetPtr offsets;
	static XtActionsRec action[];
	static char translations[];

	// Actions that map to Zinc functionality.
	static void activate(MtfWindowClient *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void arm(MtfWindowClient *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void call_default(MtfWindowClient *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->RootObject()->Event(L_SELECT); }
	static void classInitialize();
	static void drag_drop(MtfWindowClient *mtfObject, XEvent *xEvent, String *, Cardinal *);
	static void enter(MtfWindowClient *mtfObject, XEvent *xEvent, String *, Cardinal *);
	static void expose(MtfWindowClient *mtfObject, XEvent *xEvent, Region xRegion);
	static XtGeometryResult gmgr(Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *reply);
	static void help(MtfWindowClient *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->Event(L_HELP); }
	static void initialize(MtfWindowClient *request, MtfWindowClient *init, ArgList argList, Cardinal *nparams);
	static void leave(MtfWindowClient *mtfObject, XEvent *xEvent, String *, Cardinal *);
	static void mouse(MtfWindowClient *mtfObject, XEvent *xEvent, String *, Cardinal *);
	static void multi_activate(MtfWindowClient *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void multi_arm(MtfWindowClient *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void resize(MtfWindowClient *mtfObject);

	// General purpose functions.
	static ZafWindow *GetZincObject(MtfWindowClient *mtfObject)
		{ return ((ZafWindow *)mtfObject->manager.user_data); }
	static MtfWindowClient *GetMotifWidget(OSWindowID screenID)
		{ return ((MtfWindowClient *)screenID); }
	void OverrideTranslations(void);
};

// ----- MtfWindowObject widget definition ----------------------------------

#define MtfWindowObject OSWindowObject
#define MtfWindowObjectIndex (XmPrimitiveIndex + 1)

struct MtfWindowObjectClassPart
{
	XtPointer reserved;
};

struct MtfWindowObjectClassRec
{
	CoreClassPart coreClassPart;
	XmPrimitiveClassPart primitiveClassPart;
	MtfWindowObjectClassPart mtfWindowObjectClassPart;
};

struct MtfWindowObjectPart
{
};

struct MtfWindowObject
{
	CorePart core;
	XmPrimitivePart primitive;
	MtfWindowObjectPart mtfWindowObjectPart;

	static MtfWindowObjectClassRec classRecord;
	static XmOffsetPtr offsets;
	static XtActionsRec action[];
	static char translations[];

	// Actions that map to Zinc functionality.
	static void call_default(MtfWindowObject *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->RootObject()->Event(L_SELECT); }
	static void classInitialize();
	static void drag_drop(MtfWindowObject *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void enter(MtfWindowObject *mtfObject, XEvent *xEvent, String *, Cardinal *);
	static void expose(MtfWindowObject *mtfObject, XEvent *xEvent, Region xRegion);
	static void focus_in(MtfWindowObject *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void help(MtfWindowObject *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->Event(L_HELP); }
	static void highlight(MtfWindowObject *mtfObject);
	static void key(MtfWindowObject *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void mouse(MtfWindowObject *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void unhighlight(MtfWindowObject *mtfObject);
	static void resize(MtfWindowObject *mtfObject);
	static void leave(MtfWindowObject *mtfObject, XEvent *xEvent, String *, Cardinal *);

	// General purpose functions.
	static ZafWindowObject *GetZincObject(MtfWindowObject *mtfObject)
		{ return ((ZafWindowObject *)mtfObject->primitive.user_data); }
	static MtfWindowObject *GetMotifWidget(OSWindowID screenID)
		{ return ((MtfWindowObject *)screenID); }
	static bool IsMtfWindowObject(OSWindowID screenID)
		{ return (XtIsSubclass(screenID, (WidgetClassRec *)&classRecord)); }
};

#endif
