コード例 #1
0
// Initialises the info element.
bool ElementInfo::Initialise()
{
	SetInnerRML(info_rml);
	SetId("rkt-debug-info");

	Core::StyleSheet* style_sheet = Core::Factory::InstanceStyleSheetString(Core::String(common_rcss) + Core::String(info_rcss));
	if (style_sheet == NULL)
		return false;

	SetStyleSheet(style_sheet);
	style_sheet->RemoveReference();

	return true;
}
コード例 #2
0
ファイル: ElementLog.cpp プロジェクト: UIKit0/librocket-1
// Initialises the log element.
bool ElementLog::Initialise()
{
	SetInnerRML(log_rml);
	SetId("rkt-debug-log");

	message_content = GetElementById("content");
	if (message_content)
	{
		message_content->AddEventListener("resize", this);
	}

	Core::StyleSheet* style_sheet = Core::Factory::Instance()->InstanceStyleSheetString(Core::String(common_rcss) + Core::String(log_rcss));
	if (style_sheet == NULL)
		return false;

	SetStyleSheet(style_sheet);
	style_sheet->RemoveReference();

	// Create the log beacon.
	beacon = GetContext()->CreateDocument();
	if (beacon == NULL)
		return false;

	beacon->SetId("rkt-debug-log-beacon");
	beacon->SetProperty("visibility", "hidden");
	beacon->SetInnerRML(beacon_rml);

	// Remove the initial reference on the beacon.
	beacon->RemoveReference();

	Core::Element* button = beacon->GetFirstChild();
	if (button != NULL)
		beacon->GetFirstChild()->AddEventListener("click", this);

	style_sheet = Core::Factory::Instance()->InstanceStyleSheetString(Core::String(common_rcss) + Core::String(beacon_rcss));
	if (style_sheet == NULL)
	{
		GetContext()->UnloadDocument(beacon);
		beacon = NULL;

		return false;
	}

	beacon->SetStyleSheet(style_sheet);
	style_sheet->RemoveReference();

	return true;
}
コード例 #3
0
ファイル: ElementDocument.cpp プロジェクト: Kaperstone/warsow
void ElementDocument::ProcessHeader(const DocumentHeader* document_header)
{	
	// Store the source address that we came from
	source_url = document_header->source;

	// Construct a new header and copy the template details across
	DocumentHeader header;
	header.MergePaths(header.template_resources, document_header->template_resources, document_header->source);

	// Merge in any templates, note a merge may cause more templates to merge
	for (size_t i = 0; i < header.template_resources.size(); i++)
	{
		Template* merge_template = TemplateCache::LoadTemplate(URL(header.template_resources[i]).GetURL());	

		if (merge_template)
			header.MergeHeader(*merge_template->GetHeader());
		else
			Log::Message(Log::LT_WARNING, "Template %s not found", header.template_resources[i].CString());
	}

	// Merge the document's header last, as it is the most overriding.
	header.MergeHeader(*document_header);

	// Set the title to the document title.
	title = document_header->title;

	// If a style-sheet (or sheets) has been specified for this element, then we load them and set the combined sheet
	// on the element; all of its children will inherit it by default.
	StyleSheet* style_sheet = NULL;
	if (header.rcss_external.size() > 0)
		style_sheet = StyleSheetFactory::GetStyleSheet(header.rcss_external);

	// Combine any inline sheets.
	if (header.rcss_inline.size() > 0)
	{			
		for (size_t i = 0;i < header.rcss_inline.size(); i++)
		{			
			StyleSheet* new_sheet = new StyleSheet();
			StreamMemory* stream = new StreamMemory((const byte*) header.rcss_inline[i].CString(), header.rcss_inline[i].Length());
			stream->SetSourceURL(document_header->source);

			if (new_sheet->LoadStyleSheet(stream))
			{
				if (style_sheet)
				{
					StyleSheet* combined_sheet = style_sheet->CombineStyleSheet(new_sheet);
					style_sheet->RemoveReference();
					new_sheet->RemoveReference();
					style_sheet = combined_sheet;
				}
				else
					style_sheet = new_sheet;
			}
			else
				new_sheet->RemoveReference();

			stream->RemoveReference();
		}		
	}

	// If a style sheet is available, set it on the document and release it.
	if (style_sheet)
	{
		SetStyleSheet(style_sheet);
		style_sheet->RemoveReference();
	}

	// Load external scripts.
	for (size_t i = 0; i < header.scripts_external.size(); i++)
	{
		StreamFile* stream = new StreamFile();
		if (stream->Open(header.scripts_external[i]))
			LoadScript(stream, header.scripts_external[i]);

		stream->RemoveReference();
	}

	// Load internal scripts.
	for (size_t i = 0; i < header.scripts_inline.size(); i++)
	{
		StreamMemory* stream = new StreamMemory((const byte*) header.scripts_inline[i].CString(), header.scripts_inline[i].Length());
		LoadScript(stream, "");
		stream->RemoveReference();
	}

	// Hide this document.
	SetProperty(VISIBILITY, "hidden");
}