void ElementDataGrid::OnUpdate()
{
	Core::ElementDocument* document = GetOwnerDocument();
	document->LockLayout(true);
	
	if (!new_data_source.Empty())
	{
		root->SetDataSource(new_data_source);
		new_data_source = "";
	}

	bool any_new_children = root->UpdateChildren();
	if (any_new_children)
	{
		DispatchEvent("rowupdate", Rocket::Core::Dictionary());
	}
	
	if (!body_visible && (!any_new_children || root->GetNumLoadedChildren() >= Rocket::Core::Math::RealToInteger(ResolveProperty("min-rows", 0))))
	{
		body->SetProperty("display", "block");
		body_visible = true;
	}
	
	document->LockLayout(false);
}
Ejemplo n.º 2
0
void ElementGame::OnChildAdd(Rocket::Core::Element* element)
{
	Rocket::Core::Element::OnChildAdd(element);

	if (element == this)
		GetOwnerDocument()->AddEventListener("load", this);
}
Ejemplo n.º 3
0
double wxSVGVideoElement::GetDuration(wxProgressDialog* progressDlg) {
	if (GetDur() > 0)
		return GetDur();
	if (GetClipEnd() > 0)
		return GetClipEnd() > GetClipBegin() ? GetClipEnd() - GetClipBegin() : 0;
	if (m_canvasItem == NULL)
		m_canvasItem = ((wxSVGDocument*) GetOwnerDocument())->GetCanvas()->CreateItem(this, NULL, progressDlg);
	double duration = ((wxSVGCanvasVideo*) m_canvasItem)->GetDuration();
	if (!((wxSVGDocument*) GetOwnerDocument())->GetCanvas()->IsItemsCached()) {
		delete m_canvasItem;
		m_canvasItem = NULL;
	}
	if (GetClipBegin() > 0)
		duration = duration > GetClipBegin() ? duration - GetClipBegin() : 0;
	return duration;
}
/// Called when source texture has changed.
void ElementCircularBar::LoadTexture()
{
	Core::ElementDocument* document = GetOwnerDocument();
	Core::URL source_url(document == NULL ? "" : document->GetSourceURL());

	Core::String source = GetProperty< Core::String >("gauge-src");

	if (!gauge_texture.Load(source, source_url.GetPath()))
	{
		gauge_geometry.SetTexture(NULL);
		return;
	}

	gauge_geometry.SetTexture(&gauge_texture);
	actual_gauge_extent = gauge_texture.GetDimensions(GetRenderInterface());
}
Ejemplo n.º 5
0
bool ElementImage::LoadDiskTexture()
{
	texture_dirty = false;

	// Get the source URL for the image.
	String image_source = GetAttribute< String >("src", "");
	if (image_source.Empty())
		return false;

	geometry_dirty = true;

	Rocket::Core::ElementDocument* document = GetOwnerDocument();
	URL source_url(document == NULL ? "" : document->GetSourceURL());

	if (!texture.Load(image_source, source_url.GetPath()))
	{
		geometry.SetTexture(NULL);
		return false;
	}

	// Set the texture onto our geometry object.
	geometry.SetTexture(&texture);
	return true;
}
Ejemplo n.º 6
0
void ElementHandle::ProcessEvent(Event& event)
{
	Element::ProcessEvent(event);

	if (event.GetTargetElement() == this)
	{
		// Lazy initialisation.
		if (!initialised && GetOwnerDocument())
		{
			String move_target_name = GetAttribute<String>("move_target", "");
			if (!move_target_name.Empty())
				move_target = GetElementById(move_target_name);

			String size_target_name = GetAttribute<String>("size_target", "");
			if (!size_target_name.Empty())
				size_target = GetElementById(size_target_name);

			initialised = true;
		}

		if (event == DRAGSTART)
		{
			// Store the drag starting position
			drag_start.x = event.GetParameter< int >("mouse_x", 0);
			drag_start.y = event.GetParameter< int >("mouse_y", 0);

			// Store current element position and size
			if (move_target)
			{
				move_original_position.x = move_target->GetOffsetLeft();
				move_original_position.y = move_target->GetOffsetTop();
			}
			if (size_target)
				size_original_size = size_target->GetBox().GetSize(Box::CONTENT);
		}
		else if (event == DRAG)
		{
			// Work out the delta
			int x = event.GetParameter< int >("mouse_x", 0) - drag_start.x;
			int y = event.GetParameter< int >("mouse_y", 0) - drag_start.y;

			// Update the move and size objects
			if (move_target)
			{
				move_target->SetProperty(LEFT, Property(Math::RealToInteger(move_original_position.x + x), Property::PX));
				move_target->SetProperty(TOP, Property(Math::RealToInteger(move_original_position.y + y), Property::PX));
			}

			if (size_target)
			{
				// Check if we have auto-margins; if so, they have to be set to the current margins.
				if (size_target->GetProperty(MARGIN_TOP)->unit == Property::KEYWORD)
					size_target->SetProperty(MARGIN_TOP, Property((float) Math::RealToInteger(size_target->GetBox().GetEdge(Box::MARGIN, Box::TOP)), Property::PX));
				if (size_target->GetProperty(MARGIN_RIGHT)->unit == Property::KEYWORD)
					size_target->SetProperty(MARGIN_RIGHT, Property((float) Math::RealToInteger(size_target->GetBox().GetEdge(Box::MARGIN, Box::RIGHT)), Property::PX));
				if (size_target->GetProperty(MARGIN_BOTTOM)->unit == Property::KEYWORD)
					size_target->SetProperty(MARGIN_BOTTOM, Property((float) Math::RealToInteger(size_target->GetBox().GetEdge(Box::MARGIN, Box::BOTTOM)), Property::PX));
				if (size_target->GetProperty(MARGIN_LEFT)->unit == Property::KEYWORD)
					size_target->SetProperty(MARGIN_LEFT, Property((float) Math::RealToInteger(size_target->GetBox().GetEdge(Box::MARGIN, Box::LEFT)), Property::PX));

				int new_x = Math::RealToInteger(size_original_size.x + x);
				int new_y = Math::RealToInteger(size_original_size.y + y);

				size_target->SetProperty(WIDTH, Property(Math::Max< float >((float) new_x, 0), Property::PX));
				size_target->SetProperty(HEIGHT, Property(Math::Max< float >((float) new_y, 0), Property::PX));
			}

			Dictionary parameters;
			parameters.Set("handle_x", x);
			parameters.Set("handle_y", y);
			DispatchEvent("handledrag", parameters);
		}
	}
}