class LuaApp;

def gApp;
def gCApp;

function LuaApp:Init(theCObj)
{
	def mCObj = theCObj;
	gApp = self;
	gCApp = theCObj;
}

function LuaApp:WrapWidget(theClass, theDefaultClass, theCObj)
{
	if (theClass == nil)
		theClass = theDefaultClass;
	local aNewObj = theClass:new(theCObj);
	return aNewObj;}

function LuaApp:CreateLuaWidget(theClass)
{
	return WrapWidget(theClass, LuaWidget,
		mCObj:CreateLuaWidget());
}

function LuaApp:CreateHyperlinkWidget(theId, theListener, theClass)
{
	return WrapWidget(theClass, LuaHyperlinkWidget, 
		mCObj:CreateLuaHyperlinkWidget(theId, theListener.mCObj));
}

function LuaApp:CreateTextWidget(theClass)
{
	return WrapWidget(theClass, LuaTextWidget, 
		mCObj:CreateLuaTextWidget());
}

function LuaApp:CreateButtonWidget(theId, theListener, theClass)
{
	return WrapWidget(theClass, LuaButtonWidget, 
		mCObj:CreateLuaButtonWidget(theId, theListener.mCObj));
}

function LuaApp:CreateCheckboxWidget(theUncheckedImage, theCheckedImage, theId, theListener, theClass)
{
	return WrapWidget(theClass, LuaCheckboxWidget, 
		mCObj:CreateLuaCheckboxWidget(theUncheckedImage, theCheckedImage, theId, theListener.mCObj));
}

function LuaApp:CreateScrollbarWidget(theId, theListener, theClass)
{
	return WrapWidget(theClass, LuaScrollbarWidget, 
		mCObj:CreateLuaScrollbarWidget(theId, theListener.mCObj));
}

function LuaApp:CreateEditWidget(theId, theListener, theClass)
{
	return WrapWidget(theClass, LuaEditWidget, 
		mCObj:CreateLuaEditWidget(theId, theListener.mCObj));
}

function LuaApp:CreateListWidget(theId, theFont, theListener, theClass)
{
	return WrapWidget(theClass, LuaListWidget, 
		mCObj:CreateLuaListWidget(theId, theFont, theListener.mCObj));
}

function LuaApp:CreateDialog(theComponentImage, theButtonComponentImage,
	theId, isModal, theDialogHeader, theDialogLines, theDialogFooter, theButtonMode, theClass)
{
	local aWidget = WrapWidget(theClass, LuaWidget, 
		mCObj:CreateLuaDialog(theComponentImage, theButtonComponentImage,
		theId, isModal, theDialogHeader, theDialogLines, theDialogFooter, theButtonMode));
	gCApp:AddDialog(aWidget.mCObj);
	return aWidget;
}

function LuaApp:DialogButtonPress(theDialogId, theButtonId)
{
}
	
function LuaApp:DialogButtonDepress(theDialogId, theButtonId)
{
	mCObj:KillDialog(theDialogId);
}

function LuaApp:DebugKeyDown(theKey)
{
	return mCObj:DebugKeyDown(theKey);
}

RegisterLinkedClass("LuaApp", LuaApp);
