KJsEmbed

size.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 "size.h"
23 
24 #include <QDebug>
25 #include <QSize>
26 
27 using namespace KJSEmbed;
28 
29 const KJS::ClassInfo SizeBinding::info = { "QSize", &VariantBinding::info, nullptr, nullptr };
30 SizeBinding::SizeBinding(KJS::ExecState *exec, const QSize &value)
31  : VariantBinding(exec, value)
32 {
33  StaticBinding::publish(exec, this, Size::methods());
34  StaticBinding::publish(exec, this, VariantFactory::methods());
35 }
36 
37 namespace SizeNS
38 {
39 
40 START_VARIANT_METHOD(callboundedTo, QSize)
41 QSize arg0 = KJSEmbed::extractVariant<QSize>(exec, args, 0);
42 QSize cppValue = value.boundedTo(arg0);
43 result = KJSEmbed::createVariant(exec, "QSize", cppValue);
44 END_VARIANT_METHOD
45 
46 START_VARIANT_METHOD(callexpandedTo, QSize)
47 QSize arg0 = KJSEmbed::extractVariant<QSize>(exec, args, 0);
48 QSize cppValue = value.expandedTo(arg0);
49 result = KJSEmbed::createVariant(exec, "QSize", cppValue);
50 END_VARIANT_METHOD
51 
52 START_VARIANT_METHOD(callheight, QSize)
53 int cppValue = value.height();
54 result = KJS::jsNumber(cppValue);
55 END_VARIANT_METHOD
56 
57 START_VARIANT_METHOD(callisEmpty, QSize)
58 bool cppValue = value.isEmpty();
59 result = KJS::jsBoolean(cppValue);
60 END_VARIANT_METHOD
61 
62 START_VARIANT_METHOD(callisNull, QSize)
63 bool cppValue = value.isNull();
64 result = KJS::jsBoolean(cppValue);
65 END_VARIANT_METHOD
66 
67 START_VARIANT_METHOD(callisValid, QSize)
68 bool cppValue = value.isValid();
69 result = KJS::jsBoolean(cppValue);
70 END_VARIANT_METHOD
71 
72 START_VARIANT_METHOD(callrheight, QSize)
73 int cppValue = value.rheight();
74 result = KJS::jsNumber(cppValue);
75 END_VARIANT_METHOD
76 
77 START_VARIANT_METHOD(callrwidth, QSize)
78 int cppValue = value.rwidth();
79 result = KJS::jsNumber(cppValue);
80 END_VARIANT_METHOD
81 
82 START_VARIANT_METHOD(callscale, QSize)
83 if (args.size() == 2)
84 {
85  QSize arg0 = KJSEmbed::extractVariant<QSize>(exec, args, 0);
86  Qt::AspectRatioMode arg1 = (Qt::AspectRatioMode)KJSEmbed::extractInt(exec, args, 1);
87  value.scale(arg0, arg1);
88 } else if (args.size() == 3)
89 {
90  int arg0 = KJSEmbed::extractInt(exec, args, 0);
91  int arg1 = KJSEmbed::extractInt(exec, args, 1);
92  Qt::AspectRatioMode arg2 = (Qt::AspectRatioMode)KJSEmbed::extractInt(exec, args, 2);
93  value.scale(arg0, arg1, arg2);
94 }
95 END_VARIANT_METHOD
96 
97 START_VARIANT_METHOD(callsetHeight, QSize)
98 int arg0 = KJSEmbed::extractInt(exec, args, 0);
99 value.setHeight(arg0);
100 END_VARIANT_METHOD
101 
102 START_VARIANT_METHOD(callsetWidth, QSize)
103 int arg0 = KJSEmbed::extractInt(exec, args, 0);
104 value.setWidth(arg0);
105 END_VARIANT_METHOD
106 
107 START_VARIANT_METHOD(calltranspose, QSize)
108 value.transpose();
109 END_VARIANT_METHOD
110 
111 START_VARIANT_METHOD(callwidth, QSize)
112 int cppValue = value.width();
113 result = KJS::jsNumber(cppValue);
114 END_VARIANT_METHOD
115 
116 }
117 
118 START_METHOD_LUT(Size)
119 {"boundedTo", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callboundedTo},
120 {"expandedTo", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callexpandedTo},
121 {"height", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callheight},
122 {"isEmpty", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callisEmpty},
123 {"isNull", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callisNull},
124 {"isValid", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callisValid},
125 {"rheight", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callrheight},
126 {"rwidth", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callrwidth},
127 {"scale", 2, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callscale},
128 {"setHeight", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callsetHeight},
129 {"setWidth", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callsetWidth},
130 {"transpose", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::calltranspose},
131 {"width", 0, KJS::DontDelete | KJS::ReadOnly, &SizeNS::callwidth}
132 END_METHOD_LUT
133 
134 NO_ENUMS(Size)
135 NO_STATICS(Size)
136 
137 START_CTOR(Size, QSize, 0)
138 if (args.size() == 0)
139 {
140  return new KJSEmbed::SizeBinding(exec, QSize());
141 } else if (args.size() == 2)
142 {
143  return new KJSEmbed::SizeBinding(exec,
144  QSize(KJSEmbed::extractInt(exec, args, 0),
145  KJSEmbed::extractInt(exec, args, 1)
146  ));
147 }
148 return new KJSEmbed::SizeBinding(exec, QSize());
149 END_CTOR
150 
bool isNull() const const
bool isValid() const const
AspectRatioMode
static void publish(KJS::ExecState *exec, KJS::JSObject *object, const Method *methods)
Publishes an array of Methods to an object.
QVariant based binding.
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.