kjsembed
rect.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 "rect.h" 00023 00024 #include <QtCore/QDebug> 00025 #include <QtCore/QRect> 00026 #include <QtCore/QPoint> 00027 #include <QtCore/QSize> 00028 00029 using namespace KJSEmbed; 00030 00031 RectBinding::RectBinding( KJS::ExecState *exec, const QRect &value ) 00032 : VariantBinding(exec, value ) 00033 { 00034 StaticBinding::publish( exec, this, Rect::methods() ); 00035 StaticBinding::publish( exec, this, VariantFactory::methods() ); 00036 } 00037 00038 namespace RectNS 00039 { 00040 00041 START_VARIANT_METHOD( calladjust, QRect ) 00042 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00043 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00044 int arg2 = KJSEmbed::extractInt(exec, args, 2); 00045 int arg3 = KJSEmbed::extractInt(exec, args, 3); 00046 value.adjust(arg0, arg1, arg2, arg3); 00047 END_VARIANT_METHOD 00048 00049 START_VARIANT_METHOD( calladjusted, QRect ) 00050 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00051 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00052 int arg2 = KJSEmbed::extractInt(exec, args, 2); 00053 int arg3 = KJSEmbed::extractInt(exec, args, 3); 00054 QRect cppValue = value.adjusted(arg0, arg1, arg2, arg3); 00055 result = KJSEmbed::createVariant(exec, "QRect", cppValue ); 00056 END_VARIANT_METHOD 00057 00058 START_VARIANT_METHOD( callbottom, QRect ) 00059 int cppValue = value.bottom(); 00060 result = KJS::jsNumber(cppValue); 00061 END_VARIANT_METHOD 00062 00063 START_VARIANT_METHOD( callbottomLeft, QRect ) 00064 QPoint cppValue = value.bottomLeft(); 00065 result = KJSEmbed::createVariant(exec, "QPoint", cppValue ); 00066 END_VARIANT_METHOD 00067 00068 START_VARIANT_METHOD( callbottomRight, QRect ) 00069 QPoint cppValue = value.bottomRight(); 00070 result = KJSEmbed::createVariant(exec, "QPoint", cppValue ); 00071 END_VARIANT_METHOD 00072 00073 START_VARIANT_METHOD( callcenter, QRect ) 00074 QPoint cppValue = value.center(); 00075 result = KJSEmbed::createVariant(exec, "QPoint", cppValue ); 00076 END_VARIANT_METHOD 00077 00078 START_VARIANT_METHOD( callcontains, QRect ) 00079 // 1 00080 if( args.size() == 2 /* && !KJSEmbed::extractVariant<QPoint>(exec,args, 0).isNull() */) 00081 { 00082 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00083 bool arg1 = KJSEmbed::extractBool(exec, args, 1); 00084 bool cppValue = value.contains(arg0, arg1); 00085 result = KJS::jsBoolean(cppValue); 00086 } 00087 //2 00088 else if( args.size() == 3 ) 00089 { 00090 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00091 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00092 bool arg2 = KJSEmbed::extractBool(exec, args, 2); 00093 bool cppValue = value.contains(arg0, arg1, arg2); 00094 result = KJS::jsBoolean(cppValue); 00095 } 00096 // 3 00097 else 00098 { 00099 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00100 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00101 bool cppValue = value.contains(arg0, arg1); 00102 result = KJS::jsBoolean(cppValue); 00103 } 00104 END_VARIANT_METHOD 00105 00106 START_VARIANT_METHOD( callheight, QRect ) 00107 int cppValue = value.height(); 00108 result = KJS::jsNumber(cppValue); 00109 END_VARIANT_METHOD 00110 00111 START_VARIANT_METHOD( callintersect, QRect ) 00112 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0); 00113 QRect cppValue = value.intersect(arg0); 00114 result = KJSEmbed::createVariant(exec, "QRect", cppValue ); 00115 END_VARIANT_METHOD 00116 00117 START_VARIANT_METHOD( callintersects, QRect ) 00118 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0); 00119 bool cppValue = value.intersects(arg0); 00120 result = KJS::jsBoolean(cppValue); 00121 END_VARIANT_METHOD 00122 00123 START_VARIANT_METHOD( callisEmpty, QRect ) 00124 bool cppValue = value.isEmpty(); 00125 result = KJS::jsBoolean(cppValue); 00126 END_VARIANT_METHOD 00127 00128 START_VARIANT_METHOD( callisNull, QRect ) 00129 bool cppValue = value.isNull(); 00130 result = KJS::jsBoolean(cppValue); 00131 END_VARIANT_METHOD 00132 00133 START_VARIANT_METHOD( callisValid, QRect ) 00134 bool cppValue = value.isValid(); 00135 result = KJS::jsBoolean(cppValue); 00136 END_VARIANT_METHOD 00137 00138 START_VARIANT_METHOD( callleft, QRect ) 00139 int cppValue = value.left(); 00140 result = KJS::jsNumber(cppValue); 00141 END_VARIANT_METHOD 00142 00143 START_VARIANT_METHOD( callmoveBottom, QRect ) 00144 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00145 value.moveBottom(arg0); 00146 END_VARIANT_METHOD 00147 00148 START_VARIANT_METHOD( callmoveBottomLeft, QRect ) 00149 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00150 value.moveBottomLeft(arg0); 00151 END_VARIANT_METHOD 00152 00153 START_VARIANT_METHOD( callmoveBottomRight, QRect ) 00154 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00155 value.moveBottomRight(arg0); 00156 END_VARIANT_METHOD 00157 00158 START_VARIANT_METHOD( callmoveCenter, QRect ) 00159 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00160 value.moveCenter(arg0); 00161 END_VARIANT_METHOD 00162 00163 START_VARIANT_METHOD( callmoveLeft, QRect ) 00164 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00165 value.moveLeft(arg0); 00166 END_VARIANT_METHOD 00167 00168 START_VARIANT_METHOD( callmoveRight, QRect ) 00169 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00170 value.moveRight(arg0); 00171 END_VARIANT_METHOD 00172 00173 START_VARIANT_METHOD( callmoveTo, QRect ) 00174 if( args.size() == 1) 00175 { 00176 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00177 value.moveTo(arg0); 00178 } 00179 else 00180 { 00181 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00182 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00183 value.moveTo(arg0, arg1); 00184 } 00185 END_VARIANT_METHOD 00186 00187 START_VARIANT_METHOD( callmoveTop, QRect ) 00188 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00189 value.moveTop(arg0); 00190 END_VARIANT_METHOD 00191 00192 START_VARIANT_METHOD( callmoveTopLeft, QRect ) 00193 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00194 value.moveTopLeft(arg0); 00195 END_VARIANT_METHOD 00196 00197 START_VARIANT_METHOD( callmoveTopRight, QRect ) 00198 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00199 value.moveTopRight(arg0); 00200 END_VARIANT_METHOD 00201 00202 START_VARIANT_METHOD( callnormalized, QRect ) 00203 QRect cppValue = value.normalized(); 00204 result = KJSEmbed::createVariant(exec, "QRect", cppValue ); 00205 END_VARIANT_METHOD 00206 00207 START_VARIANT_METHOD( callright, QRect ) 00208 int cppValue = value.right(); 00209 result = KJS::jsNumber(cppValue); 00210 END_VARIANT_METHOD 00211 00212 START_VARIANT_METHOD( callsetBottom, QRect ) 00213 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00214 value.setBottom(arg0); 00215 END_VARIANT_METHOD 00216 00217 START_VARIANT_METHOD( callsetBottomLeft, QRect ) 00218 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00219 value.setBottomLeft(arg0); 00220 END_VARIANT_METHOD 00221 00222 START_VARIANT_METHOD( callsetBottomRight, QRect ) 00223 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00224 value.setBottomRight(arg0); 00225 END_VARIANT_METHOD 00226 00227 START_VARIANT_METHOD( callsetCoords, QRect ) 00228 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00229 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00230 int arg2 = KJSEmbed::extractInt(exec, args, 2); 00231 int arg3 = KJSEmbed::extractInt(exec, args, 3); 00232 value.setCoords(arg0, arg1, arg2, arg3); 00233 END_VARIANT_METHOD 00234 00235 START_VARIANT_METHOD( callsetHeight, QRect ) 00236 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00237 value.setHeight(arg0); 00238 END_VARIANT_METHOD 00239 00240 START_VARIANT_METHOD( callsetLeft, QRect ) 00241 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00242 value.setLeft(arg0); 00243 END_VARIANT_METHOD 00244 00245 START_VARIANT_METHOD( callsetRect, QRect ) 00246 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00247 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00248 int arg2 = KJSEmbed::extractInt(exec, args, 2); 00249 int arg3 = KJSEmbed::extractInt(exec, args, 3); 00250 value.setRect(arg0, arg1, arg2, arg3); 00251 END_VARIANT_METHOD 00252 00253 START_VARIANT_METHOD( callsetRight, QRect ) 00254 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00255 value.setRight(arg0); 00256 END_VARIANT_METHOD 00257 00258 START_VARIANT_METHOD( callsetSize, QRect ) 00259 QSize arg0 = KJSEmbed::extractVariant<QSize>(exec,args, 0); 00260 value.setSize(arg0); 00261 END_VARIANT_METHOD 00262 00263 START_VARIANT_METHOD( callsetTop, QRect ) 00264 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00265 value.setTop(arg0); 00266 END_VARIANT_METHOD 00267 00268 START_VARIANT_METHOD( callsetTopLeft, QRect ) 00269 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00270 value.setTopLeft(arg0); 00271 END_VARIANT_METHOD 00272 00273 START_VARIANT_METHOD( callsetTopRight, QRect ) 00274 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00275 value.setTopRight(arg0); 00276 END_VARIANT_METHOD 00277 00278 START_VARIANT_METHOD( callsetWidth, QRect ) 00279 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00280 value.setWidth(arg0); 00281 END_VARIANT_METHOD 00282 00283 START_VARIANT_METHOD( callsetX, QRect ) 00284 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00285 value.setX(arg0); 00286 END_VARIANT_METHOD 00287 00288 START_VARIANT_METHOD( callsetY, QRect ) 00289 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00290 value.setY(arg0); 00291 END_VARIANT_METHOD 00292 00293 START_VARIANT_METHOD( callsize, QRect ) 00294 QSize cppValue = value.size(); 00295 result = KJSEmbed::createVariant(exec, "QSize", cppValue ); 00296 END_VARIANT_METHOD 00297 00298 START_VARIANT_METHOD( calltop, QRect ) 00299 int cppValue = value.top(); 00300 result = KJS::jsNumber(cppValue); 00301 END_VARIANT_METHOD 00302 00303 START_VARIANT_METHOD( calltopLeft, QRect ) 00304 QPoint cppValue = value.topLeft(); 00305 result = KJSEmbed::createVariant(exec, "QPoint", cppValue ); 00306 END_VARIANT_METHOD 00307 00308 START_VARIANT_METHOD( calltopRight, QRect ) 00309 QPoint cppValue = value.topRight(); 00310 result = KJSEmbed::createVariant(exec, "QPoint", cppValue ); 00311 END_VARIANT_METHOD 00312 00313 START_VARIANT_METHOD( calltranslate, QRect ) 00314 if( args.size() == 1) 00315 { 00316 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00317 value.translate(arg0); 00318 } 00319 else 00320 { 00321 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00322 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00323 value.translate(arg0, arg1); 00324 } 00325 END_VARIANT_METHOD 00326 00327 START_VARIANT_METHOD( calltranslated, QRect ) 00328 if( args.size() == 1 ) 00329 { 00330 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0); 00331 QRect cppValue = value.translated(arg0); 00332 result = KJSEmbed::createVariant(exec, "QRect", cppValue ); 00333 } 00334 else 00335 { 00336 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00337 int arg1 = KJSEmbed::extractInt(exec, args, 1); 00338 QRect cppValue = value.translated(arg0, arg1); 00339 result = KJSEmbed::createVariant(exec, "QRect", cppValue ); 00340 } 00341 END_VARIANT_METHOD 00342 00343 START_VARIANT_METHOD( callunite, QRect ) 00344 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0); 00345 QRect cppValue = value.unite(arg0); 00346 result = KJSEmbed::createVariant(exec, "QRect", cppValue ); 00347 END_VARIANT_METHOD 00348 00349 START_VARIANT_METHOD( callwidth, QRect ) 00350 int cppValue = value.width(); 00351 result = KJS::jsNumber(cppValue); 00352 END_VARIANT_METHOD 00353 00354 START_VARIANT_METHOD( callx, QRect ) 00355 int cppValue = value.x(); 00356 result = KJS::jsNumber(cppValue); 00357 END_VARIANT_METHOD 00358 00359 START_VARIANT_METHOD( cally, QRect ) 00360 int cppValue = value.y(); 00361 result = KJS::jsNumber(cppValue); 00362 END_VARIANT_METHOD 00363 } 00364 00365 START_METHOD_LUT( Rect ) 00366 {"adjust", 3, KJS::DontDelete|KJS::ReadOnly, &RectNS::calladjust}, 00367 {"adjusted", 3, KJS::DontDelete|KJS::ReadOnly, &RectNS::calladjusted}, 00368 {"bottom", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callbottom}, 00369 {"bottomLeft", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callbottomLeft}, 00370 {"bottomRight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callbottomRight}, 00371 {"center", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callcenter}, 00372 {"contains", 2, KJS::DontDelete|KJS::ReadOnly, &RectNS::callcontains}, 00373 {"height", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callheight}, 00374 {"intersect", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callintersect}, 00375 {"intersects", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callintersects}, 00376 {"isEmpty", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callisEmpty}, 00377 {"isNull", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callisNull}, 00378 {"isValid", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callisValid}, 00379 {"left", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callleft}, 00380 {"moveBottom", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveBottom}, 00381 {"moveBottomLeft", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveBottomLeft}, 00382 {"moveBottomRight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveBottomRight}, 00383 {"moveCenter", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveCenter}, 00384 {"moveLeft", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveLeft}, 00385 {"moveRight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveRight}, 00386 {"moveTo", 1, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveTo}, 00387 {"moveTop", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveTop}, 00388 {"moveTopLeft", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveTopLeft}, 00389 {"moveTopRight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callmoveTopRight}, 00390 {"normalized", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callnormalized}, 00391 {"right", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callright}, 00392 {"setBottom", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetBottom}, 00393 {"setBottomLeft", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetBottomLeft}, 00394 {"setBottomRight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetBottomRight}, 00395 {"setCoords", 3, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetCoords}, 00396 {"setHeight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetHeight}, 00397 {"setLeft", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetLeft}, 00398 {"setRect", 3, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetRect}, 00399 {"setRight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetRight}, 00400 {"setSize", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetSize}, 00401 {"setTop", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetTop}, 00402 {"setTopLeft", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetTopLeft}, 00403 {"setTopRight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetTopRight}, 00404 {"setWidth", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetWidth}, 00405 {"setX", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetX}, 00406 {"setY", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsetY}, 00407 {"size", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callsize}, 00408 {"top", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::calltop}, 00409 {"topLeft", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::calltopLeft}, 00410 {"topRight", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::calltopRight}, 00411 {"translate", 1, KJS::DontDelete|KJS::ReadOnly, &RectNS::calltranslate}, 00412 {"translated", 1, KJS::DontDelete|KJS::ReadOnly, &RectNS::calltranslated}, 00413 {"unite", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callunite}, 00414 {"width", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callwidth}, 00415 {"x", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::callx}, 00416 {"y", 0, KJS::DontDelete|KJS::ReadOnly, &RectNS::cally} 00417 END_METHOD_LUT 00418 00419 NO_ENUMS( Rect ) 00420 NO_STATICS( Rect ) 00421 00422 START_CTOR( Rect, QRect, 0) 00423 if( args.size() == 2 ) 00424 { 00425 /* 00426 return KJSEmbed::RectBinding( exec, 00427 QRect( KJSEmbed::extractQString(exec,args,0 ) ) ); 00428 */ 00429 } 00430 else if( args.size() == 4 ) 00431 { 00432 return new KJSEmbed::RectBinding(exec, 00433 QRect( KJSEmbed::extractInt( exec, args, 0 ), 00434 KJSEmbed::extractInt( exec, args, 1 ), 00435 KJSEmbed::extractInt( exec, args, 2 ), 00436 KJSEmbed::extractInt( exec, args, 3 ) 00437 ) ); 00438 } 00439 00440 return new KJSEmbed::RectBinding( exec, QRect() ); 00441 END_CTOR 00442 00443 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KDE 4.6 API Reference