kjsembed
size.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org> 00003 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com> 00004 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org> 00005 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 #include "size.h" 00023 00024 #include <QtCore/QDebug> 00025 #include <QtCore/QSize> 00026 00027 using namespace KJSEmbed; 00028 00029 const KJS::ClassInfo SizeBinding::info = { "QSize", &VariantBinding::info, 0, 0 }; 00030 SizeBinding::SizeBinding( KJS::ExecState *exec, const QSize &value ) 00031 : VariantBinding(exec, value ) 00032 { 00033 StaticBinding::publish( exec, this, Size::methods() ); 00034 StaticBinding::publish( exec, this, VariantFactory::methods() ); 00035 } 00036 00037 namespace SizeNS 00038 { 00039 00040 START_VARIANT_METHOD( callboundedTo, QSize ) 00041 QSize arg0 = KJSEmbed::extractVariant<QSize>(exec,args, 0); 00042 QSize cppValue = value.boundedTo(arg0); 00043 result = KJSEmbed::createVariant(exec, "QSize", cppValue ); 00044 END_VARIANT_METHOD 00045 00046 START_VARIANT_METHOD( callexpandedTo, QSize ) 00047 QSize arg0 = KJSEmbed::extractVariant<QSize>(exec,args, 0); 00048 QSize cppValue = value.expandedTo(arg0); 00049 result = KJSEmbed::createVariant(exec, "QSize", cppValue ); 00050 END_VARIANT_METHOD 00051 00052 START_VARIANT_METHOD( callheight, QSize ) 00053 int cppValue = value.height(); 00054 result = KJS::jsNumber(cppValue); 00055 END_VARIANT_METHOD 00056 00057 START_VARIANT_METHOD( callisEmpty, QSize ) 00058 bool cppValue = value.isEmpty(); 00059 result = KJS::jsBoolean(cppValue); 00060 END_VARIANT_METHOD 00061 00062 START_VARIANT_METHOD( callisNull, QSize ) 00063 bool cppValue = value.isNull(); 00064 result = KJS::jsBoolean(cppValue); 00065 END_VARIANT_METHOD 00066 00067 START_VARIANT_METHOD( callisValid, QSize ) 00068 bool cppValue = value.isValid(); 00069 result = KJS::jsBoolean(cppValue); 00070 END_VARIANT_METHOD 00071 00072 START_VARIANT_METHOD( callrheight, QSize ) 00073 int cppValue = value.rheight(); 00074 result = KJS::jsNumber(cppValue); 00075 END_VARIANT_METHOD 00076 00077 START_VARIANT_METHOD( callrwidth, QSize ) 00078 int cppValue = value.rwidth(); 00079 result = KJS::jsNumber(cppValue); 00080 END_VARIANT_METHOD 00081 00082 START_VARIANT_METHOD( callscale, QSize ) 00083 if( args.size() == 2 ) 00084 { 00085 QSize arg0 = KJSEmbed::extractVariant<QSize>(exec,args, 0); 00086 Qt::AspectRatioMode arg1 = (Qt::AspectRatioMode)KJSEmbed::extractInt(exec, args, 1); 00087 value.scale(arg0, arg1); 00088 } 00089 else if( args.size() == 3 ) 00090 { 00091 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00092 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00093 Qt::AspectRatioMode arg2 = (Qt::AspectRatioMode)KJSEmbed::extractInt(exec, args, 2); 00094 value.scale(arg0, arg1, arg2); 00095 } 00096 END_VARIANT_METHOD 00097 00098 START_VARIANT_METHOD( callsetHeight, QSize ) 00099 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00100 value.setHeight(arg0); 00101 END_VARIANT_METHOD 00102 00103 START_VARIANT_METHOD( callsetWidth, QSize ) 00104 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00105 value.setWidth(arg0); 00106 END_VARIANT_METHOD 00107 00108 START_VARIANT_METHOD( calltranspose, QSize ) 00109 value.transpose(); 00110 END_VARIANT_METHOD 00111 00112 START_VARIANT_METHOD( callwidth, QSize ) 00113 int cppValue = value.width(); 00114 result = KJS::jsNumber(cppValue); 00115 END_VARIANT_METHOD 00116 00117 } 00118 00119 START_METHOD_LUT( Size ) 00120 {"boundedTo", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callboundedTo}, 00121 {"expandedTo", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callexpandedTo}, 00122 {"height", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callheight}, 00123 {"isEmpty", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callisEmpty}, 00124 {"isNull", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callisNull}, 00125 {"isValid", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callisValid}, 00126 {"rheight", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callrheight}, 00127 {"rwidth", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callrwidth}, 00128 {"scale", 2, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callscale}, 00129 {"setHeight", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callsetHeight}, 00130 {"setWidth", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callsetWidth}, 00131 {"transpose", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::calltranspose}, 00132 {"width", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callwidth} 00133 END_METHOD_LUT 00134 00135 NO_ENUMS( Size ) 00136 NO_STATICS( Size ) 00137 00138 START_CTOR( Size, QSize, 0) 00139 if( args.size() == 0 ) 00140 { 00141 return new KJSEmbed::SizeBinding( exec, QSize() ); 00142 } 00143 else if( args.size() == 2 ) 00144 { 00145 return new KJSEmbed::SizeBinding(exec, 00146 QSize( KJSEmbed::extractInt( exec, args, 0 ), 00147 KJSEmbed::extractInt( exec, args, 1 ) 00148 ) ); 00149 } 00150 return new KJSEmbed::SizeBinding( exec, QSize() ); 00151 END_CTOR 00152 00153 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle; 00154
KDE 4.6 API Reference