File indexing completed on 2024-05-26 11:45:01

0001 /* This file is part of the KDE libraries
0002     Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
0003     Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
0004     Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
0005     Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 #include "svg_binding.h"
0023 
0024 #include <QDebug>
0025 
0026 #include <kjs/object.h>
0027 
0028 #include "static_binding.h"
0029 #include "kjseglobal.h"
0030 
0031 using namespace KJSEmbed;
0032 
0033 namespace SvgRendererNS
0034 {
0035 START_QOBJECT_METHOD(animationDuration, QSvgRenderer)
0036 result = KJS::jsNumber(object->animationDuration());
0037 END_QOBJECT_METHOD
0038 
0039 START_QOBJECT_METHOD(defaultSize, QSvgRenderer)
0040 result = KJSEmbed::createVariant(exec, "QSize", object->defaultSize());
0041 END_QOBJECT_METHOD
0042 
0043 START_QOBJECT_METHOD(isValid, QSvgRenderer)
0044 result = KJS::jsBoolean(object->isValid());
0045 END_QOBJECT_METHOD
0046 
0047 START_QOBJECT_METHOD(animated, QSvgRenderer)
0048 result = KJS::jsBoolean(object->animated());
0049 END_QOBJECT_METHOD
0050 }
0051 
0052 START_METHOD_LUT(SvgRenderer)
0053 {"animationDuration", 0, KJS::DontDelete | KJS::ReadOnly, &SvgRendererNS::animationDuration},
0054 {"defaultSize", 0, KJS::DontDelete | KJS::ReadOnly, &SvgRendererNS::defaultSize},
0055 {"isValid", 0, KJS::DontDelete | KJS::ReadOnly, &SvgRendererNS::isValid},
0056 {"animated", 0, KJS::DontDelete | KJS::ReadOnly, &SvgRendererNS::animated}
0057 END_METHOD_LUT
0058 
0059 NO_ENUMS(SvgRenderer)
0060 NO_STATICS(SvgRenderer)
0061 
0062 KJSO_SIMPLE_BINDING_CTOR(SvgRenderer, QSvgRenderer, QObjectBinding)
0063 KJSO_QOBJECT_BIND(SvgRenderer, QSvgRenderer)
0064 
0065 KJSO_START_CTOR(SvgRenderer, QSvgRenderer, 0)
0066 QSvgRenderer *renderer = nullptr;
0067 if (args.size() == 1)
0068 {
0069     QObject *arg0 = KJSEmbed::extractObject<QObject>(exec, args, 0, nullptr);
0070     renderer = new QSvgRenderer(arg0);
0071 } else if (args.size() == 2)
0072 {
0073     QString arg0 = KJSEmbed::extractVariant<QString>(exec, args, 0);
0074     QObject *arg1 = KJSEmbed::extractObject<QObject>(exec, args, 1, nullptr);
0075     renderer = new QSvgRenderer(arg0, arg1);
0076 } else
0077 {
0078     renderer = new QSvgRenderer();
0079 }
0080 
0081 KJS::JSObject *rendererObject = new SvgRenderer(exec, renderer);
0082 return rendererObject;
0083 KJSO_END_CTOR
0084 
0085 namespace SvgWidgetNS
0086 {
0087 START_QOBJECT_METHOD(renderer, QSvgWidget)
0088 result = KJSEmbed::createQObject(exec, object->renderer(), ObjectBinding::QObjOwned);
0089 END_QOBJECT_METHOD
0090 }
0091 
0092 START_METHOD_LUT(SvgWidget)
0093 {"renderer", 0, KJS::DontDelete | KJS::ReadOnly, &SvgWidgetNS::renderer
0094 }
0095 END_METHOD_LUT
0096 
0097 NO_ENUMS(SvgWidget)
0098 NO_STATICS(SvgWidget)
0099 
0100 KJSO_SIMPLE_BINDING_CTOR(SvgWidget, QSvgWidget, QWidgetBinding)
0101 KJSO_QOBJECT_BIND(SvgWidget, QSvgWidget)
0102 
0103 KJSO_START_CTOR(SvgWidget, QSvgWidget, 0)
0104 QSvgWidget *widget = nullptr;
0105 if (args.size() == 1)
0106 {
0107     QWidget *arg0 = KJSEmbed::extractObject<QWidget>(exec, args, 0, nullptr);
0108     widget = new QSvgWidget(arg0);
0109 } else if (args.size() == 2)
0110 {
0111     QString arg0 = KJSEmbed::extractVariant<QString>(exec, args, 0);
0112     QWidget *arg1 = KJSEmbed::extractObject<QWidget>(exec, args, 1, nullptr);
0113     widget = new QSvgWidget(arg0, arg1);
0114 } else
0115 {
0116     widget = new QSvgWidget();
0117 }
0118 
0119 KJS::JSObject *rendererObject = new SvgWidget(exec, widget);
0120 return rendererObject;
0121 KJSO_END_CTOR
0122