kjsembed
QBrush_bind.cpp
Go to the documentation of this file.
00001 #include "QBrush_bind.h" 00002 #include <QtGui/QBrush> 00003 #include <value_binding.h> 00004 #include <object_binding.h> 00005 00006 00007 using namespace KJSEmbed; 00008 00009 // Temp - for building 00010 class QColorBinding { public: static const KJS::ClassInfo info; }; 00011 class QPixmapBinding { public: static const KJS::ClassInfo info; }; 00012 class QGradientBinding { public: static const KJS::ClassInfo info; }; 00013 00014 const KJS::ClassInfo QColorBinding::info = { "QColor", &VariantBinding::info, 0, 0 }; 00015 const KJS::ClassInfo QPixmapBinding::info = { "QPixmap", &VariantBinding::info, 0, 0 }; 00016 const KJS::ClassInfo QGradientBinding::info = { "QGradient", &ObjectBinding::info, 0, 0 }; 00017 00018 const KJS::ClassInfo QBrushBinding::info = { "QBrush", &VariantBinding::info, 0, 0 }; 00019 QBrushBinding::QBrushBinding( KJS::ExecState *exec, const QBrush &value ) 00020 : VariantBinding(exec, value) 00021 { 00022 StaticBinding::publish(exec, this, QBrushData::methods() ); 00023 StaticBinding::publish(exec, this, VariantFactory::methods() ); 00024 } 00025 00026 00027 namespace QBrushNS 00028 { 00029 // style 00030 KJS::JSValue *style( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ) 00031 { 00032 Q_UNUSED(args); 00033 KJS::JSValue *result = KJS::jsNull(); 00034 KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self); 00035 if( !imp ) 00036 return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?"); 00037 00038 QBrush value = imp->value<QBrush>(); 00039 if (args.size() == 0 ) 00040 { 00041 Qt::BrushStyle tmp = value.style(); 00042 result = KJS::jsNumber( tmp ); 00043 imp->setValue(qVariantFromValue(value)); 00044 return result; 00045 } 00046 00047 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.style"); 00048 } 00049 00050 // setStyle 00051 KJS::JSValue *setStyle( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ) 00052 { 00053 Q_UNUSED(args); 00054 KJS::JSValue *result = KJS::jsNull(); 00055 KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self); 00056 if( !imp ) 00057 return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?"); 00058 00059 QBrush value = imp->value<QBrush>(); 00060 if (args.size() == 1 ) 00061 { 00062 KJS::JSValue* value0=args[0]; 00063 KJS::JSObject* object0=value0->toObject(exec); 00064 if(object0 && object0->isNumber()) 00065 { 00066 Qt::BrushStyle arg0 = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 0); 00067 value.setStyle(arg0); 00068 imp->setValue(qVariantFromValue(value)); 00069 return result; 00070 } 00071 } 00072 00073 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setStyle"); 00074 } 00075 00076 // texture 00077 KJS::JSValue *texture( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ) 00078 { 00079 Q_UNUSED(args); 00080 KJS::JSValue *result = KJS::jsNull(); 00081 KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self); 00082 if( !imp ) 00083 return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?"); 00084 00085 QBrush value = imp->value<QBrush>(); 00086 if (args.size() == 0 ) 00087 { 00088 QPixmap tmp = value.texture(); 00089 result = KJSEmbed::createVariant( exec, "QPixmap", tmp ); 00090 imp->setValue(qVariantFromValue(value)); 00091 return result; 00092 } 00093 00094 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.texture"); 00095 } 00096 00097 // setTexture 00098 KJS::JSValue *setTexture( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ) 00099 { 00100 Q_UNUSED(args); 00101 KJS::JSValue *result = KJS::jsNull(); 00102 KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self); 00103 if( !imp ) 00104 return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?"); 00105 00106 QBrush value = imp->value<QBrush>(); 00107 if (args.size() == 1 ) 00108 { 00109 KJS::JSValue* value0=args[0]; 00110 KJS::JSObject* object0=value0->toObject(exec); 00111 if(object0 && object0->inherits(&QPixmapBinding::info)) 00112 { 00113 QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 0); 00114 value.setTexture(pixmap); 00115 imp->setValue(qVariantFromValue(value)); 00116 return result; 00117 } 00118 } 00119 00120 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setTexture"); 00121 } 00122 00123 // color 00124 KJS::JSValue *color( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ) 00125 { 00126 Q_UNUSED(args); 00127 KJS::JSValue *result = KJS::jsNull(); 00128 KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self); 00129 if( !imp ) 00130 return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?"); 00131 00132 QBrush value = imp->value<QBrush>(); 00133 if (args.size() == 0 ) 00134 { 00135 const QColor & tmp = value.color(); 00136 result = KJSEmbed::createVariant( exec, "QColor", tmp ); 00137 imp->setValue(qVariantFromValue(value)); 00138 return result; 00139 } 00140 00141 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.color"); 00142 } 00143 00144 // setColor 00145 KJS::JSValue *setColor( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ) 00146 { 00147 Q_UNUSED(args); 00148 KJS::JSValue *result = KJS::jsNull(); 00149 KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self); 00150 if( !imp ) 00151 return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?"); 00152 00153 QBrush value = imp->value<QBrush>(); 00154 if (args.size() == 1 ) 00155 { 00156 KJS::JSValue* value0=args[0]; 00157 KJS::JSObject* object0=value0->toObject(exec); 00158 if(object0 && object0->inherits(&QColorBinding::info)) 00159 { 00160 QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0); 00161 value.setColor(color); 00162 imp->setValue(qVariantFromValue(value)); 00163 return result; 00164 } 00165 if(object0 && object0->isNumber()) 00166 { 00167 Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0); 00168 value.setColor(color); 00169 imp->setValue(qVariantFromValue(value)); 00170 return result; 00171 } 00172 } 00173 00174 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setColor"); 00175 } 00176 00177 // gradient 00178 KJS::JSValue *gradient( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ) 00179 { 00180 Q_UNUSED(args); 00181 KJS::JSValue *result = KJS::jsNull(); 00182 KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self); 00183 if( !imp ) 00184 return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?"); 00185 00186 QBrush value = imp->value<QBrush>(); 00187 if (args.size() == 0 ) 00188 { 00189 const QGradient * tmp = value.gradient(); 00190 result = KJSEmbed::createValue( exec, "const QGradient *", tmp ); 00191 imp->setValue(qVariantFromValue(value)); 00192 return result; 00193 } 00194 00195 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.gradient"); 00196 } 00197 00198 // isOpaque 00199 KJS::JSValue *isOpaque( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ) 00200 { 00201 Q_UNUSED(args); 00202 KJS::JSValue *result = KJS::jsNull(); 00203 KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self); 00204 if( !imp ) 00205 return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?"); 00206 00207 QBrush value = imp->value<QBrush>(); 00208 if (args.size() == 0 ) 00209 { 00210 bool tmp = value.isOpaque(); 00211 result = KJSEmbed::createVariant( exec, "bool", tmp ); 00212 imp->setValue(qVariantFromValue(value)); 00213 return result; 00214 } 00215 00216 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.isOpaque"); 00217 } 00218 00219 } 00220 00221 const Enumerator KJSEmbed::QBrushData::p_enums[] = {{0, 0 }}; 00222 00223 NO_STATICS( KJSEmbed::QBrushData ) 00224 const Constructor KJSEmbed::QBrushData::p_constructor = 00225 {"QBrush", 0, KJS::DontDelete|KJS::ReadOnly, 0, &QBrushData::ctorMethod, p_statics, p_enums, KJSEmbed::QBrushData::p_methods }; 00226 KJS::JSObject *KJSEmbed::QBrushData::ctorMethod( KJS::ExecState *exec, const KJS::List &args ) 00227 { 00228 if (args.size() == 0 ) 00229 { 00230 return new KJSEmbed::QBrushBinding(exec, QBrush()); 00231 } 00232 if (args.size() == 1 ) 00233 { 00234 KJS::JSValue* value0=args[0]; 00235 KJS::JSObject* object0=value0->toObject(exec); 00236 if(object0 && object0->isNumber()) 00237 { 00238 Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 0); 00239 return new KJSEmbed::QBrushBinding(exec, QBrush(bs)); 00240 } 00241 if(object0 && object0->inherits(&QPixmapBinding::info)) 00242 { 00243 QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 0); 00244 return new KJSEmbed::QBrushBinding(exec, QBrush(pixmap)); 00245 } 00246 if(object0 && object0->inherits(&QBrushBinding::info)) 00247 { 00248 QBrush brush = KJSEmbed::extractVariant<QBrush>(exec, args, 0); 00249 return new KJSEmbed::QBrushBinding(exec, QBrush(brush)); 00250 } 00251 if(object0 && object0->inherits(&QGradientBinding::info)) 00252 { 00253 QGradient gradient = KJSEmbed::extractValue<QGradient>(exec, args, 0); 00254 return new KJSEmbed::QBrushBinding(exec, QBrush(gradient)); 00255 } 00256 } 00257 if (args.size() == 2 ) 00258 { 00259 KJS::JSValue* value0=args[0]; 00260 KJS::JSObject* object0=value0->toObject(exec); 00261 KJS::JSValue* value1=args[1]; 00262 KJS::JSObject* object1=value1->toObject(exec); 00263 if(object0 && object0->inherits(&QColorBinding::info) && ( ( object1 && object1->isNumber() ) || !object1 )) 00264 { 00265 QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0); 00266 Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 1, Qt::SolidPattern); 00267 return new KJSEmbed::QBrushBinding(exec, QBrush(color, bs)); 00268 } 00269 if(object0 && object0->isNumber() && ( ( object1 && object1->isNumber() ) || !object1 )) 00270 { 00271 Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0); 00272 Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 1, Qt::SolidPattern); 00273 return new KJSEmbed::QBrushBinding(exec, QBrush(color, bs)); 00274 } 00275 if(object0 && object0->inherits(&QColorBinding::info) && object1 && object1->inherits(&QPixmapBinding::info)) 00276 { 00277 QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0); 00278 QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 1); 00279 return new KJSEmbed::QBrushBinding(exec, QBrush(color, pixmap)); 00280 } 00281 if(object0 && object0->isNumber() && object1 && object1->inherits(&QPixmapBinding::info)) 00282 { 00283 Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0); 00284 QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 1); 00285 return new KJSEmbed::QBrushBinding(exec, QBrush(color, pixmap)); 00286 } 00287 } 00288 return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush"); 00289 } 00290 00291 const Method KJSEmbed::QBrushData::p_methods[] = 00292 { 00293 { "style", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::style }, 00294 { "setStyle", 1, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::setStyle }, 00295 { "texture", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::texture }, 00296 { "setTexture", 1, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::setTexture }, 00297 { "color", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::color }, 00298 { "setColor", 1, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::setColor }, 00299 { "gradient", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::gradient }, 00300 { "isOpaque", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::isOpaque }, 00301 {0, 0, 0, 0 } 00302 }; 00303
KDE 4.6 API Reference