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

kjsembed

  • 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
33using namespace KJSEmbed;
34
35const KJS::ClassInfo BrushBinding::info = { "QBrush", &VariantBinding::info, 0, 0 };
36BrushBinding::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
43namespace BrushNS
44{
45
46START_VARIANT_METHOD( callcolor, QBrush )
47 QColor cppValue = value.color();
48 result = KJSEmbed::createVariant(exec, "QColor", cppValue );
49END_VARIANT_METHOD
50
51START_VARIANT_METHOD( callgradient, QBrush )
52 const QGradient *cppValue = value.gradient();
53 result = KJSEmbed::createObject<QGradient>(exec, "QGradient", cppValue);
54END_VARIANT_METHOD
55
56START_VARIANT_METHOD( callisOpaque, QBrush )
57 bool cppValue = value.isOpaque();
58 result = KJS::jsBoolean(cppValue);
59END_VARIANT_METHOD
60
61START_VARIANT_METHOD( callsetColor, QBrush )
62 QColor arg0 = KJSEmbed::extractVariant<QColor>(exec,args, 0);
63 value.setColor(arg0);
64END_VARIANT_METHOD
65
66START_VARIANT_METHOD( callsetStyle, QBrush )
67 Qt::BrushStyle arg0 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 0);
68 value.setStyle(arg0);
69END_VARIANT_METHOD
70
71START_VARIANT_METHOD( callsetTexture, QBrush )
72 QPixmap arg0 = KJSEmbed::extractVariant<QPixmap>(exec,args, 0);
73 value.setTexture(arg0);
74END_VARIANT_METHOD
75
76START_VARIANT_METHOD( callstyle, QBrush )
77 Qt::BrushStyle cppValue = value.style();
78 result = KJS::jsNumber(cppValue);
79END_VARIANT_METHOD
80
81START_VARIANT_METHOD( calltexture, QBrush )
82 QPixmap cppValue = value.texture();
83 result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
84END_VARIANT_METHOD
85
86}
87
88START_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}
97END_METHOD_LUT
98
99NO_ENUMS( Brush )
100NO_STATICS( Brush )
101
102START_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
169END_CTOR
170//kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
START_METHOD_LUT
#define START_METHOD_LUT(TYPE)
Definition: binding_support.h:127
END_CTOR
#define END_CTOR
Definition: binding_support.h:166
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
START_CTOR
#define START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:157
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
brush.h
KJSEmbed::BrushBinding
Definition: brush.h:36
KJSEmbed::BrushBinding::info
static const KJS::ClassInfo info
Definition: brush.h:40
KJSEmbed::BrushBinding::BrushBinding
BrushBinding(KJS::ExecState *exec, const QBrush &value)
Definition: brush.cpp:36
KJSEmbed::ColorBinding::info
static const KJS::ClassInfo info
Definition: color.h:39
KJSEmbed::PixmapBinding::info
static const KJS::ClassInfo info
Definition: pixmap.h:39
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:89
KJSEmbed::VariantBinding::info
static const KJS::ClassInfo info
Definition: variant_binding.h:123
KJSEmbed::VariantFactory::methods
static const Method * methods()
Definition: variant_binding.h:251
result
END_VARIANT_METHOD result
Definition: color.cpp:85
color.h
if
if(file->open((QIODevice::OpenModeFlag) KJSEmbed::extractInt(exec, args, 0)))
Definition: fileio.cpp:64
BrushNS
Definition: brush.cpp:44
KJSEmbed
Definition: application.h:33
KJSEmbed::isBasic
bool isBasic(KJS::JSValue *value)
Definition: util.h:6
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
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
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
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
KJS
Implement QString-KJS::UString conversion methods.
Definition: kjs_object_model.h:29
pixmap.h
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
cppValue
END_OBJECT_METHOD QBrush cppValue
Definition: qpainter_binding.cpp:97
arg1
Qt::FillRule arg1
Definition: qpainter_binding.cpp:307
value
QVariant value
Definition: settings.cpp:35
util.h
START_VARIANT_METHOD
#define START_VARIANT_METHOD(METHODNAME, TYPE)
A simple variant syle method.
Definition: variant_binding.h:42
END_VARIANT_METHOD
#define END_VARIANT_METHOD
End a variant method started by START_VARIANT_METHOD.
Definition: variant_binding.h:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

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