예제 #1
0
bool
CKLBFormIF::updateUITextEdit(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * item, int index)
{
	CKLBUITask* pTask		= pNode->getUITask();
	CKLBUITextBox * pText	= (CKLBUITextBox *)pNode;

    // 2012-12-3(Mon)
    // pTaskが存在していない可能性が高いのでpTaskのNULLチェックを追加しました
	if ((pTask) && (pTask->getClassID() != CLS_KLBUITEXTINPUT)) {
		// Not valid
		pTask = NULL;
	}

	bool result = true;
	switch(subcmd)
	{
	default:
		{
			result = updateUIElement(lua, argc, base, subcmd, pNode, ret, item, index);
		}
		break;
	case FORM_LBL_GET_TEXT:	// Trick : label & text command backward compatible.
	case FORM_TEXT_GET:
		{
			/* Do not understand why return false for now.
			if(argc != base) {
				result = false;
				break;
			}*/
			const char * text;

			if (pTask) {
				text = ((CKLBUITextInput*)pTask)->getText();
			} else {
				text = pText->getText();
			}

			lua.retString(text);
			ret = 1;
		}
		break;
	case FORM_TEXT_SET:	// Trick : label & text command backward compatible.
	case FORM_LBL_SET_TEXT:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			const char * text = lua.getString(base + 1);
			
			if (pTask) {
				((CKLBUITextInput*)pTask)->setText(text);
			} else {
				pText->setText((char *)text);
			}
		}
		break;
	}
	return result;
}
예제 #2
0
bool
CKLBFormIF::updateLabelNode(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * item, int index)
{
	CKLBLabelNode * pLabel = (CKLBLabelNode *)pNode;
	CKLBUITask* pTask		= pNode->getUITask();

    // pTaskが存在していない可能性が高いのでpTaskのNULLチェックを追加しました
	if ((pTask) && (pTask->getClassID() != CLS_KLBUILABEL)) {
		// Not valid
		pTask = NULL;
	}

	bool result = true;
	switch(subcmd)
	{
	default:
		{
			result = updateUIElement(lua, argc, base, subcmd, pNode, ret, item, index);
		}
		break;
	case FORM_TEXT_SET:	// Trick : label & text command backward compatible.
	case FORM_LBL_SET_TEXT:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			const char * text = lua.getString(base + 1);
			if (pTask) {
				((CKLBUILabel*)pTask)->setText(text);
			} else {
				pLabel->setText((char *)text);
			}
		}
		break;
	case FORM_LBL_GET_TEXT:	// Trick : label & text command backward compatible.
	case FORM_TEXT_GET:
		{
			/*
			if(argc != base) {
				result = false;
				break;
			}*/
			const char * uri;
			if (pTask) {
				uri = ((CKLBUILabel*)pTask)->getText();
			} else {
				uri = pLabel->getText();
			}
			lua.retString(uri);
			ret = 1;
		}
		break;
	}
	return result;
}
예제 #3
0
bool
CKLBFormIF::updateUIWebView(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * item, int index)
{
	CKLBUITask* pTask		= pNode->getUITask();
	bool result = true;
	switch(subcmd)
	{
	default:
		{
			result = updateUIElement(lua, argc, base, subcmd, pNode, ret, item, index);
		}
		break;
	case FORM_WEB_SET_URI:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			const char * uri = lua.getString(base + 1);
			if (pTask) {
				CKLBUIWebArea* pWebTask = (CKLBUIWebArea*)pTask;
				pWebTask->setText(uri);
			} else {
				CKLBUIWebView * pWeb = (CKLBUIWebView *)pNode;
				pWeb->setText((char *)uri);
			}
		}
		break;
	case FORM_WEB_GET_URI:
		{
			if(argc != base) {
				result = false;
				break;
			}
			const char * uri;
			if (pTask) {
				CKLBUIWebArea* pWebTask = (CKLBUIWebArea*)pTask;
				uri = pWebTask->getText();
			} else {
				CKLBUIWebView * pWeb = (CKLBUIWebView *)pNode;
				uri = pWeb->getText();
			}

			lua.retString(uri);
			ret = 1;
		}
		break;
	}
	return result;
}