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

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

extern "C"
{
#include _DrawP_
#include _FrameP_
#include _TranslateP_
#include _ListP_
#include _BulletinBP_
}

// ----- MtfList widget definition ------------------------------------------

#define MtfList OSVtList
#define MtfListIndex (XmListIndex + 1)

struct MtfListClassPart
{
	XtPointer reserved;
};

struct MtfListClassRec
{
	CoreClassPart coreClassPart;
	XmPrimitiveClassPart primitiveClassPart;
	XmListClassPart listClassPart;
	MtfListClassPart mtfListClassPart;
};

struct MtfListPart
{
	Pixmap pixmap;
	ZafPositionStruct lastMousePosition;
	XtIntervalId intervalID;
	ZafWindowObject *mouseObject;
};

struct MtfList
{
	CorePart core;
	XmPrimitivePart primitive;
	XmListPart list;
	MtfListPart mtfListPart;

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

	// Actions that map to Zinc functionality.
	static void begin_select(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->Event(L_SELECT); }
	static void button_select(MtfList *mtfObject, XEvent *xEvent, String *params, Cardinal *num_params);
	static void call_default(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->RootObject()->Event(L_SELECT); }
	static void classInitialize();
	static void deselect_all(MtfList *mtfObject, XEvent *, String *, Cardinal *);
	static void destroy_pixmap(MtfList *mtfObject);
	static void double_click(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->Event(L_DOUBLE_CLICK); }
	static void drag_drop(MtfList *mtfObject, XEvent *xEvent, String *params, Cardinal *nparams);
	static void enter(MtfList *mtfObject, XEvent *, String *, Cardinal *);
	static void expose(MtfList *mtfObject, XEvent *xEvent, Region xRegion);
	static void first_extend(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_EXTEND_FIRST); }
	static void first_item(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_FIRST); }
	static void focus_in(MtfList *mtfObject, XEvent *, String *, Cardinal *);
	static void focus_out(MtfList *mtfObject, XEvent *, String *, Cardinal *);
	static void help(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->Event(L_HELP); }
	static void initialize(MtfList *, MtfList *mtfObject, ArgList, Cardinal *);
	static void last_extend(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_EXTEND_LAST); }
	static void last_item(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_LAST); }
	static void leave(MtfList *mtfObject, XEvent *, String *, Cardinal *);
	static void left_item(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_LEFT); }
	static void list_motion(MtfList *mtfObject, XEvent *xEvent, String *, Cardinal *);
	static void next_extend(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_EXTEND_NEXT); }
	static void next_item(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_NEXT); }
	static void next_page(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_PGDN); }
	static void noop(MtfList *, XEvent *, String *, Cardinal *)
		{ } // no operation is performed by this function.
	static void previous_extend(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_EXTEND_PREVIOUS); }
	static void previous_item(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_PREVIOUS); }
	static void previous_page(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_PGUP); }
	static void select_all(MtfList *mtfObject, XEvent *, String *, Cardinal *);
	static void repeat(MtfList *mtfObject, XtIntervalId *intervalID);
	static void resize(MtfList *mtfObject)
		{ GetZincObject(mtfObject)->Event(N_SIZE); }
	static void right_item(MtfList *mtfObject, XEvent *, String *, Cardinal *)
		{ GetZincObject(mtfObject)->MoveEvent(L_RIGHT); }

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

#define ListPixmap(mtfObject) XmField(mtfObject, MtfList::offsets, \
	MtfList, pixmap, Pixmap)
#define LastMousePos(mtfObject) XmField(mtfObject, MtfList::offsets, \
	MtfList, lastMousePosition, ZafPositionStruct)
#define ListIntervalId(mtfObject) XmField(mtfObject, MtfList::offsets, \
	MtfList, intervalID, XtIntervalId)
#define MouseObject(mtfObject) XmField(mtfObject, MtfList::offsets, \
	MtfList, mouseObject, ZafWindowObject*)

#endif
