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

#include <z_status.hpp>
#include "m_win.hpp"

// ----- ZafStatusBar -------------------------------------------------------

void ZafStatusBar::ConvertRegion(ZafRegionStruct &region, ZafCoordinateType newType)
{
	// Defer to the base class.
	ZafWindowObject::ConvertRegion(region, newType);
}

ZafPositionStruct ZafStatusBar::ConvertToOSPosition(const ZafWindowObject *object,
	const ZafPositionStruct *position) const
{
	// Defer to the base class.
	ZafPositionStruct osPosition = ZafWindowObject::ConvertToOSPosition(object, position);
	osPosition.line -= ZAF_BORDER_SIZE;
	return (osPosition);
}

ZafPositionStruct ZafStatusBar::ConvertToZafPosition(const ZafWindowObject *object,
	const ZafPositionStruct *position) const
{
	// Defer to the base class.
	return (ZafWindowObject::ConvertToZafPosition(object, position));
}

#if defined(ZAF_DEFAULT_DRAW)
ZafEventType ZafStatusBar::Draw(const ZafEventStruct &event, ZafEventType ccode)
{
	// Check for draw errors.
	if (!screenID)
		return (S_ERROR);

	// Compute the actual draw region.
	BeginDraw();

	// Draw the list items that appear on the screen.
	for (ZafWindowObject *object = First(); object; object = object->Next())
		if (object->Visible())
			object->Draw(event, S_NON_CURRENT);

	// Return the control code.
	EndDraw();
	return (ccode);
}

ZafEventType ZafStatusBar::DrawBorder(ZafRegionStruct &region, ZafEventType ccode)
{
	// Defer to the base class.
	return (ZafWindowObject::DrawBorder(region, ccode));
}
#endif

ZafEventType ZafStatusBar::Event(const ZafEventStruct &event)
{
	// Check for zinc events.
	ZafEventType ccode = event.type;
	switch (ccode)
	{
	// ----- Position & Size messages -----
	case S_COMPUTE_SIZE:
		{
		int height = zafRegion.bottom - zafRegion.top;
		ccode = ZafWindowObject::Event(event);
		zafRegion.top = zafRegion.bottom - height;
		}
		break;

	// ----- Default operation -----
	default:
		ccode = ZafWindow::Event(event);
		break;
	}

	// Return the control code.
	return (ccode);
}

ZafRegionStruct ZafStatusBar::MaxRegion(ZafWindowObject *object, ZafVtJustify vWeight, ZafHzJustify hWeight)
{
	// Defer to the base class.
	return (ZafWindow::MaxRegion(object, vWeight, hWeight));
}

// ----- OS Specific Functions ----------------------------------------------

ZafEventType ZafStatusBar::OSEvent(const ZafEventStruct &)
{
	return (S_ERROR);
}

void ZafStatusBar::OSMapPalette(ZafPaletteStruct &palette, ZafPaletteType type, ZafPaletteState state)
{
	// Defer to the base class.
	ZafWindow::OSMapPalette(palette, type, state);
}

OSWindowID ZafStatusBar::OSScreenID(ZafScreenIDType type) const
{
	// Defer to the base class.
	return (ZafWindow::OSScreenID(type));
}

void ZafStatusBar::OSRegisterObject(void)
{
	// Defer to the base class.
	ZafWindow::OSRegisterObject();

	// Set additional default values.
	MtfWindowFrame *mtfFrame = MtfWindowFrame::GetMotifWidget(OSScreenID(ZAF_FRAMEID));
	Shadow_Type((Widget)mtfFrame) = XmSHADOW_ETCHED_IN;
//	mtfFrame->shadow_type = XmSHADOW_ETCHED_IN;
}

void ZafStatusBar::OSSize(void)
{
	// Default to the base class.
	ZafWindowObject::OSSize();
}

