Esempio n. 1
0
File: WFont.C Progetto: 913862627/wt
const std::string WFont::cssText(bool combined) const
{
  WStringStream result;

  if (combined) {
    std::string s;
    s = cssStyle(false);
    if (!s.empty())
      result << s << ' ';

    s = cssVariant(false);
    if (!s.empty())
      result << s << ' ';

    s = cssWeight(false);
    if (!s.empty())
      result << s << ' ';

    result << cssSize(true) << ' ';

    s = cssFamily(true);
    if (!s.empty())
      result << s << ' ';
    else
      result << s << " inherit";
  } else {
    std::string s;
    s = cssSize(false);
    if (!s.empty())
      result << "font-size: " << s << ";";

    s = cssStyle(false);
    if (!s.empty())
      result << "font-style: " << s << ";";

    s = cssVariant(false);
    if (!s.empty())
      result << "font-variant: " << s << ";";

    s = cssWeight(false);
    if (!s.empty())
      result << "font-weight: " << s << ";";

    // Last because of workaround in WVmlImage that searches for a ','
    s = cssFamily(false);
    if (!s.empty())
      result << "font-family: " << s << ";";

  }

  return result.str();
}
void MapCSSPaintstyle::loadPainters(const QString& filename)
{
    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly))
        return;
    QByteArray css = file.readAll();
    QString cssS(css);
    file.close();

    /* Remove comments */
    QRegExp cssComments("/\\*.*\\*/");
    cssComments.setMinimal(true);
    cssS.replace(cssComments, "");

    /* Styles */
    QRegExp cssStyle("\\s*(.*)\\s*\\{(.*)\\}");
    cssStyle.setMinimal(true);

    QRegExp blanks("\\s*");
    QRegExp attSep("\\s*;\\s*");
    QHash <QString, QStringList> styles;
    int pos=0;
    while (cssStyle.indexIn(cssS, pos) != -1) {
        QString selector = parseSelector(cssStyle.capturedTexts().at(1).trimmed());
        QString attributes = cssStyle.capturedTexts().at(2).trimmed();
        styles[selector] = attributes.split(attSep);

        pos += cssStyle.matchedLength();
    }
    qDebug() << styles;


}
Esempio n. 3
0
	void HtmlInk::recssStyle()
	{
		string css;

		cssStyle(this->skin(), css);

		this->styleCSS(this->skin().name(), css);
	}
Esempio n. 4
0
File: WFont.C Progetto: 913862627/wt
void WFont::updateDomElement(DomElement& element, bool fontall, bool all)
{
  if (familyChanged_ || fontall || all) {
    std::string family = cssFamily(fontall);

    if (!family.empty())
      element.setProperty(PropertyStyleFontFamily, family);

    familyChanged_ = false;
  }

  if (styleChanged_ || fontall || all) {
    std::string style = cssStyle(fontall);

    if (!style.empty())
      element.setProperty(PropertyStyleFontStyle, style);

    styleChanged_ = false;
  }

  if (variantChanged_ || fontall || all) {
    std::string variant = cssVariant(fontall);

    if (!variant.empty())
      element.setProperty(PropertyStyleFontVariant, variant);

    variantChanged_ = false;
  }

  if (weightChanged_ || fontall || all) {
    std::string weight = cssWeight(fontall);

    if (!weight.empty())
      element.setProperty(PropertyStyleFontWeight, weight);

    weightChanged_ = false;
  }

  if (sizeChanged_ || fontall || all) {
    std::string size = cssSize(fontall);

    if (!size.empty())
      element.setProperty(PropertyStyleFontSize, size);

    sizeChanged_ = false;
  }
}
Esempio n. 5
0
void DomElement::asHTML(EscapeOStream& out,
			std::vector<std::pair<int, std::string> >& timeouts)
  const
{
  if (mode_ != ModeCreate) {
    std::cerr << "ERROR: DomElement::asHTML() called with ModeUpdate"
	      << std::endl;
    exit(1);
  }

  processEvents();

  bool needButtonWrap
    = (!(WApplication::instance()->environment().javaScript())
       && (eventHandlers_.find("click") != eventHandlers_.end())
       && (eventHandlers_.find("click")->second.first.length() > 0));

  ElementType renderedType
    = (needButtonWrap && (type_ == BUTTON)) ? SPAN : type_;

  if (needButtonWrap) {
    out << "<button type=\"submit\" name=\"signal\" value=";
    htmlAttributeValue(out, eventHandlers_.find("click")->second.second);
    out << (type_ != BUTTON ? " class=\"wrap\"" : "");

    PropertyMap::const_iterator i = properties_.find(Wt::PropertyDisabled);
    if ((i != properties_.end()) && (i->second=="true"))
      out << " disabled";

    out << ">";
  }

  out << "<" << elementNames_[renderedType];

  if (id_.length() > 0) {
    out << " id=";
    htmlAttributeValue(out, id_);
  }

  for (AttributeMap::const_iterator i = attributes_.begin();
       i != attributes_.end(); ++i) {
    out << " " << i->first << "=";
    htmlAttributeValue(out, i->second);
  }

  if (WApplication::instance()->environment().javaScript()) {
    for (EventHandlerMap::const_iterator i = eventHandlers_.begin();
	 i != eventHandlers_.end(); ++i) {
      if (i->second.first.length() != 0) {
	out << " on" << i->first << "=";
	htmlAttributeValue(out, i->second.first);
      }
    }
  }

  std::string innerHTML = "";

  for (PropertyMap::const_iterator i = properties_.begin();
       i != properties_.end(); ++i) {
    switch (i->first) {
    case Wt::PropertyText:
    case Wt::PropertyInnerHTML:
      innerHTML += i->second; break;
    case Wt::PropertyDisabled:
      if (i->second == "true")
	out << " disabled";
      break;
    case Wt::PropertyChecked:
      if (i->second == "true")
	out << " checked";
      break;
    case Wt::PropertySelected:
      if (i->second == "true")
	out << " selected";
      break;
    case Wt::PropertyValue:
      out << " value=";
      htmlAttributeValue(out, i->second);
      break;
    case Wt::PropertySrc:
      out << " src=";
      htmlAttributeValue(out, i->second);
      break;
    default:
      break;
    }
  }

  std::string style = cssStyle();

  if (style.length() > 0) {
    out << " style=";
    htmlAttributeValue(out, style);
  }

  if (renderedType != BR) {
    out << ">" << innerHTML << childrenHtml_;

    for (unsigned i = 0; i < childrenToAdd_.size(); ++i)
      childrenToAdd_[i].second->asHTML(out, timeouts);

    out << "</" << elementNames_[renderedType] << ">";
  } else
    out << " />";

  if (needButtonWrap)
    out << "</button>";

  if (timeOut_ != -1)
    timeouts.push_back(std::make_pair(timeOut_, id_));

  timeouts.insert(timeouts.end(), timeouts_.begin(), timeouts_.end());
}
Esempio n. 6
0
	string rcssStyle(InkStyle& style) { string css; cssStyle(style, css); return css; }