bool HKWidgetRenderer::SetProperty(const char *pProperty, const char *pValue, HKWidget *pWidget)
{
	if(!MFString_CaseCmp(pProperty, "background_image"))
	{
		if(pImage)
			MFMaterial_Destroy(pImage);
		pImage = MFMaterial_Create(pValue);
		if(pImage)
		{
			int texW, texH;
			MFTexture *pTex = MFMaterial_GetParameterT(pImage, MFMatStandard_Texture, MFMatStandard_Tex_DifuseMap);
			MFTexture_GetTextureDimensions(pTex, &texW, &texH);

			texWidth = (float)texW;
			texHeight = (float)texH;

			if(pWidget && (pWidget->bAutoWidth || pWidget->bAutoHeight))
			{
				if(pWidget->bAutoWidth && pWidget->bAutoHeight)
					pWidget->Resize(MakeVector(texWidth, texHeight));
				else if(pWidget->bAutoWidth)
					pWidget->UpdateWidth(texWidth);
				else
					pWidget->UpdateHeight(texHeight);
			}
		}
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "background_align"))
	{
		imageAlignment = (HKWidget::Justification)HKWidget_GetEnumValue(pValue, HKWidget::sJustifyKeys);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "background_colour"))
	{
		colour = HKWidget_GetColourFromString(pValue);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "background_padding"))
	{
		padding = HKWidget_GetVectorFromString(pValue);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "background_9-cell-margin"))
	{
		margin9Cell = MFString_AsciiToFloat(pValue);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "border_width"))
	{
		border = HKWidget_GetVectorFromString(pValue);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "border_colour"))
	{
		borderColour = HKWidget_GetColourFromString(pValue);
		return true;
	}
	return false;
}
Exemple #2
0
void HKWidgetLabel::SetProperty(const char *pProperty, const char *pValue)
{
	if(!MFString_CaseCmp(pProperty, "text"))
		SetText(pValue);
	else if(!MFString_CaseCmp(pProperty, "text_colour"))
		SetTextColour(HKWidget_GetColourFromString(pValue));
	else if(!MFString_CaseCmp(pProperty, "text_height"))
		SetTextHeight(MFString_AsciiToFloat(pValue));
	else if(!MFString_CaseCmp(pProperty, "text_shadowDepth"))
		SetShadowDepth(MFString_AsciiToFloat(pValue));
	else if(!MFString_CaseCmp(pProperty, "text_font"))
	{
		if(bOwnFont)
			MFFont_Release(pFont);
		pFont = MFFont_Create(pValue);
		bOwnFont = true;

		if(bAutoTextHeight)
			textHeight = MFFont_GetFontHeight(pFont);

		AdjustSize();
	}
	else if(!MFString_CaseCmp(pProperty, "text_align"))
		SetTextJustification((MFFontJustify)HKWidget_GetEnumValue(pValue, sJustifyKeys));
	else
		HKWidget::SetProperty(pProperty, pValue);
}
void HKWidgetLayoutLinear::SetProperty(const char *pProperty, const char *pValue)
{
	if(!MFString_CaseCmp(pProperty, "orientation"))
		SetOrientation((Orientation)HKWidget_GetEnumValue(pValue, sOrientationKeys));
	else
		HKWidgetLayout::SetProperty(pProperty, pValue);
}
Exemple #4
0
void HKWidgetListbox::SetProperty(const char *pProperty, const char *pValue)
{
	if(!MFString_CaseCmp(pProperty, "orientation"))
		SetOrientation((Orientation)HKWidget_GetEnumValue(pValue, sOrientationKeys));
	else if(!MFString_CaseCmp(pProperty, "hoverSelect"))
		flags |= HKWidget_GetBoolFromString(pValue) ? HoverSelect : 0;
	else if(!MFString_CaseCmp(pProperty, "onSelChanged"))
		HKWidget_BindWidgetEvent(OnSelChanged, pValue);
	else
		HKWidgetLayout::SetProperty(pProperty, pValue);
}