27 #include <kjs/object.h>
28 #include <QtCore/QDebug>
30 #include <QtGui/QWidget>
31 #include <QtGui/QPainter>
32 #include <QtGui/QImage>
33 #include <QtGui/QPixmap>
35 #include <QtGui/QBrush>
36 #include <QtCore/QLine>
37 #include <QtGui/QPolygon>
38 #include <QtCore/QPoint>
40 #include <QtGui/QFrame>
42 using namespace KJSEmbed;
48 ObjectBinding *imp = extractBindingImp<ObjectBinding>(exec,arg);
52 #warning There be dragons here...
62 device = qobject_cast<
QWidget*>(qobject);
64 device = imp->
object<QPaintDevice>();
67 qDebug(
"Height = %d Width = %d", device->height(), device->width() );
71 VariantBinding *valueImp = extractBindingImp<VariantBinding>(exec,arg);
72 if( valueImp && (valueImp->
variant().type() == QVariant::Pixmap ||
73 valueImp->
variant().type() == QVariant::Image ))
75 device =
static_cast<QPaintDevice*
>( valueImp->
pointer() );
88 result = KJS::jsBoolean(
false);
93 result = KJS::jsBoolean(
object->end());
102 Qt::BGMode cppValue =
object->backgroundMode();
103 result = KJS::jsNumber(cppValue);
107 if( args.size() == 3 )
109 QRect
arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
112 QRect cppValue =
object->boundingRect(arg0, arg1, arg2);
115 else if( args.size() == 6)
123 QRect
cppValue =
object->boundingRect(arg0, arg1, arg2, arg3, arg4, arg5);
129 QBrush cppValue =
object->brush();
134 QPoint cppValue =
object->brushOrigin();
139 if( args.size() == 3 )
141 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
144 object->drawArc(arg0, arg1, arg2);
146 else if( args.size() == 6 )
154 object->drawArc(arg0, arg1, arg2, arg3, arg4, arg5);
159 if( args.size() == 3 )
161 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
164 object->drawChord(arg0, arg1, arg2);
166 else if ( args.size() == 6 )
174 object->drawChord(arg0, arg1, arg2, arg3, arg4, arg5);
184 if ( args.size() == 4 )
190 object->drawEllipse(arg0, arg1, arg2, arg3);
192 else if ( args.size() == 1 )
194 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
195 object->drawEllipse(arg0);
200 if ( args.size() == 2 )
202 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
203 QImage arg1 = KJSEmbed::extractVariant<QImage>(exec,args, 1);
204 object->drawImage(arg0, arg1);
206 else if ( args.size() == 4 )
208 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
209 QImage arg1 = KJSEmbed::extractVariant<QImage>(exec,args, 1);
210 QRect arg2 = KJSEmbed::extractVariant<QRect>(exec,args, 2);
212 object->drawImage(arg0, arg1, arg2, arg3);
214 else if ( args.size() == 8 )
218 QImage arg2 = KJSEmbed::extractVariant<QImage>(exec,args, 2);
224 object->drawImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
229 if( args.size() == 1 )
231 QLine arg0 = KJSEmbed::extractVariant<QLine>(exec,args, 0);
232 object->drawLine(arg0);
234 else if ( args.size() == 2 )
236 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
237 QPoint arg1 = KJSEmbed::extractVariant<QPoint>(exec,args, 1);
238 object->drawLine(arg0, arg1);
240 else if ( args.size() == 4 )
246 object->drawLine(arg0, arg1, arg2, arg3);
251 if( args.size() == 3 )
253 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
256 object->drawPie(arg0, arg1, arg2);
258 else if (args.size() == 6 )
266 object->drawPie(arg0, arg1, arg2, arg3, arg4, arg5);
271 if ( args.size() == 2)
273 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
274 QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec,args, 1);
275 object->drawPixmap(arg0, arg1);
277 else if ( args.size() == 3 )
279 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
280 QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec,args, 1);
281 QRect arg2 = KJSEmbed::extractVariant<QRect>(exec,args, 2);
282 object->drawPixmap(arg0, arg1, arg2);
287 if( args.size() == 1 )
289 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
290 object->drawPoint(arg0);
292 else if (args.size() == 2 )
296 object->drawPoint(arg0, arg1);
307 Qt::FillRule arg1 = (Qt::FillRule)KJSEmbed::
extractInt(exec, args, 1, Qt::OddEvenFill );
317 if (args.size() == 1 )
319 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
320 object->drawRect(arg0);
322 else if ( args.size() == 4 )
328 object->drawRect(arg0, arg1, arg2, arg3);
333 if ( args.size() == 2 )
335 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
338 object->drawRoundRect(arg0, arg1, arg2);
340 else if ( args.size() == 6 )
348 object->drawRoundRect(arg0, arg1, arg2, arg3, arg4, arg5);
353 if( args.size() == 2 )
355 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
357 object->drawText(arg0, arg1);
359 else if ( args.size() == 3 )
361 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
365 object->drawText(arg0, arg1, arg2, arg3);
367 else if ( args.size () == 6 )
376 object->drawText(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
381 if( args.size() == 2 )
385 object->translate(arg0,arg1);
387 else if( args.size() == 1 )
389 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
390 object->translate(arg0);
395 if( args.size() == 3 )
397 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
398 QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec,args, 1);
399 QPoint arg2 = KJSEmbed::extractVariant<QPoint>(exec,args, 2);
400 object->drawTiledPixmap(arg0,arg1,arg2);
402 else if( args.size() == 7)
408 QPixmap arg4 = KJSEmbed::extractVariant<QPixmap>(exec,args, 4);
411 object->drawTiledPixmap(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
416 if( args.size() == 4)
422 object->eraseRect(arg0,arg1,arg2,arg3);
424 else if (args.size() == 1 )
426 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
427 object->eraseRect(arg0);
432 {
"begin", 1, KJS::DontDelete|KJS::ReadOnly, &callPainterBegin },
433 {
"end", 0, KJS::DontDelete|KJS::ReadOnly, &callPainterEnd },
434 {
"background", 0, KJS::DontDelete|KJS::ReadOnly, &callbackground},
435 {
"backgroundMode", 0, KJS::DontDelete|KJS::ReadOnly, &callbackgroundMode},
436 {
"boundingRect", 6, KJS::DontDelete|KJS::ReadOnly, &callboundingRect},
437 {
"brush", 0, KJS::DontDelete|KJS::ReadOnly, &callbrush},
438 {
"brushOrigin", 0, KJS::DontDelete|KJS::ReadOnly, &callbrushOrigin},
439 {
"drawArc", 6, KJS::DontDelete|KJS::ReadOnly, &calldrawArc},
440 {
"drawChord", 6, KJS::DontDelete|KJS::ReadOnly, &calldrawChord},
441 {
"drawConvexPolygon", 1, KJS::DontDelete|KJS::ReadOnly, &calldrawConvexPolygon},
442 {
"drawEllipse", 3, KJS::DontDelete|KJS::ReadOnly, &calldrawEllipse},
443 {
"drawImage", 7, KJS::DontDelete|KJS::ReadOnly, &calldrawImage},
444 {
"drawLine", 3, KJS::DontDelete|KJS::ReadOnly, &calldrawLine},
448 {
"drawPie", 6, KJS::DontDelete|KJS::ReadOnly, &calldrawPie},
449 {
"drawPixmap", 8, KJS::DontDelete|KJS::ReadOnly, &calldrawPixmap},
450 {
"drawPoint", 2, KJS::DontDelete|KJS::ReadOnly, &calldrawPoint},
451 {
"drawPoints", 1, KJS::DontDelete|KJS::ReadOnly, &calldrawPoints},
452 {
"drawPolygon", 2, KJS::DontDelete|KJS::ReadOnly, &calldrawPolygon},
453 {
"drawPolyline", 1, KJS::DontDelete|KJS::ReadOnly, &calldrawPolyline},
454 {
"drawRect", 4, KJS::DontDelete|KJS::ReadOnly, &calldrawRect},
456 {
"drawRoundRect", 5, KJS::DontDelete|KJS::ReadOnly, &calldrawRoundRect},
457 {
"drawText", 7, KJS::DontDelete|KJS::ReadOnly, &calldrawText},
458 {
"drawTiledPixmap", 3, KJS::DontDelete|KJS::ReadOnly, &calldrawTiledPixmap},
459 {
"eraseRect", 1, KJS::DontDelete|KJS::ReadOnly, &calleraseRect},
485 {
"translate", 1, KJS::DontDelete|KJS::ReadOnly, &calltranslate}
492 KJS::JSObject *
object;
494 if( args.size() == 1 )
503 KJS::throwError( exec, KJS::EvalError, QString(
"Cannot paint to object %1").arg(
toQString(args[0]->toString(exec))));
static void publish(KJS::ExecState *exec, KJS::JSObject *object, const Method *methods)
Publishes an array of Methods to an object.
KJS::JSValue * createVariant(KJS::ExecState *exec, const KJS::UString &className, const T &value)
Can create any known KJSEmbed::VariantBinding object and set the value.
int KJSEMBED_EXPORT extractInt(KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue=0)
Extracts an integer from an argument list.
object drawConvexPolygon(arg0)
object drawPolygon(arg0, arg1)
#define START_CTOR(TYPE, JSNAME, ARGS)
#define END_OBJECT_METHOD
End a variant method started by START_OBJECT_METHOD.
END_OBJECT_METHOD START_METHOD_LUT(Painter)
QPaintDevice * extractPaintDevice(KJS::ExecState *exec, KJS::JSValue *arg)
static const Method * methods()
#define START_OBJECT_METHOD(METHODNAME, TYPE)
A simple pointer syle method.
QVariant variant() const
Return the wrapped QVariant.
object drawPolyline(arg0)
END_OBJECT_METHOD QBrush cppValue
END_OBJECT_METHOD QPolygon arg0
QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue=QString())
Extracts a QString from an argument list.
JSObject * throwError(ExecState *e, ErrorType t, const QString &m)
QVariant KJSEMBED_EXPORT extractVariant(KJS::ExecState *exec, KJS::JSValue *value)
Extracts a QVariant from a KJS::JSValue if the conversion fails a QVariant::Null is returned...
QString toQString(const KJS::UString &u)