Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members

jsobjectproxy.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 
00003 /*
00004  *  Copyright (C) 2001-2003, Richard J. Moore <rich@kde.org>
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Library General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  *  Boston, MA 02111-1307, USA.
00020  */
00021 
00022 #ifndef KJSEMBEDJSOBJECTPROXY_H
00023 #define KJSEMBEDJSOBJECTPROXY_H
00024 
00025 #include <qguardedptr.h>
00026 #include <qcstring.h>
00027 #include <qwidget.h>
00028 
00029 #include <kjs/object.h>
00030 #include <kjsembed/jsproxy.h>
00031 #include <kjsembed/jsbinding.h>
00032 
00033 namespace KJS { class Interpreter; }
00034 
00035 namespace KJSEmbed {
00036 
00037 namespace Bindings { class JSObjectProxyImp; }
00038 
00039 class JSSecurityPolicy;
00040 class KJSEmbedPart;
00041 
00079 class JSObjectProxy : public JSProxy
00080 {
00081 public:
00086     JSObjectProxy( KJSEmbedPart *part, QObject *target );
00087 
00093     JSObjectProxy( KJSEmbedPart *part, QObject *target, QObject *root );
00094 
00101     JSObjectProxy( KJSEmbedPart *part, QObject *target, QObject *root, const JSSecurityPolicy *sp );
00102 
00103     virtual ~JSObjectProxy() {}
00104 
00106     KJSEmbedPart *part() const { return jspart; }
00107 
00109     KJS::Interpreter *interpreter() const { return js; }
00110 
00112     QObject *rootObject() const { return root; }
00113 
00115     QObject *object() const { return obj; }
00116 
00118     QWidget *widget() const
00119         {
00120             QObject *w = obj;
00121             return (w && w->isWidgetType()) ? static_cast<QWidget *>(w) : 0;
00122         }
00123 
00124     void *toVoidStar() { return obj; }
00125 
00127     bool inherits( const char *clazz ) { return obj->isA( clazz ); }
00128 
00130     const JSSecurityPolicy *securityPolicy() const { return policy; }
00131 
00136     void setSecurityPolicy( const JSSecurityPolicy *sp );
00137 
00139     virtual KJS::Value get( KJS::ExecState *exec, const KJS::Identifier &p ) const;
00140 
00142     virtual void put( KJS::ExecState *exec, const KJS::Identifier &p,
00143                       const KJS::Value &v, int attr = KJS::None );
00144 
00146     virtual KJS::UString toString( KJS::ExecState *exec ) const;
00147 
00158     virtual void addBindings( KJS::ExecState *exec, KJS::Object &object );
00159 
00160 protected:
00161     void addBindingsClass( KJS::ExecState *exec, KJS::Object &object );
00162 
00166     void addBindingsEnum( KJS::ExecState *exec, KJS::Object &object );
00167 
00171     void addBindingsSlots( KJS::ExecState *exec, KJS::Object &object );
00172 
00173 
00174 private:
00175     bool isAllowed( KJS::Interpreter *js ) const;
00176 
00177     void addSlotBinding( const QCString &name, KJS::ExecState *exec, KJS::Object &object );
00178 
00179 private:
00180     KJSEmbedPart *jspart;
00181     KJS::Interpreter *js;
00182     QGuardedPtr<QObject> obj;
00183     QGuardedPtr<QObject> root;
00184     const JSSecurityPolicy *policy;
00185     class JSObjectProxyPrivate *d;
00186     friend class Bindings::JSObjectProxyImp;
00187 };
00188 
00189 } // namespace KJSEmbed
00190 
00191 #endif // KJSEMBEDJSOBJECTPROXY_H
00192 
00193 // Local Variables:
00194 // c-basic-offset: 4
00195 // End:

Generated on Sat May 29 03:13:07 2004 for KJSEmbed by doxygen 1.3.2