当前位置: 首页>>代码示例>>C++>>正文


C++ Element::style方法代码示例

本文整理汇总了C++中dom::Element::style方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::style方法的具体用法?C++ Element::style怎么用?C++ Element::style使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dom::Element的用法示例。


在下文中一共展示了Element::style方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: select

void Textual::select(const Index& index) {
  if(index == m_curr_selected)
    return;
  DOM::HTMLDocument document = htmlDocument();
  DOM::Element currs = document.getElementById("mv_"+m_curr_selected);
  DOM::Element news = document.getElementById("mv_"+index);
  if(!currs.isNull())
    currs.style().removeProperty("background-color");
  if(!news.isNull())
    news.style().setProperty("background-color", "#C0E0FF", "important");
  m_curr_selected = index;
}
开发者ID:Axure,项目名称:tagua,代码行数:12,代码来源:movelist_textual.cpp

示例2: parseStyle

void KHTMLReader::parseStyle(DOM::Element e)
{
    // styles are broken broken broken broken broken broken.
    // FIXME: use getComputedStyle - note: it only returns 0, but works nevertheless
    kDebug(30503) << "entering parseStyle";
    DOM::CSSStyleDeclaration s1 = e.style();
    DOM::Document doc = _html->document();
    DOM::CSSStyleDeclaration s2 = doc.defaultView().getComputedStyle(e, "");

    kDebug(30503) << "font-weight=" << s1.getPropertyValue("font-weight").string();
    if (s1.getPropertyValue("font-weight").string() == "bolder") {
        _writer->formatAttribute(state()->paragraph, "WEIGHT", "value", "75");
    }
    if (s1.getPropertyValue("font-weight").string() == "bold") {
        _writer->formatAttribute(state()->paragraph, "WEIGHT", "value", "75");
    }

    // process e.g. <style="color: #ffffff">
    if (! s1.getPropertyValue("color").string().isEmpty()) {
        QColor c = parsecolor(s1.getPropertyValue("color").string());
        _writer->formatAttribute(state()->paragraph, "COLOR", "red", QString::number(c.red()));
        _writer->formatAttribute(state()->paragraph, "COLOR", "green", QString::number(c.green()));
        _writer->formatAttribute(state()->paragraph, "COLOR", "blue", QString::number(c.blue()));
    } // done
    // process e.g. <style="font-size: 42">
    if (! s1.getPropertyValue("font-size").string().isEmpty()) {
        QString size = s1.getPropertyValue("font-size").string();
        if (size.endsWith("pt")) {
            size = size.left(size.length() - 2);
        }
        _writer->formatAttribute(state()->paragraph, "SIZE", "value", size);
    }
    // done
    // process e.g. <style="text-align: center">this is in the center</style>
    if (! s1.getPropertyValue("text-align").string().isEmpty()) {
        state()->layout = _writer->setLayout(state()->paragraph, state()->layout);
        _writer->layoutAttribute(state()->paragraph, "FLOW", "align", s1.getPropertyValue("text-align").string());
    }
    // done

    /*if (DOM::PROPV("font-weight") == "bolder")
    _writer->formatAttribute(state()->paragraph,"WEIGHT","value","75");
    */
    /*
         // debugging code.
         kDebug(30503) <<"e.style()";
         for (unsigned int i=0;i<s1.length();i++) {
            kDebug(30503) << QString("%1: %2").arg(s1.item(i).string()).arg(s1.getPropertyValue(s1.item(i)).string());
         }
         kDebug(30503) <<"override style";
         for (unsigned int i=0;i<s2.length();i++) {
            kDebug(30503) << QString("%1: %2").arg(s2.item(i).string()).arg(s2.getPropertyValue(s2.item(i)).string());
         }
    */
}
开发者ID:KDE,项目名称:koffice,代码行数:55,代码来源:khtmlreader.cpp

示例3: setMove

void Textual::setMove(const Index& index, int turn, const DecoratedMove& move,
                                                          const QString& comment) {
  //kDebug() << "i= " << index;
  DOM::HTMLDocument document = htmlDocument();
  QString istr = (QString)index;

  DOM::Element this_mv = document.getElementById("mv_"+istr);
  DOM::Element this_cm = document.getElementById("cm_"+istr);
  if(!this_mv.isNull() && !this_cm.isNull()) {
    clear_node(this_mv);
    for(int i=0;i<move.size();i++) {
      DOM::Text t = document.createTextNode(move[i].m_string);
      this_mv.appendChild(t);
    }

    clear_node(this_cm);
    if(!comment.isEmpty()) {
      this_cm.appendChild(document.createTextNode(comment));
      this_cm.appendChild(document.createTextNode(QString(" ")));
    }
    return;
  }

  DOM::Element parent;
  DOM::Element prev_mv;
  DOM::Element prev_cm;

  if(index != Index(0)) {
    prev_cm = document.getElementById("cm_"+index.prev());
    prev_mv = document.getElementById("mv_"+index.prev());
    if(prev_cm.isNull() || prev_mv.isNull()) {
      kDebug() << " --> Error in Textual::setMove, no previous move!";
      return;
    }
  }

  int mv_num = 0;
  int sub_mv_num = 0;
  if(!prev_mv.isNull()) {
    int prev_turn = prev_mv.getAttribute("turn").string().toInt();
    int prev_mv_num = prev_mv.getAttribute("mvnum").string().toInt();
    int prev_sub_mv_num = prev_mv.getAttribute("submvnum").string().toInt();
    if(prev_turn != turn)
      mv_num = prev_mv_num+1;
    else {
      mv_num = prev_mv_num;
      sub_mv_num = prev_sub_mv_num+1;
    }
  }

  if(!index.nested.size()) {
    parent = document.body();
    if(parent.isNull()) {
      kDebug() << "QUEEEEEEEEE!!!!!!!";
      return;
    }
  }
  else if(index.atVariationStart()) {
    QString var_id = "vc_" + istr;
    DOM::Element add_before = prev_cm.nextSibling();

    while(!add_before.isNull()) {

      QString id = add_before.getAttribute("id").string();
      if(id.startsWith("vc_") && id < var_id)
        add_before = add_before.nextSibling();
      else
        break;
    }

    DOM::Element var_el = document.createElement("span");
    var_el.setAttribute("id", var_id);
    var_el.setAttribute("class", "variation");
    var_el.appendChild(document.createTextNode("[ "));


    parent = document.createElement("span");
    parent.setAttribute("id", "vr_" + istr);
    DOM::Element vk_el = document.createElement("span");
    vk_el.setAttribute("id", "vk_" + istr);
    vk_el.setAttribute("class", "comment");
    //vk_el.setContentEditable(true);
    parent.appendChild(vk_el);
    var_el.appendChild(parent);

    var_el.appendChild(document.createTextNode("] "));
    prev_cm.parentNode().insertBefore(var_el, add_before);

    if(!add_before.isNull() && add_before.getAttribute("id").string().startsWith("mv_")) {
      int mv_num = add_before.getAttribute("mvnum").string().toInt();
      int sub_mv_num = add_before.getAttribute("submvnum").string().toInt();
      QString num_str;
      if(m_layout_style == 0) {
        if(mv_num%2)
          num_str = QString("%1. ").arg((mv_num+1)/2);
        else
          num_str = QString("%1. ... ").arg((mv_num+2)/2);
      }
      else {
        if(sub_mv_num==0)
//.........这里部分代码省略.........
开发者ID:Axure,项目名称:tagua,代码行数:101,代码来源:movelist_textual.cpp


注:本文中的dom::Element::style方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。