File indexing completed on 2024-12-08 09:42:34
0001 /* This file is part of the KDE libraries 0002 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org> 0003 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com> 0004 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org> 0005 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 Boston, MA 02110-1301, USA. 0021 */ 0022 #include "font.h" 0023 0024 #include <QDebug> 0025 #include <QFont> 0026 #include <QStringList> 0027 using namespace KJSEmbed; 0028 0029 const KJS::ClassInfo FontBinding::info = { "QFont", &VariantBinding::info, nullptr, nullptr }; 0030 FontBinding::FontBinding(KJS::ExecState *exec, const QFont &value) 0031 : VariantBinding(exec, value) 0032 { 0033 StaticBinding::publish(exec, this, Font::methods()); 0034 StaticBinding::publish(exec, this, VariantFactory::methods()); 0035 } 0036 0037 namespace FontNS 0038 { 0039 0040 START_VARIANT_METHOD(callbold, QFont) 0041 bool cppValue = value.bold(); 0042 result = KJS::jsBoolean(cppValue); 0043 END_VARIANT_METHOD 0044 0045 START_VARIANT_METHOD(callexactMatch, QFont) 0046 bool cppValue = value.exactMatch(); 0047 result = KJS::jsBoolean(cppValue); 0048 END_VARIANT_METHOD 0049 0050 START_VARIANT_METHOD(callfamily, QFont) 0051 QString cppValue = value.family(); 0052 result = KJS::jsString(cppValue); 0053 END_VARIANT_METHOD 0054 0055 START_VARIANT_METHOD(callfixedPitch, QFont) 0056 bool cppValue = value.fixedPitch(); 0057 result = KJS::jsBoolean(cppValue); 0058 END_VARIANT_METHOD 0059 0060 START_VARIANT_METHOD(callfromString, QFont) 0061 QString arg0 = KJSEmbed::extractQString(exec, args, 0); 0062 bool cppValue = value.fromString(arg0); 0063 result = KJS::jsBoolean(cppValue); 0064 END_VARIANT_METHOD 0065 0066 START_VARIANT_METHOD(callinsertSubstitution, QFont) 0067 QString arg0 = KJSEmbed::extractQString(exec, args, 0); 0068 QString arg1 = KJSEmbed::extractQString(exec, args, 1); 0069 value.insertSubstitution(arg0, arg1); 0070 END_VARIANT_METHOD 0071 0072 START_VARIANT_METHOD(callinsertSubstitutions, QFont) 0073 QString arg0 = KJSEmbed::extractQString(exec, args, 0); 0074 QStringList arg1 = KJSEmbed::extractQStringList(exec, args, 1); 0075 value.insertSubstitutions(arg0, arg1); 0076 END_VARIANT_METHOD 0077 0078 START_VARIANT_METHOD(callisCopyOf, QFont) 0079 QFont arg0 = KJSEmbed::extractVariant<QFont>(exec, args, 0); 0080 bool cppValue = value.isCopyOf(arg0); 0081 result = KJS::jsBoolean(cppValue); 0082 END_VARIANT_METHOD 0083 0084 START_VARIANT_METHOD(callitalic, QFont) 0085 bool cppValue = value.italic(); 0086 result = KJS::jsBoolean(cppValue); 0087 END_VARIANT_METHOD 0088 0089 START_VARIANT_METHOD(callkerning, QFont) 0090 bool cppValue = value.kerning(); 0091 result = KJS::jsBoolean(cppValue); 0092 END_VARIANT_METHOD 0093 0094 START_VARIANT_METHOD(callkey, QFont) 0095 QString cppValue = value.key(); 0096 result = KJS::jsString(cppValue); 0097 END_VARIANT_METHOD 0098 0099 START_VARIANT_METHOD(calllastResortFamily, QFont) 0100 QString cppValue = value.lastResortFamily(); 0101 result = KJS::jsString(cppValue); 0102 END_VARIANT_METHOD 0103 0104 START_VARIANT_METHOD(calllastResortFont, QFont) 0105 QString cppValue = value.lastResortFont(); 0106 result = KJS::jsString(cppValue); 0107 END_VARIANT_METHOD 0108 0109 START_VARIANT_METHOD(calloverline, QFont) 0110 bool cppValue = value.overline(); 0111 result = KJS::jsBoolean(cppValue); 0112 END_VARIANT_METHOD 0113 0114 START_VARIANT_METHOD(callpixelSize, QFont) 0115 int cppValue = value.pixelSize(); 0116 result = KJS::jsNumber(cppValue); 0117 END_VARIANT_METHOD 0118 0119 START_VARIANT_METHOD(callpointSize, QFont) 0120 int cppValue = value.pointSize(); 0121 result = KJS::jsNumber(cppValue); 0122 END_VARIANT_METHOD 0123 0124 START_VARIANT_METHOD(callrawMode, QFont) 0125 bool cppValue = value.rawMode(); 0126 result = KJS::jsBoolean(cppValue); 0127 END_VARIANT_METHOD 0128 0129 START_VARIANT_METHOD(callrawName, QFont) 0130 QString cppValue = value.rawName(); 0131 result = KJS::jsString(cppValue); 0132 END_VARIANT_METHOD 0133 0134 START_VARIANT_METHOD(callremoveSubstitution, QFont) 0135 QString arg0 = KJSEmbed::extractQString(exec, args, 0); 0136 value.removeSubstitution(arg0); 0137 END_VARIANT_METHOD 0138 0139 START_VARIANT_METHOD(callresolve, QFont) 0140 QFont arg0 = KJSEmbed::extractVariant<QFont>(exec, args, 0); 0141 QFont cppValue = value.resolve(arg0); 0142 result = KJSEmbed::createVariant(exec, "QFont", cppValue); 0143 END_VARIANT_METHOD 0144 0145 START_VARIANT_METHOD(callsetBold, QFont) 0146 bool arg0 = KJSEmbed::extractBool(exec, args, 0); 0147 value.setBold(arg0); 0148 END_VARIANT_METHOD 0149 0150 START_VARIANT_METHOD(callsetFamily, QFont) 0151 QString arg0 = KJSEmbed::extractQString(exec, args, 0); 0152 value.setFamily(arg0); 0153 END_VARIANT_METHOD 0154 0155 START_VARIANT_METHOD(callsetFixedPitch, QFont) 0156 bool arg0 = KJSEmbed::extractBool(exec, args, 0); 0157 value.setFixedPitch(arg0); 0158 END_VARIANT_METHOD 0159 0160 START_VARIANT_METHOD(callsetItalic, QFont) 0161 bool arg0 = KJSEmbed::extractBool(exec, args, 0); 0162 value.setItalic(arg0); 0163 END_VARIANT_METHOD 0164 0165 START_VARIANT_METHOD(callsetKerning, QFont) 0166 bool arg0 = KJSEmbed::extractBool(exec, args, 0); 0167 value.setKerning(arg0); 0168 END_VARIANT_METHOD 0169 0170 START_VARIANT_METHOD(callsetOverline, QFont) 0171 bool arg0 = KJSEmbed::extractBool(exec, args, 0); 0172 value.setOverline(arg0); 0173 END_VARIANT_METHOD 0174 0175 START_VARIANT_METHOD(callsetPixelSize, QFont) 0176 int arg0 = KJSEmbed::extractInt(exec, args, 0); 0177 value.setPixelSize(arg0); 0178 END_VARIANT_METHOD 0179 0180 START_VARIANT_METHOD(callsetPointSize, QFont) 0181 int arg0 = KJSEmbed::extractInt(exec, args, 0); 0182 value.setPointSize(arg0); 0183 END_VARIANT_METHOD 0184 0185 START_VARIANT_METHOD(callsetRawMode, QFont) 0186 bool arg0 = KJSEmbed::extractBool(exec, args, 0); 0187 value.setRawMode(arg0); 0188 END_VARIANT_METHOD 0189 0190 START_VARIANT_METHOD(callsetRawName, QFont) 0191 QString arg0 = KJSEmbed::extractQString(exec, args, 0); 0192 value.setRawName(arg0); 0193 END_VARIANT_METHOD 0194 0195 START_VARIANT_METHOD(callsetStretch, QFont) 0196 int arg0 = KJSEmbed::extractInt(exec, args, 0); 0197 value.setStretch(arg0); 0198 END_VARIANT_METHOD 0199 0200 START_VARIANT_METHOD(callsetStrikeOut, QFont) 0201 bool arg0 = KJSEmbed::extractBool(exec, args, 0); 0202 value.setStrikeOut(arg0); 0203 END_VARIANT_METHOD 0204 0205 START_VARIANT_METHOD(callsetStyle, QFont) 0206 QFont::Style arg0 = (QFont::Style) KJSEmbed::extractInt(exec, args, 0); 0207 value.setStyle(arg0); 0208 END_VARIANT_METHOD 0209 0210 START_VARIANT_METHOD(callsetStyleHint, QFont) 0211 QFont::StyleHint arg0 = (QFont::StyleHint) KJSEmbed::extractInt(exec, args, 0); 0212 QFont::StyleStrategy arg1 = (QFont::StyleStrategy) KJSEmbed::extractInt(exec, args, 1); 0213 value.setStyleHint(arg0, arg1); 0214 END_VARIANT_METHOD 0215 0216 START_VARIANT_METHOD(callsetStyleStrategy, QFont) 0217 QFont::StyleStrategy arg0 = (QFont::StyleStrategy) KJSEmbed::extractInt(exec, args, 0); 0218 value.setStyleStrategy(arg0); 0219 END_VARIANT_METHOD 0220 0221 START_VARIANT_METHOD(callsetUnderline, QFont) 0222 bool arg0 = KJSEmbed::extractBool(exec, args, 0); 0223 value.setUnderline(arg0); 0224 END_VARIANT_METHOD 0225 0226 START_VARIANT_METHOD(callsetWeight, QFont) 0227 int arg0 = KJSEmbed::extractInt(exec, args, 0); 0228 value.setWeight(arg0); 0229 END_VARIANT_METHOD 0230 0231 START_VARIANT_METHOD(callstretch, QFont) 0232 int cppValue = value.stretch(); 0233 result = KJS::jsNumber(cppValue); 0234 END_VARIANT_METHOD 0235 0236 START_VARIANT_METHOD(callstrikeOut, QFont) 0237 bool cppValue = value.strikeOut(); 0238 result = KJS::jsBoolean(cppValue); 0239 END_VARIANT_METHOD 0240 0241 START_VARIANT_METHOD(callstyle, QFont) 0242 QFont::Style cppValue = value.style(); 0243 result = KJS::jsNumber(cppValue); 0244 END_VARIANT_METHOD 0245 0246 START_VARIANT_METHOD(callstyleHint, QFont) 0247 QFont::StyleHint cppValue = value.styleHint(); 0248 result = KJS::jsNumber(cppValue); 0249 END_VARIANT_METHOD 0250 0251 START_VARIANT_METHOD(callstyleStrategy, QFont) 0252 QFont::StyleStrategy cppValue = value.styleStrategy(); 0253 result = KJS::jsNumber(cppValue); 0254 END_VARIANT_METHOD 0255 0256 START_VARIANT_METHOD(callsubstitute, QFont) 0257 QString arg0 = KJSEmbed::extractQString(exec, args, 0); 0258 QString cppValue = value.substitute(arg0); 0259 result = KJS::jsString(cppValue); 0260 END_VARIANT_METHOD 0261 0262 START_VARIANT_METHOD(callsubstitutes, QFont) 0263 QString arg0 = KJSEmbed::extractQString(exec, args, 0); 0264 QStringList cppValue = value.substitutes(arg0); 0265 result = KJSEmbed::createQStringList(exec, cppValue); 0266 END_VARIANT_METHOD 0267 0268 START_VARIANT_METHOD(callsubstitutions, QFont) 0269 QStringList cppValue = value.substitutions(); 0270 result = KJSEmbed::createQStringList(exec, cppValue); 0271 END_VARIANT_METHOD 0272 0273 START_VARIANT_METHOD(calltoString, QFont) 0274 QString cppValue = value.toString(); 0275 result = KJS::jsString(cppValue); 0276 END_VARIANT_METHOD 0277 0278 START_VARIANT_METHOD(callunderline, QFont) 0279 bool cppValue = value.underline(); 0280 result = KJS::jsBoolean(cppValue); 0281 END_VARIANT_METHOD 0282 0283 START_VARIANT_METHOD(callweight, QFont) 0284 int cppValue = value.weight(); 0285 result = KJS::jsNumber(cppValue); 0286 END_VARIANT_METHOD 0287 } 0288 0289 START_METHOD_LUT(Font) 0290 {"bold", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callbold}, 0291 {"exactMatch", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callexactMatch}, 0292 {"family", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callfamily}, 0293 {"fixedPitch", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callfixedPitch}, 0294 {"fromString", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callfromString}, 0295 {"insertSubstitution", 1, KJS::DontDelete | KJS::ReadOnly, &FontNS::callinsertSubstitution}, 0296 {"insertSubstitutions", 1, KJS::DontDelete | KJS::ReadOnly, &FontNS::callinsertSubstitutions}, 0297 {"isCopyOf", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callisCopyOf}, 0298 {"italic", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callitalic}, 0299 {"kerning", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callkerning}, 0300 {"key", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callkey}, 0301 {"lastResortFamily", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::calllastResortFamily}, 0302 {"lastResortFont", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::calllastResortFont}, 0303 {"overline", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::calloverline}, 0304 {"pixelSize", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callpixelSize}, 0305 {"pointSize", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callpointSize}, 0306 {"rawMode", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callrawMode}, 0307 {"rawName", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callrawName}, 0308 {"removeSubstitution", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callremoveSubstitution}, 0309 {"resolve", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callresolve}, 0310 {"setBold", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetBold}, 0311 {"setFamily", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetFamily}, 0312 {"setFixedPitch", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetFixedPitch}, 0313 {"setItalic", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetItalic}, 0314 {"setKerning", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetKerning}, 0315 {"setOverline", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetOverline}, 0316 {"setPixelSize", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetPixelSize}, 0317 {"setPointSize", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetPointSize}, 0318 {"setRawMode", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetRawMode}, 0319 {"setRawName", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetRawName}, 0320 {"setStretch", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetStretch}, 0321 {"setStrikeOut", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetStrikeOut}, 0322 {"setStyle", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetStyle}, 0323 {"setStyleHint", 1, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetStyleHint}, 0324 {"setStyleStrategy", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetStyleStrategy}, 0325 {"setUnderline", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetUnderline}, 0326 {"setWeight", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsetWeight}, 0327 {"stretch", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callstretch}, 0328 {"strikeOut", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callstrikeOut}, 0329 {"style", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callstyle}, 0330 {"styleHint", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callstyleHint}, 0331 {"styleStrategy", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callstyleStrategy}, 0332 {"substitute", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsubstitute}, 0333 {"substitutes", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsubstitutes}, 0334 {"substitutions", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callsubstitutions}, 0335 {"toString", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::calltoString}, 0336 {"underline", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callunderline}, 0337 {"weight", 0, KJS::DontDelete | KJS::ReadOnly, &FontNS::callweight} 0338 END_METHOD_LUT 0339 0340 NO_ENUMS(Font) 0341 NO_STATICS(Font) 0342 0343 START_CTOR(Font, QFont, 0) 0344 if (args.size() == 0) 0345 { 0346 return new KJSEmbed::FontBinding(exec, QFont()); 0347 } 0348 return new KJSEmbed::FontBinding(exec, QFont()); 0349 END_CTOR 0350