📄 render_table.cpp
字号:
te = 0; break; case MIDDLE: te = (rHeight - cell->height())/2; break; case BOTTOM: te = rHeight - cell->height(); break; default: break; }#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << "CELL te=" << te << ", be=" << rHeight - cell->height() - te << ", rHeight=" << rHeight << ", valign=" << va << endl;#endif cell->setCellTopExtra( te ); cell->setCellBottomExtra( rHeight - cell->height() - te); if (style()->direction()==RTL) { cell->setPos( columnPos[(int)totalCols] - columnPos[(int)(indx+cell->colSpan())] + borderLeft(), rowHeights[rindx]+yoff ); } else cell->setPos( columnPos[indx] + borderLeft(), rowHeights[rindx]+yoff ); cell->setRowHeight(rHeight); // ### // cell->setHeight(cellHeight); }}void RenderTable::setCellWidths(){#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(Table, this=0x" << this << ")::setCellWidths()" << endl;#endif int indx; FOR_EACH_CELL( r, c, cell) { if ( ( indx = c-realSpan(cell)+1) < 0 ) indx = 0; int w = columnPos[c+1] - columnPos[ indx ] - spacing ; //- padding*2;#ifdef TABLE_DEBUG kdDebug( 6040 ) << "0x" << this << ": setting width " << r << "/" << indx << "-" << c << " (0x" << cell << "): " << w << " " << endl;#endif if (cell->width() != w) cell->setLayouted(false); cell->setWidth( w ); } END_FOR_EACH}void RenderTable::print( MGPainter *p, int _x, int _y, int _w, int _h, int _tx, int _ty){// if(!layouted()) return; _tx += xPos(); _ty += yPos();#ifdef TABLE_DEBUG kdDebug( 6040 ) << "RenderTable::print() w/h = (" << width() << "/" << height() << ")" << endl;#endif if (!containsPositioned() && !isRelPositioned() && !isPositioned()) { if((_ty > _y + _h) || (_ty + height() < _y)) return; if((_tx > _x + _w) || (_tx + width() < _x)) return; }#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << "RenderTable::print(2) " << _tx << "/" << _ty << " (" << _x << "/" << _y << ")" << endl;#endif if(m_visible) printBoxDecorations(p, _x, _y, _w, _h, _tx, _ty); if ( tCaption ) { tCaption->print( p, _x, _y, _w, _h, _tx, _ty ); } // draw the cells FOR_EACH_CELL(r, c, cell) {#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << "printing cell " << r << "/" << c << endl;#endif cell->print( p, _x, _y, _w, _h, _tx, _ty); } END_FOR_EACH#ifdef BOX_DEBUG outlineBox(p, _tx, _ty, "blue");#endif}void RenderTable::printBorders( MGPainter* /*p*/, int, int, int, int, int /*_tx*/, int /*_ty*/){#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(Table)::printObject()" << endl;#endif // ### don't call children here... // draw the border - needs work to print to printer}void RenderTable::calcMinMaxWidth(){#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(Table)::calcMinMaxWidth() known=" << minMaxKnown() << endl;#endif calcColMinMax();}void RenderTable::close(){// kdDebug( 6040 ) << "RenderTable::close()" << endl; setParsing(false); setLayouted(false); updateSize();}void RenderTable::updateSize(){// kdDebug( 6040 ) << "RenderTable::updateSize()" << endl;// setMinMaxKnown(false);// setLayouted(false);// parent()->updateSize(); RenderBox::updateSize();}int RenderTable::borderTopExtra(){ if (tCaption && tCaption->style()->captionSide()!=CAPBOTTOM) return -(tCaption->height() + tCaption->marginBottom() + tCaption->marginTop()); else return 0;}int RenderTable::borderBottomExtra(){ if (tCaption && tCaption->style()->captionSide()==CAPBOTTOM) return -(tCaption->height() + tCaption->marginBottom() + tCaption->marginTop()); else return 0;}// --------------------------------------------------------------------------RenderTableSection::RenderTableSection() : RenderObject(){ // init RenderObject attributes m_inline = false; // our object is not Inline}RenderTableSection::~RenderTableSection(){ nrows = 0;}void RenderTableSection::addChild(RenderObject *child, RenderObject *beforeChild){#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(TableSection)::addChild( " << child->renderName() << ", " << beforeChild ? beforeChild->renderName() : 0 << " )" << endl;#endif RenderObject *row = child; if( !beforeChild ) beforeChild = lastChild(); if ( !child->isTableRow() ) { if( beforeChild && beforeChild->isAnonymousBox() ) row = beforeChild; else {// kdDebug( 6040 ) << "creating anonymous table row" << endl; row = new RenderTableRow(); RenderStyle *newStyle = new RenderStyle(m_style); newStyle->setDisplay(TABLE_ROW); row->setPart(m_part); row->setStyle(newStyle); row->setIsAnonymousBox(true); addChild(row, beforeChild); } row->addChild(child); return; } table->startRow(); child->setTable(table); RenderObject::addChild(child,beforeChild);}// -------------------------------------------------------------------------RenderTableRow::RenderTableRow() : RenderObject(){ // init RenderObject attributes m_inline = false; // our object is not Inline rIndex = -1;}RenderTableRow::~RenderTableRow(){}long RenderTableRow::rowIndex() const{ // ### return 0;}void RenderTableRow::setRowIndex( long ){ // ###}void RenderTableRow::close(){ table->closeRow(); }void RenderTableRow::addChild(RenderObject *child, RenderObject *beforeChild){#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(TableRow)::addChild( " << child->renderName() << " )" << ", " << beforeChild ? beforeChild->renderName() : 0 << " )" << endl;#endif RenderTableCell *cell; if ( !child->isTableCell() ) { if ( !beforeChild ) beforeChild = lastChild(); RenderTableCell *cell; if( beforeChild && beforeChild->isAnonymousBox() && beforeChild->isTableCell() ) cell = static_cast<RenderTableCell *>(beforeChild); else {// kdDebug( 6040 ) << "creating anonymous table cell" << endl; cell = new RenderTableCell(); RenderStyle *newStyle = new RenderStyle(m_style); newStyle->setDisplay(TABLE_CELL); cell->setPart(m_part); cell->setStyle(newStyle); cell->setIsAnonymousBox(true); addChild(cell, beforeChild); } cell->addChild(child); return; } else cell = static_cast<RenderTableCell *>(child); cell->setTable(table); cell->setRowImpl(this); table->addCell(cell); // ### may not work for beforeChild != 0 RenderObject::addChild(cell,beforeChild);}// -------------------------------------------------------------------------RenderTableCell::RenderTableCell() : RenderFlow(){ _col = -1; _row = -1; cSpan = rSpan = 1; nWrap = false; rowHeight = 0; m_table = 0; rowimpl = 0; m_printSpecial=true; _topExtra = 0; _bottomExtra = 0;}RenderTableCell::~RenderTableCell(){}void RenderTableCell::calcMinMaxWidth(){#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(TableCell)::calcMinMaxWidth() known=" << minMaxKnown() << endl;#endif //if(minMaxKnown()) return; int oldMin = m_minWidth; int oldMax = m_maxWidth; RenderFlow::calcMinMaxWidth(); if(nWrap && m_style->width().type!=Fixed) m_minWidth = m_maxWidth; if (m_minWidth!=oldMin || m_maxWidth!=oldMax) m_table->addColInfo(this);}void RenderTableCell::calcWidth(){}void RenderTableCell::close(){ //kdDebug( 6040 ) << "renderFlow::close()" << endl; setParsing(false); if(haveAnonymousBox()) { m_last->close(); //kdDebug( 6040 ) << "RenderFlow::close(): closing anonymous box" << endl; setHaveAnonymousBox(false); } //if(m_last) // m_height += m_last->height() + m_last->marginBottom(); if(m_style->hasBorder()) m_height += borderBottom(); if(m_style->hasPadding()) m_height += paddingBottom(); setMinMaxKnown(false); calcMinMaxWidth(); setLayouted(false); m_table->updateSize();#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(RenderTableCell)::close() total height =" << m_height << endl;#endif}void RenderTableCell::updateSize(){// kdDebug( 6040 ) << renderName() << "(RenderBox)::updateSize()" << endl; RenderFlow::updateSize();}void RenderTableCell::repaintRectangle(int x, int y, int w, int h){ y += _topExtra; RenderFlow::repaintRectangle(x, y, w, h);}void RenderTableCell::repaintObject(RenderObject *o, int x, int y){ y += _topExtra; RenderFlow::repaintObject(o, x, y);}void RenderTableCell::absolutePosition(int &xPos, int &yPos, bool f){ RenderFlow::absolutePosition(xPos, yPos, f); if (yPos != -1) yPos += _topExtra;}void RenderTableCell::setStyle( RenderStyle *style ){ RenderFlow::setStyle( style ); m_printSpecial = true;}void RenderTableCell::print(MGPainter *p, int _x, int _y, int _w, int _h, int _tx, int _ty){#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(RenderTableCell)::print() w/h = (" << width() << "/" << height() << ")" << endl;#endif// if (!layouted())// return; _tx += m_x; _ty += m_y + _topExtra; // check if we need to do anything at all... if(!containsPositioned() && ((_ty-_topExtra > _y + _h) || (_ty + m_height+_topExtra+_bottomExtra < _y))) return; printObject(p, _x, _y, _w, _h, _tx, _ty);}void RenderTableCell::printBoxDecorations(MGPainter *p,int, int _y, int, int _h, int _tx, int _ty){ //kdDebug( 6040 ) << renderName() << "::printDecorations()" << endl; int w = width(); int h = height() + borderTopExtra() + borderBottomExtra(); _ty -= borderTopExtra(); int my = QMAX(_ty,_y); int mh; if (_ty<_y) mh= QMAX(0,h-(_y-_ty)); else mh = QMIN(_h,h); MGColor c = m_style->backgroundColor(); if ( !c.isValid() && parent() ) // take from row c = parent()->style()->backgroundColor(); if ( !c.isValid() && parent() && parent()->parent() ) // take from rowgroup c = parent()->parent()->style()->backgroundColor(); // ### col is missing... // ### get offsets right in case the bgimage is inherited. MGCachedImage *bg = m_bgImage; if ( !bg && parent() ) bg = parent()->backgroundImage(); if ( !bg && parent() && parent()->parent() ) bg = parent()->parent()->backgroundImage(); if ( bg || c.isValid() ) printBackground(p, c, bg, my, mh, _tx, _ty, w, h); if(m_style->hasBorder()) printBorder(p, _tx, _ty, w, h);}// -------------------------------------------------------------------------RenderTableCol::RenderTableCol() : RenderObject(){ // init RenderObject attributes m_inline = false; // our object is not Inline _span = 1;}RenderTableCol::~RenderTableCol(){}void RenderTableCol::addChild(RenderObject *child, RenderObject *beforeChild){#ifdef DEBUG_LAYOUT //kdDebug( 6040 ) << renderName() << "(Table)::addChild( " << child->renderName() << " )" << ", " << // beforeChild ? beforeChild->renderName() : 0 << " )" << endl;#endif if (child->style()->display() == TABLE_COLUMN) { // these have to come before the table definition! RenderObject::addChild(child,beforeChild); RenderTableCol* colel = static_cast<RenderTableCol *>(child); colel->setStartCol(_currentCol);// kdDebug( 6040 ) << "_currentCol=" << _currentCol << endl; table->addColInfo(colel); _currentCol++; }}Length RenderTableCol::width(){ if (m_style->width().type == Undefined && parent() && parent()->style()->display()==TABLE_COLUMN_GROUP) return static_cast<RenderTableCol*>(parent())->width(); else return m_style->width();}// -------------------------------------------------------------------------RenderTableCaption::RenderTableCaption() : RenderFlow(){}RenderTableCaption::~RenderTableCaption(){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -