void MaterialLibrary::Load()
    {
        ResourceType* currMat = nullptr;
        std::string currLine;
        auto filename = Resource::application->GetConfig().resourceBase + "/" + GetParameters()[0];
        std::ifstream inFile(filename);

        if (!inFile.is_open()) {
            throw resource_loading_error() << ::boost::errinfo_file_name(filename) << resid_info(id) << errdesc_info("Cannot open file.");
        }

        boost::regex reg_newmtl("^newmtl\\s+(\\w+)$");
        boost::regex reg_Ka("^Ka\\s+" + regex_help::flt3 + "$");
        boost::regex reg_Kd("^Kd\\s+" + regex_help::flt3 + "$");
        boost::regex reg_Ks("^Ks\\s+" + regex_help::flt3 + "$");
        boost::regex reg_d("^d\\s+" + regex_help::flt + "$");
        boost::regex reg_d_halo("^d\\s+-halo\\s+" + regex_help::flt + "$");
        boost::regex reg_Ns("^Ns\\s+" + regex_help::flt + "$");
        boost::regex reg_Ni("^Ni\\s+" + regex_help::flt + "$");
        boost::regex reg_map_Kd("^map_Kd\\s+(.*\\s+)?([\\w-]+\\.\\w+)$");
        boost::regex reg_map_bump("^(map_bump|bump)\\s+(.*\\s+)?([\\w-]+\\.\\w+)$");

        boost::smatch lineMatch;

        while (inFile.good()) {
            std::getline(inFile, currLine);

            boost::trim(currLine);
            if (currLine.length() == 0 || boost::starts_with(currLine, "#"))
                continue; // comment or empty line
            if (boost::regex_match(currLine, lineMatch, reg_newmtl)) {
                auto mtlName = lineMatch[1].str();
                currMat = SetResource(mtlName, std::move(std::make_unique<Material>()));
            } else if (boost::regex_match(currLine, lineMatch, reg_Ka) && currMat) {
                currMat->ambient = parseColor(lineMatch);
            } else if (boost::regex_match(currLine, lineMatch, reg_Kd) && currMat) {
                currMat->diffuse = parseColor(lineMatch);
            } else if (boost::regex_match(currLine, lineMatch, reg_Ks) && currMat) {
                currMat->specular = parseColor(lineMatch);
            } else if (boost::regex_match(currLine, lineMatch, reg_d) && currMat) {
                currMat->alpha = boost::lexical_cast<float>(lineMatch[1].str());
            } else if (boost::regex_match(currLine, lineMatch, reg_d_halo) && currMat) {
                currMat->minOrientedAlpha = boost::lexical_cast<float>(lineMatch[1].str());
            } else if (boost::regex_match(currLine, lineMatch, reg_Ns) && currMat) {
                currMat->N_s = boost::lexical_cast<float>(lineMatch[1].str());
            } else if (boost::regex_match(currLine, lineMatch, reg_Ni) && currMat) {
                currMat->N_i = boost::lexical_cast<float>(lineMatch[1].str());
            } else if (boost::regex_match(currLine, lineMatch, reg_map_Kd) && currMat) {
                currMat->diffuseTex = parseTexture(lineMatch[2].str(), "sRGB");
            } else if (boost::regex_match(currLine, lineMatch, reg_map_bump) && currMat) {
                currMat->bumpTex = parseTexture(lineMatch[3].str(), "");
                currMat->bumpMultiplier = parseFloatParameter("-bm", lineMatch[2].str(), 1.0f);
            } else {
                notImplemented(currLine);
            }
        }
        inFile.close();

        Resource::Load();
    }
Esempio n. 2
0
KdmLabel::KdmLabel( QObject *parent, const QDomNode &node )
	: KdmItem( parent, node )
	, action( 0 )
{
	itemType = "label";

	// Set default values for label (note: strings are already Null)
	label.normal.font = label.active.font = label.prelight.font = style.font;
	label.normal.color = label.active.color = label.prelight.color =
		style.palette.isBrushSet( QPalette::Normal, QPalette::WindowText ) ?
			style.palette.color( QPalette::Normal, QPalette::WindowText ) :
			QColor( Qt::white );
	label.active.present = false;
	label.prelight.present = false;

	const QString locale = KGlobal::locale()->language();

	// Read LABEL TAGS
	QDomNodeList childList = node.childNodes();
	bool stockUsed = false;
	for (int nod = 0; nod < childList.count(); nod++) {
		QDomNode child = childList.item( nod );
		QDomElement el = child.toElement();
		QString tagName = el.tagName();

		if (tagName == "normal") {
			parseColor( el, label.normal.color );
			parseFont( el, label.normal.font );
		} else if (tagName == "active") {
			label.active.present = true;
			parseColor( el, label.active.color );
			parseFont( el, label.active.font );
		} else if (tagName == "prelight") {
			label.prelight.present = true;
			parseColor( el, label.prelight.color );
			parseFont( el, label.prelight.font );
		} else if (tagName == "text" && el.attributes().count() == 0 && !stockUsed) {
			label.text = el.text();
		} else if (tagName == "text" && !stockUsed) {
			QString lang = el.attribute( "xml:lang", "" );
			if (lang == locale)
				label.text = el.text();
		} else if (tagName == "stock") {
			label.text = lookupStock( el.attribute( "type", "" ) );
			stockUsed = true;
		}
	}

	// Check if this is a timer label
	label.isTimer = label.text.indexOf( "%c" ) >= 0;
	if (label.isTimer) {
		timer = new QTimer( this );
		timer->start( 1000 );
		connect( timer, SIGNAL(timeout()), SLOT(update()) );
	}
	label.text.replace( '\n', ' ' );
	setCText( lookupText( label.text ) );
}
Esempio n. 3
0
TestPlugin::TestPlugin(WebFrame* frame, const WebPluginParams& params, WebTestDelegate* delegate)
    : m_frame(frame)
    , m_delegate(delegate)
    , m_container(0)
    , m_context(0)
    , m_colorTexture(0)
    , m_mailboxChanged(false)
    , m_framebuffer(0)
    , m_touchEventRequest(WebPluginContainer::TouchEventRequestTypeNone)
    , m_reRequestTouchEvents(false)
    , m_printEventDetails(false)
    , m_printUserGestureStatus(false)
    , m_canProcessDrag(false)
    , m_isPersistent(params.mimeType == pluginPersistsMimeType())
    , m_canCreateWithoutRenderer(params.mimeType == canCreateWithoutRendererMimeType())
{
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrimitive, ("primitive"));
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeBackgroundColor, ("background-color"));
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrimitiveColor, ("primitive-color"));
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeOpacity, ("opacity"));
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeAcceptsTouch, ("accepts-touch"));
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeReRequestTouchEvents, ("re-request-touch"));
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrintEventDetails, ("print-event-details"));
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeCanProcessDrag, ("can-process-drag"));
    const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrintUserGestureStatus, ("print-user-gesture-status"));

    DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size());
    size_t size = params.attributeNames.size();
    for (size_t i = 0; i < size; ++i) {
        const WebString& attributeName = params.attributeNames[i];
        const WebString& attributeValue = params.attributeValues[i];

        if (attributeName == kAttributePrimitive)
            m_scene.primitive = parsePrimitive(attributeValue);
        else if (attributeName == kAttributeBackgroundColor)
            parseColor(attributeValue, m_scene.backgroundColor);
        else if (attributeName == kAttributePrimitiveColor)
            parseColor(attributeValue, m_scene.primitiveColor);
        else if (attributeName == kAttributeOpacity)
            m_scene.opacity = parseOpacity(attributeValue);
        else if (attributeName == kAttributeAcceptsTouch)
            m_touchEventRequest = parseTouchEventRequestType(attributeValue);
        else if (attributeName == kAttributeReRequestTouchEvents)
            m_reRequestTouchEvents = parseBoolean(attributeValue);
        else if (attributeName == kAttributePrintEventDetails)
            m_printEventDetails = parseBoolean(attributeValue);
        else if (attributeName == kAttributeCanProcessDrag)
            m_canProcessDrag = parseBoolean(attributeValue);
        else if (attributeName == kAttributePrintUserGestureStatus)
            m_printUserGestureStatus = parseBoolean(attributeValue);
    }
    if (m_canCreateWithoutRenderer)
        m_delegate->printMessage(std::string("TestPlugin: canCreateWithoutRenderer\n"));
}
Esempio n. 4
0
void SvgStyleParser::parseColorStops(QGradient *gradient, const KoXmlElement &e)
{
    QGradientStops stops;
    QColor c;

    for (KoXmlNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) {
        KoXmlElement stop = n.toElement();
        if (stop.tagName() == "stop") {
            float offset;
            QString temp = stop.attribute("offset");
            if (temp.contains('%')) {
                temp = temp.left(temp.length() - 1);
                offset = temp.toFloat() / 100.0;
            } else
                offset = temp.toFloat();

            QString stopColorStr = stop.attribute("stop-color");
            if (!stopColorStr.isEmpty()) {
                if (stopColorStr == "inherit") {
                    stopColorStr = inheritedAttribute("stop-color", stop);
                }
                parseColor(c, stopColorStr);
            }
            else {
                // try style attr
                QString style = stop.attribute("style").simplified();
                QStringList substyles = style.split(';', QString::SkipEmptyParts);
                for (QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) {
                    QStringList substyle = it->split(':');
                    QString command = substyle[0].trimmed();
                    QString params  = substyle[1].trimmed();
                    if (command == "stop-color")
                        parseColor(c, params);
                    if (command == "stop-opacity")
                        c.setAlphaF(params.toDouble());
                }

            }
            QString opacityStr = stop.attribute("stop-opacity");
            if (!opacityStr.isEmpty()) {
                if (opacityStr == "inherit") {
                    opacityStr = inheritedAttribute("stop-opacity", stop);
                }
                c.setAlphaF(opacityStr.toDouble());
            }
            stops.append(QPair<qreal, QColor>(offset, c));
        }
    }
    if (stops.count())
        gradient->setStops(stops);
}
Esempio n. 5
0
TestPlugin::TestPlugin(WebFrame* frame, const WebPluginParams& params, WebTestDelegate* delegate)
    : m_frame(frame)
    , m_delegate(delegate)
    , m_container(0)
    , m_context(0)
    , m_colorTexture(0)
    , m_mailboxChanged(false)
    , m_framebuffer(0)
    , m_touchEventRequest(WebPluginContainer::TouchEventRequestTypeNone)
    , m_reRequestTouchEvents(false)
    , m_printEventDetails(false)
    , m_printUserGestureStatus(false)
    , m_canProcessDrag(false)
{
    static const WebString kAttributePrimitive = WebString::fromUTF8("primitive");
    static const WebString kAttributeBackgroundColor = WebString::fromUTF8("background-color");
    static const WebString kAttributePrimitiveColor = WebString::fromUTF8("primitive-color");
    static const WebString kAttributeOpacity = WebString::fromUTF8("opacity");
    static const WebString kAttributeAcceptsTouch = WebString::fromUTF8("accepts-touch");
    static const WebString kAttributeReRequestTouchEvents = WebString::fromUTF8("re-request-touch");
    static const WebString kAttributePrintEventDetails = WebString::fromUTF8("print-event-details");
    static const WebString kAttributeCanProcessDrag = WebString::fromUTF8("can-process-drag");
    static const WebString kAttributePrintUserGestureStatus = WebString::fromUTF8("print-user-gesture-status");

    BLINK_ASSERT(params.attributeNames.size() == params.attributeValues.size());
    size_t size = params.attributeNames.size();
    for (size_t i = 0; i < size; ++i) {
        const WebString& attributeName = params.attributeNames[i];
        const WebString& attributeValue = params.attributeValues[i];

        if (attributeName == kAttributePrimitive)
            m_scene.primitive = parsePrimitive(attributeValue);
        else if (attributeName == kAttributeBackgroundColor)
            parseColor(attributeValue, m_scene.backgroundColor);
        else if (attributeName == kAttributePrimitiveColor)
            parseColor(attributeValue, m_scene.primitiveColor);
        else if (attributeName == kAttributeOpacity)
            m_scene.opacity = parseOpacity(attributeValue);
        else if (attributeName == kAttributeAcceptsTouch)
            m_touchEventRequest = parseTouchEventRequestType(attributeValue);
        else if (attributeName == kAttributeReRequestTouchEvents)
            m_reRequestTouchEvents = parseBoolean(attributeValue);
        else if (attributeName == kAttributePrintEventDetails)
            m_printEventDetails = parseBoolean(attributeValue);
        else if (attributeName == kAttributeCanProcessDrag)
            m_canProcessDrag = parseBoolean(attributeValue);
        else if (attributeName == kAttributePrintUserGestureStatus)
            m_printUserGestureStatus = parseBoolean(attributeValue);
    }
}
Esempio n. 6
0
void MTLFileReader::parseLine(const char*& current, const char* endOfLine)
{
	if(matchCommand(current, "newmtl"))
	{
		WavefrontMaterial mat;
		mat.name = current;
		materials.push_back(mat);

		current = endOfLine;
	}
	else if(matchCommand(current, "Ka")) // ambient color
		curMaterial().ambient = parseColor(current);
	else if(matchCommand(current, "Kd")) // diffuse color
		curMaterial().diffuse = parseColor(current);
	else if(matchCommand(current, "Ks")) // specular color
		curMaterial().specular = parseColor(current);
	else if(matchCommand(current, "Ns")) // specular exponent
		curMaterial().specularExp = parseFloat(current);
	else if(matchCommand(current, "Km")) // no idea what this is
		parseFloat(current);
	else if(matchCommand(current, "Ni")) // optical density
		curMaterial().refractiveInd = parseFloat(current);
  else if(matchCommand(current, "illum")) // illumination model
    curMaterial().illuminationModel = parseInt(current);
	else if(matchCommand(current, "d")) // dissolve
	{
		if(matchCommand(current, "-halo"))
			diagnostic(true, current, "dissolve halo not supported");

		curMaterial().opacity = parseFloat(current);
	}
	else if(matchCommand(current, "map_Kd")) // diffuse texture
	{
		curMaterial().diffuseTex = current;
		current = endOfLine;
	}
	else if(matchCommand(current, "map_Bump")) // bump texture
	{
		curMaterial().bumpTex = current;
		current = endOfLine;
	}
	else if(matchCommand(current, "map_d") || matchCommand(current, "map_D")) // opacity texture
	{
		curMaterial().opacityTex = current;
		current = endOfLine;
	}
	else
		diagnostic(false, current, "unknown command");
}
Esempio n. 7
0
void
KdmRect::init( const TQDomNode &node, const char * )
{
	itemType = "rect";

	// Set default values for rect (note: strings are already Null)
	rect.normal.alpha = 1;
	rect.active.present = false;
	rect.prelight.present = false;
	rect.hasBorder = false;

	// A rect can have no properties (defaults to parent ones)
	if (node.isNull()) {
		return;
	}

	// Read RECT ID
	TQDomNode n = node;
	TQDomElement elRect = n.toElement();

	// Read RECT TAGS
	TQDomNodeList childList = node.childNodes();
	for (uint nod = 0; nod < childList.count(); nod++) {
		TQDomNode child = childList.item( nod );
		TQDomElement el = child.toElement();
		TQString tagName = el.tagName();

		if (tagName == "normal") {
			parseColor( el.attribute( "color", TQString::null ), rect.normal.color );
			rect.normal.alpha = el.attribute( "alpha", "1.0" ).toFloat();
			parseFont( el.attribute( "font", "Sans 14" ), rect.normal.font );
		}
		else if (tagName == "active") {
			rect.active.present = true;
			parseColor( el.attribute( "color", TQString::null ), rect.active.color );
			rect.active.alpha = el.attribute( "alpha", "1.0" ).toFloat();
			parseFont( el.attribute( "font", "Sans 14" ), rect.active.font );
		}
		else if (tagName == "prelight") {
			rect.prelight.present = true;
			parseColor( el.attribute( "color", TQString::null ), rect.prelight.color );
			rect.prelight.alpha = el.attribute( "alpha", "1.0" ).toFloat();
			parseFont( el.attribute( "font", "Sans 14" ), rect.prelight.font );
		}
		else if (tagName == "border") {
			rect.hasBorder = true;
		}
	}
}
Esempio n. 8
0
static int _themeParseTextureEntry(const char *json, jsmntok_t *tokens, const char *name, void *context) {
    flubGuiTheme_t *theme = (flubGuiTheme_t *)context;
    _jsonTextureEntry_t entry;
    flubGuiThemeTexture_t *texture;
    int red = 0;
    int green = 0;
    int blue = 0;

    memset(&entry, 0, sizeof(_jsonTextureEntry_t));
    if(!jsonParseToStruct(json, tokens, _themeTextureParseMap, "Theme texture entry", &entry, _jsonTextureCleanup)) {
        return 0;
    }
    texture = util_calloc(sizeof(flubGuiThemeTexture_t), 0, NULL);
    texture->type = eFlubGuiThemeTexture;
    texture->id = entry.id;
    if(entry.colorkey != NULL) {
        parseColor(entry.colorkey, &red, &green, &blue, NULL);
    }
    if((texture->texture = texmgrLoad(entry.filename, NULL, entry.minfilter,
                                      entry.magfilter,
                                      ((entry.colorkey != NULL) ? 1 : 0),
                                      red, green, blue)) == NULL) {
        _jsonTextureCleanup(&entry);
        util_free(texture);
        return 0;
    }
    critbitInsert(&theme->textures, name, texture, NULL);
    _flubGuiThemeIndexAdd(theme, entry.id, texture);
    debugf(DBG_GUI, DBG_GUI_DTL_THEME, "Found texture \"%s\" as %d, file [%s], %s %s %s", name, entry.id,
          entry.filename, texmgrGLMinFilterStr(entry.minfilter),
          texmgrGLMagFilterStr(entry.magfilter), ((entry.colorkey == NULL) ? "No colorkey" : entry.colorkey));
    _jsonTextureCleanup(&entry);
    return 1;
}
Esempio n. 9
0
int handleColorsSection(gamedef_t *gamedef, const char *name, const char *value)
{
    int result = -1;
    draw_color_t colorBuf;

    for (int i = 0; i < validBoxTypes; i++)
    {
        if (strcmp(boxTypeNames[i], name) == 0) {
            currentName = name;
            result = parseColor(value, &colorBuf, boxFillAlpha);
            if (result == 0)
            {
                memcpy(&(boxFillColors[i]), &colorBuf, sizeof(colorBuf));
                memcpy(&(boxEdgeColors[i]), &colorBuf, sizeof(colorBuf));
                boxEdgeColors[i].a = boxEdgeAlpha;
            }
            POST_CHECK;
        }
    }

    MATCH_COLOR("playerPivot", playerPivotColor, pivotAlpha);
    MATCH_COLOR("rangeMarker", closeNormalRangeColor, closeNormalRangeAlpha);
    MATCH_COLOR("gaugeBorder", gaugeBorderColor, gaugeBorderAlpha);
    MATCH_COLOR("stunGauge", stunGaugeFillColor, gaugeFillAlpha);
    MATCH_COLOR("stunRecoveryGauge", stunRecoverGaugeFillColor, gaugeFillAlpha);
    MATCH_COLOR("guardGauge", guardGaugeFillColor, gaugeFillAlpha);

    return result;
}
Esempio n. 10
0
static int _themeParseColorEntry(const char *json, jsmntok_t *tokens, const char *name, void *context) {
    flubGuiTheme_t *theme = (flubGuiTheme_t *)context;
    _jsonColorEntry_t entry;
    flubGuiThemeColor_t *color;
    int red;
    int green;
    int blue;

    memset(&entry, 0, sizeof(_jsonColorEntry_t));
    if(!jsonParseToStruct(json, tokens,_themeColorParseMap, "Theme color entry", &entry, _jsonColorCleanup)) {
        return 0;
    }

    color = util_calloc(sizeof(flubGuiThemeColor_t), 0, NULL);
    color->type = eFlubGuiThemeColor;
    color->id = entry.id;
    parseColor(entry.color, &red, &green, &blue, NULL);
    color->red = COLOR_ITOF(red);
    color->green = COLOR_ITOF(green);
    color->blue = COLOR_ITOF(blue);
    critbitInsert(&theme->colors, name, color, NULL);
    _flubGuiThemeIndexAdd(theme, entry.id, color);
    _jsonColorCleanup(&entry);
    debugf(DBG_GUI, DBG_GUI_DTL_THEME, "Found color \"%s\" as %d, value #%02x%02x%02x", name, entry.id, red, green, blue);
    return 1;
}
Esempio n. 11
0
void parseAttr(lua_State *L,int KeyIdx,int ValIdx,void *Struct,const ParseAttrib *Attrs)
{
    byte *H=(byte *)Struct;
    const char *Key=lua_tostring(L,KeyIdx);
    size_t Len;
    const char *Val=lua_tolstring(L,ValIdx,&Len);
    for (ParseAttrib const *P=Attrs; P->name!=NULL; P++)
    {
        if (0!=strcmp(P->name,Key))
            continue;
        switch (P->type)
        {
        case 2: //string
        {
            char *NewString=(char*)noxAlloc(Len+1);
            strcpy(NewString,Val);
            *((char**)( H + P->ofs))=NewString;
        }
        break;
        case 3: //color
            *((DWORD*)( H + P->ofs))=parseColor(Val);
            break;
        case 4:// wstring
        {
            wchar_t *NewString=(wchar_t *)noxAlloc(2*(Len+1));
            mbstowcs(NewString,Val,Len+1);
            *((wchar_t**)( H + P->ofs))=NewString;
        }
        break;
        case 5: //bitfield
            break;//TODO
        }
    }
}
Esempio n. 12
0
        Model::EntityDefinition* DefParser::nextDefinition() {
            Token token = m_tokenizer.nextToken();
            while (token.type() != Eof && token.type() != ODefinition)
                token = m_tokenizer.nextToken();
            if (token.type() == Eof)
                return NULL;

            expect(ODefinition, token);
            
            StringList baseClasses;
            ClassInfo classInfo;
            
            token = m_tokenizer.nextToken();
            expect(Word, token);
            classInfo.name = token.data();

            token = m_tokenizer.peekToken();
            expect(OParenthesis | Newline, token);
            if (token.type() == OParenthesis) {
                classInfo.setColor(parseColor());
                
                token = m_tokenizer.peekToken();
                expect(OParenthesis | Question, token);
                if (token.type() == OParenthesis) {
                    classInfo.setSize(parseBounds());
                } else {
                    m_tokenizer.nextToken();
                }
                
                token = m_tokenizer.peekToken();
                if (token.type() == Word) {
                    Model::FlagsPropertyDefinition::Ptr spawnflags = parseFlags();
                    classInfo.properties[spawnflags->name()] = spawnflags;
                }
            }

            expect(Newline, token = m_tokenizer.nextToken());
            parseProperties(classInfo.properties, classInfo.models, baseClasses);
            
            classInfo.setDescription(parseDescription());
            expect(CDefinition, token = m_tokenizer.nextToken());

            Model::EntityDefinition* definition = NULL;
            
            if (classInfo.hasColor) {
                ClassInfo::resolveBaseClasses(m_baseClasses, baseClasses, classInfo);
                if (classInfo.hasSize) { // point definition
                    definition = new Model::PointEntityDefinition(classInfo.name, classInfo.color, classInfo.size, classInfo.description, classInfo.propertyList(), classInfo.models);
                } else {
                    definition = new Model::BrushEntityDefinition(classInfo.name, classInfo.color, classInfo.description, classInfo.propertyList());
                }
            } else { // base definition
                m_baseClasses[classInfo.name] = classInfo;
                definition = nextDefinition();
            }
            
            return definition;
        }
