kjsembed
pen.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 "pen.h" 00023 00024 #include <QtCore/QDebug> 00025 #include <QtGui/QPen> 00026 #include <QtGui/QBrush> 00027 #include <QtGui/QColor> 00028 00029 using namespace KJSEmbed; 00030 00031 const KJS::ClassInfo PenBinding::info = { "QPen", &VariantBinding::info, 0, 0 }; 00032 PenBinding::PenBinding( KJS::ExecState *exec, const QPen &value ) 00033 : VariantBinding(exec, value ) 00034 { 00035 StaticBinding::publish( exec, this, Pen::methods() ); 00036 StaticBinding::publish( exec, this, VariantFactory::methods() ); 00037 } 00038 00039 namespace PenNS 00040 { 00041 00042 START_VARIANT_METHOD( callbrush, QPen ) 00043 QBrush cppValue = value.brush(); 00044 result = KJSEmbed::createVariant(exec, "QBrush", cppValue ); 00045 END_VARIANT_METHOD 00046 00047 START_VARIANT_METHOD( callcapStyle, QPen ) 00048 Qt::PenCapStyle cppValue = value.capStyle(); 00049 result = KJS::jsNumber( cppValue ); 00050 END_VARIANT_METHOD 00051 00052 START_VARIANT_METHOD( callcolor, QPen ) 00053 QColor cppValue = value.color(); 00054 result = KJSEmbed::createVariant(exec, "QColor", cppValue ); 00055 END_VARIANT_METHOD 00056 00057 START_VARIANT_METHOD( callisSolid, QPen ) 00058 bool cppValue = value.isSolid(); 00059 result = KJS::jsBoolean(cppValue); 00060 END_VARIANT_METHOD 00061 00062 START_VARIANT_METHOD( calljoinStyle, QPen ) 00063 Qt::PenJoinStyle cppValue = value.joinStyle(); 00064 result = KJS::jsNumber( cppValue ); 00065 END_VARIANT_METHOD 00066 00067 START_VARIANT_METHOD( callsetBrush, QPen ) 00068 QBrush arg0 = KJSEmbed::extractVariant<QBrush>(exec,args, 0); 00069 value.setBrush(arg0); 00070 END_VARIANT_METHOD 00071 00072 START_VARIANT_METHOD( callsetCapStyle, QPen ) 00073 Qt::PenCapStyle arg0 = (Qt::PenCapStyle)KJSEmbed::extractInt(exec, args, 0); 00074 value.setCapStyle(arg0); 00075 END_VARIANT_METHOD 00076 00077 START_VARIANT_METHOD( callsetColor, QPen ) 00078 QColor arg0 = KJSEmbed::extractVariant<QColor>(exec,args, 0); 00079 value.setColor(arg0); 00080 END_VARIANT_METHOD 00081 00082 START_VARIANT_METHOD( callsetJoinStyle, QPen ) 00083 Qt::PenJoinStyle arg0 = (Qt::PenJoinStyle)KJSEmbed::extractInt(exec, args, 0); 00084 value.setJoinStyle(arg0); 00085 END_VARIANT_METHOD 00086 00087 START_VARIANT_METHOD( callsetStyle, QPen ) 00088 Qt::PenStyle arg0 = (Qt::PenStyle)KJSEmbed::extractInt(exec, args, 0); 00089 value.setStyle(arg0); 00090 END_VARIANT_METHOD 00091 00092 START_VARIANT_METHOD( callsetWidth, QPen ) 00093 int arg0 = KJSEmbed::extractInt(exec, args, 0); 00094 value.setWidth(arg0); 00095 END_VARIANT_METHOD 00096 00097 START_VARIANT_METHOD( callstyle, QPen ) 00098 Qt::PenStyle cppValue = value.style(); 00099 result = KJS::jsNumber( cppValue ); 00100 END_VARIANT_METHOD 00101 00102 START_VARIANT_METHOD( callwidth, QPen ) 00103 int cppValue = value.width(); 00104 result = KJS::jsNumber(cppValue); 00105 END_VARIANT_METHOD 00106 00107 } 00108 00109 START_METHOD_LUT( Pen ) 00110 {"brush", 0, KJS::DontDelete|KJS::ReadOnly, &PenNS::callbrush}, 00111 {"capStyle", 0, KJS::DontDelete|KJS::ReadOnly, &PenNS::callcapStyle}, 00112 {"color", 0, KJS::DontDelete|KJS::ReadOnly, &PenNS::callcolor}, 00113 {"isSolid", 0, KJS::DontDelete|KJS::ReadOnly, &PenNS::callisSolid}, 00114 {"joinStyle", 0, KJS::DontDelete|KJS::ReadOnly, &PenNS::calljoinStyle}, 00115 {"setBrush", 1, KJS::DontDelete|KJS::ReadOnly, &PenNS::callsetBrush}, 00116 {"setCapStyle", 1, KJS::DontDelete|KJS::ReadOnly, &PenNS::callsetCapStyle}, 00117 {"setColor", 1, KJS::DontDelete|KJS::ReadOnly, &PenNS::callsetColor}, 00118 {"setJoinStyle", 1, KJS::DontDelete|KJS::ReadOnly, &PenNS::callsetJoinStyle}, 00119 {"setStyle", 1, KJS::DontDelete|KJS::ReadOnly, &PenNS::callsetStyle}, 00120 {"setWidth", 1, KJS::DontDelete|KJS::ReadOnly, &PenNS::callsetWidth}, 00121 {"style", 0, KJS::DontDelete|KJS::ReadOnly, &PenNS::callstyle}, 00122 {"width", 0, KJS::DontDelete|KJS::ReadOnly, &PenNS::callwidth} 00123 END_METHOD_LUT 00124 00125 00126 NO_ENUMS( Pen ) 00127 NO_STATICS( Pen ) 00128 00129 START_CTOR( Pen, QPen, 0) 00130 if( args.size() == 1 ) 00131 { 00132 return new KJSEmbed::PenBinding(exec, 00133 QPen( KJSEmbed::extractVariant<QColor>( exec, args, 0 ) 00134 ) ); 00135 } 00136 else if (args.size() >= 2) 00137 { 00138 return new KJSEmbed::PenBinding(exec, 00139 QPen( KJSEmbed::extractVariant<QBrush>( exec, args, 0 ), 00140 KJSEmbed::extractInt( exec, args, 1 ), 00141 (Qt::PenStyle)KJSEmbed::extractInt( exec, args, 2, Qt::SolidLine ), 00142 (Qt::PenCapStyle)KJSEmbed::extractInt( exec, args, 3, Qt::SquareCap ), 00143 (Qt::PenJoinStyle)KJSEmbed::extractInt( exec, args, 4, Qt::BevelJoin ) 00144 ) ); 00145 00146 } 00147 00148 return new KJSEmbed::PenBinding( exec, QPen() ); 00149 END_CTOR 00150 00151 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KDE 4.6 API Reference