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

kjsembed

  • 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
32using namespace KJSEmbed;
33
34const KJS::ClassInfo PixmapBinding::info = { "QPixmap", &VariantBinding::info, 0, 0 };
35PixmapBinding::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
42namespace PixmapNS
43{
44START_VARIANT_METHOD( callalphaChannel, QPixmap )
45 QPixmap cppValue = value.alphaChannel();
46 result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
47END_VARIANT_METHOD
48
49START_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 }
65END_VARIANT_METHOD
66
67START_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 );
71END_VARIANT_METHOD
72
73START_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 );
77END_VARIANT_METHOD
78
79START_VARIANT_METHOD( calldefaultDepth, QPixmap )
80 int cppValue = value.defaultDepth();
81 result = KJS::jsNumber(cppValue);
82END_VARIANT_METHOD
83
84START_VARIANT_METHOD( calldepth, QPixmap )
85 int cppValue = value.depth();
86 result = KJS::jsNumber(cppValue);
87END_VARIANT_METHOD
88
89START_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 }
108END_VARIANT_METHOD
109
110START_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 );
115END_VARIANT_METHOD
116
117START_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 }
135END_VARIANT_METHOD
136
137START_VARIANT_METHOD( callhasAlpha, QPixmap )
138 bool cppValue = value.hasAlpha();
139 result = KJS::jsBoolean(cppValue);
140END_VARIANT_METHOD
141
142START_VARIANT_METHOD( callhasAlphaChannel, QPixmap )
143 bool cppValue = value.hasAlphaChannel();
144 result = KJS::jsBoolean(cppValue);
145END_VARIANT_METHOD
146
147START_VARIANT_METHOD( callheight, QPixmap )
148 int cppValue = value.height();
149 result = KJS::jsNumber(cppValue);
150END_VARIANT_METHOD
151
152START_VARIANT_METHOD( callisNull, QPixmap )
153 bool cppValue = value.isNull();
154 result = KJS::jsBoolean(cppValue);
155END_VARIANT_METHOD
156
157START_VARIANT_METHOD( callisQBitmap, QPixmap )
158 bool cppValue = value.isQBitmap();
159 result = KJS::jsBoolean(cppValue);
160END_VARIANT_METHOD
161
162START_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);
168END_VARIANT_METHOD
169
170START_VARIANT_METHOD( callmask, QPixmap )
171 QBitmap cppValue = value.mask();
172 result = KJSEmbed::createVariant(exec, "QBitmap", cppValue );
173END_VARIANT_METHOD
174
175START_VARIANT_METHOD( callrect, QPixmap )
176 QRect cppValue = value.rect();
177 result = KJSEmbed::createVariant(exec, "QRect", cppValue );
178END_VARIANT_METHOD
179
180START_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);
186END_VARIANT_METHOD
187
188START_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 }
206END_VARIANT_METHOD
207
208START_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 );
213END_VARIANT_METHOD
214
215START_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 );
220END_VARIANT_METHOD
221
222START_VARIANT_METHOD( callserialNumber, QPixmap )
223 int cppValue = value.serialNumber();
224 result = KJS::jsNumber(cppValue);
225END_VARIANT_METHOD
226
227START_VARIANT_METHOD( callsetAlphaChannel, QPixmap )
228 QPixmap arg0 = KJSEmbed::extractVariant<QPixmap>(exec,args, 0);
229 value.setAlphaChannel(arg0);
230END_VARIANT_METHOD
231
232START_VARIANT_METHOD( callsetMask, QPixmap )
233 QBitmap arg0 = KJSEmbed::extractVariant<QBitmap>(exec,args, 0);
234 value.setMask(arg0);
235END_VARIANT_METHOD
236
237START_VARIANT_METHOD( callsize, QPixmap )
238 QSize cppValue = value.size();
239 result = KJSEmbed::createVariant(exec, "QSize", cppValue );
240END_VARIANT_METHOD
241
242START_VARIANT_METHOD( calltoImage, QPixmap )
243 QImage cppValue = value.toImage();
244 result = KJSEmbed::createVariant(exec, "QImage", cppValue );
245END_VARIANT_METHOD
246
247START_VARIANT_METHOD( callwidth, QPixmap )
248 int cppValue = value.width();
249 result = KJS::jsNumber(cppValue);
250END_VARIANT_METHOD
251
252}
253
254START_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}
282END_METHOD_LUT
283
284NO_STATICS( Pixmap )
285NO_ENUMS( Pixmap )
286START_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() );
315END_CTOR
316
317
318//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::PixmapBinding
Definition: pixmap.h:35
KJSEmbed::PixmapBinding::info
static const KJS::ClassInfo info
Definition: pixmap.h:39
KJSEmbed::PixmapBinding::PixmapBinding
PixmapBinding(KJS::ExecState *exec, const QPixmap &value)
Definition: pixmap.cpp:35
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::info
static const KJS::ClassInfo info
Definition: variant_binding.h:123
KJSEmbed::VariantFactory::methods
static const Method * methods()
Definition: variant_binding.h:251
QWidget
result
END_VARIANT_METHOD result
Definition: color.cpp:85
if
if(file->open((QIODevice::OpenModeFlag) KJSEmbed::extractInt(exec, args, 0)))
Definition: fileio.cpp:64
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::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::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
PixmapNS
Definition: pixmap.cpp:43
object_binding.h
pixmap.h
className
END_QOBJECT_METHOD QByteArray className
Definition: qobject_binding.cpp:832
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
cppValue
END_OBJECT_METHOD QBrush cppValue
Definition: qpainter_binding.cpp:97
arg1
Qt::FillRule arg1
Definition: qpainter_binding.cpp:307
value
QVariant value
Definition: settings.cpp:35
variant_binding.h
START_VARIANT_METHOD
#define START_VARIANT_METHOD(METHODNAME, TYPE)
A simple variant syle method.
Definition: variant_binding.h:42
END_VARIANT_METHOD
#define END_VARIANT_METHOD
End a variant method started by START_VARIANT_METHOD.
Definition: variant_binding.h:56
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