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

kjsembed

  • sources
  • kde-4.12
  • kdelibs
  • 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 
42 using namespace KJSEmbed;
43 
44 QPaintDevice *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
54 
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 
81 START_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  }
90 END_OBJECT_METHOD
91 
92 START_OBJECT_METHOD( callPainterEnd, QPainter )
93  result = KJS::jsBoolean(object->end());
94 END_OBJECT_METHOD
95 
96 START_OBJECT_METHOD( callbackground, QPainter )
97  QBrush cppValue = object->background();
98  result = KJSEmbed::createVariant(exec, "QBrush", cppValue );
99 END_OBJECT_METHOD
100 
101 START_OBJECT_METHOD( callbackgroundMode, QPainter )
102  Qt::BGMode cppValue = object->backgroundMode();
103  result = KJS::jsNumber(cppValue);
104 END_OBJECT_METHOD
105 
106 START_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  }
126 END_OBJECT_METHOD
127 
128 START_OBJECT_METHOD( callbrush, QPainter )
129  QBrush cppValue = object->brush();
130  result = KJSEmbed::createVariant(exec, "QBrush", cppValue );
131 END_OBJECT_METHOD
132 
133 START_OBJECT_METHOD( callbrushOrigin, QPainter )
134  QPoint cppValue = object->brushOrigin();
135  result = KJSEmbed::createVariant(exec, "QPoint", cppValue );
136 END_OBJECT_METHOD
137 
138 START_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  }
156 END_OBJECT_METHOD
157 
158 START_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  }
176 END_OBJECT_METHOD
177 
178 START_OBJECT_METHOD( calldrawConvexPolygon, QPainter )
179  QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec,args, 0);
180  object->drawConvexPolygon(arg0);
181 END_OBJECT_METHOD
182 
183 START_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  }
197 END_OBJECT_METHOD
198 
199 START_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  }
226 END_OBJECT_METHOD
227 
228 START_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  }
248 END_OBJECT_METHOD
249 
250 START_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  }
268 END_OBJECT_METHOD
269 
270 START_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  }
284 END_OBJECT_METHOD
285 
286 START_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  }
298 END_OBJECT_METHOD
299 
300 START_OBJECT_METHOD( calldrawPoints, QPainter )
301  QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec,args, 0);
302  object->drawPoints(arg0);
303 END_OBJECT_METHOD
304 
305 START_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);
309 END_OBJECT_METHOD
310 
311 START_OBJECT_METHOD( calldrawPolyline, QPainter )
312  QPolygon arg0 = KJSEmbed::extractVariant<QPolygon>(exec,args, 0);
313  object->drawPolyline(arg0);
314 END_OBJECT_METHOD
315 
316 START_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  }
330 END_OBJECT_METHOD
331 
332 START_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  }
350 END_OBJECT_METHOD
351 
352 START_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  }
378 END_OBJECT_METHOD
379 
380 START_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  }
392 END_OBJECT_METHOD
393 
394 START_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  }
413 END_OBJECT_METHOD
414 
415 START_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  }
429 END_OBJECT_METHOD
430 
431 START_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}
486 END_METHOD_LUT
487 
488 NO_ENUMS( Painter )
489 NO_STATICS( Painter )
490 
491 START_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;
515 END_CTOR
516 
517 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
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:88
device
QPaintDevice * device
Definition: qpainter_binding.cpp:83
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
QWidget
object
return object
Definition: qpainter_binding.cpp:514
END_CTOR
#define END_CTOR
Definition: binding_support.h:166
if
if(device)
Definition: qpainter_binding.cpp:84
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::VariantBinding::pointer
void * pointer()
Definition: variant_binding.cpp:53
QObject
drawConvexPolygon
object drawConvexPolygon(arg0)
drawPolygon
object drawPolygon(arg0, arg1)
KJSEmbed::ObjectBinding::object
T * object() const
Definition: object_binding.h:119
KJSEmbed::ObjectBinding
Definition: object_binding.h:88
object_binding.h
START_CTOR
#define START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:157
END_OBJECT_METHOD
#define END_OBJECT_METHOD
End a variant method started by START_OBJECT_METHOD.
Definition: object_binding.h:57
START_METHOD_LUT
END_OBJECT_METHOD START_METHOD_LUT(Painter)
Definition: qpainter_binding.cpp:431
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
extractPaintDevice
QPaintDevice * extractPaintDevice(KJS::ExecState *exec, KJS::JSValue *arg)
Definition: qpainter_binding.cpp:44
KJSEmbed::ObjectFactory::methods
static const Method * methods()
Definition: object_binding.h:85
drawPoints
object drawPoints(arg0)
START_OBJECT_METHOD
#define START_OBJECT_METHOD(METHODNAME, TYPE)
A simple pointer syle method.
Definition: object_binding.h:40
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
result
result
Definition: qpainter_binding.cpp:82
qpainter_binding.h
kjseglobal.h
KJSEmbed::VariantBinding::variant
QVariant variant() const
Return the wrapped QVariant.
Definition: variant_binding.cpp:68
drawPolyline
object drawPolyline(arg0)
cppValue
END_OBJECT_METHOD QBrush cppValue
Definition: qpainter_binding.cpp:97
ImageNS::arg2
int arg2
Definition: image.cpp:56
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
static_binding.h
arg1
Qt::FillRule arg1
Definition: qpainter_binding.cpp:307
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
ImageNS::arg3
int arg3
Definition: image.cpp:57
KJS::throwError
JSObject * throwError(ExecState *e, ErrorType t, const QString &m)
Definition: binding_support.h:241
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
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
KJSEmbed::toQString
QString toQString(const KJS::UString &u)
Definition: kjseglobal.h:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:53 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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