📄 render_list.cpp
字号:
}#ifdef BOX_DEBUG p->setPen( Qt::red ); p->drawRect( _tx + xoff, _ty + yoff, offset, offset );#endif const QColor color( style()->color() ); p->setPen( color ); switch(style()->listStyleType()) { case LDISC: p->setBrush( color ); p->drawEllipse( _tx + xoff, _ty + (3 * yoff)/2, (offset>>1)+1, (offset>>1)+1 ); return; case LCIRCLE: p->setBrush( Qt::NoBrush ); p->drawEllipse( _tx + xoff, _ty + (3 * yoff)/2, (offset>>1)+1, (offset>>1)+1 ); return; case LSQUARE: p->setBrush( color ); p->drawRect( _tx + xoff, _ty + (3 * yoff)/2, (offset>>1)+1, (offset>>1)+1 ); return; case LBOX: p->setBrush( Qt::NoBrush ); p->drawRect( _tx + xoff, _ty + (3 * yoff)/2, (offset>>1)+1, (offset>>1)+1 ); return; case LDIAMOND: { static QPointArray diamond(4); int x = _tx + xoff; int y = _ty + (3 * yoff)/2 - 1; int s = (offset>>2)+1; diamond[0] = QPoint(x+s, y); diamond[1] = QPoint(x+2*s, y+s); diamond[2] = QPoint(x+s, y+2*s); diamond[3] = QPoint(x, y+s); p->setBrush( color ); p->drawConvexPolygon( diamond, 0, 4 ); return; } case LNONE: return; default: if (!m_item.isEmpty()) { if(listPositionInside()) { if( style()->direction() == LTR) { p->drawText(_tx, _ty, 0, 0, Qt::AlignLeft|Qt::DontClip, m_item); p->drawText(_tx + fm.width(m_item), _ty, 0, 0, Qt::AlignLeft|Qt::DontClip, QString::fromLatin1(". ")); } else { const QString& punct(QString::fromLatin1(" .")); p->drawText(_tx, _ty, 0, 0, Qt::AlignLeft|Qt::DontClip, punct); p->drawText(_tx + fm.width(punct), _ty, 0, 0, Qt::AlignLeft|Qt::DontClip, m_item); } } else { if (style()->direction() == LTR) { const QString& punct(QString::fromLatin1(". ")); p->drawText(_tx-offset/2, _ty, 0, 0, Qt::AlignRight|Qt::DontClip, punct); p->drawText(_tx-offset/2-fm.width(punct), _ty, 0, 0, Qt::AlignRight|Qt::DontClip, m_item); } else { const QString& punct(QString::fromLatin1(" .")); p->drawText(_tx+offset/2, _ty, 0, 0, Qt::AlignLeft|Qt::DontClip, punct); p->drawText(_tx+offset/2+fm.width(punct), _ty, 0, 0, Qt::AlignLeft|Qt::DontClip, m_item); } } } }}void RenderListMarker::layout(){ KHTMLAssert( needsLayout() ); if ( !minMaxKnown() ) calcMinMaxWidth(); setNeedsLayout(false);}void RenderListMarker::setPixmap( const QPixmap &p, const QRect& r, CachedImage *o){ if(o != m_listImage) { RenderBox::setPixmap(p, r, o); return; } if(m_width != m_listImage->pixmap_size().width() || m_height != m_listImage->pixmap_size().height()) setNeedsLayoutAndMinMaxRecalc(); else repaintRectangle(0, 0, m_width, m_height);}void RenderListMarker::calcMinMaxWidth(){ KHTMLAssert( !minMaxKnown() ); m_markerWidth = m_width = 0; if(m_listImage && !m_listImage->isErrorImage()) { m_markerWidth = m_listImage->pixmap().width() + cMarkerPadding; if (listPositionInside()) m_width = m_markerWidth; m_height = m_listImage->pixmap().height(); m_minWidth = m_maxWidth = m_width; setMinMaxKnown(); return; } const QFontMetrics &fm = style()->fontMetrics(); m_height = fm.ascent(); // Skip uncounted elements switch(style()->listStyleType()) { // Glyphs: case LDISC: case LCIRCLE: case LSQUARE: case LBOX: case LDIAMOND: m_markerWidth = fm.ascent(); goto end; default: break; } { // variable scope CounterNode *counter = m_listItem->m_counter; if (!counter) { counter = m_listItem->getCounter("list-item", true); counter->setRenderer(this); m_listItem->m_counter = counter; } assert(counter); int value = counter->count(); if (counter->isReset()) value = counter->value(); int total = value; if (counter->parent()) total = counter->parent()->total(); switch(style()->listStyleType()) {// Numeric: case LDECIMAL: m_item.setNum ( value ); break; case DECIMAL_LEADING_ZERO: { int decimals = 2; int t = total/100; while (t>0) { t = t/10; decimals++; } decimals = kMax(decimals, 2); QString num = QString::number(value); m_item.fill('0',decimals-num.length()); m_item.append(num); break; } case ARABIC_INDIC: m_item = toArabicIndic( value ); break; case LAO: m_item = toLao( value ); break; case PERSIAN: case URDU: m_item = toPersianUrdu( value ); break; case THAI: m_item = toThai( value ); break; case TIBETAN: m_item = toTibetan( value ); break;// Algoritmic: case LOWER_ROMAN: m_item = toRoman( value, false ); break; case UPPER_ROMAN: m_item = toRoman( value, true ); break; case HEBREW: m_item = toHebrew( value ); break; case ARMENIAN: m_item = toArmenian( value ); break; case GEORGIAN: m_item = toGeorgian( value ); break;// Alphabetic: case LOWER_ALPHA: case LOWER_LATIN: m_item = toLowerLatin( value ); break; case UPPER_ALPHA: case UPPER_LATIN: m_item = toUpperLatin( value ); break; case LOWER_GREEK: m_item = toLowerGreek( value ); break; case UPPER_GREEK: m_item = toUpperGreek( value ); break; case HIRAGANA: m_item = toHiragana( value ); break; case HIRAGANA_IROHA: m_item = toHiraganaIroha( value ); break; case KATAKANA: m_item = toKatakana( value ); break; case KATAKANA_IROHA: m_item = toKatakanaIroha( value ); break;// Ideographic: case JAPANESE_FORMAL: m_item = toJapaneseFormal( value ); break; case JAPANESE_INFORMAL: m_item = toJapaneseInformal( value ); break; case SIMP_CHINESE_FORMAL: m_item = toSimpChineseFormal( value ); break; case SIMP_CHINESE_INFORMAL: m_item = toSimpChineseInformal( value ); break; case TRAD_CHINESE_FORMAL: m_item = toTradChineseFormal( value ); break; case CJK_IDEOGRAPHIC: // CSS 3 List says treat as trad-chinese-informal case TRAD_CHINESE_INFORMAL: m_item = toTradChineseInformal( value ); break;// Quotes: case OPEN_QUOTE: m_item = style()->openQuote( value ); break; case CLOSE_QUOTE: m_item = style()->closeQuote( value ); break; case LNONE: break; default: KHTMLAssert(false); } m_markerWidth = fm.width(m_item) + fm.width(QString::fromLatin1(". ")); }end: if(listPositionInside()) m_width = m_markerWidth; m_minWidth = m_width; m_maxWidth = m_width; setMinMaxKnown();}short RenderListMarker::lineHeight(bool /*b*/) const{ return height();}short RenderListMarker::baselinePosition(bool /*b*/) const{ return height();}void RenderListMarker::calcWidth(){ RenderBox::calcWidth();}/*int CounterListItem::recount() const{ static_cast<RenderListItem*>(m_renderer)->m_marker->setNeedsLayoutAndMinMaxRecalc();}void CounterListItem::setSelfDirty(){}*/#undef BOX_DEBUG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -