KJsEmbed

pen.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005, 2006 Ian Reinhart Geiser <[email protected]>
3  Copyright (C) 2005, 2006 Matt Broadstone <[email protected]>
4  Copyright (C) 2005, 2006 Richard J. Moore <[email protected]>
5  Copyright (C) 2005, 2006 Erik L. Bunce <[email protected]>
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 "pen.h"
23 
24 #include <QDebug>
25 #include <QPen>
26 #include <QBrush>
27 #include <QColor>
28 
29 using namespace KJSEmbed;
30 
31 const KJS::ClassInfo PenBinding::info = { "QPen", &VariantBinding::info, nullptr, nullptr };
32 PenBinding::PenBinding(KJS::ExecState *exec, const QPen &value)
33  : VariantBinding(exec, value)
34 {
35  StaticBinding::publish(exec, this, Pen::methods());
36  StaticBinding::publish(exec, this, VariantFactory::methods());
37 }
38 
39 namespace PenNS
40 {
41 
42 START_VARIANT_METHOD(callbrush, QPen)
43 QBrush cppValue = value.brush();
44 result = KJSEmbed::createVariant(exec, "QBrush", cppValue);
45 END_VARIANT_METHOD
46 
47 START_VARIANT_METHOD(callcapStyle, QPen)
48 Qt::PenCapStyle cppValue = value.capStyle();
49 result = KJS::jsNumber(cppValue);
50 END_VARIANT_METHOD
51 
52 START_VARIANT_METHOD(callcolor, QPen)
53 QColor cppValue = value.color();
54 result = KJSEmbed::createVariant(exec, "QColor", cppValue);
55 END_VARIANT_METHOD
56 
57 START_VARIANT_METHOD(callisSolid, QPen)
58 bool cppValue = value.isSolid();
59 result = KJS::jsBoolean(cppValue);
60 END_VARIANT_METHOD
61 
62 START_VARIANT_METHOD(calljoinStyle, QPen)
63 Qt::PenJoinStyle cppValue = value.joinStyle();
64 result = KJS::jsNumber(cppValue);
65 END_VARIANT_METHOD
66 
67 START_VARIANT_METHOD(callsetBrush, QPen)
68 QBrush arg0 = KJSEmbed::extractVariant<QBrush>(exec, args, 0);
69 value.setBrush(arg0);
70 END_VARIANT_METHOD
71 
72 START_VARIANT_METHOD(callsetCapStyle, QPen)
73 Qt::PenCapStyle arg0 = (Qt::PenCapStyle)KJSEmbed::extractInt(exec, args, 0);
74 value.setCapStyle(arg0);
75 END_VARIANT_METHOD
76 
77 START_VARIANT_METHOD(callsetColor, QPen)
78 QColor arg0 = KJSEmbed::extractVariant<QColor>(exec, args, 0);
79 value.setColor(arg0);
80 END_VARIANT_METHOD
81 
82 START_VARIANT_METHOD(callsetJoinStyle, QPen)
83 Qt::PenJoinStyle arg0 = (Qt::PenJoinStyle)KJSEmbed::extractInt(exec, args, 0);
84 value.setJoinStyle(arg0);
85 END_VARIANT_METHOD
86 
87 START_VARIANT_METHOD(callsetStyle, QPen)
88 Qt::PenStyle arg0 = (Qt::PenStyle)KJSEmbed::extractInt(exec, args, 0);
89 value.setStyle(arg0);
90 END_VARIANT_METHOD
91 
92 START_VARIANT_METHOD(callsetWidth, QPen)
93 int arg0 = KJSEmbed::extractInt(exec, args, 0);
94 value.setWidth(arg0);
95 END_VARIANT_METHOD
96 
97 START_VARIANT_METHOD(callstyle, QPen)
98 Qt::PenStyle cppValue = value.style();
99 result = KJS::jsNumber(cppValue);
100 END_VARIANT_METHOD
101 
102 START_VARIANT_METHOD(callwidth, QPen)
103 int cppValue = value.width();
104 result = KJS::jsNumber(cppValue);
105 END_VARIANT_METHOD
106 
107 }
108 
109 START_METHOD_LUT(Pen)
110 {"brush", 0, KJS::DontDelete | KJS::ReadOnly, &PenNS::callbrush},
111 {"capStyle", 0, KJS::DontDelete | KJS::ReadOnly, &PenNS::callcapStyle},
112 {"color", 0, KJS::DontDelete | KJS::ReadOnly, &PenNS::callcolor},
113 {"isSolid", 0, KJS::DontDelete | KJS::ReadOnly, &PenNS::callisSolid},
114 {"joinStyle", 0, KJS::DontDelete | KJS::ReadOnly, &PenNS::calljoinStyle},
115 {"setBrush", 1, KJS::DontDelete | KJS::ReadOnly, &PenNS::callsetBrush},
116 {"setCapStyle", 1, KJS::DontDelete | KJS::ReadOnly, &PenNS::callsetCapStyle},
117 {"setColor", 1, KJS::DontDelete | KJS::ReadOnly, &PenNS::callsetColor},
118 {"setJoinStyle", 1, KJS::DontDelete | KJS::ReadOnly, &PenNS::callsetJoinStyle},
119 {"setStyle", 1, KJS::DontDelete | KJS::ReadOnly, &PenNS::callsetStyle},
120 {"setWidth", 1, KJS::DontDelete | KJS::ReadOnly, &PenNS::callsetWidth},
121 {"style", 0, KJS::DontDelete | KJS::ReadOnly, &PenNS::callstyle},
122 {"width", 0, KJS::DontDelete | KJS::ReadOnly, &PenNS::callwidth}
123 END_METHOD_LUT
124 
125 NO_ENUMS(Pen)
126 NO_STATICS(Pen)
127 
128 START_CTOR(Pen, QPen, 0)
129 if (args.size() == 1)
130 {
131  return new KJSEmbed::PenBinding(exec,
132  QPen(KJSEmbed::extractVariant<QColor>(exec, args, 0)
133  ));
134 } else if (args.size() >= 2)
135 {
136  return new KJSEmbed::PenBinding(exec,
137  QPen(KJSEmbed::extractVariant<QBrush>(exec, args, 0),
138  KJSEmbed::extractInt(exec, args, 1),
139  (Qt::PenStyle)KJSEmbed::extractInt(exec, args, 2, Qt::SolidLine),
140  (Qt::PenCapStyle)KJSEmbed::extractInt(exec, args, 3, Qt::SquareCap),
141  (Qt::PenJoinStyle)KJSEmbed::extractInt(exec, args, 4, Qt::BevelJoin)
142  ));
143 
144 }
145 
146 return new KJSEmbed::PenBinding(exec, QPen());
147 END_CTOR
148 
PenJoinStyle
PenCapStyle
static void publish(KJS::ExecState *exec, KJS::JSObject *object, const Method *methods)
Publishes an array of Methods to an object.
QVariant based binding.
PenStyle
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 10 2023 03:59:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.