Example #1
0
		void BitmapFont::read(const string& filename)
		{
			string filePath = filename;
			for (auto i = filePath.begin(); i != filePath.end(); ++i)
			{
				if (*i == '\\')
					*i = '/';
			}
			fileName = filePath;

			auto lastPathSeparator = filePath.find_last_of('/');
			if (lastPathSeparator != string::npos)
				basePath = filePath.substr(0, lastPathSeparator) + "/";
			else
				basePath = "";
#ifdef WIN32
			for (auto i = filePath.begin(); i != filePath.end(); ++i)
			{
				if (*i == '/')
					*i = '\\';
			}
#endif
			std::ifstream ifs(filePath, std::ios_base::in | std::ios_base::binary);
			if (!ifs.good())
				throw io::FileNotFoundException(filename);
			string buffer = string(std::istreambuf_iterator<char>(ifs), std::istreambuf_iterator<char>());
			if (isBinaryBmfont(buffer))
				readFromBinary(filename, buffer);
			else if (isXmlBmfont(buffer))
				readFromXml(filename, buffer);
			else if (isTextBmfont(buffer))
				readFromText(filename, buffer);
			else
				throw io::BadFileFormatException("unknown bitmap font format");
		}
Example #2
0
Section::Section(XmlStreamReader *reader, QGraphicsItem *parent) :
	GridSnap(GS120)
{
	setParentItem(parent);
	setPen(blockPen);
	setRect(0, 0, 3 * grid(), 4 * grid());	// default size
	graphic.setParentItem(this);

	if (reader)
		readFromXml(reader);
}
Example #3
0
IwsConfig::IwsConfig(QObject *parent):QObject(parent)
{
    QString appPath = QCoreApplication::applicationDirPath();
    m_connectionTimeOut = 5 * 1000;
    m_port=80;
    m_address = QHostAddress("127.0.0.1");
    m_meta  = QString("<meta http-equiv=\"content-type\" content=\"text/html;charset=UTF-8\"/>");
    m_docType = QString("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
    m_imageTypes << "jpeg" << "jpg" << "png" << "bmp" << "gif";
    m_imageTypes << "JPEG" << "JPG" << "PNG" << "BMP" << "GIF";
    populateImageFileFilter();

    QDir dir(appPath);

    if (!dir.cd("../webRoot")) {
        IwsConfig::m_webRoot = appPath;
    }
    else{
        IwsConfig::m_webRoot=dir.absolutePath();
    }

    dir.setPath(appPath);
    if (!dir.cd("../resources"))
    {
        m_resourceDirPath = appPath;
    }
    else{
        m_resourceDirPath=dir.absolutePath();
    }

    readFromXml();

    qDebug() << "================================================";
    qDebug() << "initializing server with the following settings"<<endl;
    qDebug() <<  "IP Address............:" << m_address.toString();
    qDebug() <<  "Port .................:" << m_port;
    qDebug() <<  "webRoot path .........:" << m_webRoot;
    qDebug() <<  "resource dir path.....:" << m_resourceDirPath;
     qDebug() << "================================================";

    m_dirViewCss = readCssFromFile(m_resourceDirPath+"/dir-view.css");
    m_singleImageCss = readCssFromFile(m_resourceDirPath+"/single-image-view.css");
}
Example #4
0
Pin::Pin(XmlStreamReader *reader, QGraphicsItem *parent) :
	GridSnap(GS120),
	pinname(this),
	pinnumber(this),
	hidden(false),
	_length(360),
	_bubble(false),
	bubbleToggle(false),
	clock(false)
{
	setParentItem(parent);
	setPen(FreeSCH::standardPen);
	attributes.setValue("size", _length / grid());

	if (reader)
		readFromXml(reader);

	rebuild();
}