void* GetElementUserData(Rocket::Core::Element *element, const Rocket::Core::String& key) {
	void *result = NULL;
    if (element != NULL) {
        Rocket::Core::Variant *value = element->GetAttribute(key);
        if (value != NULL) {
            Rocket::Core::String strval;
            value->GetInto(strval);
            sscanf(strval.CString(), "%x", &result);
        }
    }
	return result;
}
示例#2
0
void GUIElement::GetAttribute(const char* attribute, char* buffer, size_t buffer_size ) const
{
	if( buffer_size && buffer )
	{
		buffer[0] = 0;
		Rocket::Core::Variant* pVar = m_pElement->GetAttribute(attribute);
		if( pVar )
		{
			Rocket::Core::String strvalue;
			pVar->GetInto( strvalue );
			strcpy_s( buffer, buffer_size, strvalue.CString() );
		}
	}
}
示例#3
0
// Submits the form.
void ElementForm::Submit(const Rocket::Core::String& name, const Rocket::Core::String& submit_value)
{
	Rocket::Core::Dictionary values;
	if (name.Empty())
		values.Set("submit", submit_value);
	else
		values.Set(name, submit_value);

	Core::ElementList form_controls;
	Core::ElementUtilities::GetElementsByTagName(form_controls, this, "input");
	Core::ElementUtilities::GetElementsByTagName(form_controls, this, "textarea");
	Core::ElementUtilities::GetElementsByTagName(form_controls, this, "select");
	Core::ElementUtilities::GetElementsByTagName(form_controls, this, "dataselect");

	for (size_t i = 0; i < form_controls.size(); i++)
	{
		ElementFormControl* control = rocket_dynamic_cast< ElementFormControl* >(form_controls[i]);
		if (!control)
			continue;

		// Skip disabled controls.
		if (control->IsDisabled())
			continue;

		// Only process controls that should be submitted.
		if (!control->IsSubmitted())
			continue;

		Rocket::Core::String control_name = control->GetName();
		Rocket::Core::String control_value = control->GetValue();

		// Skip over unnamed form controls.
		if (control_name.Empty())
			continue;

		// If the item already exists, append to it.
		Rocket::Core::Variant* value = values.Get(control_name);
		if (value != NULL)
			value->Set(value->Get< Rocket::Core::String >() + ", " + control_value);
		else
			values.Set< Rocket::Core::String >(control_name, control_value);					
	}

	DispatchEvent("submit", values);
}
void GUIElement::GetAttribute(const char* attribute, char* buffer, size_t buffer_size ) const
{
	if( buffer_size && buffer )
	{
		buffer[0] = 0;
		Rocket::Core::Variant* pVar = m_pElement->GetAttribute(attribute);
		if( pVar )
		{
			Rocket::Core::String strvalue;
			pVar->GetInto( strvalue );
#ifdef _WIN32
			strcpy_s( buffer, buffer_size, strvalue.CString() );
#else
            strncpy( buffer, strvalue.CString(), buffer_size); //not quite the same, but similar safe effect.
#endif
		}
	}
}