• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

kjsembed

  • kjsembed
  • kjsembed
qpainter_binding.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
3 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
4 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
5 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
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 <QtCore/QDebug>
29
30#include <QtGui/QWidget>
31#include <QtGui/QPainter>
32#include <QtGui/QImage>
33#include <QtGui/QPixmap>
34#include <QtGui/QPen>
35#include <QtGui/QBrush>
36#include <QtCore/QLine>
37#include <QtGui/QPolygon>
38#include <QtCore/QPoint>
39
40#include <QtGui/QFrame>
41
42using namespace KJSEmbed;
43
44QPaintDevice *extractPaintDevice( KJS::ExecState *exec, KJS::JSValue *arg)
45{
46 QPaintDevice *device = 0;
47
48 ObjectBinding *imp = extractBindingImp<ObjectBinding>(exec,arg);
49 if( imp )
50 {
51#ifdef __GNUC__
52#warning There be dragons here...
53#endif
60 QObject *qobject = imp->object<QObject>();
61 if( qobject )
62 device = qobject_cast<QWidget*>(qobject);
63 else
64 device = imp->object<QPaintDevice>();
65
66 if( device )
67 qDebug("Height = %d Width = %d", device->height(), device->width() );
68 }
69 else
70 {
71 VariantBinding *valueImp = extractBindingImp<VariantBinding>(exec,arg);
72 if( valueImp && (valueImp->variant().type() == QVariant::Pixmap ||
73 valueImp->variant().type() == QVariant::Image ))
74 {
75 device = static_cast<QPaintDevice*>( valueImp->pointer() );
76 }
77 }
78 return device;
79}
80
81START_OBJECT_METHOD( callPainterBegin, QPainter )
82 result = KJS::jsBoolean(false);
83 QPaintDevice *device = extractPaintDevice(exec, args[0]);
84 if( device )
85 {
86 result = KJS::jsBoolean(object->begin(device));
87 } else {
88 result = KJS::jsBoolean(false);
89 }
90END_OBJECT_METHOD
91
92START_OBJECT_METHOD( callPainterEnd, QPainter )
93 result = KJS::jsBoolean(object->end());
94END_OBJECT_METHOD
95
96START_OBJECT_METHOD( callbackground, QPainter )
97 QBrush cppValue = object->background();
98 result = KJSEmbed::createVariant(exec, "QBrush", cppValue );
99END_OBJECT_METHOD
100
101START_OBJECT_METHOD( callbackgroundMode, QPainter )
102 Qt::BGMode cppValue = object->backgroundMode();
103 result = KJS::jsNumber(cppValue);
104END_OBJECT_METHOD
105
106START_OBJECT_METHOD( callboundingRect, QPainter )
107 if( args.size() == 3 )
108 {
109 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
110 int arg1 = KJSEmbed::extractInt(exec, args, 1);
111 QString arg2 = KJSEmbed::extractQString(exec, args, 2);
112 QRect cppValue = object->boundingRect(arg0, arg1, arg2);
113 result = KJSEmbed::createVariant(exec, "QRect", cppValue );
114 }
115 else if( args.size() == 6)
116 {
117 int arg0 = KJSEmbed::extractInt(exec, args, 0);
118 int arg1 = KJSEmbed::extractInt(exec, args, 1);
119 int arg2 = KJSEmbed::extractInt(exec, args, 2);
120 int arg3 = KJSEmbed::extractInt(exec, args, 3);
121 int arg4 = KJSEmbed::extractInt(exec, args, 4);
122 QString arg5 = KJSEmbed::extractQString(exec, args, 5);
123 QRect cppValue = object->boundingRect(arg0, arg1, arg2, arg3, arg4, arg5);
124 result = KJSEmbed::createVariant(exec, "QRect", cppValue );
125 }
126END_OBJECT_METHOD
127
128START_OBJECT_METHOD( callbrush, QPainter )
129 QBrush cppValue = object->brush();
130 result = KJSEmbed::createVariant(exec, "QBrush", cppValue );
131END_OBJECT_METHOD
132
133START_OBJECT_METHOD( callbrushOrigin, QPainter )
134 QPoint cppValue = object->brushOrigin();
135 result = KJSEmbed::createVariant(exec, "QPoint", cppValue );
136END_OBJECT_METHOD
137
138START_OBJECT_METHOD( calldrawArc, QPainter )
139 if( args.size() == 3 )
140 {
141 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
142 int arg1 = KJSEmbed::extractInt(exec, args, 1);
143 int arg2 = KJSEmbed::extractInt(exec, args, 2);
144 object->drawArc(arg0, arg1, arg2);
145 }
146 else if( args.size() == 6 )
147 {
148 int arg0 = KJSEmbed::extractInt(exec, args, 0);
149 int arg1 = KJSEmbed::extractInt(exec, args, 1);
150 int arg2 = KJSEmbed::extractInt(exec, args, 2);
151 int arg3 = KJSEmbed::extractInt(exec, args, 3);
152 int arg4 = KJSEmbed::extractInt(exec, args, 4);
153 int arg5 = KJSEmbed::extractInt(exec, args, 5);
154 object->drawArc(arg0, arg1, arg2, arg3, arg4, arg5);
155 }
156END_OBJECT_METHOD
157
158START_OBJECT_METHOD( calldrawChord, QPainter )
159 if( args.size() == 3 )
160 {
161 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
162 int arg1 = KJSEmbed::extractInt(exec, args, 1);
163 int arg2 = KJSEmbed::extractInt(exec, args, 2);
164 object->drawChord(arg0, arg1, arg2);
165 }
166 else if ( args.size() == 6 )
167 {
168 int arg0 = KJSEmbed::extractInt(exec, args, 0);
169 int arg1 = KJSEmbed::extractInt(exec, args, 1);
170 int arg2 = KJSEmbed::extractInt(exec, args, 2);
171 int arg3 = KJSEmbed::extractInt(exec, args, 3);
172 int arg4 = KJSEmbed::extractInt(exec, args, 4);
173 int arg5 = KJSEmbed::extractInt(exec, args, 5);
174 object->drawChord(arg0, arg1, arg2, arg3, arg4, arg5);
175 }
176END_OBJECT_METHOD
177
178START_OBJECT_METHOD( calldrawConvexPolygon, QPainter )
179 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec,args, 0);
180 object->drawConvexPolygon(arg0);
181END_OBJECT_METHOD
182
183START_OBJECT_METHOD( calldrawEllipse, QPainter )
184 if ( args.size() == 4 )
185 {
186 int arg0 = KJSEmbed::extractInt(exec, args, 0);
187 int arg1 = KJSEmbed::extractInt(exec, args, 1);
188 int arg2 = KJSEmbed::extractInt(exec, args, 2);
189 int arg3 = KJSEmbed::extractInt(exec, args, 3);
190 object->drawEllipse(arg0, arg1, arg2, arg3);
191 }
192 else if ( args.size() == 1 )
193 {
194 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
195 object->drawEllipse(arg0);
196 }
197END_OBJECT_METHOD
198
199START_OBJECT_METHOD( calldrawImage, QPainter )
200 if ( args.size() == 2 )
201 {
202 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
203 QImage arg1 = KJSEmbed::extractVariant<QImage>(exec,args, 1);
204 object->drawImage(arg0, arg1);
205 }
206 else if ( args.size() == 4 )
207 {
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);
211 Qt::ImageConversionFlags arg3 = (Qt::ImageConversionFlags)KJSEmbed::extractInt(exec, args, 3);
212 object->drawImage(arg0, arg1, arg2, arg3);
213 }
214 else if ( args.size() == 8 )
215 {
216 int arg0 = KJSEmbed::extractInt(exec, args, 0);
217 int arg1 = KJSEmbed::extractInt(exec, args, 1);
218 QImage arg2 = KJSEmbed::extractVariant<QImage>(exec,args, 2);
219 int arg3 = KJSEmbed::extractInt(exec, args, 3);
220 int arg4 = KJSEmbed::extractInt(exec, args, 4);
221 int arg5 = KJSEmbed::extractInt(exec, args, 5);
222 int arg6 = KJSEmbed::extractInt(exec, args, 6);
223 Qt::ImageConversionFlags arg7 = (Qt::ImageConversionFlags)KJSEmbed::extractInt(exec, args, 7);
224 object->drawImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
225 }
226END_OBJECT_METHOD
227
228START_OBJECT_METHOD( calldrawLine, QPainter )
229 if( args.size() == 1 )
230 {
231 QLine arg0 = KJSEmbed::extractVariant<QLine>(exec,args, 0);
232 object->drawLine(arg0);
233 }
234 else if ( args.size() == 2 )
235 {
236 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
237 QPoint arg1 = KJSEmbed::extractVariant<QPoint>(exec,args, 1);
238 object->drawLine(arg0, arg1);
239 }
240 else if ( args.size() == 4 )
241 {
242 int arg0 = KJSEmbed::extractInt(exec, args, 0);
243 int arg1 = KJSEmbed::extractInt(exec, args, 1);
244 int arg2 = KJSEmbed::extractInt(exec, args, 2);
245 int arg3 = KJSEmbed::extractInt(exec, args, 3);
246 object->drawLine(arg0, arg1, arg2, arg3);
247 }
248END_OBJECT_METHOD
249
250START_OBJECT_METHOD( calldrawPie, QPainter )
251 if( args.size() == 3 )
252 {
253 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
254 int arg1 = KJSEmbed::extractInt(exec, args, 1);
255 int arg2 = KJSEmbed::extractInt(exec, args, 2);
256 object->drawPie(arg0, arg1, arg2);
257 }
258 else if (args.size() == 6 )
259 {
260 int arg0 = KJSEmbed::extractInt(exec, args, 0);
261 int arg1 = KJSEmbed::extractInt(exec, args, 1);
262 int arg2 = KJSEmbed::extractInt(exec, args, 2);
263 int arg3 = KJSEmbed::extractInt(exec, args, 3);
264 int arg4 = KJSEmbed::extractInt(exec, args, 4);
265 int arg5 = KJSEmbed::extractInt(exec, args, 5);
266 object->drawPie(arg0, arg1, arg2, arg3, arg4, arg5);
267 }
268END_OBJECT_METHOD
269
270START_OBJECT_METHOD( calldrawPixmap, QPainter )
271 if ( args.size() == 2)
272 {
273 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
274 QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec,args, 1);
275 object->drawPixmap(arg0, arg1);
276 }
277 else if ( args.size() == 3 )
278 {
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);
283 }
284END_OBJECT_METHOD
285
286START_OBJECT_METHOD( calldrawPoint, QPainter )
287 if( args.size() == 1 )
288 {
289 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
290 object->drawPoint(arg0);
291 }
292 else if (args.size() == 2 )
293 {
294 int arg0 = KJSEmbed::extractInt(exec, args, 0);
295 int arg1 = KJSEmbed::extractInt(exec, args, 1);
296 object->drawPoint(arg0, arg1);
297 }
298END_OBJECT_METHOD
299
300START_OBJECT_METHOD( calldrawPoints, QPainter )
301 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec,args, 0);
302 object->drawPoints(arg0);
303END_OBJECT_METHOD
304
305START_OBJECT_METHOD( calldrawPolygon, QPainter )
306 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec,args, 0);
307 Qt::FillRule arg1 = (Qt::FillRule)KJSEmbed::extractInt(exec, args, 1, Qt::OddEvenFill );
308 object->drawPolygon(arg0, arg1);
309END_OBJECT_METHOD
310
311START_OBJECT_METHOD( calldrawPolyline, QPainter )
312 QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec,args, 0);
313 object->drawPolyline(arg0);
314END_OBJECT_METHOD
315
316START_OBJECT_METHOD( calldrawRect, QPainter )
317 if (args.size() == 1 )
318 {
319 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
320 object->drawRect(arg0);
321 }
322 else if ( args.size() == 4 )
323 {
324 int arg0 = KJSEmbed::extractInt(exec, args, 0);
325 int arg1 = KJSEmbed::extractInt(exec, args, 1);
326 int arg2 = KJSEmbed::extractInt(exec, args, 2);
327 int arg3 = KJSEmbed::extractInt(exec, args, 3);
328 object->drawRect(arg0, arg1, arg2, arg3);
329 }
330END_OBJECT_METHOD
331
332START_OBJECT_METHOD( calldrawRoundRect, QPainter )
333 if ( args.size() == 2 )
334 {
335 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
336 int arg1 = KJSEmbed::extractInt(exec, args, 1);
337 int arg2 = KJSEmbed::extractInt(exec, args, 2);
338 object->drawRoundRect(arg0, arg1, arg2);
339 }
340 else if ( args.size() == 6 )
341 {
342 int arg0 = KJSEmbed::extractInt(exec, args, 0);
343 int arg1 = KJSEmbed::extractInt(exec, args, 1);
344 int arg2 = KJSEmbed::extractInt(exec, args, 2);
345 int arg3 = KJSEmbed::extractInt(exec, args, 3);
346 int arg4 = KJSEmbed::extractInt(exec, args, 4);
347 int arg5 = KJSEmbed::extractInt(exec, args, 5);
348 object->drawRoundRect(arg0, arg1, arg2, arg3, arg4, arg5);
349 }
350END_OBJECT_METHOD
351
352START_OBJECT_METHOD( calldrawText, QPainter )
353 if( args.size() == 2 )
354 {
355 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
356 QString arg1 = KJSEmbed::extractQString(exec, args, 1);
357 object->drawText(arg0, arg1);
358 }
359 else if ( args.size() == 3 )
360 {
361 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
362 int arg1 = KJSEmbed::extractInt(exec, args, 1);
363 QString arg2 = KJSEmbed::extractQString(exec, args, 2);
364 QRect* arg3 = 0;
365 object->drawText(arg0, arg1, arg2, arg3);
366 }
367 else if ( args.size () == 6 )
368 {
369 int arg0 = KJSEmbed::extractInt(exec, args, 0);
370 int arg1 = KJSEmbed::extractInt(exec, args, 1);
371 int arg2 = KJSEmbed::extractInt(exec, args, 2);
372 int arg3 = KJSEmbed::extractInt(exec, args, 3);
373 int arg4 = KJSEmbed::extractInt(exec, args, 4);
374 QString arg5 = KJSEmbed::extractQString(exec, args, 5);
375 QRect* arg6 = 0;
376 object->drawText(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
377 }
378END_OBJECT_METHOD
379
380START_OBJECT_METHOD( calltranslate, QPainter )
381 if( args.size() == 2 )
382 {
383 int arg0 = KJSEmbed::extractInt(exec, args, 0);
384 int arg1 = KJSEmbed::extractInt(exec, args, 1);
385 object->translate(arg0,arg1);
386 }
387 else if( args.size() == 1 )
388 {
389 QPoint arg0 = KJSEmbed::extractVariant<QPoint>(exec,args, 0);
390 object->translate(arg0);
391 }
392END_OBJECT_METHOD
393
394START_OBJECT_METHOD( calldrawTiledPixmap, QPainter)
395 if( args.size() == 3 )
396 {
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);
401 }
402 else if( args.size() == 7)
403 {
404 int arg0 = KJSEmbed::extractInt(exec, args, 0);
405 int arg1 = KJSEmbed::extractInt(exec, args, 1);
406 int arg2 = KJSEmbed::extractInt(exec, args, 2);
407 int arg3 = KJSEmbed::extractInt(exec, args, 3);
408 QPixmap arg4 = KJSEmbed::extractVariant<QPixmap>(exec,args, 4);
409 int arg5 = KJSEmbed::extractInt(exec, args, 5);
410 int arg6 = KJSEmbed::extractInt(exec, args, 6);
411 object->drawTiledPixmap(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
412 }
413END_OBJECT_METHOD
414
415START_OBJECT_METHOD( calleraseRect, QPainter)
416 if( args.size() == 4)
417 {
418 int arg0 = KJSEmbed::extractInt(exec, args, 0);
419 int arg1 = KJSEmbed::extractInt(exec, args, 1);
420 int arg2 = KJSEmbed::extractInt(exec, args, 2);
421 int arg3 = KJSEmbed::extractInt(exec, args, 3);
422 object->eraseRect(arg0,arg1,arg2,arg3);
423 }
424 else if (args.size() == 1 )
425 {
426 QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
427 object->eraseRect(arg0);
428 }
429END_OBJECT_METHOD
430
431START_METHOD_LUT( Painter )
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},
445 //{drawLines", 1, KJS::DontDelete|KJS::ReadOnly, &calldrawLines},
446 //{"drawPath", 0, KJS::DontDelete|KJS::ReadOnly, &calldrawPath},
447 //{"drawPicture", 2, KJS::DontDelete|KJS::ReadOnly, &calldrawPicture},
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},
455 //{"drawRects", 0, KJS::DontDelete|KJS::ReadOnly, &calldrawRects},
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},
460 //{"fillPath", 1, KJS::DontDelete|KJS::ReadOnly, &callfillPath},
461 //{"fillRect", 4, KJS::DontDelete|KJS::ReadOnly, &callfillRect},
462 //{"font", 0, KJS::DontDelete|KJS::ReadOnly, &callfont},
463 //{"hasClipping", 0, KJS::DontDelete|KJS::ReadOnly, &callhasClipping},
464 //{"isActive", 0, KJS::DontDelete|KJS::ReadOnly, &callisActive},
465 //{"pen", 0, KJS::DontDelete|KJS::ReadOnly, &callpen},
466 //{"renderHints", 0, KJS::DontDelete|KJS::ReadOnly, &callrenderHints},
467 //{"restore", 0, KJS::DontDelete|KJS::ReadOnly, &callrestore},
468 //{"rotate", 0, KJS::DontDelete|KJS::ReadOnly, &callrotate},
469 //{"save", 0, KJS::DontDelete|KJS::ReadOnly, &callsave},
470 //{"scale", 1, KJS::DontDelete|KJS::ReadOnly, &callscale},
471 //{"setBackground", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackground},
472 //{"setBackgroundColor", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackgroundColor},
473 //{"setBackgroundMode", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBackgroundMode},
474 //{"setBrush", 0, KJS::DontDelete|KJS::ReadOnly, &callsetBrush},
475 //{"setBrushOrigin", 1, KJS::DontDelete|KJS::ReadOnly, &callsetBrushOrigin},
476 //{"setClipPath", 1, KJS::DontDelete|KJS::ReadOnly, &callsetClipPath},
477 //{"setClipRect", 4, KJS::DontDelete|KJS::ReadOnly, &callsetClipRect},
478 //{"setClipRegion", 1, KJS::DontDelete|KJS::ReadOnly, &callsetClipRegion},
479 //{"setClipping", 0, KJS::DontDelete|KJS::ReadOnly, &callsetClipping},
480 //{"setFont", 1, KJS::DontDelete|KJS::ReadOnly, &callsetFont},
481 //{"setPen", 1, KJS::DontDelete|KJS::ReadOnly, &callsetPen},
482 //{"setRenderHint", 1, KJS::DontDelete|KJS::ReadOnly, &callsetRenderHint},
483 //{"shear", 2, KJS::DontDelete|KJS::ReadOnly, &callshear},
484 //{"strokePath", 1, KJS::DontDelete|KJS::ReadOnly, &callstrokePath},
485 {"translate", 1, KJS::DontDelete|KJS::ReadOnly, &calltranslate}
486END_METHOD_LUT
487
488NO_ENUMS( Painter )
489NO_STATICS( Painter )
490
491START_CTOR( Painter, QPainter, 0 )
492 KJS::JSObject *object;
493
494 if( args.size() == 1 )
495 {
496 QPaintDevice *device = extractPaintDevice(exec, args[0]);
497 if ( device )
498 {
499 object = new KJSEmbed::ObjectBinding(exec, "Painter", new QPainter(device) );
500 }
501 else
502 {
503 KJS::throwError( exec, KJS::EvalError, QString("Cannot paint to object %1").arg(toQString(args[0]->toString(exec))));
504 return 0L;
505 }
506 }
507 else
508 {
509 object = new KJSEmbed::ObjectBinding(exec, "Painter", new QPainter() );
510 }
511
512 StaticBinding::publish( exec, object, ObjectFactory::methods() );
513 StaticBinding::publish( exec, object, Painter::methods() );
514 return object;
515END_CTOR
516
517//kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
START_METHOD_LUT
#define START_METHOD_LUT(TYPE)
Definition: binding_support.h:127
END_CTOR
#define END_CTOR
Definition: binding_support.h:166
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
START_CTOR
#define START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:157
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
KJSEmbed::ObjectBinding
Definition: object_binding.h:89
KJSEmbed::ObjectBinding::object
T * object() const
Definition: object_binding.h:119
KJSEmbed::ObjectFactory::methods
static const Method * methods()
Definition: object_binding.h:85
KJSEmbed::StaticBinding::publish
static void publish(KJS::ExecState *exec, KJS::JSObject *object, const Method *methods)
Publishes an array of Methods to an object.
Definition: static_binding.cpp:60
KJSEmbed::VariantBinding
QVariant based binding.
Definition: variant_binding.h:89
KJSEmbed::VariantBinding::pointer
void * pointer()
Definition: variant_binding.cpp:53
KJSEmbed::VariantBinding::variant
QVariant variant() const
Return the wrapped QVariant.
Definition: variant_binding.cpp:68
QObject
kjseglobal.h
ImageNS::arg2
int arg2
Definition: image.cpp:56
ImageNS::arg3
int arg3
Definition: image.cpp:57
KJSEmbed
Definition: application.h:33
KJSEmbed::extractQString
QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue=QString())
Extracts a QString from an argument list.
Definition: binding_support.cpp:34
KJSEmbed::extractInt
int KJSEMBED_EXPORT extractInt(KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue=0)
Extracts an integer from an argument list.
Definition: binding_support.cpp:72
KJSEmbed::toQString
QString toQString(const KJS::UString &u)
Definition: kjseglobal.h:58
KJSEmbed::extractVariant
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.
Definition: variant_binding.cpp:407
KJSEmbed::createVariant
KJS::JSValue * createVariant(KJS::ExecState *exec, const KJS::UString &className, const T &value)
Can create any known KJSEmbed::VariantBinding object and set the value.
Definition: variant_binding.h:185
KJS
Implement QString-KJS::UString conversion methods.
Definition: kjs_object_model.h:29
KJS::throwError
JSObject * throwError(ExecState *e, ErrorType t, const QString &m)
Definition: binding_support.h:241
object_binding.h
START_OBJECT_METHOD
#define START_OBJECT_METHOD(METHODNAME, TYPE)
A simple pointer syle method.
Definition: object_binding.h:40
END_OBJECT_METHOD
#define END_OBJECT_METHOD
End a variant method started by START_OBJECT_METHOD.
Definition: object_binding.h:57
device
QPaintDevice * device
Definition: qpainter_binding.cpp:83
if
if(device)
Definition: qpainter_binding.cpp:84
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
extractPaintDevice
QPaintDevice * extractPaintDevice(KJS::ExecState *exec, KJS::JSValue *arg)
Definition: qpainter_binding.cpp:44
result
result
Definition: qpainter_binding.cpp:82
cppValue
END_OBJECT_METHOD QBrush cppValue
Definition: qpainter_binding.cpp:97
arg1
Qt::FillRule arg1
Definition: qpainter_binding.cpp:307
object
return object
Definition: qpainter_binding.cpp:514
drawConvexPolygon
object drawConvexPolygon(arg0)
qpainter_binding.h
static_binding.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kjsembed

Skip menu "kjsembed"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal