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

kjsembed

  • sources
  • kde-4.12
  • kdelibs
  • kjsembed
  • kjsembed
QBrush_bind.cpp
Go to the documentation of this file.
1 #include "QBrush_bind.h"
2 #include <QtGui/QBrush>
3 #include <value_binding.h>
4 #include <object_binding.h>
5 
6 
7 using namespace KJSEmbed;
8 
9 // Temp - for building
10 class QColorBinding { public: static const KJS::ClassInfo info; };
11 class QPixmapBinding { public: static const KJS::ClassInfo info; };
12 class QGradientBinding { public: static const KJS::ClassInfo info; };
13 
14 const KJS::ClassInfo QColorBinding::info = { "QColor", &VariantBinding::info, 0, 0 };
15 const KJS::ClassInfo QPixmapBinding::info = { "QPixmap", &VariantBinding::info, 0, 0 };
16 const KJS::ClassInfo QGradientBinding::info = { "QGradient", &ObjectBinding::info, 0, 0 };
17 
18 const KJS::ClassInfo QBrushBinding::info = { "QBrush", &VariantBinding::info, 0, 0 };
19 QBrushBinding::QBrushBinding( KJS::ExecState *exec, const QBrush &value )
20  : VariantBinding(exec, value)
21 {
22  StaticBinding::publish(exec, this, QBrushData::methods() );
23  StaticBinding::publish(exec, this, VariantFactory::methods() );
24 }
25 
26 
27 namespace QBrushNS
28 {
29 // style
30 KJS::JSValue *style( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
31 {
32  Q_UNUSED(args);
33  KJS::JSValue *result = KJS::jsNull();
34  KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
35  if( !imp )
36  return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
37 
38  QBrush value = imp->value<QBrush>();
39  if (args.size() == 0 )
40  {
41  Qt::BrushStyle tmp = value.style();
42  result = KJS::jsNumber( tmp );
43  imp->setValue(qVariantFromValue(value));
44  return result;
45  }
46 
47  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.style");
48 }
49 
50 // setStyle
51 KJS::JSValue *setStyle( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
52 {
53  Q_UNUSED(args);
54  KJS::JSValue *result = KJS::jsNull();
55  KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
56  if( !imp )
57  return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
58 
59  QBrush value = imp->value<QBrush>();
60  if (args.size() == 1 )
61  {
62  KJS::JSValue* value0=args[0];
63  KJS::JSObject* object0=value0->toObject(exec);
64  if(object0 && object0->isNumber())
65  {
66  Qt::BrushStyle arg0 = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 0);
67  value.setStyle(arg0);
68  imp->setValue(qVariantFromValue(value));
69  return result;
70  }
71  }
72 
73  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setStyle");
74 }
75 
76 // texture
77 KJS::JSValue *texture( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
78 {
79  Q_UNUSED(args);
80  KJS::JSValue *result = KJS::jsNull();
81  KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
82  if( !imp )
83  return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
84 
85  QBrush value = imp->value<QBrush>();
86  if (args.size() == 0 )
87  {
88  QPixmap tmp = value.texture();
89  result = KJSEmbed::createVariant( exec, "QPixmap", tmp );
90  imp->setValue(qVariantFromValue(value));
91  return result;
92  }
93 
94  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.texture");
95 }
96 
97 // setTexture
98 KJS::JSValue *setTexture( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
99 {
100  Q_UNUSED(args);
101  KJS::JSValue *result = KJS::jsNull();
102  KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
103  if( !imp )
104  return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
105 
106  QBrush value = imp->value<QBrush>();
107  if (args.size() == 1 )
108  {
109  KJS::JSValue* value0=args[0];
110  KJS::JSObject* object0=value0->toObject(exec);
111  if(object0 && object0->inherits(&QPixmapBinding::info))
112  {
113  QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 0);
114  value.setTexture(pixmap);
115  imp->setValue(qVariantFromValue(value));
116  return result;
117  }
118  }
119 
120  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setTexture");
121 }
122 
123 // color
124 KJS::JSValue *color( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
125 {
126  Q_UNUSED(args);
127  KJS::JSValue *result = KJS::jsNull();
128  KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
129  if( !imp )
130  return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
131 
132  QBrush value = imp->value<QBrush>();
133  if (args.size() == 0 )
134  {
135  const QColor & tmp = value.color();
136  result = KJSEmbed::createVariant( exec, "QColor", tmp );
137  imp->setValue(qVariantFromValue(value));
138  return result;
139  }
140 
141  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.color");
142 }
143 
144 // setColor
145 KJS::JSValue *setColor( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
146 {
147  Q_UNUSED(args);
148  KJS::JSValue *result = KJS::jsNull();
149  KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
150  if( !imp )
151  return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
152 
153  QBrush value = imp->value<QBrush>();
154  if (args.size() == 1 )
155  {
156  KJS::JSValue* value0=args[0];
157  KJS::JSObject* object0=value0->toObject(exec);
158  if(object0 && object0->inherits(&QColorBinding::info))
159  {
160  QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0);
161  value.setColor(color);
162  imp->setValue(qVariantFromValue(value));
163  return result;
164  }
165  if(object0 && object0->isNumber())
166  {
167  Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0);
168  value.setColor(color);
169  imp->setValue(qVariantFromValue(value));
170  return result;
171  }
172  }
173 
174  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setColor");
175 }
176 
177 // gradient
178 KJS::JSValue *gradient( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
179 {
180  Q_UNUSED(args);
181  KJS::JSValue *result = KJS::jsNull();
182  KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
183  if( !imp )
184  return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
185 
186  QBrush value = imp->value<QBrush>();
187  if (args.size() == 0 )
188  {
189  const QGradient * tmp = value.gradient();
190  result = KJSEmbed::createValue( exec, "const QGradient *", tmp );
191  imp->setValue(qVariantFromValue(value));
192  return result;
193  }
194 
195  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.gradient");
196 }
197 
198 // isOpaque
199 KJS::JSValue *isOpaque( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
200 {
201  Q_UNUSED(args);
202  KJS::JSValue *result = KJS::jsNull();
203  KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
204  if( !imp )
205  return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
206 
207  QBrush value = imp->value<QBrush>();
208  if (args.size() == 0 )
209  {
210  bool tmp = value.isOpaque();
211  result = KJSEmbed::createVariant( exec, "bool", tmp );
212  imp->setValue(qVariantFromValue(value));
213  return result;
214  }
215 
216  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.isOpaque");
217 }
218 
219 }
220 
221 const Enumerator KJSEmbed::QBrushData::p_enums[] = {{0, 0 }};
222 
223 NO_STATICS( KJSEmbed::QBrushData )
224 const Constructor KJSEmbed::QBrushData::p_constructor =
225 {"QBrush", 0, KJS::DontDelete|KJS::ReadOnly, 0, &QBrushData::ctorMethod, p_statics, p_enums, KJSEmbed::QBrushData::p_methods };
226 KJS::JSObject *KJSEmbed::QBrushData::ctorMethod( KJS::ExecState *exec, const KJS::List &args )
227 {
228  if (args.size() == 0 )
229  {
230  return new KJSEmbed::QBrushBinding(exec, QBrush());
231  }
232  if (args.size() == 1 )
233  {
234  KJS::JSValue* value0=args[0];
235  KJS::JSObject* object0=value0->toObject(exec);
236  if(object0 && object0->isNumber())
237  {
238  Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 0);
239  return new KJSEmbed::QBrushBinding(exec, QBrush(bs));
240  }
241  if(object0 && object0->inherits(&QPixmapBinding::info))
242  {
243  QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 0);
244  return new KJSEmbed::QBrushBinding(exec, QBrush(pixmap));
245  }
246  if(object0 && object0->inherits(&QBrushBinding::info))
247  {
248  QBrush brush = KJSEmbed::extractVariant<QBrush>(exec, args, 0);
249  return new KJSEmbed::QBrushBinding(exec, QBrush(brush));
250  }
251  if(object0 && object0->inherits(&QGradientBinding::info))
252  {
253  QGradient gradient = KJSEmbed::extractValue<QGradient>(exec, args, 0);
254  return new KJSEmbed::QBrushBinding(exec, QBrush(gradient));
255  }
256  }
257  if (args.size() == 2 )
258  {
259  KJS::JSValue* value0=args[0];
260  KJS::JSObject* object0=value0->toObject(exec);
261  KJS::JSValue* value1=args[1];
262  KJS::JSObject* object1=value1->toObject(exec);
263  if(object0 && object0->inherits(&QColorBinding::info) && ( ( object1 && object1->isNumber() ) || !object1 ))
264  {
265  QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0);
266  Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 1, Qt::SolidPattern);
267  return new KJSEmbed::QBrushBinding(exec, QBrush(color, bs));
268  }
269  if(object0 && object0->isNumber() && ( ( object1 && object1->isNumber() ) || !object1 ))
270  {
271  Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0);
272  Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 1, Qt::SolidPattern);
273  return new KJSEmbed::QBrushBinding(exec, QBrush(color, bs));
274  }
275  if(object0 && object0->inherits(&QColorBinding::info) && object1 && object1->inherits(&QPixmapBinding::info))
276  {
277  QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0);
278  QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
279  return new KJSEmbed::QBrushBinding(exec, QBrush(color, pixmap));
280  }
281  if(object0 && object0->isNumber() && object1 && object1->inherits(&QPixmapBinding::info))
282  {
283  Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0);
284  QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
285  return new KJSEmbed::QBrushBinding(exec, QBrush(color, pixmap));
286  }
287  }
288  return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush");
289 }
290 
291 const Method KJSEmbed::QBrushData::p_methods[] =
292 {
293  { "style", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::style },
294  { "setStyle", 1, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::setStyle },
295  { "texture", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::texture },
296  { "setTexture", 1, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::setTexture },
297  { "color", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::color },
298  { "setColor", 1, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::setColor },
299  { "gradient", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::gradient },
300  { "isOpaque", 0, KJS::DontDelete|KJS::ReadOnly, &QBrushNS::isOpaque },
301  {0, 0, 0, 0 }
302 };
303 
KJSEmbed::QBrushData::ctorMethod
static KJS::JSObject * ctorMethod(KJS::ExecState *exec, const KJS::List &args)
Definition: QBrush_bind.cpp:226
KJSEmbed::VariantBinding::info
static const KJS::ClassInfo info
Definition: variant_binding.h:123
KJSEmbed::VariantBinding::value
T value() const
Extract the actual value from the wrapper.
Definition: variant_binding.h:112
KJSEmbed::QBrushData::p_methods
static const KJSEmbed::Method p_methods[]
Definition: QBrush_bind.h:22
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::QBrushBinding::info
static const KJS::ClassInfo info
Definition: QBrush_bind.h:15
KJSEmbed::VariantBinding
QVariant based binding.
Definition: variant_binding.h:88
KJSEmbed::QBrushBinding
Definition: QBrush_bind.h:11
QBrushNS::setColor
KJS::JSValue * setColor(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:145
KJSEmbed::Enumerator
Enumerator structure.
Definition: binding_support.h:317
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
KJSEmbed::QBrushData
Definition: QBrush_bind.h:19
QBrushNS::setStyle
KJS::JSValue * setStyle(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:51
KJSEmbed::QBrushData::methods
static const KJSEmbed::Method * methods()
Definition: QBrush_bind.h:28
KJSEmbed::ObjectBinding::info
static const KJS::ClassInfo info
Definition: object_binding.h:92
KJSEmbed::Method
Method structure.
Definition: binding_support.h:294
object_binding.h
KJSEmbed::Constructor
Definition: binding_support.h:345
QBrushNS::isOpaque
KJS::JSValue * isOpaque(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:199
QBrushNS::setTexture
KJS::JSValue * setTexture(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:98
BrushNS::result
result
Definition: brush.cpp:48
QBrushNS::color
KJS::JSValue * color(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:124
QBrushNS::texture
KJS::JSValue * texture(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:77
KJSEmbed::VariantBinding::setValue
void setValue(const QVariant &val)
Set the internal value of the QVariant.
Definition: variant_binding.cpp:73
KJSEmbed::QBrushData::p_enums
static const KJSEmbed::Enumerator p_enums[]
Definition: QBrush_bind.h:24
KJSEmbed::VariantFactory::methods
static const Method * methods()
Definition: variant_binding.h:251
value_binding.h
QBrushNS::gradient
KJS::JSValue * gradient(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:178
List
Definition: variant_binding.cpp:130
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
KJSEmbed::createValue
KJS::JSValue * createValue(KJS::ExecState *exec, const KJS::UString &className, const T &value)
Definition: value_binding.h:195
value
QVariant value
Definition: settings.cpp:35
KJS::throwError
JSObject * throwError(ExecState *e, ErrorType t, const QString &m)
Definition: binding_support.h:241
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
KJSEmbed::QBrushBinding::QBrushBinding
QBrushBinding(KJS::ExecState *exec, const QBrush &value)
Definition: QBrush_bind.cpp:19
QBrush_bind.h
QBrushNS::style
KJS::JSValue * style(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:53 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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