Esempio n. 13
0
KdmPixmap::KdmPixmap(KdmItem *parent, const QDomNode &node, const char *name) : KdmItem(parent, node, name)
{
    itemType = "pixmap";

    // Set default values for pixmap (note: strings are already Null)
    pixmap.normal.tint.setRgb(0xFFFFFF);
    pixmap.normal.alpha = 1.0;
    pixmap.active.present = false;
    pixmap.prelight.present = false;

    // Read PIXMAP ID
    // it rarely happens that a pixmap can be a button too!
    QDomNode n = node;
    QDomElement elPix = n.toElement();

    // Read PIXMAP TAGS
    QDomNodeList childList = node.childNodes();
    for(uint nod = 0; nod < childList.count(); nod++)
    {
        QDomNode child = childList.item(nod);
        QDomElement el = child.toElement();
        QString tagName = el.tagName();

        if(tagName == "normal")
        {
            loadPixmap(el.attribute("file", ""), pixmap.normal.pixmap, pixmap.normal.fullpath);
            parseColor(el.attribute("tint", "#ffffff"), pixmap.normal.tint);
            pixmap.normal.alpha = el.attribute("alpha", "1.0").toFloat();
        }
        else if(tagName == "active")
        {
            pixmap.active.present = true;
            loadPixmap(el.attribute("file", ""), pixmap.active.pixmap, pixmap.active.fullpath);
            parseColor(el.attribute("tint", "#ffffff"), pixmap.active.tint);
            pixmap.active.alpha = el.attribute("alpha", "1.0").toFloat();
        }
        else if(tagName == "prelight")
        {
            pixmap.prelight.present = true;
            loadPixmap(el.attribute("file", ""), pixmap.prelight.pixmap, pixmap.prelight.fullpath);
            parseColor(el.attribute("tint", "#ffffff"), pixmap.prelight.tint);
            pixmap.prelight.alpha = el.attribute("alpha", "1.0").toFloat();
        }
    }
}
Esempio n. 14
0
void Conf::get(const Common::String &key, byte *color, const byte *defaultColor) {
	if (ConfMan.hasKey(key)) {
		parseColor(ConfMan.get(key), color);
	} else if (defaultColor) {
		Common::copy(defaultColor, defaultColor + 3, color);
	} else {
		Common::fill(color, color + 3, 0);
	}
}
Esempio n. 15
0
StyleColor CSSParser::colorFromRGBColorString(const String& string)
{
    // FIXME: Rework css parser so it is more SVG aware.
    RGBA32 color;
    if (parseColor(color, string.stripWhiteSpace()))
        return StyleColor(color);
    // FIXME: This branch catches the string currentColor, but we should error if we have an illegal color value.
    return StyleColor::currentColor();
}
Esempio n. 16
0
TxSkin::color TxSkin::parseColor( LPCWSTR section, LPCWSTR key, TxSkin::color defColor, LPCWSTR iniFile )
{
	WCHAR str[255];
	GetPrivateProfileString(section, key, L"", str, 255, iniFile);
	if(!str[0])
	{
		return defColor;
	}
	return parseColor(str);
}
Esempio n. 17
0
void Model3DS::parseMaterial()
{
	cout << "parseMaterial" << endl;
	DWord length = currentChunk.length;
	DWord n = cfg3ds::chunkHeaderSize;
	
	Material *material = new Material();
	
	while (n < length)
	{
		readChunkHeader();
		n += currentChunk.length;
		switch (currentChunk.id)
		{
			case chunks::MATERIAL_NAME:
				readString(material->name);
				break;
			
			case chunks::MATERIAL_AMBIENT:
				parseColor(material->ambient);
				break;
				
			case chunks::MATERIAL_DIFFUSE:
				parseColor(material->diffuse);
				break;
			
			case chunks::MATERIAL_SPECULAR:
				parseColor(material->specular);
				break;
				
			case chunks::MATERIAL_TEXMAP:
				parseTexmap(material);
				break;
			
			default:
				skipChunk();
		}
	}
	
	cout << "\tname: " << material->name << endl;
	materials.push_back(material);
}
Esempio n. 18
0
PassRefPtrWillBeRawPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode)
{
    if (RefPtrWillBeRawPtr<CSSValue> length = parseSimpleLengthValue(propertyID, string, parserMode))
        return length.release();
    if (isColorPropertyID(propertyID))
        return parseColor(string, isQuirksModeBehavior(parserMode));
    if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, string))
        return keyword.release();
    if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID, string))
        return transform.release();
    return nullptr;
}
Esempio n. 19
0
void ColorEditor::parseText()
{
  QColor new_color = parseColor( text() );
  if( new_color.isValid() )
  {
    color_ = new_color;
    if( property_ )
    {
      property_->setColor( new_color );
    }
  }
}
Esempio n. 20
0
CSSValue* CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID,
                                              const String& string,
                                              CSSParserMode parserMode) {
  if (CSSValue* length = parseSimpleLengthValue(propertyID, string, parserMode))
    return length;
  if (isColorPropertyID(propertyID))
    return parseColor(string, parserMode);
  if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode))
    return keyword;
  if (CSSValue* transform = parseSimpleTransform(propertyID, string))
    return transform;
  return nullptr;
}
Esempio n. 21
0
void SmilText::process()
{
    SmilMedia::process();
    SmilMediaParam *p = findParameter("foregroundColor");
    if (!p)
        p = findParameter("foreground-color");
    if (p)
        textColor = parseColor(p->value);
    if (!source.isEmpty() && !waiting) {
        waiting = true;
        sys->transferServer()->requestData(this, source);
    }
}
	void CModelReaderNode093_Color::parseXML(_In_ CXmlReader * pXMLReader)
	{
		// Parse name
		parseName(pXMLReader);

		// Parse attribute
		parseAttributes(pXMLReader);

		// Parse Content
		parseContent(pXMLReader);

		// Parse Color
		parseColor();
	}
