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

kjsembed

  • sources
  • kde-4.12
  • kdelibs
  • kjsembed
  • kjsembed
size.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 "size.h"
23 
24 #include <QtCore/QDebug>
25 #include <QtCore/QSize>
26 
27 using namespace KJSEmbed;
28 
29 const KJS::ClassInfo SizeBinding::info = { "QSize", &VariantBinding::info, 0, 0 };
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  }
89  else if( args.size() == 3 )
90  {
91  int arg0 = KJSEmbed::extractInt(exec, args, 0);
92  int arg1 = KJSEmbed::extractInt(exec, args, 1);
93  Qt::AspectRatioMode arg2 = (Qt::AspectRatioMode)KJSEmbed::extractInt(exec, args, 2);
94  value.scale(arg0, arg1, arg2);
95  }
96 END_VARIANT_METHOD
97 
98 START_VARIANT_METHOD( callsetHeight, QSize )
99  int arg0 = KJSEmbed::extractInt(exec, args, 0);
100  value.setHeight(arg0);
101 END_VARIANT_METHOD
102 
103 START_VARIANT_METHOD( callsetWidth, QSize )
104  int arg0 = KJSEmbed::extractInt(exec, args, 0);
105  value.setWidth(arg0);
106 END_VARIANT_METHOD
107 
108 START_VARIANT_METHOD( calltranspose, QSize )
109  value.transpose();
110 END_VARIANT_METHOD
111 
112 START_VARIANT_METHOD( callwidth, QSize )
113  int cppValue = value.width();
114  result = KJS::jsNumber(cppValue);
115 END_VARIANT_METHOD
116 
117 }
118 
119 START_METHOD_LUT( Size )
120  {"boundedTo", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callboundedTo},
121  {"expandedTo", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callexpandedTo},
122  {"height", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callheight},
123  {"isEmpty", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callisEmpty},
124  {"isNull", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callisNull},
125  {"isValid", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callisValid},
126  {"rheight", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callrheight},
127  {"rwidth", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callrwidth},
128  {"scale", 2, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callscale},
129  {"setHeight", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callsetHeight},
130  {"setWidth", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callsetWidth},
131  {"transpose", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::calltranspose},
132  {"width", 0, KJS::DontDelete|KJS::ReadOnly, &SizeNS::callwidth}
133 END_METHOD_LUT
134 
135 NO_ENUMS( Size )
136 NO_STATICS( Size )
137 
138 START_CTOR( Size, QSize, 0)
139  if( args.size() == 0 )
140  {
141  return new KJSEmbed::SizeBinding( exec, QSize() );
142  }
143  else if( args.size() == 2 )
144  {
145  return new KJSEmbed::SizeBinding(exec,
146  QSize( KJSEmbed::extractInt( exec, args, 0 ),
147  KJSEmbed::extractInt( exec, args, 1 )
148  ) );
149  }
150  return new KJSEmbed::SizeBinding( exec, QSize() );
151 END_CTOR
152 
153 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
154 
KJSEmbed::VariantBinding::info
static const KJS::ClassInfo info
Definition: variant_binding.h:123
SizeNS::setHeight
value setHeight(arg0)
KJSEmbed::SizeBinding::info
static const KJS::ClassInfo info
Definition: size.h:38
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:88
SizeNS::result
result
Definition: size.cpp:43
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
SizeNS::transpose
END_VARIANT_METHOD value transpose()
END_CTOR
#define END_CTOR
Definition: binding_support.h:166
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
START_CTOR
#define START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:157
KJSEmbed::SizeBinding::SizeBinding
SizeBinding(KJS::ExecState *exec, const QSize &value)
Definition: size.cpp:30
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
KJSEmbed::SizeBinding
Definition: size.h:33
size.h
SizeNS::if
END_VARIANT_METHOD if(args.size()==2)
Definition: size.cpp:83
KJSEmbed::VariantFactory::methods
static const Method * methods()
Definition: variant_binding.h:251
SizeNS::setWidth
value setWidth(arg0)
cppValue
END_OBJECT_METHOD QBrush cppValue
Definition: qpainter_binding.cpp:97
ImageNS::arg2
int arg2
Definition: image.cpp:56
END_VARIANT_METHOD
#define END_VARIANT_METHOD
End a variant method started by START_VARIANT_METHOD.
Definition: variant_binding.h:56
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
arg1
Qt::FillRule arg1
Definition: qpainter_binding.cpp:307
WidgetNS::width
END_QOBJECT_METHOD int width
Definition: qwidget_binding.cpp:90
START_METHOD_LUT
START_METHOD_LUT(Size)
Definition: size.cpp:119
START_VARIANT_METHOD
#define START_VARIANT_METHOD(METHODNAME, TYPE)
A simple variant syle method.
Definition: variant_binding.h:42
value
QVariant value
Definition: settings.cpp:35
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
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:53 by doxygen 1.8.7 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 API Reference

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

Search



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