// COPYRIGHT (C) 1990-1999.  All Rights Reserved. - INTLWN3.CPP
// Zinc Software Incorporated.  Pleasant Grove, Utah  USA
// May be freely copied, used and distributed.

#include "intlwn3.hpp"

// ----- InternationalWindow ------------------------------------------------

InternationalWindow::InternationalWindow(ZafIChar *name, ZafObjectPersistence &persist) :
	ZafWindow(name, persist)
{
	// Center the window on the display.
	zafWindowManager->Center(this);

	// Determine the current setting.
	i18nSetting = GetObject(ZAF_ITEXT("LanguageString"));
	i18nSetting->SetText(ZafI18nData::I18nName());

	ZafWindowObject *newSetting = GetObject("NewI18nSetting");
	ZafComboBox *comboSetting = newSetting ? DynamicPtrCast(newSetting, ZafComboBox) :
		ZAF_NULLP(ZafComboBox);
	if (comboSetting)
		for (ZafButton *button = DynamicPtrCast(comboSetting->First(), ZafButton);
			button; button = DynamicPtrCast(button->Next(), ZafButton))
			if (!strncmp(button->SendMessageText(), i18nSetting->Text(),
				strlen(button->SendMessageText())))
				button->SetSelected(true);
}

ZafEventType InternationalWindow::Event(const ZafEventStruct &event)
{
	// Reset the current setting, based on the i18n information.
	if (event.type == N_RESET_I18N)
		i18nSetting->SetText(ZafI18nData::I18nName());

	// Defer to the base class.
	return (ZafWindow::Event(event));
}
