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

📄 render_replaced.cpp

📁 monqueror一个很具有参考价值的源玛
💻 CPP
字号:
/** * This file is part of the HTML widget for KDE. * * Copyright (C) 1999 Lars Knoll (knoll@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_replaced.cpp,v 1.2 2002/01/28 04:31:02 leon Exp $ */#include <assert.h>#include "render_interface.h"#include "mgcolor.h"#include "mgpen.h"#include "mgbrush.h"#include "mgsize.h"#include "mgrect.h"#include "mgfontmetrics.h"#include "mgpainter.h"#include "mghtmlview.h"#include "mghtml_part.h"#include "render_replaced.h"#include "kdebug.h"using namespace khtml;RenderReplaced::RenderReplaced()    : RenderBox(){    // init RenderObject attributes    m_replaced = true;}void RenderReplaced::print( MGPainter *p, int _x, int _y, int _w, int _h,                            int _tx, int _ty){//fprintf(stderr,"RenderReplaced ");		    if ( !m_visible )        return;    _tx += m_x;   _ty += m_y;   if((_ty > _y + _h) || (_ty + m_height < _y)) return;   if(m_printSpecial) printBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);   printReplaced(p, _tx, _ty);}RenderWidget::RenderWidget(MGHTMLView *view)        : RenderReplaced(){    deleted = false;    m_widget = 0;    m_view = view;}RenderWidget::~RenderWidget(){    assert(!deleted);    if (m_widget)    {    //   disconnect( m_widget, SIGNAL( destroyed()),    //        this, SLOT( slotWidgetDestructed()));       delete m_widget;    }    deleted = true;}void RenderWidget::setQWidget(MGWidget *widget, bool show){    if (widget != m_widget)    {        if(m_widget) {    //        disconnect( m_widget, SIGNAL( destroyed()),    //                    this, SLOT( slotWidgetDestructed()));            delete m_widget;        }		//widget->setFocusPolicy(QWidget::ClickFocus);        m_widget = widget;        //connect( m_widget, SIGNAL( destroyed()),         //        this, SLOT( slotWidgetDestructed()));    }    //if( show )	//m_widget->show();}	/*void RenderWidget::slotWidgetDestructed(){    m_widget = 0;}*/void RenderWidget::setStyle(RenderStyle *style){    RenderReplaced::setStyle(style);    if(m_widget)    {        m_widget->setFont(m_style->font());        if(!m_visible) m_widget->hide();    }}void RenderWidget::printReplaced(MGPainter *, int _tx, int _ty){    // ### this does not get called if a form element moves of the screen, so    // the widget stays in it's old place!    assert(!deleted);//	kdDebug(0) << "visible = " << m_visible << endl;    if(!(m_widget && m_view) || !m_visible) return;    // add offset for relative positioning    if(isRelPositioned())     	relativePositionOffset(_tx, _ty);	// we cant call this func, for when repainting, we	// cant move child    //m_view->addChild(m_widget, _tx+borderLeft()+paddingLeft(), _ty+borderTop()+paddingTop());	if( !isFrame() ) // move none frame child	{		int x = _tx+borderLeft()+paddingLeft();		int y = _ty+borderTop()+paddingTop(); 		assert( m_view != 0 );#if 0		if( x < 0 || x > m_view->visibleWidth() || y < 0 || y > m_view->visibleHeight() )		{			m_widget->setVisible( false );			return;		}		int lParam = MAKELONG( x, y ); 		assert( m_widget->getParent() != HWND_INVALID );#endif		m_widget->setVisible( true );		m_widget->moveWindow( x, y );	}}short RenderWidget::verticalPositionHint() const{    assert(!deleted);    switch(m_style->verticalAlign())    {    case BASELINE:        return (m_height - MGFontMetrics(m_style->font(), m_part).ascent());    case SUB:        // ###    case SUPER:        // ###    case TOP:        return PositionTop;    case BOTTOM:        return PositionBottom;    case MIDDLE:#if 1	return MGFontMetrics (m_style->font(), m_part).width('x')/2;#else		return -MGFontMetrics(m_style->font(), m_part).width('x')/2;#endif    case TEXT_TOP:#if 1	return MGFontMetrics (m_style->font(), m_part).descent();#else	return MGFontMetrics(m_style->font(), m_part).ascent();#endif    case TEXT_BOTTOM:#if 1	return MGFontMetrics (m_style->font(), m_part).ascent();#else	return MGFontMetrics(m_style->font(), m_part).descent();#endif    }    return 0;}short RenderWidget::intrinsicWidth() const{    if (m_widget)        return m_widget->width();    else        return 0;}int RenderWidget::intrinsicHeight() const{    if (m_widget)        return m_widget->height();    else        return 0;}void RenderWidget::focus(){    if (m_widget)	m_widget->setFocus();}void RenderWidget::blur(){    if (m_widget)	m_widget->clearFocus();}void RenderWidget::absolutePosition(int &xPos, int &yPos, bool){    if (m_widget)    {	xPos = m_widget->x();	yPos = m_widget->y();    }}//#include "render_replaced.moc"

⌨️ 快捷键说明

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