• 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
pixmap.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 "pixmap.h"
23 
24 #include <QtCore/QDebug>
25 #include <QtGui/QPixmap>
26 #include <QtGui/QBitmap>
27 #include <QtGui/QWidget>
28 
29 #include <variant_binding.h>
30 #include <object_binding.h>
31 
32 using namespace KJSEmbed;
33 
34 const KJS::ClassInfo PixmapBinding::info = { "QPixmap", &VariantBinding::info, 0, 0 };
35 PixmapBinding::PixmapBinding( KJS::ExecState *exec, const QPixmap &value )
36  : VariantBinding(exec, value )
37 {
38  StaticBinding::publish( exec, this, Pixmap::methods() );
39  StaticBinding::publish( exec, this, VariantFactory::methods() );
40 }
41 
42 namespace PixmapNS
43 {
44 START_VARIANT_METHOD( callalphaChannel, QPixmap )
45  QPixmap cppValue = value.alphaChannel();
46  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
47 END_VARIANT_METHOD
48 
49 START_VARIANT_METHOD( callcopy, QPixmap )
50  if( args.size() == 1)
51  {
52  QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
53  QPixmap cppValue = value.copy(arg0);
54  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
55  }
56  else if( args.size() == 4)
57  {
58  int arg0 = KJSEmbed::extractInt(exec, args, 0);
59  int arg1 = KJSEmbed::extractInt(exec, args, 1);
60  int arg2 = KJSEmbed::extractInt(exec, args, 2);
61  int arg3 = KJSEmbed::extractInt(exec, args, 3);
62  QPixmap cppValue = value.copy(arg0, arg1, arg2, arg3);
63  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
64  }
65 END_VARIANT_METHOD
66 
67 START_VARIANT_METHOD( callcreateHeuristicMask, QPixmap )
68  bool arg0 = KJSEmbed::extractBool(exec, args, 0);
69  QBitmap cppValue = value.createHeuristicMask(arg0);
70  result = KJSEmbed::createVariant(exec, "QBitmap", cppValue );
71 END_VARIANT_METHOD
72 
73 START_VARIANT_METHOD( callcreateMaskFromColor, QPixmap )
74  QColor arg0 = KJSEmbed::extractVariant<QColor>(exec,args, 0);
75  QBitmap cppValue = value.createMaskFromColor(arg0);
76  result = KJSEmbed::createVariant(exec, "QBitmap", cppValue );
77 END_VARIANT_METHOD
78 
79 START_VARIANT_METHOD( calldefaultDepth, QPixmap )
80  int cppValue = value.defaultDepth();
81  result = KJS::jsNumber(cppValue);
82 END_VARIANT_METHOD
83 
84 START_VARIANT_METHOD( calldepth, QPixmap )
85  int cppValue = value.depth();
86  result = KJS::jsNumber(cppValue);
87 END_VARIANT_METHOD
88 
89 START_VARIANT_METHOD( callfill, QPixmap )
90  if( args.size() == 3)
91  {
92  QWidget* arg0 = KJSEmbed::extractObject<QWidget>(exec,args, 0);
93  int arg1 = KJSEmbed::extractInt(exec, args, 1);
94  int arg2 = KJSEmbed::extractInt(exec, args, 2);
95  value.fill(arg0, arg1, arg2);
96  }
97  else if( args.size() == 1)
98  {
99  QColor arg0 = KJSEmbed::extractVariant<QColor>(exec,args, 0);
100  value.fill(arg0);
101  }
102  else if( args.size() == 2)
103  {
104  QWidget* arg0 = KJSEmbed::extractObject<QWidget>(exec,args, 0);
105  QPoint arg1 = KJSEmbed::extractVariant<QPoint>(exec,args, 1);
106  value.fill(arg0, arg1);
107  }
108 END_VARIANT_METHOD
109 
110 START_VARIANT_METHOD( callfromImage, QPixmap )
111  QImage arg0 = KJSEmbed::extractVariant<QImage>(exec,args, 0);
112  Qt::ImageConversionFlags arg1 = (Qt::ImageConversionFlags)KJSEmbed::extractInt(exec, args, 1);
113  QPixmap cppValue = QPixmap::fromImage(arg0, arg1);
114  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
115 END_VARIANT_METHOD
116 
117 START_VARIANT_METHOD( callgrabWidget, QPixmap )
118  if( args.size() == 2)
119  {
120  QWidget* arg0 = KJSEmbed::extractObject<QWidget>(exec,args, 0);
121  QRect arg1 = KJSEmbed::extractVariant<QRect>(exec,args, 1);
122  QPixmap cppValue = value.grabWidget(arg0, arg1);
123  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
124  }
125  else if( args.size() == 5)
126  {
127  QWidget* arg0 = KJSEmbed::extractObject<QWidget>(exec,args, 0);
128  int arg1 = KJSEmbed::extractInt(exec, args, 1);
129  int arg2 = KJSEmbed::extractInt(exec, args, 2);
130  int arg3 = KJSEmbed::extractInt(exec, args, 3);
131  int arg4 = KJSEmbed::extractInt(exec, args, 4);
132  QPixmap cppValue = value.grabWidget(arg0, arg1, arg2, arg3, arg4);
133  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
134  }
135 END_VARIANT_METHOD
136 
137 START_VARIANT_METHOD( callhasAlpha, QPixmap )
138  bool cppValue = value.hasAlpha();
139  result = KJS::jsBoolean(cppValue);
140 END_VARIANT_METHOD
141 
142 START_VARIANT_METHOD( callhasAlphaChannel, QPixmap )
143  bool cppValue = value.hasAlphaChannel();
144  result = KJS::jsBoolean(cppValue);
145 END_VARIANT_METHOD
146 
147 START_VARIANT_METHOD( callheight, QPixmap )
148  int cppValue = value.height();
149  result = KJS::jsNumber(cppValue);
150 END_VARIANT_METHOD
151 
152 START_VARIANT_METHOD( callisNull, QPixmap )
153  bool cppValue = value.isNull();
154  result = KJS::jsBoolean(cppValue);
155 END_VARIANT_METHOD
156 
157 START_VARIANT_METHOD( callisQBitmap, QPixmap )
158  bool cppValue = value.isQBitmap();
159  result = KJS::jsBoolean(cppValue);
160 END_VARIANT_METHOD
161 
162 START_VARIANT_METHOD( callload, QPixmap )
163  QString arg0 = KJSEmbed::extractQString(exec, args, 0);
164  QByteArray arg1 = KJSEmbed::extractQString( exec, args, 1 ).toLatin1();
165  Qt::ImageConversionFlags arg2 = (Qt::ImageConversionFlags) KJSEmbed::extractInt(exec, args, 2);
166  bool cppValue = value.load(arg0, arg1, arg2);
167  result = KJS::jsBoolean(cppValue);
168 END_VARIANT_METHOD
169 
170 START_VARIANT_METHOD( callmask, QPixmap )
171  QBitmap cppValue = value.mask();
172  result = KJSEmbed::createVariant(exec, "QBitmap", cppValue );
173 END_VARIANT_METHOD
174 
175 START_VARIANT_METHOD( callrect, QPixmap )
176  QRect cppValue = value.rect();
177  result = KJSEmbed::createVariant(exec, "QRect", cppValue );
178 END_VARIANT_METHOD
179 
180 START_VARIANT_METHOD( callsave, QPixmap )
181  QString arg0 = KJSEmbed::extractQString(exec, args, 0);
182  QByteArray arg1 = KJSEmbed::extractQString( exec, args, 1 ).toLatin1();
183  int arg2 = KJSEmbed::extractInt(exec, args, 2, -1);
184  bool cppValue = value.save(arg0, arg1, arg2);
185  result = KJS::jsBoolean(cppValue);
186 END_VARIANT_METHOD
187 
188 START_VARIANT_METHOD( callscaled, QPixmap )
189  if( args.size() == 3 )
190  {
191  QSize arg0 = KJSEmbed::extractVariant<QSize>(exec,args, 0);
192  Qt::AspectRatioMode arg1 = (Qt::AspectRatioMode) KJSEmbed::extractInt(exec, args, 1);
193  Qt::TransformationMode arg2 = (Qt::TransformationMode) KJSEmbed::extractInt(exec, args, 3);
194  QPixmap cppValue = value.scaled(arg0, arg1, arg2);
195  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
196  }
197  else if ( args.size() == 4)
198  {
199  int arg0 = KJSEmbed::extractInt(exec, args, 0);
200  int arg1 = KJSEmbed::extractInt(exec, args, 1);
201  Qt::AspectRatioMode arg2 = (Qt::AspectRatioMode) KJSEmbed::extractInt(exec, args, 2);
202  Qt::TransformationMode arg3 = (Qt::TransformationMode) KJSEmbed::extractInt(exec, args, 3);
203  QPixmap cppValue = value.scaled(arg0, arg1, arg2, arg3);
204  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
205  }
206 END_VARIANT_METHOD
207 
208 START_VARIANT_METHOD( callscaledToHeight, QPixmap )
209  int arg0 = KJSEmbed::extractInt(exec, args, 0);
210  Qt::TransformationMode arg1 = (Qt::TransformationMode) KJSEmbed::extractInt(exec, args, 1);
211  QPixmap cppValue = value.scaledToHeight(arg0, arg1);
212  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
213 END_VARIANT_METHOD
214 
215 START_VARIANT_METHOD( callscaledToWidth, QPixmap )
216  int arg0 = KJSEmbed::extractInt(exec, args, 0);
217  Qt::TransformationMode arg1 = (Qt::TransformationMode) KJSEmbed::extractInt(exec, args, 1);
218  QPixmap cppValue = value.scaledToWidth(arg0, arg1);
219  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
220 END_VARIANT_METHOD
221 
222 START_VARIANT_METHOD( callserialNumber, QPixmap )
223  int cppValue = value.serialNumber();
224  result = KJS::jsNumber(cppValue);
225 END_VARIANT_METHOD
226 
227 START_VARIANT_METHOD( callsetAlphaChannel, QPixmap )
228  QPixmap arg0 = KJSEmbed::extractVariant<QPixmap>(exec,args, 0);
229  value.setAlphaChannel(arg0);
230 END_VARIANT_METHOD
231 
232 START_VARIANT_METHOD( callsetMask, QPixmap )
233  QBitmap arg0 = KJSEmbed::extractVariant<QBitmap>(exec,args, 0);
234  value.setMask(arg0);
235 END_VARIANT_METHOD
236 
237 START_VARIANT_METHOD( callsize, QPixmap )
238  QSize cppValue = value.size();
239  result = KJSEmbed::createVariant(exec, "QSize", cppValue );
240 END_VARIANT_METHOD
241 
242 START_VARIANT_METHOD( calltoImage, QPixmap )
243  QImage cppValue = value.toImage();
244  result = KJSEmbed::createVariant(exec, "QImage", cppValue );
245 END_VARIANT_METHOD
246 
247 START_VARIANT_METHOD( callwidth, QPixmap )
248  int cppValue = value.width();
249  result = KJS::jsNumber(cppValue);
250 END_VARIANT_METHOD
251 
252 }
253 
254 START_METHOD_LUT( Pixmap )
255  {"alphaChannel", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callalphaChannel},
256  {"copy", 3, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callcopy},
257  {"createHeuristicMask", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callcreateHeuristicMask},
258  {"createMaskFromColor", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callcreateMaskFromColor},
259  {"defaultDepth", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::calldefaultDepth},
260  {"depth", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::calldepth},
261  {"fill", 2, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callfill},
262  {"fromImage", 1, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callfromImage},
263  {"grabWidget", 4, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callgrabWidget},
264  {"hasAlpha", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callhasAlpha},
265  {"hasAlphaChannel", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callhasAlphaChannel},
266  {"height", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callheight},
267  {"isNull", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callisNull},
268  {"isQBitmap", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callisQBitmap},
269  {"load", 2, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callload},
270  {"mask", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callmask},
271  {"rect", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callrect},
272  {"save", 2, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callsave},
273  {"scaled", 3, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callscaled},
274  {"scaledToHeight", 1, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callscaledToHeight},
275  {"scaledToWidth", 1, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callscaledToWidth},
276  {"serialNumber", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callserialNumber},
277  {"setAlphaChannel", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callsetAlphaChannel},
278  {"setMask", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callsetMask},
279  {"size", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callsize},
280  {"toImage", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::calltoImage},
281  {"width", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callwidth}
282 END_METHOD_LUT
283 
284 NO_STATICS( Pixmap )
285 NO_ENUMS( Pixmap )
286 START_CTOR( Pixmap, QPixmap, 0)
287  if( args.size() == 0 )
288  {
289  return new KJSEmbed::PixmapBinding( exec, QPixmap() );
290  }
291  else if( args.size() == 1 )
292  {
293  return new KJSEmbed::PixmapBinding( exec,
294  QPixmap( KJSEmbed::extractQString(exec,args, 0) ) );
295  }
296  else if( args.size() == 2 )
297  {
298  return new KJSEmbed::PixmapBinding(exec,
299  QPixmap( KJSEmbed::extractInt( exec, args, 0 ),
300  KJSEmbed::extractInt( exec, args, 1 )
301  ) );
302  }
303  else if( args.size() == 3 )
304  {
305  QString tmp = toQString(args[2]->toObject(exec)->className());
306  qDebug() << tmp;
307 
308  return new KJSEmbed::PixmapBinding(exec,
309  QPixmap( KJSEmbed::extractQString( exec, args, 0 ),
310  KJSEmbed::extractVariant<QByteArray>( exec, args, 1 ).constData(),
311  (Qt::ImageConversionFlags)KJSEmbed::extractInt( exec, args, 2 )
312  ) );
313  }
314  return new KJSEmbed::PixmapBinding( exec, QPixmap() );
315 END_CTOR
316 
317 
318 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KJSEmbed::VariantBinding::info
static const KJS::ClassInfo info
Definition: variant_binding.h:123
PixmapNS::setMask
value setMask(arg0)
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
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
KJSEmbed::extractBool
bool KJSEMBED_EXPORT extractBool(KJS::ExecState *exec, const KJS::List &args, int idx, bool defaultValue=false)
Extracts a bool from an argument list.
Definition: binding_support.cpp:149
KJSEmbed::PixmapBinding
Definition: pixmap.h:34
END_CTOR
#define END_CTOR
Definition: binding_support.h:166
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
className
END_QOBJECT_METHOD QByteArray className
Definition: qobject_binding.cpp:832
PixmapNS::if
END_VARIANT_METHOD if(args.size()==1)
Definition: pixmap.cpp:50
object_binding.h
START_CTOR
#define START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:157
KJSEmbed::PixmapBinding::PixmapBinding
PixmapBinding(KJS::ExecState *exec, const QPixmap &value)
Definition: pixmap.cpp:35
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
pixmap.h
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
PixmapNS::setAlphaChannel
value setAlphaChannel(arg0)
PixmapNS::arg2
Qt::ImageConversionFlags arg2
Definition: pixmap.cpp:165
KJSEmbed::VariantFactory::methods
static const Method * methods()
Definition: variant_binding.h:251
KJSEmbed::PixmapBinding::info
static const KJS::ClassInfo info
Definition: pixmap.h:39
PixmapNS::result
result
Definition: pixmap.cpp:46
cppValue
END_OBJECT_METHOD QBrush cppValue
Definition: qpainter_binding.cpp:97
START_METHOD_LUT
START_METHOD_LUT(Pixmap)
Definition: pixmap.cpp:254
END_VARIANT_METHOD
#define END_VARIANT_METHOD
End a variant method started by START_VARIANT_METHOD.
Definition: variant_binding.h:56
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
arg1
Qt::FillRule arg1
Definition: qpainter_binding.cpp:307
WidgetNS::width
END_QOBJECT_METHOD int width
Definition: qwidget_binding.cpp:90
START_VARIANT_METHOD
#define START_VARIANT_METHOD(METHODNAME, TYPE)
A simple variant syle method.
Definition: variant_binding.h:42
variant_binding.h
value
QVariant value
Definition: settings.cpp:35
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
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