summaryrefslogtreecommitdiffstats
path: root/kjsembed/qtbindings/qcanvasview_imp.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/qtbindings/qcanvasview_imp.cpp
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/qtbindings/qcanvasview_imp.cpp')
-rw-r--r--kjsembed/qtbindings/qcanvasview_imp.cpp276
1 files changed, 276 insertions, 0 deletions
diff --git a/kjsembed/qtbindings/qcanvasview_imp.cpp b/kjsembed/qtbindings/qcanvasview_imp.cpp
new file mode 100644
index 00000000..f51e7f0c
--- /dev/null
+++ b/kjsembed/qtbindings/qcanvasview_imp.cpp
@@ -0,0 +1,276 @@
+
+
+
+#include <qcstring.h>
+#include <qimage.h>
+#include <qpainter.h>
+#include <qpalette.h>
+#include <qpixmap.h>
+#include <qfont.h>
+
+#include <kjs/object.h>
+
+#include <kjsembed/global.h>
+#include <kjsembed/jsobjectproxy.h>
+#include <kjsembed/jsopaqueproxy.h>
+#include <kjsembed/jsbinding.h>
+
+#include <qcanvas.h>
+#include "qcanvasview_imp.h"
+
+/**
+ * Namespace containing the KJSEmbed library.
+ */
+namespace KJSEmbed {
+
+QCanvasViewImp::QCanvasViewImp( KJS::ExecState *exec, int mid, bool constructor )
+ : JSProxyImp(exec), id(mid), cons(constructor)
+{
+}
+
+QCanvasViewImp::~QCanvasViewImp()
+{
+}
+
+/**
+ * Adds bindings for static methods and enum constants to the specified Object.
+ */
+void QCanvasViewImp::addStaticBindings( KJS::ExecState *exec, KJS::Object &object )
+{
+ JSProxy::MethodTable methods[] = {
+
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ QCString lastName;
+
+ while( methods[idx].name ) {
+ if ( lastName != methods[idx].name ) {
+ QCanvasViewImp *meth = new QCanvasViewImp( exec, methods[idx].id );
+ object.put( exec , methods[idx].name, KJS::Object(meth) );
+ lastName = methods[idx].name;
+ }
+ ++idx;
+ }
+
+
+}
+
+/**
+ * Adds bindings for instance methods to the specified Object.
+ */
+void QCanvasViewImp::addBindings( KJS::ExecState *exec, KJS::Object &object )
+{
+ JSProxy::MethodTable methods[] = {
+
+ { Method_canvas_4, "canvas" },
+ { Method_setCanvas_5, "setCanvas" },
+ { Method_worldMatrix_6, "worldMatrix" },
+ { Method_inverseWorldMatrix_7, "inverseWorldMatrix" },
+ { Method_setWorldMatrix_8, "setWorldMatrix" },
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ QCString lastName;
+
+ while( methods[idx].name ) {
+ if ( lastName != methods[idx].name ) {
+ QCanvasViewImp *meth = new QCanvasViewImp( exec, methods[idx].id );
+ object.put( exec , methods[idx].name, KJS::Object(meth) );
+ lastName = methods[idx].name;
+ }
+ ++idx;
+ }
+}
+
+/**
+ * Extract a QCanvasView pointer from an Object.
+ */
+QCanvasView *QCanvasViewImp::toQCanvasView( KJS::Object &self )
+{
+ JSObjectProxy *ob = JSProxy::toObjectProxy( self.imp() );
+ if ( ob ) {
+ QObject *obj = ob->object();
+ if ( obj )
+ return dynamic_cast<QCanvasView *>( obj );
+ }
+
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
+ if ( !op )
+ return 0;
+
+ if ( op->typeName() != "QCanvasView" )
+ return 0;
+
+ return op->toNative<QCanvasView>();
+}
+
+/**
+ * Select and invoke the correct constructor.
+ */
+KJS::Object QCanvasViewImp::construct( KJS::ExecState *exec, const KJS::List &args )
+{
+ switch( id ) {
+
+ case Constructor_QCanvasView_1:
+ return QCanvasView_1( exec, args );
+ break;
+
+ case Constructor_QCanvasView_2:
+ return QCanvasView_2( exec, args );
+ break;
+
+ default:
+ break;
+ }
+
+ QString msg = i18n("QCanvasViewCons has no constructor with id '%1'.").arg(id);
+ return throwError(exec, msg,KJS::ReferenceError);
+}
+
+
+KJS::Object QCanvasViewImp::QCanvasView_1( KJS::ExecState *exec, const KJS::List &args )
+{
+
+ QWidget *arg0 = extractQWidget(exec, args, 0);
+
+
+ const char *arg1 = (args.size() >= 2) ? args[1].toString(exec).ascii() : 0;
+
+ Qt::WFlags arg2 = 0; // TODO (hack for QCanvasView)
+
+
+ // We should now create an instance of the QCanvasView object
+
+ QCanvasView *ret = new QCanvasView(
+
+ arg0,
+ arg1,
+ arg2 );
+
+ JSOpaqueProxy *prx = new JSOpaqueProxy( ret, "QCanvasView");
+ return KJS::Object( prx );
+}
+
+KJS::Object QCanvasViewImp::QCanvasView_2( KJS::ExecState *exec, const KJS::List &args )
+{
+ QCanvas * arg0 = 0L;;
+
+ KJS::Object obj = args[0].toObject(exec);
+ JSObjectProxy *proxy = JSProxy::toObjectProxy( obj.imp() );
+ if ( proxy ) arg0 = dynamic_cast<QCanvas *>( proxy->widget() );
+
+ QWidget * arg1 = extractQWidget(exec, args, 1);
+
+ const char *arg2 = (args.size() >= 3) ? args[2].toString(exec).ascii() : 0;
+
+ Qt::WFlags arg3 = 0; // TODO (hack for QCanvasView)
+
+
+ // We should now create an instance of the QCanvasView object
+
+ QCanvasView *ret = new QCanvasView(
+ arg0,
+ arg1,
+ arg2,
+ arg3 );
+
+ JSOpaqueProxy *prx = new JSOpaqueProxy( ret, "QCanvasView");
+ return KJS::Object( prx );
+}
+
+KJS::Value QCanvasViewImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args )
+{
+ instance = QCanvasViewImp::toQCanvasView( self );
+
+ switch( id ) {
+
+ case Method_canvas_4:
+ return canvas_4( exec, self, args );
+ break;
+
+ case Method_setCanvas_5:
+ return setCanvas_5( exec, self, args );
+ break;
+
+ case Method_worldMatrix_6:
+ return worldMatrix_6( exec, self, args );
+ break;
+
+ case Method_inverseWorldMatrix_7:
+ return inverseWorldMatrix_7( exec, self, args );
+ break;
+
+ case Method_setWorldMatrix_8:
+ return setWorldMatrix_8( exec, self, args );
+ break;
+
+ default:
+ break;
+ }
+
+ QString msg = i18n( "QCanvasViewImp has no method with id '%1'." ).arg( id );
+ return throwError(exec, msg,KJS::ReferenceError);
+}
+
+
+KJS::Value QCanvasViewImp::canvas_4( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->canvas( );
+ return KJS::Value(); // Returns 'QCanvas *'
+
+}
+
+KJS::Value QCanvasViewImp::setCanvas_5( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ // Unsupported parameter QCanvas *
+ return KJS::Value();
+
+ QCanvas * arg0; // Dummy
+
+ instance->setCanvas(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QCanvasViewImp::worldMatrix_6( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->worldMatrix( );
+ return KJS::Value(); // Returns 'const QWMatrix &'
+
+}
+
+KJS::Value QCanvasViewImp::inverseWorldMatrix_7( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->inverseWorldMatrix( );
+ return KJS::Value(); // Returns 'const QWMatrix &'
+
+}
+
+KJS::Value QCanvasViewImp::setWorldMatrix_8( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QWMatrix arg0; // TODO (hack for qcanvasview)
+
+ bool ret;
+ ret = instance->setWorldMatrix(
+ arg0 );
+ return KJS::Boolean( ret );
+
+}
+
+
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
+
+