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

📄 render_frames.cpp

📁 khtml在gtk上的移植版本
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    int _x = evt->clientX();    int _y = evt->clientY();        if ( !m_resizing && evt->id() == EventImpl::MOUSEMOVE_EVENT || evt->id() == EventImpl::MOUSEDOWN_EVENT )    {#ifdef DEBUG_LAYOUT        kdDebug( 6031 ) << "mouseEvent:check" << endl;#endif                m_hSplit = -1;        m_vSplit = -1;        //bool resizePossible = true;                // check if we're over a horizontal or vertical boundary        int pos = m_gridLayout[1][0] + xPos();        for(int c = 1; c < element()->totalCols(); c++)        {            if(_x >= pos && _x <= pos+element()->border())            {            if(m_vSplitVar && m_vSplitVar[c-1] == true) m_vSplit = c-1;#ifdef DEBUG_LAYOUT            kdDebug( 6031 ) << "vsplit!" << endl;#endif            res = true;            break;            }            pos += m_gridLayout[1][c] + element()->border();        }                pos = m_gridLayout[0][0] + yPos();        for(int r = 1; r < element()->totalRows(); r++)        {            if( _y >= pos && _y <= pos+element()->border())            {            if(m_hSplitVar && m_hSplitVar[r-1] == true) m_hSplit = r-1;#ifdef DEBUG_LAYOUT            kdDebug( 6031 ) << "hsplitvar = " << m_hSplitVar << endl;            kdDebug( 6031 ) << "hsplit!" << endl;#endif            res = true;            break;            }            pos += m_gridLayout[0][r] + element()->border();        }#ifdef DEBUG_LAYOUT        kdDebug( 6031 ) << m_hSplit << "/" << m_vSplit << endl;#endif                QCursor cursor;        if(m_hSplit != -1 && m_vSplit != -1)        {            cursor = KCursor::sizeAllCursor();        }        else if( m_vSplit != -1 )        {            cursor = KCursor::sizeHorCursor();        }        else if( m_hSplit != -1 )        {            cursor = KCursor::sizeVerCursor();        }                if(evt->id() == EventImpl::MOUSEDOWN_EVENT)        {            setResizing(true);            KApplication::setOverrideCursor(cursor);            m_vSplitPos = _x;            m_hSplitPos = _y;            m_oldpos = -1;        }        else            canvas()->view()->viewport()->setCursor(cursor);            }        // ### check the resize is not going out of bounds.    if(m_resizing && evt->id() == EventImpl::MOUSEUP_EVENT)    {        setResizing(false);        KApplication::restoreOverrideCursor();                if(m_vSplit != -1 )        {        #ifdef DEBUG_LAYOUT            kdDebug( 6031 ) << "split xpos=" << _x << endl;#endif            int delta = m_vSplitPos - _x;            m_gridDelta[1][m_vSplit] -= delta;            m_gridDelta[1][m_vSplit+1] += delta;        }        if(m_hSplit != -1 )        {#ifdef DEBUG_LAYOUT            kdDebug( 6031 ) << "split ypos=" << _y << endl;#endif            int delta = m_hSplitPos - _y;            m_gridDelta[0][m_hSplit] -= delta;            m_gridDelta[0][m_hSplit+1] += delta;        }                // this just schedules the relayout        // important, otherwise the moving indicator is not correctly erased        setNeedsLayout(true);    }        else if (m_resizing || evt->id() == EventImpl::MOUSEUP_EVENT) {#if APPLE_CHANGES        KHTMLView *v = canvas()->view();        QPainter paint;                v->disableFlushDrawing();        v->lockDrawingFocus();#else        QPainter paint( canvas()->view() );#endif        paint.setPen( Qt::gray );        paint.setBrush( Qt::gray );        #if !APPLE_CHANGES        paint.setRasterOp( Qt::XorROP );#endif        QRect r(xPos(), yPos(), width(), height());        const int rBord = 3;        int sw = element()->border();        int p = m_resizing ? (m_vSplit > -1 ? _x : _y) : -1;        if (m_vSplit > -1) {            if ( m_oldpos >= 0 )#if APPLE_CHANGES                v->updateContents( m_oldpos + sw/2 - rBord , r.y(), 2*rBord, r.height(), true );#else                paint.drawRect( m_oldpos + sw/2 - rBord , r.y(),                                2*rBord, r.height() );#endif            if ( p >= 0 ){#if APPLE_CHANGES                paint.setPen( Qt::NoPen );                paint.setBrush( Qt::gray );                v->setDrawingAlpha((float)0.25);                paint.drawRect( p  + sw/2 - rBord, r.y(), 2*rBord, r.height() );                v->setDrawingAlpha((float)1.0);#else                paint.drawRect( p  + sw/2 - rBord, r.y(), 2*rBord, r.height() );#endif            }        } else {            if ( m_oldpos >= 0 )#if APPLE_CHANGES                v->updateContents( r.x(), m_oldpos + sw/2 - rBord, r.width(), 2*rBord, true );#else                paint.drawRect( r.x(), m_oldpos + sw/2 - rBord,                                r.width(), 2*rBord );#endif            if ( p >= 0 ){#if APPLE_CHANGES                paint.setPen( Qt::NoPen );                paint.setBrush( Qt::gray );                v->setDrawingAlpha((float)0.25);                paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );                v->setDrawingAlpha((float)1.0);#else                paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );#endif            }        }        m_oldpos = p;#if APPLE_CHANGES        v->unlockDrawingFocus();        v->enableFlushDrawing();#endif    }        return res;}void RenderFrameSet::setResizing(bool e){      m_resizing = e;      for (RenderObject* p = parent(); p; p = p->parent())          if (p->isFrameSet()) static_cast<RenderFrameSet*>(p)->m_clientresizing = m_resizing;}bool RenderFrameSet::canResize( int _x, int _y ){    // if we haven't received a layout, then the gridLayout doesn't contain useful data yet    if (needsLayout() || !m_gridLayout[0] || !m_gridLayout[1] ) return false;    // check if we're over a horizontal or vertical boundary    int pos = m_gridLayout[1][0];    for(int c = 1; c < element()->totalCols(); c++)        if(_x >= pos && _x <= pos+element()->border())            return true;    pos = m_gridLayout[0][0];    for(int r = 1; r < element()->totalRows(); r++)        if( _y >= pos && _y <= pos+element()->border())            return true;    return false;}#ifndef NDEBUGvoid RenderFrameSet::dump(QTextStream *stream, QString ind) const{  *stream << " totalrows=" << element()->totalRows();  *stream << " totalcols=" << element()->totalCols();  uint i;  for (i = 0; i < (uint)element()->totalRows(); i++)    *stream << " hSplitvar(" << i << ")=" << m_hSplitVar[i];  for (i = 0; i < (uint)element()->totalCols(); i++)    *stream << " vSplitvar(" << i << ")=" << m_vSplitVar[i];  RenderBox::dump(stream,ind);}#endif/**************************************************************************************/RenderPart::RenderPart(DOM::HTMLElementImpl* node)    : RenderWidget(node){#if KWIQ//    QOBJECT_TYPE(RenderPart);#endif    // init RenderObject attributes    setInline(false);}RenderPart::~RenderPart(){    if(m_widget->inherits("KHTMLView")) {	static_cast<KHTMLView *>(m_widget)->deref();    }}void RenderPart::setWidget( QWidget *widget ){#ifdef DEBUG_LAYOUT    kdDebug(6031) << "RenderPart::setWidget()" << endl;#endif        if (widget == m_widget) {	return;    }    if(m_widget->inherits("KHTMLView")) {	static_cast<KHTMLView *>(m_widget)->deref();    }        if(widget->inherits("KHTMLView")) {		static_cast<KHTMLView *>(widget)->ref();	setQWidget( widget, false );	connect( widget, SIGNAL( cleared() ), this, SLOT( slotViewCleared() ) );    } else {	setQWidget( widget );    }    setNeedsLayoutAndMinMaxRecalc();        // make sure the scrollbars are set correctly for restore    // ### find better fix    slotViewCleared();}bool RenderPart::partLoadingErrorNotify(khtml::ChildFrame *, const KURL& , const QString& ){    return false;}int RenderPart::intrinsicWidth() const{  // KDE may need a non-zero width here, although this will mess up pages (e.g., thinker.org).#if APPLE_CHANGES    return 0;#else    return 300;#endif}int RenderPart::intrinsicHeight() const{  // KDE may need a non-zero height here, although this will mess up pages (e.g., thinker.org).#if APPLE_CHANGES    return 0;#else    return 200;#endif}void RenderPart::slotViewCleared(){}/***************************************************************************************/RenderFrame::RenderFrame( DOM::HTMLFrameElementImpl *frame )    : RenderPart(frame){    setInline( false );}void RenderFrame::slotViewCleared(){    if(element() && m_widget->inherits("QScrollView")) {#ifdef DEBUG_LAYOUT        kdDebug(6031) << "frame is a scrollview!" << endl;#endif        QScrollView *view = static_cast<QScrollView *>(m_widget);        if(!element()->frameBorder || !((static_cast<HTMLFrameSetElementImpl *>(element()->parentNode()))->frameBorder()))            view->setFrameStyle(QFrame::NoFrame);#if APPLE_CHANGES        // Qt creates QScrollView w/ a default style of QFrame::StyledPanel | QFrame::Sunken.        else            view->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );#else        view->setHScrollBarMode(element()->scrolling );        view->setVScrollBarMode(element()->scrolling );#endif        if(view->inherits("KHTMLView")) {#ifdef DEBUG_LAYOUT            kdDebug(6031) << "frame is a KHTMLview!" << endl;#endif            KHTMLView *htmlView = static_cast<KHTMLView *>(view);            if(element()->marginWidth != -1) htmlView->setMarginWidth(element()->marginWidth);            if(element()->marginHeight != -1) htmlView->setMarginHeight(element()->marginHeight);        }    }}/****************************************************************************************/RenderPartObject::RenderPartObject( DOM::HTMLElementImpl* element )    : RenderPart( element ){    // init RenderObject attributes

⌨️ 快捷键说明

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