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

#include <w_app.hpp>
#include <z_title.hpp>

// ----- ZafTitle ----------------------------------------------------------

ZafEventType ZafTitle::Event(const ZafEventStruct &event)
{
	if (event.type == S_REGISTER_OBJECT)
	{
		screenID = parent->OSScreenID(ZAF_FRAMEID);
		OSSetText();
	}
	else if (event.type == S_DEINITIALIZE)
		screenID = 0;

	return (S_UNKNOWN);
}

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

void ZafTitle::OSRegisterObject(void)
{
}

ZafError ZafTitle::OSSetText(void)
{
	// Set the windows text.
	if (screenID && stringData)
	{
		if (ZafMSWindowsApp::convertText)
		{
			char *osText = zafCodeSet->ConvertToOSString(*stringData, ZAF_NULLP(char), FALSE);
#if defined(ZAF_WIN32) && defined(ZAF_UNICODE)
			::SendMessageA(screenID, WM_SETTEXT, (WPARAM)0, (LPARAM)osText);
#else
			::SendMessage(screenID, WM_SETTEXT, (WPARAM)0, (LPARAM)osText);
#endif
		}
		else
			::SendMessage(screenID, WM_SETTEXT, (WPARAM)0, (LPARAM)stringData->Text());
	}

	return ZAF_ERROR_NONE;
}

// ----- Stubs --------------------------------------------------------------

#if defined(ZAF_DEFAULT_DRAW)
ZafEventType ZafTitle::Draw(const ZafEventStruct &, ZafEventType ccode)
{
	// Handled by windows.
	return (ccode);
}
#endif

void ZafTitle::OSSize(void)
{
	// Handled automatically by Windows.
}

ZafError ZafTitle::OSUpdatePalettes(ZafPaletteType, ZafPaletteType)
{
	return (ZAF_ERROR_NONE);
}

