⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 render_hr.cpp

📁 monqueror一个很具有参考价值的源玛
💻 CPP
字号:
/** * This file is part of the DOM implementation for KDE. * * Copyright (C) 1999 Lars Knoll (knoll@kde.org) *           (C) 1999 Antti Koivisto (koivisto@kde.org) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * $Id: render_hr.cpp,v 1.1.1.1 2002/01/16 10:39:56 ymwei Exp $ *///#define DEBUG_LAYOUT#include "render_interface.h"#include "mgpoint.h"#include "mgcolor.h"#include "mgcolorgroup.h"#include "mgpen.h"#include "mgbrush.h"#include "mgsize.h"#include "mgrect.h"#include "mgpixmap.h"#include "mgfontmetrics.h"#include "mgpainter.h"#include "mghtmlview.h"#include "mghtml_part.h"#include "render_hr.h"#include "render_style.h"#include "render_flow.h"#include "kdebug.h"using namespace DOM;using namespace khtml;// -------------------------------------------------------------------------RenderHR::RenderHR()    : RenderReplaced(){    // init RenderObject attributes    m_inline = false;   // our object is not Inline    m_printSpecial=false;}RenderHR::~RenderHR(){}void RenderHR::printReplaced(MGPainter *p, int _tx, int _ty){    // add offset for relative positioning    if(isRelPositioned())        relativePositionOffset(_tx, _ty);    MGColorGroup colorGrp( MG::black, MG::black, MGColor(220,220,220), MGColor(100,100,100),    MG::gray, MG::black, MG::black );    int xp = _tx;    RenderObject *prev = m_previous;    while(prev && !prev->isFlow())        prev = prev->previousSibling();    if(prev && static_cast<RenderFlow *>(prev)->floatBottom() > prev->height() )        xp += static_cast<RenderFlow *>(prev)->leftOffset( prev->height() );    int yp = _ty ;    switch(m_style->textAlign()) {    case LEFT:        break;    case RIGHT:        xp += m_width - length;        break;    case JUSTIFY:    case CENTER:    case KONQ_CENTER:        xp += (m_width - length)/2;        break;    }    int lw = size/2;    if ( shade )    {        if(size < 2) size = 2, lw = 1;        MGDrawShadePanel( p, xp, yp, length, size,                colorGrp, true, lw, 0 );    }    else    {        if(size < 1) size = 1;        p->fillRect( xp, yp, length, size, MG::black );    }}void RenderHR::layout(){    calcMinMaxWidth();    m_height = size+2;    if( length == 0 )        length = m_width;    calcHeight();    setLayouted(true);}void RenderHR::calcMinMaxWidth(){    // contentWidth    Length w = m_style->width();    // a bit hacky....    calcWidth();    length = m_width;    //m_width = intrinsicWidth();    switch(w.type)    {    case Fixed:        m_minWidth = m_width;        m_maxWidth = m_width;        break;    case Percent:        m_minWidth = 1;        m_maxWidth = m_width;        break;    default:        m_minWidth = 0;        m_maxWidth = 0;    }}short RenderHR::intrinsicWidth() const{    RenderObject *prev = m_previous;    while(prev && !prev->isFlow())        prev = prev->previousSibling();    int w;    if(prev && static_cast<RenderFlow *>(prev)->floatBottom() > prev->height() )        w = static_cast<RenderFlow *>(prev)->lineWidth( prev->height() );    else        w =containingBlockWidth();    return w;}int RenderHR::intrinsicHeight() const{    return size+2;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -