• 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
pen.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 "pen.h"
23 
24 #include <QtCore/QDebug>
25 #include <QtGui/QPen>
26 #include <QtGui/QBrush>
27 #include <QtGui/QColor>
28 
29 using namespace KJSEmbed;
30 
31 const KJS::ClassInfo PenBinding::info = { "QPen", &VariantBinding::info, 0, 0 };
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 
126 NO_ENUMS( Pen )
127 NO_STATICS( Pen )
128 
129 START_CTOR( Pen, QPen, 0)
130  if( args.size() == 1 )
131  {
132  return new KJSEmbed::PenBinding(exec,
133  QPen( KJSEmbed::extractVariant<QColor>( exec, args, 0 )
134  ) );
135  }
136  else if (args.size() >= 2)
137  {
138  return new KJSEmbed::PenBinding(exec,
139  QPen( KJSEmbed::extractVariant<QBrush>( exec, args, 0 ),
140  KJSEmbed::extractInt( exec, args, 1 ),
141  (Qt::PenStyle)KJSEmbed::extractInt( exec, args, 2, Qt::SolidLine ),
142  (Qt::PenCapStyle)KJSEmbed::extractInt( exec, args, 3, Qt::SquareCap ),
143  (Qt::PenJoinStyle)KJSEmbed::extractInt( exec, args, 4, Qt::BevelJoin )
144  ) );
145 
146  }
147 
148  return new KJSEmbed::PenBinding( exec, QPen() );
149 END_CTOR
150 
151 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KJSEmbed::VariantBinding::info
static const KJS::ClassInfo info
Definition: variant_binding.h:123
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
START_METHOD_LUT
START_METHOD_LUT(Pen)
Definition: pen.cpp:109
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
PenNS::setColor
value setColor(arg0)
PenNS::setStyle
value setStyle(arg0)
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
DomDocumentNS::if
if(!success)
Definition: dom.cpp:363
PenNS::setJoinStyle
value setJoinStyle(arg0)
START_CTOR
#define START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:157
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
QBrushNS::color
KJS::JSValue * color(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:124
PenNS::setWidth
value setWidth(arg0)
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
pen.h
PenNS::result
result
Definition: pen.cpp:44
KJSEmbed::VariantFactory::methods
static const Method * methods()
Definition: variant_binding.h:251
PenNS::setBrush
value setBrush(arg0)
PenNS::setCapStyle
value setCapStyle(arg0)
cppValue
END_OBJECT_METHOD QBrush cppValue
Definition: qpainter_binding.cpp:97
END_VARIANT_METHOD
#define END_VARIANT_METHOD
End a variant method started by START_VARIANT_METHOD.
Definition: variant_binding.h:56
KJSEmbed::PenBinding
Definition: pen.h:35
KJSEmbed::PenBinding::PenBinding
PenBinding(KJS::ExecState *exec, const QPen &value)
Definition: pen.cpp:32
arg0
END_OBJECT_METHOD QPolygon arg0
Definition: qpainter_binding.cpp:179
WidgetNS::width
END_QOBJECT_METHOD int width
Definition: qwidget_binding.cpp:90
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
QBrushNS::style
KJS::JSValue * style(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: QBrush_bind.cpp:30
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