• 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
brush.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
3  Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
4  Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
5  Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #include "brush.h"
23 
24 #include <QtCore/QDebug>
25 #include <QtGui/QBrush>
26 #include <QtGui/QPixmap>
27 #include <QtGui/QColor>
28 
29 #include "pixmap.h"
30 #include "color.h"
31 #include "util.h"
32 
33 using namespace KJSEmbed;
34 
35 const KJS::ClassInfo BrushBinding::info = { "QBrush", &VariantBinding::info, 0, 0 };
36 BrushBinding::BrushBinding( KJS::ExecState *exec, const QBrush &value )
37  : VariantBinding(exec, value )
38 {
39  StaticBinding::publish( exec, this, Brush::methods() );
40  StaticBinding::publish( exec, this, VariantFactory::methods() );
41 }
42 
43 namespace BrushNS
44 {
45 
46 START_VARIANT_METHOD( callcolor, QBrush )
47  QColor cppValue = value.color();
48  result = KJSEmbed::createVariant(exec, "QColor", cppValue );
49 END_VARIANT_METHOD
50 
51 START_VARIANT_METHOD( callgradient, QBrush )
52  const QGradient *cppValue = value.gradient();
53  result = KJSEmbed::createObject<QGradient>(exec, "QGradient", cppValue);
54 END_VARIANT_METHOD
55 
56 START_VARIANT_METHOD( callisOpaque, QBrush )
57  bool cppValue = value.isOpaque();
58  result = KJS::jsBoolean(cppValue);
59 END_VARIANT_METHOD
60 
61 START_VARIANT_METHOD( callsetColor, QBrush )
62  QColor arg0 = KJSEmbed::extractVariant<QColor>(exec,args, 0);
63  value.setColor(arg0);
64 END_VARIANT_METHOD
65 
66 START_VARIANT_METHOD( callsetStyle, QBrush )
67  Qt::BrushStyle arg0 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 0);
68  value.setStyle(arg0);
69 END_VARIANT_METHOD
70 
71 START_VARIANT_METHOD( callsetTexture, QBrush )
72  QPixmap arg0 = KJSEmbed::extractVariant<QPixmap>(exec,args, 0);
73  value.setTexture(arg0);
74 END_VARIANT_METHOD
75 
76 START_VARIANT_METHOD( callstyle, QBrush )
77  Qt::BrushStyle cppValue = value.style();
78  result = KJS::jsNumber(cppValue);
79 END_VARIANT_METHOD
80 
81 START_VARIANT_METHOD( calltexture, QBrush )
82  QPixmap cppValue = value.texture();
83  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
84 END_VARIANT_METHOD
85 
86 }
87 
88 START_METHOD_LUT( Brush )
89  {"color", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callcolor},
90  {"gradient", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callgradient},
91  {"isOpaque", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callisOpaque},
92  {"setColor", 1, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callsetColor},
93  {"setStyle", 1, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callsetStyle},
94  {"setTexture", 1, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callsetTexture},
95  {"style", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callstyle},
96  {"texture", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::calltexture}
97 END_METHOD_LUT
98 
99 NO_ENUMS( Brush )
100 NO_STATICS( Brush )
101 
102 START_CTOR( Brush, QBrush, 0)
103  if( args.size() == 0 )
104  {
105  return new KJSEmbed::BrushBinding( exec, QBrush() );
106  }
107  else if( args.size() == 1 )
108  {
109  KJS::JSValue* value0 = args[0];
110  KJS::JSObject* obj0 = value0->toObject(exec);
111  if(obj0)
112  {
113  if(obj0->inherits(&PixmapBinding::info))
114  {
115  QPixmap arg0 = KJSEmbed::extractVariant<QPixmap>(exec, args, 0);
116  return new KJSEmbed::BrushBinding(exec, QBrush(arg0));
117  }
118  if(obj0->inherits(&BrushBinding::info))
119  {
120  QBrush arg0 = KJSEmbed::extractVariant<QBrush>(exec, args, 0);
121  return new KJSEmbed::BrushBinding(exec, QBrush(arg0));
122  }
123 // if(obj0->inherits(&GradientBinding::info))
124 // {
125 // QGradient arg0 = KJSEmbed::extractVariant<QGradient>(exec, args, 0);
126 // return new KJSEmbed::BrushBinding(exec, QBrush(arg0));
127 // }
128  }
129  else if(isBasic(value0))
130  {
131  Qt::BrushStyle arg0 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 0);
132  return new KJSEmbed::BrushBinding(exec, QBrush(arg0));
133  }
134  }
135  else if( args.size() == 2 )
136  {
137  KJS::JSValue* value0= args[0];
138  KJS::JSValue* value1= args[1];
139  KJS::JSObject* obj0 = value0->toObject(exec);
140  KJS::JSObject* obj1 = value1->toObject(exec);
141 
142  if(obj0 && obj1 && obj0->inherits(&ColorBinding::info) && obj1->inherits(&PixmapBinding::info))
143  {
144  QColor arg0 = KJSEmbed::extractVariant<QColor>(exec, args, 0);
145  QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
146  return new KJSEmbed::BrushBinding(exec, QBrush(arg0, arg1));
147  }
148  if(obj1 && isBasic(value0) && obj1->inherits(&PixmapBinding::info))
149  {
150  Qt::GlobalColor arg0 = (Qt::GlobalColor)KJSEmbed::extractInt(exec, args, 0);
151  QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
152  return new KJSEmbed::BrushBinding(exec, QBrush(arg0, arg1));
153  }
154  if(obj0 && obj0->inherits(&ColorBinding::info) && isBasic(value1))
155  {
156  QColor arg0 = KJSEmbed::extractVariant<QColor>(exec, args, 0);
157  Qt::BrushStyle arg1 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 1);
158  return new KJSEmbed::BrushBinding(exec, QBrush(arg0, arg1));
159  }
160  if(isBasic(value0) && isBasic(value1))
161  {
162  Qt::GlobalColor arg0 = (Qt::GlobalColor)KJSEmbed::extractInt(exec, args, 0);
163  Qt::BrushStyle arg1 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 1);
164  return new KJSEmbed::BrushBinding(exec, QBrush(arg0, arg1));
165  }
166  }
167  return new KJSEmbed::BrushBinding( exec, QBrush() );
168 
169 END_CTOR
170 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KJSEmbed::VariantBinding::info
static const KJS::ClassInfo info
Definition: variant_binding.h:123
KJSEmbed::isBasic
bool isBasic(KJS::JSValue *value)
Definition: util.h:6
START_METHOD_LUT
START_METHOD_LUT(Brush)
Definition: brush.cpp:88
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::VariantBinding
QVariant based binding.
Definition: variant_binding.h:88
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
END_CTOR
#define END_CTOR
Definition: binding_support.h:166
KJSEmbed::BrushBinding::info
static const KJS::ClassInfo info
Definition: brush.h:40
KJSEmbed::extractInt
int KJSEMBED_EXPORT extractInt(KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue=0)
Extracts an integer from an argument list.
Definition: binding_support.cpp:72
DomDocumentNS::if
if(!success)
Definition: dom.cpp:363
brush.h
KJSEmbed::ColorBinding::info
static const KJS::ClassInfo info
Definition: color.h:39
START_CTOR
#define START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:157
QBrushNS::isOpaque
KJS::JSValue * isOpaque(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:199
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
pixmap.h
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
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
util.h
QBrushNS::texture
KJS::JSValue * texture(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:77
KJSEmbed::VariantFactory::methods
static const Method * methods()
Definition: variant_binding.h:251
color.h
BrushNS::setColor
value setColor(arg0)
BrushNS::setTexture
value setTexture(arg0)
KJSEmbed::PixmapBinding::info
static const KJS::ClassInfo info
Definition: pixmap.h:39
QBrushNS::gradient
KJS::JSValue * gradient(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:178
cppValue
END_OBJECT_METHOD QBrush cppValue
Definition: qpainter_binding.cpp:97
END_VARIANT_METHOD
#define END_VARIANT_METHOD
End a variant method started by START_VARIANT_METHOD.
Definition: variant_binding.h:56
BrushNS::setStyle
value setStyle(arg0)
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
KJSEmbed::createObject
KJS::JSValue * createObject(KJS::ExecState *exec, const KJS::UString &className, const T *value, KJSEmbed::ObjectBinding::Ownership owner=KJSEmbed::ObjectBinding::JSOwned)
Can create any known KJSEmbed::ObjectBinding object and set the value.
Definition: object_binding.h:200
arg1
Qt::FillRule arg1
Definition: qpainter_binding.cpp:307
KJSEmbed::BrushBinding::BrushBinding
BrushBinding(KJS::ExecState *exec, const QBrush &value)
Definition: brush.cpp:36
KJSEmbed::BrushBinding
Definition: brush.h:35
START_VARIANT_METHOD
#define START_VARIANT_METHOD(METHODNAME, TYPE)
A simple variant syle method.
Definition: variant_binding.h:42
value
QVariant value
Definition: settings.cpp:35
KJSEmbed::extractVariant
QVariant KJSEMBED_EXPORT extractVariant(KJS::ExecState *exec, KJS::JSValue *value)
Extracts a QVariant from a KJS::JSValue if the conversion fails a QVariant::Null is returned...
Definition: variant_binding.cpp:407
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
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