render_applet.cpp Source File (khtml Library)

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

# render_applet.cpp

    00001
    00023 #include <config.h>
    00024 #include <klocale.h>
    00025
    00026 #include <kdebug.h>
    00027
    00028 #include "rendering/render_applet.h"
    00029 #include "rendering/render_root.h"
    00030 #include "xml/dom_docimpl.h"
    00031 #include "khtmlview.h"
    00032 #include "khtml_part.h"
    00033
    00034 #include <qlabel.h>
    00035
    00036 #ifndef Q_WS_QWS // We don't have Java in Qt Embedded
    00037
    00038 #include "java/kjavaappletwidget.h"
    00039 #include "misc/htmltags.h"
    00040 #include "html/html_objectimpl.h"
    00041
    00042 using namespace khtml;
    00043 using namespace DOM;
    00044
    00045 RenderApplet::RenderApplet(HTMLElementImpl *applet, const QMap<QString, QString> &args )
    00046     : RenderWidget(applet)
    00047 {
    00048     // init RenderObject attributes
    00049     setInline(true);
    00050
    00051     KJavaAppletContext *context = 0;
    00052     KHTMLView *_view = applet->getDocument()->view();
    00053     if ( _view ) {
    00054         KHTMLPart *part = _view->part();
    00055         context = part->createJavaContext();
    00056     }
    00057
    00058     if ( context ) {
    00059         //kdDebug(6100) << "RenderApplet::RenderApplet, setting QWidget" << endl;
    00060         setQWidget( new KJavaAppletWidget(context, _view->viewport()) );
    00061         processArguments(args);
    00062     }
    00063 }
    00064
    00065 RenderApplet::~RenderApplet()
    00066 {
    00067 }
    00068
    00069 short RenderApplet::intrinsicWidth() const
    00070 {
    00071     int rval = 150;
    00072
    00073     if( m_widget )
    00074         rval = ((KJavaAppletWidget*)(m_widget))->sizeHint().width();
    00075
    00076     return rval > 10 ? rval : 50;
    00077 }
    00078
    00079 int RenderApplet::intrinsicHeight() const
    00080 {
    00081     int rval = 150;
    00082
    00083     if( m_widget )
    00084         rval = m_widget->sizeHint().height();
    00085
    00086     return rval > 10 ? rval : 50;
    00087 }
    00088
    00089 void RenderApplet::layout()
    00090 {
    00091     //kdDebug(6100) << "RenderApplet::layout" << endl;
    00092
    00093     KHTMLAssert( !layouted() );
    00094     KHTMLAssert( minMaxKnown() );
    00095
    00096     calcWidth();
    00097     calcHeight();
    00098
    00099     KJavaAppletWidget *tmp = static_cast<KJavaAppletWidget*>(m_widget);
    00100     if ( tmp ) {
    00101         NodeImpl *child = element()->firstChild();
    00102
    00103         while(child) {
    00104
    00105             if(child->id() == ID_PARAM) {
    00106                 HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>(child);
    00107                 if(tmp->applet())
    00108                     tmp->applet()->setParameter( p->name(), p->value());
    00109             }
    00110             child = child->nextSibling();
    00111         }
    00112         //kdDebug(6100) << "setting applet widget to size: " << m_width << ", " << m_height << endl;
    00113         m_widget->resize(m_width-borderLeft()-borderRight()-paddingLeft()-paddingRight(),
    00114                          m_height-borderTop()-borderBottom()-paddingTop()-paddingBottom());
    00115         tmp->showApplet();
    00116     }
    00117
    00118     setLayouted();
    00119 }
    00120
    00121 void RenderApplet::processArguments(const QMap<QString, QString> &args)
    00122 {
    00123     KJavaAppletWidget *w = static_cast<KJavaAppletWidget*>(m_widget);
    00124     KJavaApplet* applet = w ? w->applet() : 0;
    00125
    00126     if ( applet ) {
    00127         applet->setBaseURL( args[QString::fromLatin1("baseURL") ] );
    00128         applet->setAppletClass( args[QString::fromLatin1("code") ] );
    00129
    00130         QString str = args[QString::fromLatin1("codeBase") ];
    00131         if( !str.isEmpty() )
    00132             applet->setCodeBase( str );
    00133
    00134         str = args[QString::fromLatin1("name") ];
    00135         if( !str.isNull() )
    00136             applet->setAppletName( str );
    00137         else
    00138             applet->setAppletName( args[QString::fromLatin1("code") ] );
    00139
    00140         str = args[QString::fromLatin1("archive") ];
    00141         if( !str.isEmpty() )
    00142             applet->setArchives( args[QString::fromLatin1("archive") ] );
    00143     }
    00144 }
    00145
    00146 #endif

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:29 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001