00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KJSEMBEDJSCONSOLEPART_H
00023 #define KJSEMBEDJSCONSOLEPART_H
00024
00025 #include <qstringlist.h>
00026
00027 #include <kparts/part.h>
00028 #include <kjs/interpreter.h>
00029 #include <kjs/object.h>
00030 #include <kjs/value.h>
00031
00032 #include <kjsembed/jsbinding.h>
00033 #include <kjsembed/xmlactionclient.h>
00034
00035 class QWidget;
00036
00037 #define KJSEMBED_VERSION_STRING "0.3"
00038 #define KJSEMBED_VERSION_MAJOR 0
00039 #define KJSEMBED_VERSION_MINOR 3
00040
00044 namespace KJSEmbed {
00045
00046 class JSObjectProxy;
00047 class JSConsoleWidget;
00048 class JSFactory;
00049 class JSBuiltIn;
00050
00057 class KJSEmbedPart : public KParts::ReadOnlyPart
00058 {
00059 Q_OBJECT
00060 Q_PROPERTY( QStringList constructorNames READ constructorNames )
00061 Q_PROPERTY( QCString versionString READ versionString )
00062 Q_PROPERTY( int versionMajor READ versionMajor )
00063 Q_PROPERTY( int versionMinor READ versionMinor )
00064
00065 public:
00067 KJSEmbedPart( QObject *parent=0, const char *name=0 );
00068
00078 KJSEmbedPart( QWidget *wparent, const char *wname=0, QObject *parent=0, const char *name=0 );
00079
00085 KJSEmbedPart( KJS::Interpreter *js, QWidget *wparent, const char *wname=0,
00086 QObject *parent=0, const char *name=0 );
00087
00089 virtual ~KJSEmbedPart();
00090
00091
00092
00093
00094
00096 QCString versionString() const;
00097
00099 int versionMajor() const;
00100
00102 int versionMinor() const;
00103
00104
00105
00106
00107
00109 KJS::Object globalObject() const { return js->globalObject(); }
00110
00112 KJS::Completion completion() const { return res; }
00113
00115 KJS::Object partObject() const { return partobj; }
00116
00121 KJS::Object addObject( QObject *obj, const char *name=0 );
00122
00127 KJS::Object addObject( QObject *obj, KJS::Object &parent, const char *name=0 );
00128
00130 KJS::Object bind( QObject *obj );
00131
00132
00133
00134
00135
00137 QStringList constructorNames() const;
00138
00140 KJS::Value constructors() const;
00141
00143 KJS::List constructorList() const;
00144
00145 public slots:
00146
00147
00148
00149
00151 virtual KJSEmbed::JSConsoleWidget *view();
00152
00154 virtual bool openURL( const KURL &url );
00155
00156
00157
00158
00159
00161 KJSEmbed::XMLActionClient *actionClient() const { return xmlclient; }
00162
00164 bool loadActionSet( const QString &file );
00165
00166
00167
00168
00169
00171 KJS::Interpreter *interpreter() const { return js; }
00172
00174 KJS::ExecState *globalExec() const { return js->globalExec(); }
00175
00177 JSFactory *factory() const { return jsfactory; }
00178
00180 virtual KJS::Value evaluate( const QString &script, const KJS::Value &self=KJS::Null() );
00181
00183 bool execute( const QString &script, const KJS::Value &self=KJS::Null() );
00184
00189 virtual bool execute( KJS::Completion &result, const QString &script, const KJS::Value &self );
00190
00192 virtual bool runFile( const QString &filename, const KJS::Value &self=KJS::Null() );
00193
00199 QString loadFile( const QString &file );
00200
00201 protected:
00203 void createInterpreter();
00204
00212 void createBuiltIn( KJS::ExecState *exec, KJS::Object &parent );
00213
00215 void createActionClient();
00216
00218 virtual bool openFile() { return false; }
00219
00221 virtual void virtual_hook( int id, void *data );
00222
00223 private:
00224 XMLActionClient *xmlclient;
00225 JSConsoleWidget *jsConsole;
00226 JSFactory *jsfactory;
00227 JSBuiltIn *builtins;
00228 QWidget *widgetparent;
00229 QCString widgetname;
00230
00231 KJS::Object partobj;
00232 KJS::Completion res;
00233 KJS::Interpreter *js;
00234 bool deletejs;
00235
00236 class KJSEmbedPartPrivate *d;
00237 };
00238
00239
00240 }
00241
00242 #endif // KJSEMBEDJSCONSOLEPART_H
00243
00244
00245
00246
00247