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

#if !defined(M_STR_HPP)
#define M_STR_HPP
#include <z_str1.hpp>
#include "m_utils.hpp"

extern "C"
{
#include _Text_
#include _TextFP_
}

// ----- MtfString widget definition ----------------------------------------

#define MtfString OSString
#define MtfStringIndex (XmTextFieldIndex + 1)

struct MtfStringClassPart
{
	XtPointer reserved;
};

struct MtfStringClassRec
{
	CoreClassPart coreClassPart;
	XmPrimitiveClassPart primitiveClassPart;
	XmTextFieldClassPart textClassPart;
	MtfStringClassPart mtfStringClassPart;  	
};

struct MtfStringPart
{
#if defined(__linux__)
	// The liniux tile_stipple pixmap is created with the depth of one so
	// it we need to create on of the correct depth.
	Pixmap linuxTileStipple;
#endif
};

struct MtfString
{
	CorePart core;
	XmPrimitivePart primitive;
	XmTextFieldPart text;
	MtfStringPart mtfStringPart;

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

	// Actions that map to Zinc functionality.
	static void activate(MtfString *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->Event(L_SELECT); }
	static void call_default(MtfString *mtfObject, XEvent *, String *, Cardinal *);
	static void changed(MtfString *mtfObject, ZafString *object, XmTextVerifyCallbackStruct *callback);
	static void classInitialize();
	static void drag_drop(MtfString *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void enter(MtfString *mtfObject, XEvent *xEvent, String *, Cardinal *);
	static void expose(MtfString *mtfObject, XEvent *xEvent, Region xRegion);
	static void extend_adjust(MtfString *mtfObject, XEvent *, String *, Cardinal *);
	static void extend_end(MtfString *mtfObject, XEvent *, String *, Cardinal *);
	static void extend_start(MtfString *mtfObject, XEvent *, String *, Cardinal *);
	static void focus_in(MtfString *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void grab_focus(MtfString *mtfObject, XEvent *, String *, Cardinal *);
	static void help(MtfString *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->Event(L_HELP); }
	static void highlight(MtfString *mtfObject);
	static void unhighlight(MtfString *mtfObject);
	static void input_filter(MtfString *mtfObject, ZafString *object, XmTextVerifyCallbackStruct *callback);
	static void leave(MtfString *mtfObject, XEvent *xEvent, String *, Cardinal *);

	// General purpose functions.
	static ZafString *GetZincObject(MtfString *mtfObject)
		{ return ((ZafString *)mtfObject->primitive.user_data); }
	static MtfString *GetMotifWidget(OSWindowID screenID)
		{ return ((MtfString *)screenID); }
};

#if defined(__linux__)
#	define LinuxTileStipple(mtfStr) XmField(mtfStr,\
	MtfString::offsets, MtfString, linuxTileStipple, Pixmap)
#endif

#endif
