00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KJSEMBEDFACTORY_H
00023 #define KJSEMBEDFACTORY_H
00024
00025 #include <qmap.h>
00026 #include <qdict.h>
00027 #include <qstringlist.h>
00028
00029 #include <kjs/interpreter.h>
00030 #include <kjs/object.h>
00031
00032 class QEvent;
00033 class QObject;
00034 class QWidget;
00035 class QTextStream;
00036
00037 namespace KParts {
00038 class ReadOnlyPart;
00039 class ReadWritePart;
00040 }
00041
00045 namespace KJSEmbed {
00046
00047 namespace Bindings { class JSFactoryImp;
00048 class JSBindingPlugin; }
00049
00050 class KJSEmbedPart;
00051 class JSEventMapper;
00052 class JSOpaqueProxy;
00053 class JSObjectProxy;
00054
00060 class JSFactory
00061 {
00062 public:
00067 enum ProxyTypes {
00068 TypeInvalid=0,
00069 TypeQObject=1,
00070 TypeValue=2,
00071 TypeOpaque=4,
00072 TypePlugin=8,
00073 TypeQObjectPlugin=9
00074 };
00075
00077 JSFactory( KJSEmbedPart *part );
00078
00080 virtual ~JSFactory();
00081
00086 JSEventMapper *eventMapper() const { return evmapper; }
00087
00089 KJSEmbedPart *part() const { return jspart; }
00090
00091
00092
00093
00094
00096 KJS::Object create( KJS::ExecState *exec, const QString &classname, const KJS::List &args );
00097
00099 KJS::Object createProxy( KJS::ExecState *exec, QObject *target,
00100 const JSObjectProxy *context=0 ) const;
00101
00103 KJS::Object createProxy( KJS::ExecState *exec, QTextStream *target,
00104 const JSObjectProxy *context=0 ) const;
00105
00107 KJS::Object createProxy( KJS::ExecState *exec, QEvent *target,
00108 const JSObjectProxy *context ) const;
00109
00110
00111
00112
00113
00120 KParts::ReadOnlyPart *createROPart( const QString &svc, QObject *parent=0, const char *name=0 );
00121
00126 KParts::ReadOnlyPart *createROPart( const QString &svc, const QString &constraint,
00127 QObject *parent=0, const char *name=0 );
00128
00135 KParts::ReadWritePart *createRWPart( const QString &svc, QObject *parent=0, const char *name=0 );
00136
00141 KParts::ReadWritePart *createRWPart( const QString &svc, const QString &constraint,
00142 QObject *parent=0, const char *name=0 );
00143
00148 QWidget *loadUI( const QString &uiFile, QObject *connector=0, QWidget *parent=0, const char *name=0 );
00149
00154 QStringList listBindingPlugins( KJS::ExecState *exec, KJS::Object &self);
00155
00156
00157
00161 void addBindingPluginTypes(KJS::ExecState *exec, KJS::Object &parent);
00162 bool isBindingPlugin(const QString &classname) const;
00166 KJS::Object createBindingPlugin(KJS::ExecState *exec, const QString &classname, const KJS::List &args );
00171 bool isSupported( const QString &clazz ) const;
00172
00177 bool isQObject( const QString &clazz ) const;
00178
00183 bool isValue( const QString &clazz ) const;
00184
00189 bool isOpaque( const QString &clazz ) const;
00190
00196 uint proxyType( const QString &clazz ) const;
00197
00198
00203 void addQObjectPlugin(const QString &classname, KJSEmbed::Bindings::JSBindingPlugin* plugin);
00204
00205 void addBindingsPlugin(KJS::ExecState *exec, KJS::Object &target) const;
00206
00212 void addType( const QString &clazz, uint proxytype=JSFactory::TypeQObject );
00213
00215 void addTypes( KJS::ExecState *exec, KJS::Object &parent );
00216
00217 QStringList types() const;
00218
00219 protected:
00221 KJS::Object extendProxy( KJS::ExecState *exec, KJS::Object &target ) const;
00222
00224 KJS::Object createValue( KJS::ExecState *exec, const QString &cname, const KJS::List &args );
00225
00230 QObject *create( const QString &classname, QObject *parent=0, const char *name=0 );
00231
00233 KJS::Object createOpaque( KJS::ExecState *exec, const QString &cname, const KJS::List &args );
00234
00235
00237 QObject *createBinding( const QString &cname, QObject *parent, const char *name );
00238
00243 QObject *createObject( const QString &cname, QObject *parent, const char *name );
00244
00249 QWidget *createWidget( const QString &cname, QWidget *parent, const char *name );
00250
00251 private:
00253 void addWidgetFactoryTypes( KJS::ExecState *exec, KJS::Object &parent );
00254
00256 void addCustomTypes( KJS::ExecState *exec, KJS::Object &parent );
00257
00259 void addBindingTypes( KJS::ExecState *exec, KJS::Object &parent );
00260
00265 void addObjectTypes( KJS::ExecState *exec, KJS::Object &parent );
00266
00267 void addOpaqueTypes( KJS::ExecState *exec, KJS::Object &parent );
00268
00269 void addValueTypes( KJS::ExecState *exec, KJS::Object &parent );
00270
00271 private:
00272 KJSEmbedPart *jspart;
00273 JSEventMapper *evmapper;
00274 QMap<QString,uint> objtypes;
00275 class JSFactoryPrivate *d;
00276 };
00277
00278 }
00279
00280 #endif // KJSEMBEDFACTORY_H
00281
00282
00283
00284