Ejemplo n.º 1
0
/*static*/
AutoPtr<WindowConfig> WindowConfig::FromWindowConfig(AutoPtr<WindowConfig> config)
{
	WindowConfig* newConfig = new WindowConfig();

	// Just use defaults given a NULL instance.
	if (config.isNull())
		return newConfig;

	newConfig->SetURL(config->GetURL());
	newConfig->SetTitle(config->GetTitle());
	newConfig->SetX(config->GetX());
	newConfig->SetY(config->GetY());
	newConfig->SetWidth(config->GetWidth());
	newConfig->SetMinWidth(config->GetMinWidth());
	newConfig->SetMaxWidth(config->GetMaxWidth());
	newConfig->SetHeight(config->GetHeight());
	newConfig->SetMinHeight(config->GetMinHeight());
	newConfig->SetMaxHeight(config->GetMaxHeight());
	newConfig->SetVisible(config->IsVisible());
	newConfig->SetMaximizable(config->IsMaximizable());
	newConfig->SetMinimizable(config->IsMinimizable());
	newConfig->SetResizable(config->IsResizable());
	newConfig->SetFullscreen(config->IsFullscreen());
	newConfig->SetMaximized(config->IsMaximized());
	newConfig->SetMinimized(config->IsMinimized());
	newConfig->SetUsingChrome(config->IsUsingChrome());
	newConfig->SetUsingScrollbars(config->IsUsingScrollbars());
	newConfig->SetTopMost(config->IsTopMost());
	newConfig->SetTransparency(config->GetTransparency());
	newConfig->SetTransparentBackground(config->HasTransparentBackground());
#ifdef OS_OSX
	newConfig->SetTexturedBackground(config->HasTexturedBackground());
#endif

	return newConfig;
}
Ejemplo n.º 2
0
/*static*/
AutoPtr<WindowConfig> WindowConfig::FromXMLNode(xmlNodePtr element)
{
	WindowConfig* config = new WindowConfig();

	xmlNodePtr child = element->children;
	while (child)
	{
		if (child->type != XML_ELEMENT_NODE)
		{
			child = child->next;
			continue;
		}

		// This should always be a UTF-8, so we can just cast
		// the node name here to a char*
		std::string nodeName(reinterpret_cast<char*>(
			const_cast<xmlChar*>(child->name)));

		if (nodeName == "id")
		{
			config->SetID(ConfigUtils::GetNodeValue(child));
		}
		else if (nodeName == "title")
		{
			config->SetTitle(ConfigUtils::GetNodeValue(child));
		}
		else if (nodeName == "url")
		{
			config->SetURL(ConfigUtils::GetNodeValue(child));
		}
		else if (nodeName == "url-regex")
		{
			config->SetURLRegex(ConfigUtils::GetNodeValue(child));
		}
		else if (nodeName == "maximizable")
		{
			config->SetMaximizable(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "minimizable")
		{
			config->SetMinimizable(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "closeable")
		{
			config->SetCloseable(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "resizable")
		{
			config->SetResizable(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "fullscreen")
		{
			config->SetFullscreen(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "maximized")
		{
			config->SetMaximized(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "minimized")
		{
			config->SetMinimized(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "chrome")
		{
			config->SetUsingChrome(ConfigUtils::GetNodeValueAsBool(child));
			std::string scrollbars(ConfigUtils::GetPropertyValue(child, "scrollbars"));
			if (!scrollbars.empty())
			{
				config->SetUsingScrollbars(ConfigUtils::StringToBool(scrollbars));
			}
		}
		else if (nodeName == "tool-window")
		{
			config->SetToolWindow(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "transparency")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetTransparency((float) atof(value.c_str()));
		}
		else if (nodeName == "transparent-background")
		{
			config->SetTransparentBackground(
				ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "x")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetX(atoi(value.c_str()));
		}
		else if (nodeName == "y")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetY(atoi(value.c_str()));
		}
		else if (nodeName == "width")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetWidth(atoi(value.c_str()));
		}
		else if (nodeName == "height")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetHeight(atoi(value.c_str()));
		}
		else if (nodeName == "visible")
		{
			config->SetVisible(ConfigUtils::GetNodeValueAsBool(child));
		}
		else if (nodeName == "min-width")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetMinWidth(atoi(value.c_str()));
		}
		else if (nodeName == "max-width")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetMaxWidth(atoi(value.c_str()));
		}
		else if (nodeName == "min-height")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetMinHeight(atoi(value.c_str()));
		}
		else if (nodeName == "max-height")
		{
			std::string value(ConfigUtils::GetNodeValue(child));
			config->SetMaxHeight(atoi(value.c_str()));
		}
		else if (nodeName == "top-most")
		{
			config->SetTopMost(ConfigUtils::GetNodeValueAsBool(child));
		}
#ifdef OS_OSX
		else if (nodeName == "texturedBackground" || nodeName == "textured-background")
		{
			config->SetTexturedBackground(ConfigUtils::GetNodeValueAsBool(child));
		}
#endif
		child = child->next;
	}

	EnforceMaxMinConstraints(config);
	EnforceTransparentBackgroundSettings(config);
	return config;
}