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

kjsembed

  • kjsembed
  • kjsembed
font.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 "font.h"
23
24#include <QtCore/QDebug>
25#include <QtGui/QFont>
26#include <QtCore/QStringList>
27using namespace KJSEmbed;
28
29const KJS::ClassInfo FontBinding::info = { "QFont", &VariantBinding::info, 0, 0 };
30FontBinding::FontBinding( KJS::ExecState *exec, const QFont &value )
31 : VariantBinding(exec, value )
32{
33 StaticBinding::publish( exec, this, Font::methods() );
34 StaticBinding::publish( exec, this, VariantFactory::methods() );
35}
36
37namespace FontNS
38{
39
40START_VARIANT_METHOD( callbold, QFont )
41 bool cppValue = value.bold();
42 result = KJS::jsBoolean(cppValue);
43END_VARIANT_METHOD
44
45START_VARIANT_METHOD( callexactMatch, QFont )
46 bool cppValue = value.exactMatch();
47 result = KJS::jsBoolean(cppValue);
48END_VARIANT_METHOD
49
50START_VARIANT_METHOD( callfamily, QFont )
51 QString cppValue = value.family();
52 result = KJS::jsString( cppValue );
53END_VARIANT_METHOD
54
55START_VARIANT_METHOD( callfixedPitch, QFont )
56 bool cppValue = value.fixedPitch();
57 result = KJS::jsBoolean(cppValue);
58END_VARIANT_METHOD
59
60START_VARIANT_METHOD( callfromString, QFont )
61 QString arg0 = KJSEmbed::extractQString(exec, args, 0);
62 bool cppValue = value.fromString(arg0);
63 result = KJS::jsBoolean(cppValue);
64END_VARIANT_METHOD
65
66START_VARIANT_METHOD( callinsertSubstitution, QFont )
67 QString arg0 = KJSEmbed::extractQString(exec, args, 0);
68 QString arg1 = KJSEmbed::extractQString(exec, args, 1);
69 value.insertSubstitution(arg0, arg1);
70END_VARIANT_METHOD
71
72START_VARIANT_METHOD( callinsertSubstitutions, QFont )
73 QString arg0 = KJSEmbed::extractQString(exec, args, 0);
74 QStringList arg1 = KJSEmbed::extractQStringList(exec,args, 1);
75 value.insertSubstitutions(arg0, arg1);
76END_VARIANT_METHOD
77
78START_VARIANT_METHOD( callisCopyOf, QFont )
79 QFont arg0 = KJSEmbed::extractVariant<QFont>(exec,args, 0);
80 bool cppValue = value.isCopyOf(arg0);
81 result = KJS::jsBoolean(cppValue);
82END_VARIANT_METHOD
83
84START_VARIANT_METHOD( callitalic, QFont )
85 bool cppValue = value.italic();
86 result = KJS::jsBoolean(cppValue);
87END_VARIANT_METHOD
88
89START_VARIANT_METHOD( callkerning, QFont )
90 bool cppValue = value.kerning();
91 result = KJS::jsBoolean(cppValue);
92END_VARIANT_METHOD
93
94START_VARIANT_METHOD( callkey, QFont )
95 QString cppValue = value.key();
96 result = KJS::jsString( cppValue );
97END_VARIANT_METHOD
98
99START_VARIANT_METHOD( calllastResortFamily, QFont )
100 QString cppValue = value.lastResortFamily();
101 result = KJS::jsString( cppValue );
102END_VARIANT_METHOD
103
104START_VARIANT_METHOD( calllastResortFont, QFont )
105 QString cppValue = value.lastResortFont();
106 result = KJS::jsString( cppValue );
107END_VARIANT_METHOD
108
109START_VARIANT_METHOD( calloverline, QFont )
110 bool cppValue = value.overline();
111 result = KJS::jsBoolean(cppValue);
112END_VARIANT_METHOD
113
114START_VARIANT_METHOD( callpixelSize, QFont )
115 int cppValue = value.pixelSize();
116 result = KJS::jsNumber(cppValue);
117END_VARIANT_METHOD
118
119START_VARIANT_METHOD( callpointSize, QFont )
120 int cppValue = value.pointSize();
121 result = KJS::jsNumber(cppValue);
122END_VARIANT_METHOD
123
124START_VARIANT_METHOD( callrawMode, QFont )
125 bool cppValue = value.rawMode();
126 result = KJS::jsBoolean(cppValue);
127END_VARIANT_METHOD
128
129START_VARIANT_METHOD( callrawName, QFont )
130 QString cppValue = value.rawName();
131 result = KJS::jsString( cppValue );
132END_VARIANT_METHOD
133
134START_VARIANT_METHOD( callremoveSubstitution, QFont )
135 QString arg0 = KJSEmbed::extractQString(exec, args, 0);
136 value.removeSubstitution(arg0);
137END_VARIANT_METHOD
138
139START_VARIANT_METHOD( callresolve, QFont )
140 QFont arg0 = KJSEmbed::extractVariant<QFont>(exec,args, 0);
141 QFont cppValue = value.resolve(arg0);
142 result = KJSEmbed::createVariant(exec, "QFont", cppValue );
143END_VARIANT_METHOD
144
145START_VARIANT_METHOD( callsetBold, QFont )
146 bool arg0 = KJSEmbed::extractBool(exec, args, 0);
147 value.setBold(arg0);
148END_VARIANT_METHOD
149
150START_VARIANT_METHOD( callsetFamily, QFont )
151 QString arg0 = KJSEmbed::extractQString(exec, args, 0);
152 value.setFamily(arg0);
153END_VARIANT_METHOD
154
155START_VARIANT_METHOD( callsetFixedPitch, QFont )
156 bool arg0 = KJSEmbed::extractBool(exec, args, 0);
157 value.setFixedPitch(arg0);
158END_VARIANT_METHOD
159
160START_VARIANT_METHOD( callsetItalic, QFont )
161 bool arg0 = KJSEmbed::extractBool(exec, args, 0);
162 value.setItalic(arg0);
163END_VARIANT_METHOD
164
165START_VARIANT_METHOD( callsetKerning, QFont )
166 bool arg0 = KJSEmbed::extractBool(exec, args, 0);
167 value.setKerning(arg0);
168END_VARIANT_METHOD
169
170START_VARIANT_METHOD( callsetOverline, QFont )
171 bool arg0 = KJSEmbed::extractBool(exec, args, 0);
172 value.setOverline(arg0);
173END_VARIANT_METHOD
174
175START_VARIANT_METHOD( callsetPixelSize, QFont )
176 int arg0 = KJSEmbed::extractInt(exec, args, 0);
177 value.setPixelSize(arg0);
178END_VARIANT_METHOD
179
180START_VARIANT_METHOD( callsetPointSize, QFont )
181 int arg0 = KJSEmbed::extractInt(exec, args, 0);
182 value.setPointSize(arg0);
183END_VARIANT_METHOD
184
185START_VARIANT_METHOD( callsetRawMode, QFont )
186 bool arg0 = KJSEmbed::extractBool(exec, args, 0);
187 value.setRawMode(arg0);
188END_VARIANT_METHOD
189
190START_VARIANT_METHOD( callsetRawName, QFont )
191 QString arg0 = KJSEmbed::extractQString(exec, args, 0);
192 value.setRawName(arg0);
193END_VARIANT_METHOD
194
195START_VARIANT_METHOD( callsetStretch, QFont )
196 int arg0 = KJSEmbed::extractInt(exec, args, 0);
197 value.setStretch(arg0);
198END_VARIANT_METHOD
199
200START_VARIANT_METHOD( callsetStrikeOut, QFont )
201 bool arg0 = KJSEmbed::extractBool(exec, args, 0);
202 value.setStrikeOut(arg0);
203END_VARIANT_METHOD
204
205START_VARIANT_METHOD( callsetStyle, QFont )
206 QFont::Style arg0 = (QFont::Style) KJSEmbed::extractInt(exec, args, 0);
207 value.setStyle(arg0);
208END_VARIANT_METHOD
209
210START_VARIANT_METHOD( callsetStyleHint, QFont )
211 QFont::StyleHint arg0 = (QFont::StyleHint) KJSEmbed::extractInt(exec, args, 0);
212 QFont::StyleStrategy arg1 = (QFont::StyleStrategy) KJSEmbed::extractInt(exec, args, 1);
213 value.setStyleHint(arg0, arg1);
214END_VARIANT_METHOD
215
216START_VARIANT_METHOD( callsetStyleStrategy, QFont )
217 QFont::StyleStrategy arg0 = (QFont::StyleStrategy) KJSEmbed::extractInt(exec, args, 0);
218 value.setStyleStrategy(arg0);
219END_VARIANT_METHOD
220
221START_VARIANT_METHOD( callsetUnderline, QFont )
222 bool arg0 = KJSEmbed::extractBool(exec, args, 0);
223 value.setUnderline(arg0);
224END_VARIANT_METHOD
225
226START_VARIANT_METHOD( callsetWeight, QFont )
227 int arg0 = KJSEmbed::extractInt(exec, args, 0);
228 value.setWeight(arg0);
229END_VARIANT_METHOD
230
231START_VARIANT_METHOD( callstretch, QFont )
232 int cppValue = value.stretch();
233 result = KJS::jsNumber(cppValue);
234END_VARIANT_METHOD
235
236START_VARIANT_METHOD( callstrikeOut, QFont )
237 bool cppValue = value.strikeOut();
238 result = KJS::jsBoolean(cppValue);
239END_VARIANT_METHOD
240
241START_VARIANT_METHOD( callstyle, QFont )
242 QFont::Style cppValue = value.style();
243 result = KJS::jsNumber(cppValue);
244END_VARIANT_METHOD
245
246START_VARIANT_METHOD( callstyleHint, QFont )
247 QFont::StyleHint cppValue = value.styleHint();
248 result = KJS::jsNumber(cppValue);
249END_VARIANT_METHOD
250
251START_VARIANT_METHOD( callstyleStrategy, QFont )
252 QFont::StyleStrategy cppValue = value.styleStrategy();
253 result = KJS::jsNumber(cppValue);
254END_VARIANT_METHOD
255
256START_VARIANT_METHOD( callsubstitute, QFont )
257 QString arg0 = KJSEmbed::extractQString(exec, args, 0);
258 QString cppValue = value.substitute(arg0);
259 result = KJS::jsString( cppValue );
260END_VARIANT_METHOD
261
262START_VARIANT_METHOD( callsubstitutes, QFont )
263 QString arg0 = KJSEmbed::extractQString(exec, args, 0);
264 QStringList cppValue = value.substitutes(arg0);
265 result = KJSEmbed::createQStringList(exec, cppValue );
266END_VARIANT_METHOD
267
268START_VARIANT_METHOD( callsubstitutions, QFont )
269 QStringList cppValue = value.substitutions();
270 result = KJSEmbed::createQStringList(exec, cppValue );
271END_VARIANT_METHOD
272
273START_VARIANT_METHOD( calltoString, QFont )
274 QString cppValue = value.toString();
275 result = KJS::jsString( cppValue );
276END_VARIANT_METHOD
277
278START_VARIANT_METHOD( callunderline, QFont )
279 bool cppValue = value.underline();
280 result = KJS::jsBoolean(cppValue);
281END_VARIANT_METHOD
282
283START_VARIANT_METHOD( callweight, QFont )
284 int cppValue = value.weight();
285 result = KJS::jsNumber(cppValue);
286END_VARIANT_METHOD
287}
288
289START_METHOD_LUT( Font )
290 {"bold", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callbold},
291 {"exactMatch", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callexactMatch},
292 {"family", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callfamily},
293 {"fixedPitch", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callfixedPitch},
294 {"fromString", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callfromString},
295 {"insertSubstitution", 1, KJS::DontDelete|KJS::ReadOnly, &FontNS::callinsertSubstitution},
296 {"insertSubstitutions", 1, KJS::DontDelete|KJS::ReadOnly, &FontNS::callinsertSubstitutions},
297 {"isCopyOf", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callisCopyOf},
298 {"italic", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callitalic},
299 {"kerning", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callkerning},
300 {"key", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callkey},
301 {"lastResortFamily", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::calllastResortFamily},
302 {"lastResortFont", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::calllastResortFont},
303 {"overline", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::calloverline},
304 {"pixelSize", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callpixelSize},
305 {"pointSize", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callpointSize},
306 {"rawMode", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callrawMode},
307 {"rawName", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callrawName},
308 {"removeSubstitution", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callremoveSubstitution},
309 {"resolve", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callresolve},
310 {"setBold", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetBold},
311 {"setFamily", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetFamily},
312 {"setFixedPitch", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetFixedPitch},
313 {"setItalic", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetItalic},
314 {"setKerning", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetKerning},
315 {"setOverline", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetOverline},
316 {"setPixelSize", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetPixelSize},
317 {"setPointSize", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetPointSize},
318 {"setRawMode", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetRawMode},
319 {"setRawName", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetRawName},
320 {"setStretch", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetStretch},
321 {"setStrikeOut", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetStrikeOut},
322 {"setStyle", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetStyle},
323 {"setStyleHint", 1, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetStyleHint},
324 {"setStyleStrategy", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetStyleStrategy},
325 {"setUnderline", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetUnderline},
326 {"setWeight", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsetWeight},
327 {"stretch", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callstretch},
328 {"strikeOut", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callstrikeOut},
329 {"style", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callstyle},
330 {"styleHint", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callstyleHint},
331 {"styleStrategy", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callstyleStrategy},
332 {"substitute", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsubstitute},
333 {"substitutes", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsubstitutes},
334 {"substitutions", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callsubstitutions},
335 {"toString", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::calltoString},
336 {"underline", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callunderline},
337 {"weight", 0, KJS::DontDelete|KJS::ReadOnly, &FontNS::callweight}
338END_METHOD_LUT
339
340NO_ENUMS( Font )
341NO_STATICS( Font )
342
343START_CTOR( Font, QFont, 0)
344 if( args.size() == 0 )
345 {
346 return new KJSEmbed::FontBinding( exec, QFont() );
347 }
348 return new KJSEmbed::FontBinding( exec, QFont() );
349END_CTOR
350
351//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
KJSEmbed::FontBinding
Definition: font.h:36
KJSEmbed::FontBinding::info
static const KJS::ClassInfo info
Definition: font.h:40
KJSEmbed::FontBinding::FontBinding
FontBinding(KJS::ExecState *exec, const QFont &value)
Definition: font.cpp:30
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
if
if(file->open((QIODevice::OpenModeFlag) KJSEmbed::extractInt(exec, args, 0)))
Definition: fileio.cpp:64
font.h
FontNS
Definition: font.cpp:38
KJSEmbed
Definition: application.h:33
KJSEmbed::createQStringList
KJS::JSValue * createQStringList(KJS::ExecState *exec, const QStringList &value)
Create a new KJS::JSValue with the value of the QStringList.
Definition: binding_support.cpp:243
KJSEmbed::extractQString
QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue=QString())
Extracts a QString from an argument list.
Definition: binding_support.cpp:34
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::extractBool
bool KJSEMBED_EXPORT extractBool(KJS::ExecState *exec, const KJS::List &args, int idx, bool defaultValue=false)
Extracts a bool from an argument list.
Definition: binding_support.cpp:149
KJSEmbed::extractQStringList
QStringList KJSEMBED_EXPORT extractQStringList(KJS::ExecState *exec, const KJS::List &args, int idx, const QStringList &defaultValue=QStringList())
Extracts a QStringList from an argument list.
Definition: binding_support.cpp:231
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
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
key
END_QOBJECT_METHOD QString key
Definition: settings.cpp:34
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