File indexing completed on 2023-11-26 07:35:14

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 "size.h"
0023 
0024 #include <QDebug>
0025 #include <QSize>
0026 
0027 using namespace KJSEmbed;
0028 
0029 const KJS::ClassInfo SizeBinding::info = { "QSize", &VariantBinding::info, nullptr, nullptr };
0030 SizeBinding::SizeBinding(KJS::ExecState *exec, const QSize &value)
0031     : VariantBinding(exec, value)
0032 {
0033     StaticBinding::publish(exec, this, Size::methods());
0034     StaticBinding::publish(exec, this, VariantFactory::methods());
0035 }
0036 
0037 namespace SizeNS
0038 {
0039 
0040 START_VARIANT_METHOD(callboundedTo, QSize)
0041 QSize arg0 = KJSEmbed::extractVariant<QSize>(exec, args, 0);
0042 QSize cppValue = value.boundedTo(arg0);
0043 result = KJSEmbed::createVariant(exec, "QSize", cppValue);
0044 END_VARIANT_METHOD
0045 
0046 START_VARIANT_METHOD(callexpandedTo, QSize)
0047 QSize arg0 = KJSEmbed::extractVariant<QSize>(exec, args, 0);
0048 QSize cppValue = value.expandedTo(arg0);
0049 result = KJSEmbed::createVariant(exec, "QSize", cppValue);
0050 END_VARIANT_METHOD
0051 
0052 START_VARIANT_METHOD(callheight, QSize)
0053 int cppValue = value.height();
0054 result = KJS::jsNumber(cppValue);
0055 END_VARIANT_METHOD
0056 
0057 START_VARIANT_METHOD(callisEmpty, QSize)
0058 bool cppValue = value.isEmpty();
0059 result = KJS::jsBoolean(cppValue);
0060 END_VARIANT_METHOD
0061 
0062 START_VARIANT_METHOD(callisNull, QSize)
0063 bool cppValue = value.isNull();
0064 result = KJS::jsBoolean(cppValue);
0065 END_VARIANT_METHOD
0066 
0067 START_VARIANT_METHOD(callisValid, QSize)
0068 bool cppValue = value.isValid();
0069 result = KJS::jsBoolean(cppValue);
0070 END_VARIANT_METHOD
0071 
0072 START_VARIANT_METHOD(callrheight, QSize)
0073 int cppValue = value.rheight();
0074 result = KJS::jsNumber(cppValue);
0075 END_VARIANT_METHOD
0076 
0077 START_VARIANT_METHOD(callrwidth, QSize)
0078 int cppValue = value.rwidth();
0079 result = KJS::jsNumber(cppValue);
0080 END_VARIANT_METHOD
0081 
0082 START_VARIANT_METHOD(callscale, QSize)
0083 if (args.size() == 2)
0084 {
0085     QSize arg0 = KJSEmbed::extractVariant<QSize>(exec, args, 0);
0086     Qt::AspectRatioMode arg1 = (Qt::AspectRatioMode)KJSEmbed::extractInt(exec, args, 1);
0087     value.scale(arg0, arg1);
0088 } else if (args.size() == 3)
0089 {
0090     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0091     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0092     Qt::AspectRatioMode arg2 = (Qt::AspectRatioMode)KJSEmbed::extractInt(exec, args, 2);
0093     value.scale(arg0, arg1, arg2);
0094 }
0095 END_VARIANT_METHOD
0096 
0097 START_VARIANT_METHOD(callsetHeight, QSize)
0098 int arg0 = KJSEmbed::extractInt(exec, args, 0);
0099 value.setHeight(arg0);
0100 END_VARIANT_METHOD
0101 
0102 START_VARIANT_METHOD(callsetWidth, QSize)
0103 int arg0 = KJSEmbed::extractInt(exec, args, 0);
0104 value.setWidth(arg0);
0105 END_VARIANT_METHOD
0106 
0107 START_VARIANT_METHOD(calltranspose, QSize)
0108 value.transpose();
0109 END_VARIANT_METHOD
0110 
0111 START_VARIANT_METHOD(callwidth, QSize)
0112 int cppValue = value.width();
0113 result = KJS::jsNumber(cppValue);
0114 END_VARIANT_METHOD
0115 
0116 }
0117 
0118 START_METHOD_LUT(Size)
0119 {"boundedTo", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callboundedTo},
0120 {"expandedTo", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callexpandedTo},
0121 {"height", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callheight},
0122 {"isEmpty", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callisEmpty},
0123 {"isNull", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callisNull},
0124 {"isValid", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callisValid},
0125 {"rheight", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callrheight},
0126 {"rwidth", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callrwidth},
0127 {"scale", 2, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callscale},
0128 {"setHeight", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callsetHeight},
0129 {"setWidth", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callsetWidth},
0130 {"transpose", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::calltranspose},
0131 {"width", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callwidth}
0132 END_METHOD_LUT
0133 
0134 NO_ENUMS(Size)
0135 NO_STATICS(Size)
0136 
0137 START_CTOR(Size, QSize, 0)
0138 if (args.size() == 0)
0139 {
0140     return new KJSEmbed::SizeBinding(exec, QSize());
0141 } else if (args.size() == 2)
0142 {
0143     return new KJSEmbed::SizeBinding(exec,
0144                                      QSize(KJSEmbed::extractInt(exec, args, 0),
0145                                            KJSEmbed::extractInt(exec, args, 1)
0146                                           ));
0147 }
0148 return new KJSEmbed::SizeBinding(exec, QSize());
0149 END_CTOR
0150