KJsEmbed

qpainter_binding.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005, 2006 Ian Reinhart Geiser <[email protected]>
3  Copyright (C) 2005, 2006 Matt Broadstone <[email protected]>
4  Copyright (C) 2005, 2006 Richard J. Moore <[email protected]>
5  Copyright (C) 2005, 2006 Erik L. Bunce <[email protected]>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #include "qpainter_binding.h"
23 #include "object_binding.h"
24 #include "static_binding.h"
25 #include "kjseglobal.h"
26 
27 #include <kjs/object.h>
28 #include <QDebug>
29 
30 #include <QWidget>
31 #include <QPainter>
32 #include <QImage>
33 #include <QPixmap>
34 #include <QPen>
35 #include <QBrush>
36 #include <QLine>
37 #include <QPolygon>
38 #include <QPoint>
39 
40 #include <QFrame>
41 
42 using namespace KJSEmbed;
43 
44 QPaintDevice *extractPaintDevice(KJS::ExecState *exec, KJS::JSValue *arg)
45 {
46  QPaintDevice *device = nullptr;
47 
48  ObjectBinding *imp = extractBindingImp<ObjectBinding>(exec, arg);
49  if (imp) {
50 #ifdef __GNUC__
51 #warning There be dragons here...
52 #endif
53  /**
54  * Because of something odd with multiple inheritance and qobject cast
55  * we need to first cast it to a QObject, then cast it to a QWidget.
56  * All other paint devices in Qt that are objects are single inheritance
57  * so dynamic_cast will work properly.
58  */
59  QObject *qobject = imp->object<QObject>();
60  if (qobject) {
61  device = qobject_cast<QWidget *>(qobject);
62  } else {
63  device = imp->object<QPaintDevice>();
64  }
65 
66  if (device) {
67  qDebug("Height = %d Width = %d", device->height(), device->width());
68  }
69  } else {
70  VariantBinding *valueImp = extractBindingImp<VariantBinding>(exec, arg);
71  if (valueImp && (valueImp->variant().type() == QVariant::Pixmap ||
72  valueImp->variant().type() == QVariant::Image)) {
73  device = static_cast<QPaintDevice *>(valueImp->pointer());
74  }
75  }
76  return device;
77 }
78 
79 START_OBJECT_METHOD(callPainterBegin, QPainter)
80 result = KJS::jsBoolean(false);
81 QPaintDevice *device = extractPaintDevice(exec, args[0]);
82 if (device)
83 {
84  result = KJS::jsBoolean(object->begin(device));
85 } else
86 {
87  result = KJS::jsBoolean(false);
88 }
89 END_OBJECT_METHOD
90 
91 START_OBJECT_METHOD(callPainterEnd, QPainter)
92 result = KJS::jsBoolean(object->end());
93 END_OBJECT_METHOD
94 
95 START_OBJECT_METHOD(callbackground, QPainter)
96 QBrush cppValue = object->background();
97 result = KJSEmbed::createVariant(exec, "QBrush", cppValue);
98 END_OBJECT_METHOD
99 
100 START_OBJECT_METHOD(callbackgroundMode, QPainter)
101 Qt::BGMode cppValue = object->backgroundMode();
102 result = KJS::jsNumber(cppValue);
103 END_OBJECT_METHOD
104 
105 START_OBJECT_METHOD(callboundingRect, QPainter)
106 if (args.size() == 3)
107 {
108  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
109  int arg1 = KJSEmbed::extractInt(exec, args, 1);
110  QString arg2 = KJSEmbed::extractQString(exec, args, 2);
111  QRect cppValue = object->boundingRect(arg0, arg1, arg2);
112  result = KJSEmbed::createVariant(exec, "QRect", cppValue);
113 } else if (args.size() == 6)
114 {
115  int arg0 = KJSEmbed::extractInt(exec, args, 0);
116  int arg1 = KJSEmbed::extractInt(exec, args, 1);
117  int arg2 = KJSEmbed::extractInt(exec, args, 2);
118  int arg3 = KJSEmbed::extractInt(exec, args, 3);
119  int arg4 = KJSEmbed::extractInt(exec, args, 4);
120  QString arg5 = KJSEmbed::extractQString(exec, args, 5);
121  QRect cppValue = object->boundingRect(arg0, arg1, arg2, arg3, arg4, arg5);
122  result = KJSEmbed::createVariant(exec, "QRect", cppValue);
123 }
124 END_OBJECT_METHOD
125 
126 START_OBJECT_METHOD(callbrush, QPainter)
127 QBrush cppValue = object->brush();
128 result = KJSEmbed::createVariant(exec, "QBrush", cppValue);
129 END_OBJECT_METHOD
130 
131 START_OBJECT_METHOD(callbrushOrigin, QPainter)
132 QPoint cppValue = object->brushOrigin();
133 result = KJSEmbed::createVariant(exec, "QPoint", cppValue);
134 END_OBJECT_METHOD
135 
136 START_OBJECT_METHOD(calldrawArc, QPainter)
137 if (args.size() == 3)
138 {
139  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
140  int arg1 = KJSEmbed::extractInt(exec, args, 1);
141  int arg2 = KJSEmbed::extractInt(exec, args, 2);
142  object->drawArc(arg0, arg1, arg2);
143 } else if (args.size() == 6)
144 {
145  int arg0 = KJSEmbed::extractInt(exec, args, 0);
146  int arg1 = KJSEmbed::extractInt(exec, args, 1);
147  int arg2 = KJSEmbed::extractInt(exec, args, 2);
148  int arg3 = KJSEmbed::extractInt(exec, args, 3);
149  int arg4 = KJSEmbed::extractInt(exec, args, 4);
150  int arg5 = KJSEmbed::extractInt(exec, args, 5);
151  object->drawArc(arg0, arg1, arg2, arg3, arg4, arg5);
152 }
153 END_OBJECT_METHOD
154 
155 START_OBJECT_METHOD(calldrawChord, QPainter)
156 if (args.size() == 3)
157 {
158  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
159  int arg1 = KJSEmbed::extractInt(exec, args, 1);
160  int arg2 = KJSEmbed::extractInt(exec, args, 2);
161  object->drawChord(arg0, arg1, arg2);
162 } else if (args.size() == 6)
163 {
164  int arg0 = KJSEmbed::extractInt(exec, args, 0);
165  int arg1 = KJSEmbed::extractInt(exec, args, 1);
166  int arg2 = KJSEmbed::extractInt(exec, args, 2);
167  int arg3 = KJSEmbed::extractInt(exec, args, 3);
168  int arg4 = KJSEmbed::extractInt(exec, args, 4);
169  int arg5 = KJSEmbed::extractInt(exec, args, 5);
170  object->drawChord(arg0, arg1, arg2, arg3, arg4, arg5);
171 }
172 END_OBJECT_METHOD
173 
174 START_OBJECT_METHOD(calldrawConvexPolygon, QPainter)
175 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec, args, 0);
176 object->drawConvexPolygon(arg0);
177 END_OBJECT_METHOD
178 
179 START_OBJECT_METHOD(calldrawEllipse, QPainter)
180 if (args.size() == 4)
181 {
182  int arg0 = KJSEmbed::extractInt(exec, args, 0);
183  int arg1 = KJSEmbed::extractInt(exec, args, 1);
184  int arg2 = KJSEmbed::extractInt(exec, args, 2);
185  int arg3 = KJSEmbed::extractInt(exec, args, 3);
186  object->drawEllipse(arg0, arg1, arg2, arg3);
187 } else if (args.size() == 1)
188 {
189  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
190  object->drawEllipse(arg0);
191 }
192 END_OBJECT_METHOD
193 
194 START_OBJECT_METHOD(calldrawImage, QPainter)
195 if (args.size() == 2)
196 {
197  QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
198  QImage arg1 = KJSEmbed::extractVariant<QImage>(exec, args, 1);
199  object->drawImage(arg0, arg1);
200 } else if (args.size() == 4)
201 {
202  QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
203  QImage arg1 = KJSEmbed::extractVariant<QImage>(exec, args, 1);
204  QRect arg2 = KJSEmbed::extractVariant<QRect>(exec, args, 2);
205  Qt::ImageConversionFlags arg3 = (Qt::ImageConversionFlags)KJSEmbed::extractInt(exec, args, 3);
206  object->drawImage(arg0, arg1, arg2, arg3);
207 } else if (args.size() == 8)
208 {
209  int arg0 = KJSEmbed::extractInt(exec, args, 0);
210  int arg1 = KJSEmbed::extractInt(exec, args, 1);
211  QImage arg2 = KJSEmbed::extractVariant<QImage>(exec, args, 2);
212  int arg3 = KJSEmbed::extractInt(exec, args, 3);
213  int arg4 = KJSEmbed::extractInt(exec, args, 4);
214  int arg5 = KJSEmbed::extractInt(exec, args, 5);
215  int arg6 = KJSEmbed::extractInt(exec, args, 6);
216  Qt::ImageConversionFlags arg7 = (Qt::ImageConversionFlags)KJSEmbed::extractInt(exec, args, 7);
217  object->drawImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
218 }
219 END_OBJECT_METHOD
220 
221 START_OBJECT_METHOD(calldrawLine, QPainter)
222 if (args.size() == 1)
223 {
224  QLine arg0 = KJSEmbed::extractVariant<QLine>(exec, args, 0);
225  object->drawLine(arg0);
226 } else if (args.size() == 2)
227 {
228  QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
229  QPoint arg1 = KJSEmbed::extractVariant<QPoint>(exec, args, 1);
230  object->drawLine(arg0, arg1);
231 } else if (args.size() == 4)
232 {
233  int arg0 = KJSEmbed::extractInt(exec, args, 0);
234  int arg1 = KJSEmbed::extractInt(exec, args, 1);
235  int arg2 = KJSEmbed::extractInt(exec, args, 2);
236  int arg3 = KJSEmbed::extractInt(exec, args, 3);
237  object->drawLine(arg0, arg1, arg2, arg3);
238 }
239 END_OBJECT_METHOD
240 
241 START_OBJECT_METHOD(calldrawPie, QPainter)
242 if (args.size() == 3)
243 {
244  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
245  int arg1 = KJSEmbed::extractInt(exec, args, 1);
246  int arg2 = KJSEmbed::extractInt(exec, args, 2);
247  object->drawPie(arg0, arg1, arg2);
248 } else if (args.size() == 6)
249 {
250  int arg0 = KJSEmbed::extractInt(exec, args, 0);
251  int arg1 = KJSEmbed::extractInt(exec, args, 1);
252  int arg2 = KJSEmbed::extractInt(exec, args, 2);
253  int arg3 = KJSEmbed::extractInt(exec, args, 3);
254  int arg4 = KJSEmbed::extractInt(exec, args, 4);
255  int arg5 = KJSEmbed::extractInt(exec, args, 5);
256  object->drawPie(arg0, arg1, arg2, arg3, arg4, arg5);
257 }
258 END_OBJECT_METHOD
259 
260 START_OBJECT_METHOD(calldrawPixmap, QPainter)
261 if (args.size() == 2)
262 {
263  QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
264  QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
265  object->drawPixmap(arg0, arg1);
266 } else if (args.size() == 3)
267 {
268  QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
269  QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
270  QRect arg2 = KJSEmbed::extractVariant<QRect>(exec, args, 2);
271  object->drawPixmap(arg0, arg1, arg2);
272 }
273 END_OBJECT_METHOD
274 
275 START_OBJECT_METHOD(calldrawPoint, QPainter)
276 if (args.size() == 1)
277 {
278  QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
279  object->drawPoint(arg0);
280 } else if (args.size() == 2)
281 {
282  int arg0 = KJSEmbed::extractInt(exec, args, 0);
283  int arg1 = KJSEmbed::extractInt(exec, args, 1);
284  object->drawPoint(arg0, arg1);
285 }
286 END_OBJECT_METHOD
287 
288 START_OBJECT_METHOD(calldrawPoints, QPainter)
289 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec, args, 0);
290 object->drawPoints(arg0);
291 END_OBJECT_METHOD
292 
293 START_OBJECT_METHOD(calldrawPolygon, QPainter)
294 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec, args, 0);
295 Qt::FillRule arg1 = (Qt::FillRule)KJSEmbed::extractInt(exec, args, 1, Qt::OddEvenFill);
296 object->drawPolygon(arg0, arg1);
297 END_OBJECT_METHOD
298 
299 START_OBJECT_METHOD(calldrawPolyline, QPainter)
300 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec, args, 0);
301 object->drawPolyline(arg0);
302 END_OBJECT_METHOD
303 
304 START_OBJECT_METHOD(calldrawRect, QPainter)
305 if (args.size() == 1)
306 {
307  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
308  object->drawRect(arg0);
309 } else if (args.size() == 4)
310 {
311  int arg0 = KJSEmbed::extractInt(exec, args, 0);
312  int arg1 = KJSEmbed::extractInt(exec, args, 1);
313  int arg2 = KJSEmbed::extractInt(exec, args, 2);
314  int arg3 = KJSEmbed::extractInt(exec, args, 3);
315  object->drawRect(arg0, arg1, arg2, arg3);
316 }
317 END_OBJECT_METHOD
318 
319 START_OBJECT_METHOD(calldrawRoundRect, QPainter)
320 if (args.size() == 2)
321 {
322  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
323  int arg1 = KJSEmbed::extractInt(exec, args, 1);
324  int arg2 = KJSEmbed::extractInt(exec, args, 2);
325  object->drawRoundRect(arg0, arg1, arg2);
326 } else if (args.size() == 6)
327 {
328  int arg0 = KJSEmbed::extractInt(exec, args, 0);
329  int arg1 = KJSEmbed::extractInt(exec, args, 1);
330  int arg2 = KJSEmbed::extractInt(exec, args, 2);
331  int arg3 = KJSEmbed::extractInt(exec, args, 3);
332  int arg4 = KJSEmbed::extractInt(exec, args, 4);
333  int arg5 = KJSEmbed::extractInt(exec, args, 5);
334  object->drawRoundRect(arg0, arg1, arg2, arg3, arg4, arg5);
335 }
336 END_OBJECT_METHOD
337 
338 START_OBJECT_METHOD(calldrawText, QPainter)
339 if (args.size() == 2)
340 {
341  QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
342  QString arg1 = KJSEmbed::extractQString(exec, args, 1);
343  object->drawText(arg0, arg1);
344 } else if (args.size() == 3)
345 {
346  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
347  int arg1 = KJSEmbed::extractInt(exec, args, 1);
348  QString arg2 = KJSEmbed::extractQString(exec, args, 2);
349  QRect *arg3 = nullptr;
350  object->drawText(arg0, arg1, arg2, arg3);
351 } else if (args.size() == 6)
352 {
353  int arg0 = KJSEmbed::extractInt(exec, args, 0);
354  int arg1 = KJSEmbed::extractInt(exec, args, 1);
355  int arg2 = KJSEmbed::extractInt(exec, args, 2);
356  int arg3 = KJSEmbed::extractInt(exec, args, 3);
357  int arg4 = KJSEmbed::extractInt(exec, args, 4);
358  QString arg5 = KJSEmbed::extractQString(exec, args, 5);
359  QRect *arg6 = nullptr;
360  object->drawText(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
361 }
362 END_OBJECT_METHOD
363 
364 START_OBJECT_METHOD(calltranslate, QPainter)
365 if (args.size() == 2)
366 {
367  int arg0 = KJSEmbed::extractInt(exec, args, 0);
368  int arg1 = KJSEmbed::extractInt(exec, args, 1);
369  object->translate(arg0, arg1);
370 } else if (args.size() == 1)
371 {
372  QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec, args, 0);
373  object->translate(arg0);
374 }
375 END_OBJECT_METHOD
376 
377 START_OBJECT_METHOD(calldrawTiledPixmap, QPainter)
378 if (args.size() == 3)
379 {
380  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
381  QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
382  QPoint arg2 = KJSEmbed::extractVariant<QPoint>(exec, args, 2);
383  object->drawTiledPixmap(arg0, arg1, arg2);
384 } else if (args.size() == 7)
385 {
386  int arg0 = KJSEmbed::extractInt(exec, args, 0);
387  int arg1 = KJSEmbed::extractInt(exec, args, 1);
388  int arg2 = KJSEmbed::extractInt(exec, args, 2);
389  int arg3 = KJSEmbed::extractInt(exec, args, 3);
390  QPixmap arg4 = KJSEmbed::extractVariant<QPixmap>(exec, args, 4);
391  int arg5 = KJSEmbed::extractInt(exec, args, 5);
392  int arg6 = KJSEmbed::extractInt(exec, args, 6);
393  object->drawTiledPixmap(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
394 }
395 END_OBJECT_METHOD
396 
397 START_OBJECT_METHOD(calleraseRect, QPainter)
398 if (args.size() == 4)
399 {
400  int arg0 = KJSEmbed::extractInt(exec, args, 0);
401  int arg1 = KJSEmbed::extractInt(exec, args, 1);
402  int arg2 = KJSEmbed::extractInt(exec, args, 2);
403  int arg3 = KJSEmbed::extractInt(exec, args, 3);
404  object->eraseRect(arg0, arg1, arg2, arg3);
405 } else if (args.size() == 1)
406 {
407  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec, args, 0);
408  object->eraseRect(arg0);
409 }
410 END_OBJECT_METHOD
411 
412 START_METHOD_LUT(Painter)
413 {"begin", 1, KJS::DontDelete | KJS::ReadOnly, &callPainterBegin },
414 {"end", 0, KJS::DontDelete | KJS::ReadOnly, &callPainterEnd },
415 {"background", 0, KJS::DontDelete | KJS::ReadOnly, &callbackground},
416 {"backgroundMode", 0, KJS::DontDelete | KJS::ReadOnly, &callbackgroundMode},
417 {"boundingRect", 6, KJS::DontDelete | KJS::ReadOnly, &callboundingRect},
418 {"brush", 0, KJS::DontDelete | KJS::ReadOnly, &callbrush},
419 {"brushOrigin", 0, KJS::DontDelete | KJS::ReadOnly, &callbrushOrigin},
420 {"drawArc", 6, KJS::DontDelete | KJS::ReadOnly, &calldrawArc},
421 {"drawChord", 6, KJS::DontDelete | KJS::ReadOnly, &calldrawChord},
422 {"drawConvexPolygon", 1, KJS::DontDelete | KJS::ReadOnly, &calldrawConvexPolygon},
423 {"drawEllipse", 3, KJS::DontDelete | KJS::ReadOnly, &calldrawEllipse},
424 {"drawImage", 7, KJS::DontDelete | KJS::ReadOnly, &calldrawImage},
425 {"drawLine", 3, KJS::DontDelete | KJS::ReadOnly, &calldrawLine},
426 //{drawLines", 1, KJS::DontDelete|KJS::ReadOnly, &calldrawLines},
427 //{"drawPath", 0, KJS::DontDelete|KJS::ReadOnly, &calldrawPath},
428 //{"drawPicture", 2, KJS::DontDelete|KJS::ReadOnly, &calldrawPicture},
429 {"drawPie", 6, KJS::DontDelete | KJS::ReadOnly, &calldrawPie},
430 {"drawPixmap", 8, KJS::DontDelete | KJS::ReadOnly, &calldrawPixmap},
431 {"drawPoint", 2, KJS::DontDelete | KJS::ReadOnly, &calldrawPoint},
432 {"drawPoints", 1, KJS::DontDelete | KJS::ReadOnly, &calldrawPoints},
433 {"drawPolygon", 2, KJS::DontDelete | KJS::ReadOnly, &calldrawPolygon},
434 {"drawPolyline", 1, KJS::DontDelete | KJS::ReadOnly, &calldrawPolyline},
435 {"drawRect", 4, KJS::DontDelete | KJS::ReadOnly, &calldrawRect},
436 //{"drawRects", 0, KJS::DontDelete|KJS::ReadOnly, &calldrawRects},
437 {"drawRoundRect", 5, KJS::DontDelete | KJS::ReadOnly, &calldrawRoundRect},
438 {"drawText", 7, KJS::DontDelete | KJS::ReadOnly, &calldrawText},
439 {"drawTiledPixmap", 3, KJS::DontDelete | KJS::ReadOnly, &calldrawTiledPixmap},
440 {"eraseRect", 1, KJS::DontDelete | KJS::ReadOnly, &calleraseRect},
441 //{"fillPath", 1, KJS::DontDelete|KJS::ReadOnly, &callfillPath},
442 //{"fillRect", 4, KJS::DontDelete|KJS::ReadOnly, &callfillRect},
443 //{"font", 0, KJS::DontDelete|KJS::ReadOnly, &callfont},
444 //{"hasClipping", 0, KJS::DontDelete|KJS::ReadOnly, &callhasClipping},
445 //{"isActive", 0, KJS::DontDelete|KJS::ReadOnly, &callisActive},
446 //{"pen", 0, KJS::DontDelete|KJS::ReadOnly, &callpen},
447 //{"renderHints", 0, KJS::DontDelete|KJS::ReadOnly, &callrenderHints},
448 //{"restore", 0, KJS::DontDelete|KJS::ReadOnly, &callrestore},
449 //{"rotate", 0, KJS::DontDelete|KJS::ReadOnly, &callrotate},
450 //{"save", 0, KJS::DontDelete|KJS::ReadOnly, &callsave},
451 //{"scale", 1, KJS::DontDelete|KJS::ReadOnly, &callscale},
452 //{"setBackground", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackground},
453 //{"setBackgroundColor", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackgroundColor},
454 //{"setBackgroundMode", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackgroundMode},
455 //{"setBrush", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBrush},
456 //{"setBrushOrigin", 1, KJS::DontDelete|KJS::ReadOnly, &callsetBrushOrigin},
457 //{"setClipPath", 1, KJS::DontDelete|KJS::ReadOnly, &callsetClipPath},
458 //{"setClipRect", 4, KJS::DontDelete|KJS::ReadOnly, &callsetClipRect},
459 //{"setClipRegion", 1, KJS::DontDelete|KJS::ReadOnly, &callsetClipRegion},
460 //{"setClipping", 0, KJS::DontDelete|KJS::ReadOnly, &callsetClipping},
461 //{"setFont", 1, KJS::DontDelete|KJS::ReadOnly, &callsetFont},
462 //{"setPen", 1, KJS::DontDelete|KJS::ReadOnly, &callsetPen},
463 //{"setRenderHint", 1, KJS::DontDelete|KJS::ReadOnly, &callsetRenderHint},
464 //{"shear", 2, KJS::DontDelete|KJS::ReadOnly, &callshear},
465 //{"strokePath", 1, KJS::DontDelete|KJS::ReadOnly, &callstrokePath},
466 {"translate", 1, KJS::DontDelete | KJS::ReadOnly, &calltranslate}
467 END_METHOD_LUT
468 
469 NO_ENUMS(Painter)
470 NO_STATICS(Painter)
471 
472 START_CTOR(Painter, QPainter, 0)
473 KJS::JSObject *object;
474 
475 if (args.size() == 1)
476 {
477  QPaintDevice *device = extractPaintDevice(exec, args[0]);
478  if (device) {
479  object = new KJSEmbed::ObjectBinding(exec, "Painter", new QPainter(device));
480  } else {
481  KJS::throwError(exec, KJS::EvalError, QString("Cannot paint to object %1").arg(toQString(args[0]->toString(exec))));
482  return nullptr;
483  }
484 } else
485 {
486  object = new KJSEmbed::ObjectBinding(exec, "Painter", new QPainter());
487 }
488 
489 StaticBinding::publish(exec, object, ObjectFactory::methods());
490 StaticBinding::publish(exec, object, Painter::methods());
491 return object;
492 END_CTOR
493 
int width() const const
Implement QString-KJS::UString conversion methods.
int height() const const
FillRule
QVariant::Type type() const const
static void publish(KJS::ExecState *exec, KJS::JSObject *object, const Method *methods)
Publishes an array of Methods to an object.
QVariant based binding.
typedef ImageConversionFlags
QVariant variant() const
Return the wrapped QVariant.
char * toString(const EngineQuery &query)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 10 2023 03:59:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.