Example #1
0
bool CThemeProvider::ThemeHasSize(const wxString& themePath, const wxString& size)
{
	wxFileName fn(wxGetApp().GetResourceDir() + themePath, _T("theme.xml"));
	TiXmlElement* pDocument = GetXmlFile(fn.GetFullPath(), false);
	if (!pDocument)
		return false;

	TiXmlElement* pTheme = pDocument->FirstChildElement("Theme");

	if (!pTheme)
	{
		delete pDocument->GetDocument();
		return false;
	}

	for (TiXmlElement* pSize = pTheme->FirstChildElement("size"); pSize; pSize = pSize->NextSiblingElement("size"))
	{
		const char* txt = pSize->GetText();
		if (!txt)
			continue;

		if (size == ConvLocal(txt))
		{
			delete pDocument->GetDocument();
			return true;
		}
	}

	delete pDocument->GetDocument();

	return false;
}
Example #2
0
void CWrapEngine::SetWidthToCache(const char* name, int width)
{
	if (!m_use_cache)
		return;

	if (!name || !*name)
		return;

	// We have to synchronize access to layout.xml so that multiple processed don't write
	// to the same file or one is reading while the other one writes.
	CInterProcessMutex mutex(MUTEX_LAYOUT);

	wxFileName file(COptions::Get()->GetOption(OPTION_DEFAULT_SETTINGSDIR), _T("layout.xml"));
	TiXmlElement* pDocument = GetXmlFile(file);

	if (!pDocument)
		return;

	TiXmlElement* pElement = pDocument->FirstChildElement("Layout");
	if (!pElement)
	{
		delete pDocument->GetDocument();
		return;
	}

	wxString language = wxGetApp().GetCurrentLanguageCode();
	if (language.empty())
		language = _T("default");

	TiXmlElement* pLanguage = FindElementWithAttribute(pElement, "Language", "id", language.mb_str());
	if (!pLanguage)
	{
		delete pDocument->GetDocument();
		return;
	}

	TiXmlElement* pDialog = FindElementWithAttribute(pLanguage, "Dialog", "name", name);
	if (!pDialog)
	{
		pDialog = pLanguage->LinkEndChild(new TiXmlElement("Dialog"))->ToElement();
		pDialog->SetAttribute("name", name);
	}

	pDialog->SetAttribute("width", width);
	wxString error;
	SaveXmlFile(file, pDocument, &error);

	delete pDocument->GetDocument();
}
Example #3
0
int ExportAnyData(CString filename, vector<string> &orders)
{
	Book* book = xlCreateBook();
	if(!book)
		return 0;

	for(vector<string>::iterator it = orders.begin(); it != orders.end(); it++)
	{
		CString Filename = it->c_str();
		Filename += ".xml";
		TiXmlElement *Root = getXMLRoot(Filename);
		Sheet* sheet = book->addSheet(it->c_str());
		if(!sheet)
			return 0;
		addOneSheet(sheet, Root);

		delete Root->GetDocument();
	}

	if(book->save(_T(filename.GetBuffer(0)) )) 
	{
		return 1;
	}
	else
	{
		return 0;
	}

	book->release();
}
Example #4
0
TiXmlElement* CXmlFile::Load(const wxFileName& fileName)
{
	if (fileName.IsOk())
		SetFileName(fileName);

	wxCHECK(m_fileName.IsOk(), 0);

	delete m_pDocument;
	m_pDocument = 0;

	wxString error;
	TiXmlElement* pElement = GetXmlFile(m_fileName, true, &error);
	if (!pElement)
	{
		m_error.Printf(_("The file '%s' could not be loaded."), m_fileName.GetFullPath().c_str());
		if (!error.empty())
			m_error += _T("\n") + error;
		else
			m_error += wxString(_T("\n")) + _("Make sure the file can be accessed and is a well-formed XML document.");
		m_modificationTime = wxDateTime();
		return 0;
	}

	{
		wxLogNull log;
		m_modificationTime = m_fileName.GetModificationTime();
	}

	m_pDocument = pElement->GetDocument();
	return pElement;
}
Example #5
0
std::list<wxString> CThemeProvider::GetThemeSizes(const wxString& themePath)
{
	std::list<wxString> sizes;

	wxFileName fn(wxGetApp().GetResourceDir() + themePath, _T("theme.xml"));
	TiXmlElement* pDocument = GetXmlFile(fn.GetFullPath(), false);
	if (!pDocument)
		return sizes;

	TiXmlElement* pTheme = pDocument->FirstChildElement("Theme");
	if (pTheme)
	{
		for (TiXmlElement* pSize = pTheme->FirstChildElement("size"); pSize; pSize = pSize->NextSiblingElement("size"))
		{
			const char* txt = pSize->GetText();
			if (!txt)
				continue;

			wxString size = ConvLocal(txt);
			if (size == _T(""))
				continue;

			sizes.push_back(size);
		}
	}

	delete pDocument->GetDocument();

	return sizes;
}
Example #6
0
bool CThemeProvider::GetThemeData(const wxString& themePath, wxString& name, wxString& author, wxString& email)
{
	wxFileName fn(wxGetApp().GetResourceDir() + themePath, _T("theme.xml"));
	TiXmlElement* pDocument = GetXmlFile(fn.GetFullPath(), false);
	if (!pDocument)
		return false;

	TiXmlElement* pTheme = pDocument->FirstChildElement("Theme");
	if (pTheme)
	{
		name = GetTextElement(pTheme, "Name");
		author = GetTextElement(pTheme, "Author");
		email = GetTextElement(pTheme, "Mail");
	}
	delete pDocument->GetDocument();

	return pTheme != 0;
}
Example #7
0
	/// Visit an element.
	virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* attribute)
	{
		if(element.ValueStr() == "world")
		{
			if(element.Parent() != element.GetDocument()) return false;
			return true;
		}
		else if(element.ValueStr() == "materials")
		{
			return true;
		}
		else if(element.ValueStr() == "material")
		{
            return true;
		}
		else if(element.ValueStr() == "bodies")
		{
			if(element.Parent()->ValueStr() != "world") return false;
			return true;
		}
		else if(element.ValueStr() == "ground")
		{
			if(element.Parent()->ValueStr() != "bodies") return false;
			assert(m_curBody == NULL);

            m_curBody = new World::Ground();
			return true;
		}
		else if(element.ValueStr() == "box")
		{
			if(element.Parent()->ValueStr() != "bodies") return false;
			assert(m_curBody == NULL);

			double hx = 0.5;
			double hy = 0.5;
			double hz = 0.5;
			
			element.Attribute("hx", &hx);
			element.Attribute("hy", &hy);
			element.Attribute("hz", &hz);

            World::Cube* cube = new World::Cube();
            cube->hx = hx;
            cube->hy = hy;
            cube->hz = hz;
            m_curBody = cube;
			return true;
		}
		else if(element.ValueStr() == "sphere")
		{
			if(element.Parent()->ValueStr() != "bodies") return false;
			assert(m_curBody == NULL);

			double r = 1;
			element.Attribute("r", &r);

            World::Sphere* sphere = new World::Sphere();
            sphere->r = r;
            m_curBody = sphere;
			return true;
		}
		else if(element.ValueStr() == "cylinder")
		{
			if(element.Parent()->ValueStr() != "bodies") return false;
			assert(m_curBody == NULL);

			double r = 1;
            double startx, starty, startz;
            double endx, endy, endz;
			element.Attribute("r", &r);

            element.Attribute("sx", &startx);
			element.Attribute("sy", &starty);
			element.Attribute("sz", &startz);

            element.Attribute("ex", &endx);
			element.Attribute("ey", &endy);
			element.Attribute("ez", &endz);

            World::Cylinder* cylinder = new World::Cylinder();
            cylinder->start = vec3(startx, starty, startz);
            cylinder->end = vec3(endx, endy, endz);
            cylinder->r = r;
            m_curBody = cylinder;
			return true;
		}
		else if(element.ValueStr() == "cone")
		{
			if(element.Parent()->ValueStr() != "bodies") return false;
			assert(m_curBody == NULL);
			double r = 0.05;
			double startx, starty, startz;
			double endx, endy, endz;

			element.Attribute("r", &r);
			
			element.Attribute("sx",&startx);
			element.Attribute("sy",&starty);
			element.Attribute("sz",&startz);
			
			element.Attribute("ex", &endx);
			element.Attribute("ey", &endy);
			element.Attribute("ez", &endz);

			World::Cone* cone = new World::Cone();
			cone->start = vec3(startx, starty, startz);
			cone->end = vec3(endx, endy, endz);
			cone->r = r;
			m_curBody = cone;
			return true;
		}
		else if(element.ValueStr() == "pos")
		{
			if(!IsBody(element.Parent())) return false;
			assert(m_curBody != NULL);
			double x = 0;
			double y = 0;
			double z = 0;

			element.Attribute("x", &x);
			element.Attribute("y", &y);
			element.Attribute("z", &z);

			m_curBody->pos = vec3(float(x), float(y), float(z));
			return true;
		}
		else if(element.ValueStr() == "vel")
		{
            return false;
		}
		else if(element.ValueStr() == "ori")
		{
            return false;
		}
		else if(element.ValueStr() == "avel")
		{
            return false;
		}
		else if(element.ValueStr() == "bodymaterial")
		{
            return false;
		}
		else
		{
			return false;
		}

		assert(false); // we should never get here
		return false;
	}