don't discard iframe children.
[kdelibs.git] / khtml / java / kjavaappletwidget.h
blobaf1d96de5cc69e66d75ce7755962d309e399d91a
1 // -*- c++ -*-
3 /* This file is part of the KDE project
5 * Copyright (C) 2000 Richard Moore <rich@kde.org>
6 * 2000 Wynn Wilkes <wynnw@caldera.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #ifndef KJAVAAPPLETWIDGET_H
25 #define KJAVAAPPLETWIDGET_H
27 #include <QtGui/QImage>
29 #include "java/kjavaappletcontext.h"
30 #include "java/kjavaapplet.h"
31 #ifdef Q_WS_X11
32 #include <QX11EmbedContainer>
33 #else
34 #define QX11EmbedContainer QWidget
35 #include <QWidget>
36 #endif
38 /**
39 * @short A widget for displaying Java applets
41 * KJavaAppletWidget provides support for the inclusion of Java applets
42 * in Qt and KDE applications. To create an applet, you must first create
43 * a context object in which it will run. There can be several applets and
44 * contexts in operation at a given time, for example in a web browser there
45 * would be one context object for each web page. Applets in the same context
46 * can communicate with each other, applets in different contexts cannot.
47 * Once you have created a KJavaAppletContext, you can create as many
48 * applets in it as you want.
50 * Once you have created the applet widget, you should access the applet() method
51 * to call the various setXXX methods to configure the applet,
52 * They correspond to the HTML tags used to embed applets in a web page.
53 * Once the applet is configured, call the create() method to set things in motion.
54 * The applet is running when it first appears, but you can start or stop it
55 * when you like (for example if it scrolls off the screen).
57 * This widget works by using the KJavaAppletServer, which fires off a
58 * Java server process with which it communicates using the
59 * KDE Java Applet Server (KJAS) protocol over stdin and stdout.
60 * The applet windows are swallowed and attached to the QWidget, but they are
61 * actually running in a different process. This has the advantage of robustness
62 * and reusability. The details of the communication are hidden from the user
63 * in the KJASAppletServer class. Normally only a single server process is used for
64 * all of the applets in a given application, this is all sorted automatically.
65 * The KJAS server is 100% pure Java, and should also prove useful for people
66 * wishing to add java support to other systems (for example a perl/Tk binding
67 * is perfectly feasible). All you need to do is implement the protocol and
68 * (optionally) swallow the applet windows.
70 * The applet support in KDE is still dependent on the KWin Window Manager. The
71 * applet swallowing will not work under other Window Managers. Hopefully this
72 * will be fixed in the future.
74 * For a description of the KJAS protocol, please see the KJAS_GRAMMAR.txt file.
76 * @author Richard J. Moore, rich@kde.org
77 * @author Wynn Wilkes, wynnw@caldera.com
80 class KJavaAppletWidgetPrivate;
82 class KJavaAppletWidget : public QX11EmbedContainer
84 Q_OBJECT
85 public:
86 KJavaAppletWidget( QWidget* parent=0 );
88 ~KJavaAppletWidget();
90 /**
91 * Returns a pointer to the KJavaApplet. Use this to
92 * configure the applet's parameters. You can also
93 * use it to start and stop the Applet.
95 KJavaApplet* applet() { return m_applet; }
97 /**
98 * Tells the AppletServer to create, initialize, and
99 * show the Applet.
101 void showApplet();
103 QSize sizeHint() const;
104 void resize( int, int );
106 protected Q_SLOTS:
108 * This slot is called by KWin when new windows are added. We check
109 * to see if the window has the title we set. If so we embed it.
111 void setWindow( WId w );
113 protected:
114 //The counter to generate ID's for the applets
115 static int appletCount;
116 void showEvent (QShowEvent *);
118 private:
119 KJavaAppletWidgetPrivate* const d;
121 KJavaApplet* m_applet;
122 QString m_swallowTitle;
126 #endif // KJAVAAPPLETWIDGET_H