Esempio n. 23
0
TxSkin::brush* TxSkin::parseBrush( LPWSTR str )
{
	WCHAR fncName[255]	= L"";
	WCHAR params[255]	= L"";
	LPWSTR fnc = findFunction(str, fncName, params);
	while(fnc)
	{
		if(!StrCmpI(fncName, L"solidBrush"))
		{
			WCHAR strColor[255]	= L"";
			::findParam(params, strColor);

			TxSkin::color	brushColor	= parseColor(strColor);
			return new TxSkin::solid_brush(brushColor);
		}
		if(!StrCmpI(fncName, L"xGradient"))
		{
			WCHAR strColor1[255]	= L"";
			WCHAR strColor2[255]	= L"";
			LPWSTR nextParam = ::findParam(params, strColor1);
			nextParam = ::findParam(nextParam, strColor2);

			TxSkin::color	brushColor1	= parseColor(strColor1);
			TxSkin::color	brushColor2	= parseColor(strColor2);
			return new TxSkin::h_gradient_brush(brushColor1, brushColor2);
		}
		if(!StrCmpI(fncName, L"yGradient"))
		{
			WCHAR strColor1[255]	= L"";
			WCHAR strColor2[255]	= L"";
			LPWSTR nextParam = ::findParam(params, strColor1);
			nextParam = ::findParam(nextParam, strColor2);

			TxSkin::color	brushColor1	= parseColor(strColor1);
			TxSkin::color	brushColor2	= parseColor(strColor2);
			return new TxSkin::v_gradient_brush(brushColor1, brushColor2);
		}
		if(!StrCmpI(fncName, L"radialGradient"))
		{
			WCHAR strColor1[255]	= L"";
			WCHAR strColor2[255]	= L"";
			LPWSTR nextParam = ::findParam(params, strColor1);
			nextParam = ::findParam(nextParam, strColor2);

			TxSkin::color	brushColor1	= parseColor(strColor1);
			TxSkin::color	brushColor2	= parseColor(strColor2);
			return new TxSkin::radial_gradient_brush(brushColor1, brushColor2);
		}
		fnc = findFunction(fnc, fncName, params);
	}
	return NULL;
}
Esempio n. 24
0
void gtAction:: setCharStyleAttributes(gtFont *font, CharStyle& style)
{
	int flags = font->getFlags();
	style.erase();

	if ((flags & gtFont::familyWasSet) || (flags & gtFont::weightWasSet) || (flags & gtFont::slantWasSet))
		style.setFont(validateFont(font));
	if (flags & gtFont::sizeWasSet)
		style.setFontSize(font->getSize());
	if (flags & gtFont::effectWasSet)
		style.setFeatures(static_cast<StyleFlag>(font->getEffectsValue()).featureList());
	if (flags & gtFont::fillColorWasSet)
		style.setFillColor(parseColor(font->getColor()));
	if (flags & gtFont::fillShadeWasSet)
		style.setFillShade(font->getShade());
	if (flags & gtFont::strokeColorWasSet)
		style.setStrokeColor(parseColor(font->getStrokeColor()));
	if (flags & gtFont::strokeShadeWasSet)
		style.setStrokeShade(font->getStrokeShade());
	if (flags & gtFont::hscaleWasSet)
		style.setScaleH(font->getHscale());
	if (flags & gtFont::kerningWasSet)
		style.setTracking(font->getKerning());
}
Esempio n. 25
0
PassRefPtr<CanvasStyle> CanvasStyle::createFromString(const String& color)
{
    RGBA32 rgba;
    ColorParseResult parseResult = parseColor(rgba, color);
    switch (parseResult) {
    case ParsedRGBA:
        return adoptRef(new CanvasStyle(rgba));
    case ParsedCurrentColor:
        return adoptRef(new CanvasStyle(CurrentColor));
    case ParseFailed:
        return 0;
    default:
        ASSERT_NOT_REACHED();
        return 0;
    }
}
Esempio n. 26
0
CanvasStyle CanvasStyle::createFromStringWithOverrideAlpha(const String& color, float alpha)
{
    RGBA32 rgba;
    ColorParseResult parseResult = parseColor(rgba, color);
    switch (parseResult) {
    case ParsedRGBA:
        return CanvasStyle(colorWithOverrideAlpha(rgba, alpha));
    case ParsedCurrentColor:
        return CanvasStyle(CurrentColorWithOverrideAlpha, alpha);
    case ParseFailed:
        return CanvasStyle();
    default:
        ASSERT_NOT_REACHED();
        return CanvasStyle();
    }
}
Esempio n. 27
0
//auto, #000000, 78px
QSharedPointer<Value> CSSParser::parseValue(){
#ifdef CSS_DEBUG
    qDebug() << Q_FUNC_INFO;
#endif /* CSS_DEBUG */
    QChar c = peekChar();
    if (c.isDigit()) {
        return parseLength();
    } else if (c == '#') {
        return parseColor();
    } else {
//        QSharedPointer<KeywordValue> ret = QSharedPointer<KeywordValue>(new KeywordValue(parseIdentifier()));
        return QSharedPointer<KeywordValue>(new KeywordValue(parseIdentifier()));
    }
    qDebug() << Q_FUNC_INFO << "enter a dead end";

}
Esempio n. 28
0
PassRefPtrWillBeRawPtr<CanvasStyle> CanvasStyle::createFromStringWithOverrideAlpha(const String& color, float alpha)
{
    RGBA32 rgba;
    ColorParseResult parseResult = parseColor(rgba, color);
    switch (parseResult) {
    case ParsedRGBA:
        return adoptRefWillBeNoop(new CanvasStyle(colorWithOverrideAlpha(rgba, alpha)));
    case ParsedCurrentColor:
        return adoptRefWillBeNoop(new CanvasStyle(CurrentColorWithOverrideAlpha, alpha));
    case ParseFailed:
        return nullptr;
    default:
        ASSERT_NOT_REACHED();
        return nullptr;
    }
}
Esempio n. 29
0
bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString, HTMLCanvasElement* canvas)
{
    ColorParseResult parseResult = parseColor(parsedColor, colorString);
    switch (parseResult) {
    case ParsedRGBA:
        return true;
    case ParsedCurrentColor:
        parsedColor = currentColor(canvas);
        return true;
    case ParseFailed:
        return false;
    default:
        ASSERT_NOT_REACHED();
        return false;
    }
}
Esempio n. 30
0
CanvasStyle CanvasStyle::createFromString(const String& color, Document* document)
{
    RGBA32 rgba;
    ColorParseResult parseResult = parseColor(rgba, color, document);
    switch (parseResult) {
    case ParsedRGBA:
    case ParsedSystemColor:
        return CanvasStyle(rgba);
    case ParsedCurrentColor:
        return CanvasStyle(ConstructCurrentColor);
    case ParseFailed:
        return CanvasStyle();
    default:
        ASSERT_NOT_REACHED();
        return CanvasStyle();
    }
}