render_body.cpp Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# render_body.cpp

    00001
    00023 #include "render_body.h"
    00024 #include "render_root.h"
    00025 #include "html/html_baseimpl.h"
    00026 #include "xml/dom_docimpl.h"
    00027 #include "khtmlview.h"
    00028
    00029 #include <kglobal.h>
    00030 #include <kdebug.h>
    00031
    00032 using namespace khtml;
    00033 using namespace DOM;
    00034
    00035 RenderBody::RenderBody(HTMLBodyElementImpl* element)
    00036     : RenderFlow(element)
    00037 {
    00038     scrollbarsStyled = false;
    00039 }
    00040
    00041 RenderBody::~RenderBody()
    00042 {
    00043 }
    00044
    00045 void RenderBody::setStyle(RenderStyle* style)
    00046 {
    00047 //     qDebug("RenderBody::setStyle()");
    00048     // ignore position: on body
    00049     if (style->htmlHacks() && style->position() != STATIC)
    00050         style->setPosition(STATIC);
    00051
    00052     RenderFlow::setStyle(style);
    00053     element()->getDocument()->setTextColor( style->color() );
    00054     scrollbarsStyled = false;
    00055 }
    00056
    00057 void RenderBody::paintBoxDecorations(QPainter *p,int, int _y,
    00058                                        int, int _h, int _tx, int _ty)
    00059 {
    00060     //kdDebug( 6040 ) << renderName() << "::paintDecorations()" << endl;
    00061     QColor c;
    00062     if( parent()->style()->backgroundColor().isValid() )
    00063         c =  style()->backgroundColor();
    00064     CachedImage *bg = 0;
    00065     if( parent()->style()->backgroundImage() )
    00066         bg = style()->backgroundImage();
    00067
    00068     int w = width();
    00069     int h = height() + borderTopExtra() + borderBottomExtra();
    00070     _ty -= borderTopExtra();
    00071
    00072     int my = QMAX(_ty,_y);
    00073     int end = QMIN( _y + _h,  _ty + h );
    00074     int mh = end - my;
    00075
    00076     paintBackground(p, c, bg, my, mh, _tx, _ty, w, h);
    00077
    00078     if(style()->hasBorder())
    00079         paintBorder( p, _tx, _ty, w, h, style() );
    00080
    00081 }
    00082
    00083 void RenderBody::repaint()
    00084 {
    00085     RenderObject *cb = containingBlock();
    00086     if(cb != this)
    00087         cb->repaint();
    00088 }
    00089
    00090 void RenderBody::layout()
    00091 {
    00092     RenderFlow::layout();
    00093
    00094     if (!scrollbarsStyled)
    00095     {
    00096         if (root()->view())
    00097         {
    00098             root()->view()->horizontalScrollBar()->setPalette(style()->palette());
    00099             root()->view()->verticalScrollBar()->setPalette(style()->palette());
    00100         }
    00101         scrollbarsStyled=true;
    00102     }
    00103 }
    00104
    00105 int RenderBody::availableHeight() const
    00106 {
    00107     int h = RenderFlow::availableHeight();
    00108
    00109     if( style()->marginTop().isFixed() )
    00110         h  -= style()->marginTop().value();
    00111     if( style()->marginBottom().isFixed() )
    00112         h -= style()->marginBottom().value();
    00113
    00114     return kMax(0, h);
    00115 }

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:30 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001