// Checks for changes to the 'disabled' attribute.
void ElementFormControl::OnAttributeChange(const Core::AttributeNameList& changed_attributes)
{
	Core::Element::OnAttributeChange(changed_attributes);

	if (changed_attributes.find("disabled") != changed_attributes.end())
		SetPseudoClass("disabled", IsDisabled());
}
// Checks for changes to the data source or formatting attributes.
void ElementFormControlDataSelect::OnAttributeChange(const Core::AttributeNameList& changed_attributes)
{
	ElementFormControlSelect::OnAttributeChange(changed_attributes);

	if (changed_attributes.find("source") != changed_attributes.end())
	{
		if (data_source != NULL)
			data_source->DetachListener(this);

		initialised = false;
	}
	else if (changed_attributes.find("fields") != changed_attributes.end() ||
			 changed_attributes.find("valuefield") != changed_attributes.end() ||
			 changed_attributes.find("formatter") != changed_attributes.end())
	{
		BuildOptions();
	}
}
Exemple #3
0
// Checks for necessary functional changes in the control as a result of changed attributes.
bool InputTypeText::OnAttributeChange(const Core::AttributeNameList& changed_attributes)
{
    bool dirty_layout = false;

    // Check if maxlength has been defined.
    if (changed_attributes.find("maxlength") != changed_attributes.end())
        widget->SetMaxLength(element->GetAttribute< int >("maxlength", -1));

    // Check if size has been defined.
    if (changed_attributes.find("size") != changed_attributes.end())
    {
        size = element->GetAttribute< int >("size", 20);
        dirty_layout = true;
    }

    // Check if the value has been changed.
    if (changed_attributes.find("value") != changed_attributes.end())
        widget->SetValue(element->GetAttribute< Rocket::Core::String >("value", ""));

    return !dirty_layout;
}
// Called when attributes on the element are changed.
void ElementFormControlTextArea::OnAttributeChange(const Core::AttributeNameList& changed_attributes)
{
	ElementFormControl::OnAttributeChange(changed_attributes);

	if (changed_attributes.find("wrap") != changed_attributes.end())
	{
		if (GetWordWrap())
			SetProperty("white-space", "pre-wrap");
		else
			SetProperty("white-space", "pre");
	}

	if (changed_attributes.find("rows") != changed_attributes.end() ||
			 changed_attributes.find("cols") != changed_attributes.end())
		DirtyLayout();

	if (changed_attributes.find("maxlength") != changed_attributes.end())
		widget->SetMaxLength(GetMaxLength());

	if (changed_attributes.find("value") != changed_attributes.end())
		widget->SetValue(GetValue());
}
// Checks for necessary functional changes in the control as a result of changed attributes.
bool InputTypeCheckbox::OnAttributeChange(const Core::AttributeNameList& changed_attributes)
{
	// Check if maxlength has been defined.
	if (changed_attributes.find("checked") != changed_attributes.end())
	{
		bool checked = element->HasAttribute("checked");
		element->SetPseudoClass("checked", checked);

		Rocket::Core::Dictionary parameters;
		parameters.Set("value", Rocket::Core::String(checked ? GetValue() : ""));
		element->DispatchEvent("change", parameters);
	}

	return true;
}
// Called when attributes on the element are changed.
void ElementCircularBar::OnAttributeChange(const Core::AttributeNameList& changed_attributes)
{
	Element::OnAttributeChange(changed_attributes);

	if (changed_attributes.find("value") != changed_attributes.end())
	{
		value = GetAttribute< float >("value", 0.0f);

		if (value < 0)
			value = 0.0f;
		else if (value > 1)
			value = 1.0f;

		geometry_dirty = true;
	}
}