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

#if !defined(Z_POS_HPP)
#define Z_POS_HPP
#include <z_coord.hpp>

// --------------------------------------------------------------------------
// ----- ZafPositionStruct --------------------------------------------------
// --------------------------------------------------------------------------

class ZAF_EXPORT ZafDisplay;
struct ZAF_EXPORT ZafPositionStruct
{
	int column, line;
	ZafCoordinateType coordinateType;

	void Assign(int column, int line, ZafCoordinateType type = ZAF_COORD_DEFAULT);
	void HzShift(int shift);
	void VtShift(int shift);

	// --- Conversion ---
	void ConvertCoordinates(ZafCoordinateType newType, ZafDisplay *display = ZAF_NULLP(ZafDisplay));
	ZafPositionStruct Position(ZafCoordinateType type) const;

	// --- Operators ---
	bool operator==(const ZafPositionStruct &position) const;
	bool operator!=(const ZafPositionStruct &position) const;

	// --- OS specific functions ---
#	if defined(ZAF_MSWINDOWS)
	void Export(POINT &point) const { point.x = column, point.y = line; }
	void Import(const POINT &point) { column = point.x, line = point.y, coordinateType = ZAF_PIXEL; }
#	elif defined(ZAF_MACINTOSH)
	void Export(Point &point) const { point.h = (short)column, point.v = (short)line; }
	void Import(const Point &point) { column = point.h, line = point.v, coordinateType = ZAF_PIXEL; }
#	endif
};

// --- inline functions ---
inline void ZafPositionStruct::Assign(int tcolumn, int tline, ZafCoordinateType tCoordinateType)
	{ column = tcolumn, line = tline;
	  coordinateType = (tCoordinateType != ZAF_COORD_DEFAULT) ? tCoordinateType : coordinateType; }
inline void ZafPositionStruct::HzShift(int shift)
	{ column += shift; }
inline void ZafPositionStruct::VtShift(int shift)
	{ line += shift; }

#endif // Z_POS_HPP


