don't discard iframe children.
[kdelibs.git] / khtml / java / kjavaapplet.h
blob45e2c256c9996b37b3251c345b6b0e545a1d0ad9
1 // -*- c++ -*-
2 /* This file is part of the KDE project
4 * Copyright (C) 2000 Richard Moore <rich@kde.org>
5 * 2000 Wynn Wilkes <wynnw@caldera.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef KJAVAAPPLET_H
25 #define KJAVAAPPLET_H
27 #include <kurl.h>
29 #include <QtCore/QObject>
30 #include <QtCore/QStringList>
31 #include <QtCore/QMap>
33 /**
34 * @short A Java applet
36 * This class encapsulates the data the Applet Server needs to load
37 * the Applet class files, and set the proper size of the Applet. It also
38 * has an interface for applets to resize themselves.
40 * @author Richard J. Moore, rich@kde.org
41 * @author Wynn Wilkes, wynnw@kde.org
44 class KJavaApplet;
45 class KJavaAppletWidget;
46 class KJavaAppletContext;
47 class KJavaAppletPrivate;
50 class KJavaApplet : public QObject
52 Q_OBJECT
54 public:
55 // states describing the life cycle of an applet.
56 // keep in sync with applet state in KJASAppletStub.java !
57 typedef enum {
58 UNKNOWN = 0,
59 CLASS_LOADED = 1,
60 INSTANCIATED = 2,
61 INITIALIZED = 3,
62 STARTED = 4,
63 STOPPED = 5,
64 DESTROYED = 6
65 } AppletState;
66 KJavaApplet( KJavaAppletWidget* _parent, KJavaAppletContext* _context = 0 );
67 ~KJavaApplet();
69 /**
70 * Set the applet context'.
72 void setAppletContext( KJavaAppletContext* _context );
74 /**
75 * Specify the name of the class file to run. For example 'Lake.class'.
77 void setAppletClass( const QString& clazzName );
79 /**
80 * Get the name of the Class file the applet should run
82 QString& appletClass();
84 /**
85 * Set the URL of the document embedding the applet.
87 void setBaseURL( const QString& base );
89 /**
90 * get the Base URL of the document embedding the applet
92 QString& baseURL();
94 /**
95 * Set the codebase of the applet classes.
97 void setCodeBase( const QString& codeBase );
99 /**
100 * Get the codebase of the applet classes
102 QString& codeBase();
105 * Set the list of archives at the Applet's codebase to search in for
106 * class files and other resources
108 void setArchives( const QString& _archives );
111 * Get the list of Archives that should be searched for class files
112 * and other resources
114 QString& archives();
117 * Set the name the applet should be called in its context
119 void setAppletName( const QString& name );
122 * Get the name the applet should be called in its context
124 QString& appletName();
127 * Set the size of the applet
129 void setSize( QSize size );
132 * Get the size of the applet
134 QSize size();
137 * Specify a parameter to be passed to the applet.
139 void setParameter( const QString& name, const QString& value );
142 * Look up the parameter value for the given Parameter. Returns
143 * QString() if the name has not been set.
145 QString& parameter( const QString& name );
148 * Get a reference to the Parameters and their values
150 QMap<QString,QString>& getParams();
153 * Set the window title for swallowing
155 void setWindowName( const QString& title );
158 * Get the window title this applet should use
160 QString& getWindowName();
163 * Interface for applets to resize themselves
165 void resizeAppletWidget( int width, int height );
168 * Send message to AppletServer to create this applet's
169 * frame to be swallowed and download the applet classes
171 void create();
174 * Send message to AppletServer to Initialize and show
175 * this applet
177 void init();
180 * Returns status of applet- whether it's been created or not
182 bool isCreated();
185 * Run the applet.
187 void start();
190 * Pause the applet.
192 void stop();
195 * Returns the unique ID this applet is given
197 int appletId();
200 * Set the applet ID.
202 void setAppletId( int id );
204 KJavaAppletContext* getContext() const { return context; }
207 * Get/Set the user name
209 void setUser(const QString & _user) { username = _user; }
210 const QString & user () const { return username; }
213 * Get/Set the user password
215 void setPassword(const QString & _password) { userpassword = _password; }
216 const QString & password () const { return userpassword; }
219 * Get/Set the auth name
221 void setAuthName(const QString & _auth) { authname = _auth; }
222 const QString & authName () const { return authname; }
225 * called from the protocol engine
226 * changes the status according to the one on the java side.
227 * Do not call this yourself!
229 void stateChange ( const int newState );
230 void setFailed ();
231 AppletState state() const;
232 bool failed() const;
233 bool isAlive() const;
235 * JavaScript coming from Java
237 void jsData (const QStringList & args) { emit jsEvent (args); }
238 Q_SIGNALS:
239 void jsEvent (const QStringList & args);
240 private:
241 void showStatus( const QString &msg);
242 KJavaAppletPrivate* const d;
243 QMap<QString, QString> params;
244 KJavaAppletContext* context;
245 int id;
246 QString username;
247 QString userpassword;
248 QString authname;
251 #endif // KJAVAAPPLET_H