File indexing completed on 2024-05-19 11:43:19

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 "qpainter_binding.h"
0023 #include "object_binding.h"
0024 #include "static_binding.h"
0025 #include "kjseglobal.h"
0026 
0027 #include <kjs/object.h>
0028 #include <QDebug>
0029 
0030 #include <QWidget>
0031 #include <QPainter>
0032 #include <QImage>
0033 #include <QPixmap>
0034 #include <QPen>
0035 #include <QBrush>
0036 #include <QLine>
0037 #include <QPolygon>
0038 #include <QPoint>
0039 
0040 #include <QFrame>
0041 
0042 using namespace KJSEmbed;
0043 
0044 QPaintDevice *extractPaintDevice(KJS::ExecState *exec, KJS::JSValue *arg)
0045 {
0046     QPaintDevice *device = nullptr;
0047 
0048     ObjectBinding *imp = extractBindingImp<ObjectBinding>(exec, arg);
0049     if (imp) {
0050 #ifdef __GNUC__
0051 #warning There be dragons here...
0052 #endif
0053         /**
0054          * Because of something odd with multiple inheritance and qobject cast
0055          * we need to first cast it to a QObject, then cast it to a QWidget.
0056          * All other paint devices in Qt that are objects are single inheritance
0057          * so dynamic_cast will work properly.
0058          */
0059         QObject *qobject = imp->object<QObject>();
0060         if (qobject) {
0061             device = qobject_cast<QWidget *>(qobject);
0062         } else {
0063             device = imp->object<QPaintDevice>();
0064         }
0065 
0066         if (device) {
0067             qDebug("Height = %d Width = %d", device->height(), device->width());
0068         }
0069     } else {
0070         VariantBinding *valueImp = extractBindingImp<VariantBinding>(exec, arg);
0071         if (valueImp && (valueImp->variant().type() == QVariant::Pixmap ||
0072                          valueImp->variant().type() == QVariant::Image)) {
0073             device = static_cast<QPaintDevice *>(valueImp->pointer());
0074         }
0075     }
0076     return device;
0077 }
0078 
0079 START_OBJECT_METHOD(callPainterBegin, QPainter)
0080 result = KJS::jsBoolean(false);
0081 QPaintDevice *device = extractPaintDevice(exec, args[0]);
0082 if (device)
0083 {
0084     result = KJS::jsBoolean(object->begin(device));
0085 } else
0086 {
0087     result = KJS::jsBoolean(false);
0088 }
0089 END_OBJECT_METHOD
0090 
0091 START_OBJECT_METHOD(callPainterEnd, QPainter)
0092 result = KJS::jsBoolean(object->end());
0093 END_OBJECT_METHOD
0094 
0095 START_OBJECT_METHOD(callbackground, QPainter)
0096 QBrush cppValue = object->background();
0097 result = KJSEmbed::createVariant(exec, "QBrush", cppValue);
0098 END_OBJECT_METHOD
0099 
0100 START_OBJECT_METHOD(callbackgroundMode, QPainter)
0101 Qt::BGMode cppValue = object->backgroundMode();
0102 result = KJS::jsNumber(cppValue);
0103 END_OBJECT_METHOD
0104 
0105 START_OBJECT_METHOD(callboundingRect, QPainter)
0106 if (args.size() == 3)
0107 {
0108     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0109     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0110     QString arg2 = KJSEmbed::extractQString(exec, args, 2);
0111     QRect cppValue = object->boundingRect(arg0, arg1, arg2);
0112     result = KJSEmbed::createVariant(exec, "QRect", cppValue);
0113 } else if (args.size() == 6)
0114 {
0115     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0116     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0117     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0118     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0119     int arg4 = KJSEmbed::extractInt(exec, args, 4);
0120     QString arg5 = KJSEmbed::extractQString(exec, args, 5);
0121     QRect cppValue = object->boundingRect(arg0, arg1, arg2, arg3, arg4, arg5);
0122     result = KJSEmbed::createVariant(exec, "QRect", cppValue);
0123 }
0124 END_OBJECT_METHOD
0125 
0126 START_OBJECT_METHOD(callbrush, QPainter)
0127 QBrush cppValue = object->brush();
0128 result = KJSEmbed::createVariant(exec, "QBrush", cppValue);
0129 END_OBJECT_METHOD
0130 
0131 START_OBJECT_METHOD(callbrushOrigin, QPainter)
0132 QPoint cppValue = object->brushOrigin();
0133 result = KJSEmbed::createVariant(exec, "QPoint", cppValue);
0134 END_OBJECT_METHOD
0135 
0136 START_OBJECT_METHOD(calldrawArc, QPainter)
0137 if (args.size() == 3)
0138 {
0139     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0140     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0141     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0142     object->drawArc(arg0, arg1, arg2);
0143 } else if (args.size() == 6)
0144 {
0145     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0146     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0147     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0148     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0149     int arg4 = KJSEmbed::extractInt(exec, args, 4);
0150     int arg5 = KJSEmbed::extractInt(exec, args, 5);
0151     object->drawArc(arg0, arg1, arg2, arg3, arg4, arg5);
0152 }
0153 END_OBJECT_METHOD
0154 
0155 START_OBJECT_METHOD(calldrawChord, QPainter)
0156 if (args.size() == 3)
0157 {
0158     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0159     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0160     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0161     object->drawChord(arg0, arg1, arg2);
0162 } else if (args.size() == 6)
0163 {
0164     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0165     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0166     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0167     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0168     int arg4 = KJSEmbed::extractInt(exec, args, 4);
0169     int arg5 = KJSEmbed::extractInt(exec, args, 5);
0170     object->drawChord(arg0, arg1, arg2, arg3, arg4, arg5);
0171 }
0172 END_OBJECT_METHOD
0173 
0174 START_OBJECT_METHOD(calldrawConvexPolygon, QPainter)
0175 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec, args, 0);
0176 object->drawConvexPolygon(arg0);
0177 END_OBJECT_METHOD
0178 
0179 START_OBJECT_METHOD(calldrawEllipse, QPainter)
0180 if (args.size() == 4)
0181 {
0182     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0183     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0184     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0185     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0186     object->drawEllipse(arg0, arg1, arg2, arg3);
0187 } else if (args.size() == 1)
0188 {
0189     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0190     object->drawEllipse(arg0);
0191 }
0192 END_OBJECT_METHOD
0193 
0194 START_OBJECT_METHOD(calldrawImage, QPainter)
0195 if (args.size() == 2)
0196 {
0197     QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
0198     QImage arg1 = KJSEmbed::extractVariant<QImage>(exec, args, 1);
0199     object->drawImage(arg0, arg1);
0200 } else if (args.size() == 4)
0201 {
0202     QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
0203     QImage arg1 = KJSEmbed::extractVariant<QImage>(exec, args, 1);
0204     QRect arg2 = KJSEmbed::extractVariant<QRect>(exec, args, 2);
0205     Qt::ImageConversionFlags arg3 = (Qt::ImageConversionFlags)KJSEmbed::extractInt(exec, args, 3);
0206     object->drawImage(arg0, arg1, arg2, arg3);
0207 } else if (args.size() == 8)
0208 {
0209     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0210     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0211     QImage arg2 = KJSEmbed::extractVariant<QImage>(exec, args, 2);
0212     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0213     int arg4 = KJSEmbed::extractInt(exec, args, 4);
0214     int arg5 = KJSEmbed::extractInt(exec, args, 5);
0215     int arg6 = KJSEmbed::extractInt(exec, args, 6);
0216     Qt::ImageConversionFlags arg7 = (Qt::ImageConversionFlags)KJSEmbed::extractInt(exec, args, 7);
0217     object->drawImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
0218 }
0219 END_OBJECT_METHOD
0220 
0221 START_OBJECT_METHOD(calldrawLine, QPainter)
0222 if (args.size() == 1)
0223 {
0224     QLine arg0 = KJSEmbed::extractVariant<QLine>(exec, args, 0);
0225     object->drawLine(arg0);
0226 } else if (args.size() == 2)
0227 {
0228     QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
0229     QPoint arg1 = KJSEmbed::extractVariant<QPoint>(exec, args, 1);
0230     object->drawLine(arg0, arg1);
0231 } else if (args.size() == 4)
0232 {
0233     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0234     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0235     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0236     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0237     object->drawLine(arg0, arg1, arg2, arg3);
0238 }
0239 END_OBJECT_METHOD
0240 
0241 START_OBJECT_METHOD(calldrawPie, QPainter)
0242 if (args.size() == 3)
0243 {
0244     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0245     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0246     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0247     object->drawPie(arg0, arg1, arg2);
0248 } else if (args.size() == 6)
0249 {
0250     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0251     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0252     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0253     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0254     int arg4 = KJSEmbed::extractInt(exec, args, 4);
0255     int arg5 = KJSEmbed::extractInt(exec, args, 5);
0256     object->drawPie(arg0, arg1, arg2, arg3, arg4, arg5);
0257 }
0258 END_OBJECT_METHOD
0259 
0260 START_OBJECT_METHOD(calldrawPixmap, QPainter)
0261 if (args.size() == 2)
0262 {
0263     QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
0264     QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
0265     object->drawPixmap(arg0, arg1);
0266 } else if (args.size() == 3)
0267 {
0268     QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
0269     QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
0270     QRect arg2 = KJSEmbed::extractVariant<QRect>(exec, args, 2);
0271     object->drawPixmap(arg0, arg1, arg2);
0272 }
0273 END_OBJECT_METHOD
0274 
0275 START_OBJECT_METHOD(calldrawPoint, QPainter)
0276 if (args.size() == 1)
0277 {
0278     QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
0279     object->drawPoint(arg0);
0280 } else if (args.size() == 2)
0281 {
0282     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0283     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0284     object->drawPoint(arg0, arg1);
0285 }
0286 END_OBJECT_METHOD
0287 
0288 START_OBJECT_METHOD(calldrawPoints, QPainter)
0289 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec, args, 0);
0290 object->drawPoints(arg0);
0291 END_OBJECT_METHOD
0292 
0293 START_OBJECT_METHOD(calldrawPolygon, QPainter)
0294 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec, args, 0);
0295 Qt::FillRule arg1 = (Qt::FillRule)KJSEmbed::extractInt(exec, args, 1,  Qt::OddEvenFill);
0296 object->drawPolygon(arg0, arg1);
0297 END_OBJECT_METHOD
0298 
0299 START_OBJECT_METHOD(calldrawPolyline, QPainter)
0300 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec, args, 0);
0301 object->drawPolyline(arg0);
0302 END_OBJECT_METHOD
0303 
0304 START_OBJECT_METHOD(calldrawRect, QPainter)
0305 if (args.size() == 1)
0306 {
0307     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0308     object->drawRect(arg0);
0309 } else if (args.size() == 4)
0310 {
0311     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0312     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0313     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0314     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0315     object->drawRect(arg0, arg1, arg2, arg3);
0316 }
0317 END_OBJECT_METHOD
0318 
0319 START_OBJECT_METHOD(calldrawRoundRect, QPainter)
0320 if (args.size() == 2)
0321 {
0322     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0323     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0324     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0325     object->drawRoundRect(arg0, arg1, arg2);
0326 } else if (args.size() == 6)
0327 {
0328     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0329     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0330     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0331     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0332     int arg4 = KJSEmbed::extractInt(exec, args, 4);
0333     int arg5 = KJSEmbed::extractInt(exec, args, 5);
0334     object->drawRoundRect(arg0, arg1, arg2, arg3, arg4, arg5);
0335 }
0336 END_OBJECT_METHOD
0337 
0338 START_OBJECT_METHOD(calldrawText, QPainter)
0339 if (args.size() == 2)
0340 {
0341     QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
0342     QString arg1 = KJSEmbed::extractQString(exec, args, 1);
0343     object->drawText(arg0, arg1);
0344 } else if (args.size() == 3)
0345 {
0346     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0347     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0348     QString arg2 = KJSEmbed::extractQString(exec, args, 2);
0349     QRect *arg3 = nullptr;
0350     object->drawText(arg0, arg1, arg2, arg3);
0351 } else if (args.size() == 6)
0352 {
0353     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0354     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0355     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0356     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0357     int arg4 = KJSEmbed::extractInt(exec, args, 4);
0358     QString arg5 = KJSEmbed::extractQString(exec, args, 5);
0359     QRect *arg6 = nullptr;
0360     object->drawText(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
0361 }
0362 END_OBJECT_METHOD
0363 
0364 START_OBJECT_METHOD(calltranslate, QPainter)
0365 if (args.size() == 2)
0366 {
0367     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0368     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0369     object->translate(arg0, arg1);
0370 } else if (args.size() == 1)
0371 {
0372     QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
0373     object->translate(arg0);
0374 }
0375 END_OBJECT_METHOD
0376 
0377 START_OBJECT_METHOD(calldrawTiledPixmap, QPainter)
0378 if (args.size() == 3)
0379 {
0380     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0381     QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
0382     QPoint arg2 = KJSEmbed::extractVariant<QPoint>(exec, args, 2);
0383     object->drawTiledPixmap(arg0, arg1, arg2);
0384 } else if (args.size() == 7)
0385 {
0386     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0387     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0388     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0389     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0390     QPixmap arg4 = KJSEmbed::extractVariant<QPixmap>(exec, args, 4);
0391     int arg5 = KJSEmbed::extractInt(exec, args, 5);
0392     int arg6 = KJSEmbed::extractInt(exec, args, 6);
0393     object->drawTiledPixmap(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
0394 }
0395 END_OBJECT_METHOD
0396 
0397 START_OBJECT_METHOD(calleraseRect, QPainter)
0398 if (args.size() == 4)
0399 {
0400     int arg0 = KJSEmbed::extractInt(exec, args, 0);
0401     int arg1 = KJSEmbed::extractInt(exec, args, 1);
0402     int arg2 = KJSEmbed::extractInt(exec, args, 2);
0403     int arg3 = KJSEmbed::extractInt(exec, args, 3);
0404     object->eraseRect(arg0, arg1, arg2, arg3);
0405 } else if (args.size() == 1)
0406 {
0407     QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
0408     object->eraseRect(arg0);
0409 }
0410 END_OBJECT_METHOD
0411 
0412 START_METHOD_LUT(Painter)
0413 {"begin", 1, KJS::DontDelete | KJS::ReadOnly, &callPainterBegin },
0414 {"end", 0, KJS::DontDelete | KJS::ReadOnly, &callPainterEnd },
0415 {"background", 0, KJS::DontDelete | KJS::ReadOnly, &callbackground},
0416 {"backgroundMode", 0, KJS::DontDelete | KJS::ReadOnly, &callbackgroundMode},
0417 {"boundingRect", 6, KJS::DontDelete | KJS::ReadOnly, &callboundingRect},
0418 {"brush", 0, KJS::DontDelete | KJS::ReadOnly, &callbrush},
0419 {"brushOrigin", 0, KJS::DontDelete | KJS::ReadOnly, &callbrushOrigin},
0420 {"drawArc", 6, KJS::DontDelete | KJS::ReadOnly, &calldrawArc},
0421 {"drawChord", 6, KJS::DontDelete | KJS::ReadOnly, &calldrawChord},
0422 {"drawConvexPolygon", 1, KJS::DontDelete | KJS::ReadOnly, &calldrawConvexPolygon},
0423 {"drawEllipse", 3, KJS::DontDelete | KJS::ReadOnly, &calldrawEllipse},
0424 {"drawImage", 7, KJS::DontDelete | KJS::ReadOnly, &calldrawImage},
0425 {"drawLine", 3, KJS::DontDelete | KJS::ReadOnly, &calldrawLine},
0426 //{drawLines", 1, KJS::DontDelete|KJS::ReadOnly, &calldrawLines},
0427 //{"drawPath", 0, KJS::DontDelete|KJS::ReadOnly, &calldrawPath},
0428 //{"drawPicture", 2, KJS::DontDelete|KJS::ReadOnly, &calldrawPicture},
0429 {"drawPie", 6, KJS::DontDelete | KJS::ReadOnly, &calldrawPie},
0430 {"drawPixmap", 8, KJS::DontDelete | KJS::ReadOnly, &calldrawPixmap},
0431 {"drawPoint", 2, KJS::DontDelete | KJS::ReadOnly, &calldrawPoint},
0432 {"drawPoints", 1, KJS::DontDelete | KJS::ReadOnly, &calldrawPoints},
0433 {"drawPolygon", 2, KJS::DontDelete | KJS::ReadOnly, &calldrawPolygon},
0434 {"drawPolyline", 1, KJS::DontDelete | KJS::ReadOnly, &calldrawPolyline},
0435 {"drawRect", 4, KJS::DontDelete | KJS::ReadOnly, &calldrawRect},
0436 //{"drawRects", 0, KJS::DontDelete|KJS::ReadOnly, &calldrawRects},
0437 {"drawRoundRect", 5, KJS::DontDelete | KJS::ReadOnly, &calldrawRoundRect},
0438 {"drawText", 7, KJS::DontDelete | KJS::ReadOnly, &calldrawText},
0439 {"drawTiledPixmap", 3, KJS::DontDelete | KJS::ReadOnly, &calldrawTiledPixmap},
0440 {"eraseRect", 1, KJS::DontDelete | KJS::ReadOnly, &calleraseRect},
0441 //{"fillPath", 1, KJS::DontDelete|KJS::ReadOnly, &callfillPath},
0442 //{"fillRect", 4, KJS::DontDelete|KJS::ReadOnly, &callfillRect},
0443 //{"font", 0, KJS::DontDelete|KJS::ReadOnly, &callfont},
0444 //{"hasClipping", 0, KJS::DontDelete|KJS::ReadOnly, &callhasClipping},
0445 //{"isActive", 0, KJS::DontDelete|KJS::ReadOnly, &callisActive},
0446 //{"pen", 0, KJS::DontDelete|KJS::ReadOnly, &callpen},
0447 //{"renderHints", 0, KJS::DontDelete|KJS::ReadOnly, &callrenderHints},
0448 //{"restore", 0, KJS::DontDelete|KJS::ReadOnly, &callrestore},
0449 //{"rotate", 0, KJS::DontDelete|KJS::ReadOnly, &callrotate},
0450 //{"save", 0, KJS::DontDelete|KJS::ReadOnly, &callsave},
0451 //{"scale", 1, KJS::DontDelete|KJS::ReadOnly, &callscale},
0452 //{"setBackground", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackground},
0453 //{"setBackgroundColor", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackgroundColor},
0454 //{"setBackgroundMode", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackgroundMode},
0455 //{"setBrush", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBrush},
0456 //{"setBrushOrigin", 1, KJS::DontDelete|KJS::ReadOnly, &callsetBrushOrigin},
0457 //{"setClipPath", 1, KJS::DontDelete|KJS::ReadOnly, &callsetClipPath},
0458 //{"setClipRect", 4, KJS::DontDelete|KJS::ReadOnly, &callsetClipRect},
0459 //{"setClipRegion", 1, KJS::DontDelete|KJS::ReadOnly, &callsetClipRegion},
0460 //{"setClipping", 0, KJS::DontDelete|KJS::ReadOnly, &callsetClipping},
0461 //{"setFont", 1, KJS::DontDelete|KJS::ReadOnly, &callsetFont},
0462 //{"setPen", 1, KJS::DontDelete|KJS::ReadOnly, &callsetPen},
0463 //{"setRenderHint", 1, KJS::DontDelete|KJS::ReadOnly, &callsetRenderHint},
0464 //{"shear", 2, KJS::DontDelete|KJS::ReadOnly, &callshear},
0465 //{"strokePath", 1, KJS::DontDelete|KJS::ReadOnly, &callstrokePath},
0466 {"translate", 1, KJS::DontDelete | KJS::ReadOnly, &calltranslate}
0467 END_METHOD_LUT
0468 
0469 NO_ENUMS(Painter)
0470 NO_STATICS(Painter)
0471 
0472 START_CTOR(Painter, QPainter, 0)
0473 KJS::JSObject *object;
0474 
0475 if (args.size() == 1)
0476 {
0477     QPaintDevice *device = extractPaintDevice(exec, args[0]);
0478     if (device) {
0479         object = new KJSEmbed::ObjectBinding(exec, "Painter", new QPainter(device));
0480     } else {
0481         KJS::throwError(exec, KJS::EvalError, QString("Cannot paint to object %1").arg(toQString(args[0]->toString(exec))));
0482         return nullptr;
0483     }
0484 } else
0485 {
0486     object = new KJSEmbed::ObjectBinding(exec, "Painter", new QPainter());
0487 }
0488 
0489 StaticBinding::publish(exec, object, ObjectFactory::methods());
0490 StaticBinding::publish(exec, object, Painter::methods());
0491 return object;
0492 END_CTOR
0493