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

kjsembed

pixmap.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
00003     Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
00004     Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
00005     Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 #include "pixmap.h"
00023 
00024 #include <QtCore/QDebug>
00025 #include <QtGui/QPixmap>
00026 #include <QtGui/QBitmap>
00027 #include <QtGui/QWidget>
00028 
00029 #include <variant_binding.h>
00030 #include <object_binding.h>
00031 
00032 using namespace KJSEmbed;
00033 
00034 const KJS::ClassInfo PixmapBinding::info = { "QPixmap", &VariantBinding::info, 0, 0 };
00035 PixmapBinding::PixmapBinding( KJS::ExecState *exec, const QPixmap &value )
00036     : VariantBinding(exec, value )
00037 {
00038     StaticBinding::publish( exec, this, Pixmap::methods() );
00039     StaticBinding::publish( exec, this, VariantFactory::methods() );
00040 }
00041 
00042 namespace PixmapNS
00043 {
00044 START_VARIANT_METHOD( callalphaChannel, QPixmap )
00045     QPixmap cppValue = value.alphaChannel();
00046     result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00047 END_VARIANT_METHOD
00048 
00049 START_VARIANT_METHOD( callcopy, QPixmap )
00050     if( args.size() == 1)
00051     {
00052         QRect arg0 = KJSEmbed::extractVariant<QRect>(exec,args, 0);
00053         QPixmap cppValue = value.copy(arg0);
00054         result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00055     }
00056     else if( args.size() == 4)
00057     {
00058         int arg0 = KJSEmbed::extractInt(exec, args, 0);
00059         int arg1 = KJSEmbed::extractInt(exec, args, 1);
00060         int arg2 = KJSEmbed::extractInt(exec, args, 2);
00061         int arg3 = KJSEmbed::extractInt(exec, args, 3);
00062         QPixmap cppValue = value.copy(arg0, arg1, arg2, arg3);
00063         result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00064     }
00065 END_VARIANT_METHOD
00066 
00067 START_VARIANT_METHOD( callcreateHeuristicMask, QPixmap )
00068     bool arg0 = KJSEmbed::extractBool(exec, args, 0);
00069     QBitmap cppValue = value.createHeuristicMask(arg0);
00070     result = KJSEmbed::createVariant(exec, "QBitmap", cppValue );
00071 END_VARIANT_METHOD
00072 
00073 START_VARIANT_METHOD( callcreateMaskFromColor, QPixmap )
00074     QColor arg0 = KJSEmbed::extractVariant<QColor>(exec,args, 0);
00075     QBitmap cppValue = value.createMaskFromColor(arg0);
00076     result = KJSEmbed::createVariant(exec, "QBitmap", cppValue );
00077 END_VARIANT_METHOD
00078 
00079 START_VARIANT_METHOD( calldefaultDepth, QPixmap )
00080     int cppValue = value.defaultDepth();
00081     result = KJS::jsNumber(cppValue);
00082 END_VARIANT_METHOD
00083 
00084 START_VARIANT_METHOD( calldepth, QPixmap )
00085     int cppValue = value.depth();
00086     result = KJS::jsNumber(cppValue);
00087 END_VARIANT_METHOD
00088 
00089 START_VARIANT_METHOD( callfill, QPixmap )
00090     if( args.size() == 3)
00091     {
00092         QWidget* arg0 = KJSEmbed::extractObject<QWidget>(exec,args, 0);
00093         int arg1 = KJSEmbed::extractInt(exec, args, 1);
00094         int arg2 = KJSEmbed::extractInt(exec, args, 2);
00095         value.fill(arg0, arg1, arg2);
00096     }
00097     else if( args.size() == 1)
00098     {
00099         QColor arg0 = KJSEmbed::extractVariant<QColor>(exec,args, 0);
00100         value.fill(arg0);
00101     }
00102     else if( args.size() == 2)
00103     {
00104         QWidget* arg0 = KJSEmbed::extractObject<QWidget>(exec,args, 0);
00105         QPoint arg1 = KJSEmbed::extractVariant<QPoint>(exec,args, 1);
00106         value.fill(arg0, arg1);
00107     }
00108 END_VARIANT_METHOD
00109 
00110 START_VARIANT_METHOD( callfromImage, QPixmap )
00111     QImage arg0 = KJSEmbed::extractVariant<QImage>(exec,args, 0);
00112     Qt::ImageConversionFlags arg1 = (Qt::ImageConversionFlags)KJSEmbed::extractInt(exec, args, 1);
00113     QPixmap cppValue = QPixmap::fromImage(arg0, arg1);
00114     result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00115 END_VARIANT_METHOD
00116 
00117 START_VARIANT_METHOD( callgrabWidget, QPixmap )
00118     if( args.size() == 2)
00119     {
00120         QWidget* arg0 = KJSEmbed::extractObject<QWidget>(exec,args, 0);
00121         QRect arg1 = KJSEmbed::extractVariant<QRect>(exec,args, 1);
00122         QPixmap cppValue = value.grabWidget(arg0, arg1);
00123         result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00124     }
00125     else if( args.size() == 5)
00126     {
00127         QWidget* arg0 = KJSEmbed::extractObject<QWidget>(exec,args, 0);
00128         int arg1 = KJSEmbed::extractInt(exec, args, 1);
00129         int arg2 = KJSEmbed::extractInt(exec, args, 2);
00130         int arg3 = KJSEmbed::extractInt(exec, args, 3);
00131         int arg4 = KJSEmbed::extractInt(exec, args, 4);
00132         QPixmap cppValue = value.grabWidget(arg0, arg1, arg2, arg3, arg4);
00133         result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00134     }
00135 END_VARIANT_METHOD
00136 
00137 START_VARIANT_METHOD( callhasAlpha, QPixmap )
00138     bool cppValue = value.hasAlpha();
00139     result = KJS::jsBoolean(cppValue);
00140 END_VARIANT_METHOD
00141 
00142 START_VARIANT_METHOD( callhasAlphaChannel, QPixmap )
00143     bool cppValue = value.hasAlphaChannel();
00144     result = KJS::jsBoolean(cppValue);
00145 END_VARIANT_METHOD
00146 
00147 START_VARIANT_METHOD( callheight, QPixmap )
00148     int cppValue = value.height();
00149     result = KJS::jsNumber(cppValue);
00150 END_VARIANT_METHOD
00151 
00152 START_VARIANT_METHOD( callisNull, QPixmap )
00153     bool cppValue = value.isNull();
00154     result = KJS::jsBoolean(cppValue);
00155 END_VARIANT_METHOD
00156 
00157 START_VARIANT_METHOD( callisQBitmap, QPixmap )
00158     bool cppValue = value.isQBitmap();
00159     result = KJS::jsBoolean(cppValue);
00160 END_VARIANT_METHOD
00161 
00162 START_VARIANT_METHOD( callload, QPixmap )
00163     QString arg0 = KJSEmbed::extractQString(exec, args, 0);
00164     QByteArray arg1 = KJSEmbed::extractQString( exec, args, 1 ).toLatin1();
00165     Qt::ImageConversionFlags arg2 = (Qt::ImageConversionFlags) KJSEmbed::extractInt(exec, args, 2);
00166     bool cppValue = value.load(arg0, arg1, arg2);
00167     result = KJS::jsBoolean(cppValue);
00168 END_VARIANT_METHOD
00169 
00170 START_VARIANT_METHOD( callmask, QPixmap )
00171     QBitmap cppValue = value.mask();
00172     result = KJSEmbed::createVariant(exec, "QBitmap", cppValue );
00173 END_VARIANT_METHOD
00174 
00175 START_VARIANT_METHOD( callrect, QPixmap )
00176     QRect cppValue = value.rect();
00177     result = KJSEmbed::createVariant(exec, "QRect", cppValue );
00178 END_VARIANT_METHOD
00179 
00180 START_VARIANT_METHOD( callsave, QPixmap )
00181     QString arg0 = KJSEmbed::extractQString(exec, args, 0);
00182     QByteArray arg1 = KJSEmbed::extractQString( exec, args, 1 ).toLatin1();
00183     int arg2 = KJSEmbed::extractInt(exec, args, 2, -1);
00184     bool cppValue = value.save(arg0, arg1, arg2);
00185     result = KJS::jsBoolean(cppValue);
00186 END_VARIANT_METHOD
00187 
00188 START_VARIANT_METHOD( callscaled, QPixmap )
00189     if( args.size() == 3 )
00190     {
00191         QSize arg0 = KJSEmbed::extractVariant<QSize>(exec,args, 0);
00192         Qt::AspectRatioMode arg1 = (Qt::AspectRatioMode) KJSEmbed::extractInt(exec, args, 1);
00193         Qt::TransformationMode arg2 = (Qt::TransformationMode) KJSEmbed::extractInt(exec, args, 3);
00194         QPixmap cppValue = value.scaled(arg0, arg1, arg2);
00195         result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00196     }
00197     else if ( args.size() == 4)
00198     {
00199         int arg0 = KJSEmbed::extractInt(exec, args, 0);
00200         int arg1 = KJSEmbed::extractInt(exec, args, 1);
00201         Qt::AspectRatioMode arg2 = (Qt::AspectRatioMode) KJSEmbed::extractInt(exec, args, 2);
00202         Qt::TransformationMode arg3 = (Qt::TransformationMode) KJSEmbed::extractInt(exec, args, 3);
00203         QPixmap cppValue = value.scaled(arg0, arg1, arg2, arg3);
00204         result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00205     }
00206 END_VARIANT_METHOD
00207 
00208 START_VARIANT_METHOD( callscaledToHeight, QPixmap )
00209     int arg0 = KJSEmbed::extractInt(exec, args, 0);
00210     Qt::TransformationMode arg1  = (Qt::TransformationMode) KJSEmbed::extractInt(exec, args, 1);
00211     QPixmap cppValue = value.scaledToHeight(arg0, arg1);
00212     result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00213 END_VARIANT_METHOD
00214 
00215 START_VARIANT_METHOD( callscaledToWidth, QPixmap )
00216     int arg0 = KJSEmbed::extractInt(exec, args, 0);
00217     Qt::TransformationMode arg1  = (Qt::TransformationMode) KJSEmbed::extractInt(exec, args, 1);
00218     QPixmap cppValue = value.scaledToWidth(arg0, arg1);
00219     result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
00220 END_VARIANT_METHOD
00221 
00222 START_VARIANT_METHOD( callserialNumber, QPixmap )
00223     int cppValue = value.serialNumber();
00224     result = KJS::jsNumber(cppValue);
00225 END_VARIANT_METHOD
00226 
00227 START_VARIANT_METHOD( callsetAlphaChannel, QPixmap )
00228     QPixmap arg0 = KJSEmbed::extractVariant<QPixmap>(exec,args, 0);
00229     value.setAlphaChannel(arg0);
00230 END_VARIANT_METHOD
00231 
00232 START_VARIANT_METHOD( callsetMask, QPixmap )
00233     QBitmap arg0 = KJSEmbed::extractVariant<QBitmap>(exec,args, 0);
00234     value.setMask(arg0);
00235 END_VARIANT_METHOD
00236 
00237 START_VARIANT_METHOD( callsize, QPixmap )
00238     QSize cppValue = value.size();
00239     result = KJSEmbed::createVariant(exec, "QSize", cppValue );
00240 END_VARIANT_METHOD
00241 
00242 START_VARIANT_METHOD( calltoImage, QPixmap )
00243     QImage cppValue = value.toImage();
00244     result = KJSEmbed::createVariant(exec, "QImage", cppValue );
00245 END_VARIANT_METHOD
00246 
00247 START_VARIANT_METHOD( callwidth, QPixmap )
00248     int cppValue = value.width();
00249     result = KJS::jsNumber(cppValue);
00250 END_VARIANT_METHOD
00251 
00252 }
00253 
00254 START_METHOD_LUT( Pixmap )
00255     {"alphaChannel", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callalphaChannel},
00256     {"copy", 3, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callcopy},
00257     {"createHeuristicMask", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callcreateHeuristicMask},
00258     {"createMaskFromColor", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callcreateMaskFromColor},
00259     {"defaultDepth", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::calldefaultDepth},
00260     {"depth", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::calldepth},
00261     {"fill", 2, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callfill},
00262     {"fromImage", 1, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callfromImage},
00263     {"grabWidget", 4, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callgrabWidget},
00264     {"hasAlpha", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callhasAlpha},
00265     {"hasAlphaChannel", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callhasAlphaChannel},
00266     {"height", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callheight},
00267     {"isNull", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callisNull},
00268     {"isQBitmap", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callisQBitmap},
00269     {"load", 2, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callload},
00270     {"mask", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callmask},
00271     {"rect", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callrect},
00272     {"save", 2, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callsave},
00273     {"scaled", 3, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callscaled},
00274     {"scaledToHeight", 1, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callscaledToHeight},
00275     {"scaledToWidth", 1, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callscaledToWidth},
00276     {"serialNumber", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callserialNumber},
00277     {"setAlphaChannel", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callsetAlphaChannel},
00278     {"setMask", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callsetMask},
00279     {"size", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callsize},
00280     {"toImage", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::calltoImage},
00281     {"width", 0, KJS::DontDelete|KJS::ReadOnly, &PixmapNS::callwidth}
00282 END_METHOD_LUT
00283 
00284 NO_STATICS( Pixmap )
00285 NO_ENUMS( Pixmap )
00286 START_CTOR( Pixmap, QPixmap, 0)
00287     if( args.size() == 0 )
00288     {
00289         return new KJSEmbed::PixmapBinding( exec, QPixmap() );
00290     }
00291     else if( args.size() == 1 )
00292     {
00293         return new KJSEmbed::PixmapBinding( exec,
00294                                         QPixmap( KJSEmbed::extractQString(exec,args, 0) ) );
00295     }
00296     else if( args.size() == 2 )
00297     {
00298         return new KJSEmbed::PixmapBinding(exec,
00299                                 QPixmap( KJSEmbed::extractInt( exec, args, 0 ),
00300                                                 KJSEmbed::extractInt( exec, args, 1 )
00301                                         ) );
00302     }
00303     else if( args.size() == 3 )
00304     {
00305         QString tmp = toQString(args[2]->toObject(exec)->className());
00306         qDebug() << tmp;
00307 
00308         return new KJSEmbed::PixmapBinding(exec,
00309                                 QPixmap( KJSEmbed::extractQString( exec, args, 0 ),
00310                                                 KJSEmbed::extractVariant<QByteArray>( exec, args, 1 ).constData(),
00311                                                 (Qt::ImageConversionFlags)KJSEmbed::extractInt( exec, args, 2 )
00312                                         ) );
00313     }
00314     return new KJSEmbed::PixmapBinding( exec, QPixmap() );
00315 END_CTOR
00316 
00317 
00318 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;

kjsembed

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal