void QtCurveShadowConfiguration::defaults() { m_hOffset = 0; m_vOffset = 5; if(QPalette::Active==m_colorGroup) { m_size = 35; setColorType(CT_FOCUS); m_shadowType = SH_ACTIVE; } else { m_size = 30; setColorType(CT_GRAY); m_shadowType = SH_INACTIVE; } }
void SVGPaint::setUri(const String& uri) { // Spec: Sets the paintType to SVG_PAINTTYPE_URI_NONE and sets uri to the specified value. m_uri = uri; m_paintType = SVG_PAINTTYPE_URI_NONE; setColor(Color()); setColorType(colorTypeForPaintType(m_paintType)); setNeedsStyleRecalc(); }
void SVGPaint::setPaint(unsigned short paintType, const String& uri, const String& rgbColor, const String& iccColor, ExceptionCode& ec) { if ((paintType > SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR && paintType < SVG_PAINTTYPE_NONE) || paintType > SVG_PAINTTYPE_URI) { ec = SVGException::SVG_WRONG_TYPE_ERR; return; } bool requiresURI = false; SVGPaintType type = static_cast<SVGPaintType>(paintType); switch (type) { case SVG_PAINTTYPE_UNKNOWN: // Spec: It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type. ec = SVGException::SVG_INVALID_VALUE_ERR; return; case SVG_PAINTTYPE_RGBCOLOR: case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: case SVG_PAINTTYPE_NONE: case SVG_PAINTTYPE_CURRENTCOLOR: break; case SVG_PAINTTYPE_URI_NONE: case SVG_PAINTTYPE_URI_CURRENTCOLOR: case SVG_PAINTTYPE_URI_RGBCOLOR: case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: case SVG_PAINTTYPE_URI: requiresURI = true; break; }; // Spec: If paintType requires a URI, then uri must be non-null; otherwise, uri must be null. if (requiresURI && uri.isEmpty()) { ec = SVGException::SVG_INVALID_VALUE_ERR; return; } SVGColor::SVGColorType colorType = colorTypeForPaintType(type); if (colorType == SVGColor::SVG_COLORTYPE_UNKNOWN) { // The standard setColor() code path used in the else branch // raises an exception when attempting to switch to an unknown color type. // Here we explicitely want to reset to Color() and an unknown type, so force it. setColorType(colorType); setColor(Color()); } else { setColor(colorType, rgbColor, iccColor, ec); if (ec) return; } m_paintType = type; m_uri = requiresURI ? uri : String(); setNeedsStyleRecalc(); }
void parse( const std::string& value ) { if ( value.length() != 7 && value.length() != 9 ) { return; // bad input } auto c = value.cbegin(); if ( *c != '#' ) { return; // bad input } if ( value.substr( 1, value.length()-1).find_first_not_of( "ABCDEF0123456789" ) != std::string::npos ) { return; // bad input } Color::ColorType colortype = Color::ColorType::RGB; IntType alpha = 255; IntType red = 255; IntType green = 255; IntType blue = 255; if ( value.length() == 9 ) { colortype = Color::ColorType::ARGB; alpha = getInt( value, 1 ); red = getInt( value, 3 ); green = getInt( value, 5 ); blue = getInt( value, 7 ); } else if ( value.length() == 7 ) { colortype = Color::ColorType::RGB; alpha = 255; red = getInt( value, 1 ); green = getInt( value, 3 ); blue = getInt( value, 5 ); } setAlpha( alpha ); setRed( red ); setGreen( green ); setBlue( blue ); setColorType( colortype ); }
void QtCurveShadowConfiguration::load(KConfig *cfg) { KConfigGroup group(cfg, CFG_GROUP); QtCurveShadowConfiguration def(m_colorGroup); READ_ENTRY("Size", m_size); READ_ENTRY("HOffset", m_hOffset); READ_ENTRY("VOffset", m_vOffset); READ_ENTRY("ColorType", m_colorType); READ_ENTRY("ShadowType", m_shadowType); if(CT_CUSTOM==m_colorType) READ_ENTRY("Color", m_color); if(m_size<MIN_SIZE || m_size>MAX_SIZE) m_size=def.shadowSize(); if(m_hOffset<MIN_OFFSET || m_hOffset>MAX_OFFSET) m_hOffset=def.horizontalOffset(); if(m_vOffset<MIN_OFFSET || m_vOffset>MAX_OFFSET) m_vOffset=def.verticalOffset(); setColorType((ColorType)m_colorType); }