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

kjsembed

color.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 "color.h"
00023 
00024 #include <QtCore/QDebug>
00025 #include <QtGui/QColor>
00026 
00027 using namespace KJSEmbed;
00028 
00029 const KJS::ClassInfo ColorBinding::info = { "QColor", &VariantBinding::info, 0, 0 };
00030 ColorBinding::ColorBinding( KJS::ExecState *exec, const QColor &value )
00031     : VariantBinding(exec, value )
00032 {
00033     StaticBinding::publish( exec, this, Color::methods() );
00034     StaticBinding::publish( exec, this, VariantFactory::methods() );
00035 }
00036 
00037 START_VARIANT_METHOD( callSetAlpha, QColor )
00038     value.setAlpha( KJSEmbed::extractInt(exec, args, 0) );
00039 END_VARIANT_METHOD
00040 
00041 START_VARIANT_METHOD( callSetBlue, QColor )
00042     value.setBlue( KJSEmbed::extractInt(exec, args, 0) );
00043 END_VARIANT_METHOD
00044 
00045 START_VARIANT_METHOD( callSetGreen, QColor )
00046     value.setGreen( KJSEmbed::extractInt(exec, args, 0) );
00047 END_VARIANT_METHOD
00048 
00049 START_VARIANT_METHOD( callSetRed, QColor )
00050     value.setRed( KJSEmbed::extractInt(exec, args, 0) );
00051 END_VARIANT_METHOD
00052 
00053 START_VARIANT_METHOD( callSetRgb, QColor )
00054     value.setRgb( KJSEmbed::extractInt(exec, args, 0),
00055                   KJSEmbed::extractInt(exec, args, 1),
00056                   KJSEmbed::extractInt(exec, args, 2),
00057                   KJSEmbed::extractInt(exec, args, 3, 255));
00058 END_VARIANT_METHOD
00059 
00060 START_VARIANT_METHOD( callSetCmyk, QColor )
00061     value.setCmyk( KJSEmbed::extractInt(exec, args, 0),
00062                    KJSEmbed::extractInt(exec, args, 1),
00063                    KJSEmbed::extractInt(exec, args, 2),
00064                    KJSEmbed::extractInt(exec, args, 3),
00065                    KJSEmbed::extractInt(exec, args, 4,255));
00066 END_VARIANT_METHOD
00067 
00068 START_VARIANT_METHOD( callSetHsv, QColor )
00069     value.setHsv( KJSEmbed::extractInt(exec, args, 0),
00070                   KJSEmbed::extractInt(exec, args, 1),
00071                   KJSEmbed::extractInt(exec, args, 2),
00072                   KJSEmbed::extractInt(exec, args, 3,255));
00073 END_VARIANT_METHOD
00074 
00075 START_VARIANT_METHOD( callSetNamedColor, QColor )
00076     value.setNamedColor( KJSEmbed::extractQString(exec, args, 0) );
00077 END_VARIANT_METHOD
00078 
00079 
00080 START_VARIANT_METHOD( callAlpha, QColor )
00081     value.setAlpha( KJSEmbed::extractInt(exec, args, 0) );
00082 END_VARIANT_METHOD
00083 
00084 START_VARIANT_METHOD( callBlue, QColor )
00085     result = KJSEmbed::createInt( exec, value.blue() );
00086 END_VARIANT_METHOD
00087 
00088 START_VARIANT_METHOD( callCyan, QColor )
00089     result = KJSEmbed::createInt( exec, value.cyan() );
00090 END_VARIANT_METHOD
00091 
00092 START_VARIANT_METHOD( callGreen, QColor )
00093     result = KJSEmbed::createInt( exec, value.green() );
00094 END_VARIANT_METHOD
00095 
00096 START_VARIANT_METHOD( callHue, QColor )
00097     result = KJSEmbed::createInt( exec, value.hue() );
00098 END_VARIANT_METHOD
00099 
00100 START_VARIANT_METHOD( callMagenta, QColor )
00101     result = KJSEmbed::createInt( exec, value.magenta() );
00102 END_VARIANT_METHOD
00103 
00104 START_VARIANT_METHOD( callRed, QColor )
00105     result = KJSEmbed::createInt( exec, value.red() );
00106 END_VARIANT_METHOD
00107 
00108 START_VARIANT_METHOD( callYellow, QColor )
00109     result = KJSEmbed::createInt( exec, value.yellow() );
00110 END_VARIANT_METHOD
00111 
00112 START_VARIANT_METHOD( callSaturation, QColor )
00113     result = KJSEmbed::createInt( exec, value.saturation() );
00114 END_VARIANT_METHOD
00115 
00116 START_VARIANT_METHOD( callDark, QColor )
00117     QColor darkColor = value.dark( KJSEmbed::extractInt( exec, args, 0, 200));
00118     result = KJSEmbed::createVariant(exec, "QColor", darkColor);
00119 END_VARIANT_METHOD
00120 
00121 START_VARIANT_METHOD( callLight, QColor )
00122     QColor darkColor = value.light( KJSEmbed::extractInt( exec, args, 0, 200));
00123     result = KJSEmbed::createVariant(exec, "QColor", darkColor);
00124 END_VARIANT_METHOD
00125 
00126 START_VARIANT_METHOD( callConvertTo, QColor )
00127     QColor otherColor = value.convertTo( (QColor::Spec)KJSEmbed::extractInt( exec, args, 0));
00128     result = KJSEmbed::createVariant(exec, "QColor", otherColor);
00129 END_VARIANT_METHOD
00130 
00131 START_VARIANT_METHOD( callSpec, QColor )
00132     result = KJS::jsNumber( value.spec() );
00133 END_VARIANT_METHOD
00134 
00135 START_METHOD_LUT( Color )
00136     {"setAlpha", 1, KJS::DontDelete|KJS::ReadOnly, &callSetAlpha},
00137     {"setBlue", 1, KJS::DontDelete|KJS::ReadOnly, &callSetBlue},
00138     {"setGreen", 1, KJS::DontDelete|KJS::ReadOnly, &callSetGreen},
00139     {"setRed", 1, KJS::DontDelete|KJS::ReadOnly, &callSetRed},
00140     {"setRgb", 4, KJS::DontDelete|KJS::ReadOnly, &callSetRgb},
00141     {"setCmyk", 5, KJS::DontDelete|KJS::ReadOnly, &callSetCmyk},
00142     {"setHsv", 4, KJS::DontDelete|KJS::ReadOnly, &callSetHsv},
00143     {"setNamedColor", 1, KJS::DontDelete|KJS::ReadOnly, &callSetNamedColor},
00144     {"alpha", 0, KJS::DontDelete|KJS::ReadOnly, &callAlpha},
00145     {"blue", 0, KJS::DontDelete|KJS::ReadOnly, &callBlue},
00146     {"cyan", 0, KJS::DontDelete|KJS::ReadOnly, &callCyan},
00147     {"green", 0, KJS::DontDelete|KJS::ReadOnly, &callGreen},
00148     {"hue", 0, KJS::DontDelete|KJS::ReadOnly, &callHue},
00149     {"magenta", 0, KJS::DontDelete|KJS::ReadOnly, &callMagenta},
00150     {"red", 0, KJS::DontDelete|KJS::ReadOnly, &callRed},
00151     {"saturation", 0, KJS::DontDelete|KJS::ReadOnly, &callSaturation},
00152     {"yellow", 0, KJS::DontDelete|KJS::ReadOnly, &callYellow},
00153     {"light", 1, KJS::DontDelete|KJS::ReadOnly, &callLight},
00154     {"dark", 1, KJS::DontDelete|KJS::ReadOnly, &callDark},
00155     {"convertTo", 1, KJS::DontDelete|KJS::ReadOnly, &callConvertTo},
00156     {"spec", 0, KJS::DontDelete|KJS::ReadOnly, &callSpec}
00157 END_METHOD_LUT
00158 
00159 
00160 START_ENUM_LUT( Color )
00161     {"Rgb",QColor::Rgb},
00162     {"Hsv",QColor::Hsv},
00163     {"Cmyk",QColor::Cmyk},
00164     {"Invalid",QColor::Invalid}
00165 END_ENUM_LUT
00166 
00167 NO_STATICS( Color )
00168 
00169 START_CTOR( Color, QColor, 0)
00170     if( args.size() == 1 )
00171     {
00172         return new KJSEmbed::ColorBinding( exec, QColor( KJSEmbed::extractQString(exec,args,0 ) ) );
00173     }
00174     else if( args.size() >= 3 )
00175     {
00176         return new KJSEmbed::ColorBinding(exec,
00177                     QColor( KJSEmbed::extractInt( exec, args, 0 ),
00178                             KJSEmbed::extractInt( exec, args, 1 ),
00179                             KJSEmbed::extractInt( exec, args, 2 )) );
00180     }
00181 
00182     if( args.size() == 4 )
00183     {
00184         return new KJSEmbed::ColorBinding(exec,
00185                     QColor( KJSEmbed::extractInt( exec, args, 0 ),
00186                             KJSEmbed::extractInt( exec, args, 1 ),
00187                             KJSEmbed::extractInt( exec, args, 2 ),
00188                             KJSEmbed::extractInt( exec, args, 3 )) );
00189     }
00190 
00191     return new KJSEmbed::ColorBinding( exec, QColor() );
00192 END_CTOR
00193 
00194 //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