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

kjsembed

  • kjsembed
  • kjsembed
brush.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 "brush.h"
23 
24 #include <QtCore/QDebug>
25 #include <QtGui/QBrush>
26 #include <QtGui/QPixmap>
27 #include <QtGui/QColor>
28 
29 #include "pixmap.h"
30 #include "color.h"
31 #include "util.h"
32 
33 using namespace KJSEmbed;
34 
35 const KJS::ClassInfo BrushBinding::info = { "QBrush", &VariantBinding::info, 0, 0 };
36 BrushBinding::BrushBinding( KJS::ExecState *exec, const QBrush &value )
37  : VariantBinding(exec, value )
38 {
39  StaticBinding::publish( exec, this, Brush::methods() );
40  StaticBinding::publish( exec, this, VariantFactory::methods() );
41 }
42 
43 namespace BrushNS
44 {
45 
46 START_VARIANT_METHOD( callcolor, QBrush )
47  QColor cppValue = value.color();
48  result = KJSEmbed::createVariant(exec, "QColor", cppValue );
49 END_VARIANT_METHOD
50 
51 START_VARIANT_METHOD( callgradient, QBrush )
52  const QGradient *cppValue = value.gradient();
53  result = KJSEmbed::createObject<QGradient>(exec, "QGradient", cppValue);
54 END_VARIANT_METHOD
55 
56 START_VARIANT_METHOD( callisOpaque, QBrush )
57  bool cppValue = value.isOpaque();
58  result = KJS::jsBoolean(cppValue);
59 END_VARIANT_METHOD
60 
61 START_VARIANT_METHOD( callsetColor, QBrush )
62  QColor arg0 = KJSEmbed::extractVariant<QColor>(exec,args, 0);
63  value.setColor(arg0);
64 END_VARIANT_METHOD
65 
66 START_VARIANT_METHOD( callsetStyle, QBrush )
67  Qt::BrushStyle arg0 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 0);
68  value.setStyle(arg0);
69 END_VARIANT_METHOD
70 
71 START_VARIANT_METHOD( callsetTexture, QBrush )
72  QPixmap arg0 = KJSEmbed::extractVariant<QPixmap>(exec,args, 0);
73  value.setTexture(arg0);
74 END_VARIANT_METHOD
75 
76 START_VARIANT_METHOD( callstyle, QBrush )
77  Qt::BrushStyle cppValue = value.style();
78  result = KJS::jsNumber(cppValue);
79 END_VARIANT_METHOD
80 
81 START_VARIANT_METHOD( calltexture, QBrush )
82  QPixmap cppValue = value.texture();
83  result = KJSEmbed::createVariant(exec, "QPixmap", cppValue );
84 END_VARIANT_METHOD
85 
86 }
87 
88 START_METHOD_LUT( Brush )
89  {"color", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callcolor},
90  {"gradient", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callgradient},
91  {"isOpaque", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callisOpaque},
92  {"setColor", 1, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callsetColor},
93  {"setStyle", 1, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callsetStyle},
94  {"setTexture", 1, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callsetTexture},
95  {"style", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::callstyle},
96  {"texture", 0, KJS::DontDelete|KJS::ReadOnly, &BrushNS::calltexture}
97 END_METHOD_LUT
98 
99 NO_ENUMS( Brush )
100 NO_STATICS( Brush )
101 
102 START_CTOR( Brush, QBrush, 0)
103  if( args.size() == 0 )
104  {
105  return new KJSEmbed::BrushBinding( exec, QBrush() );
106  }
107  else if( args.size() == 1 )
108  {
109  KJS::JSValue* value0 = args[0];
110  KJS::JSObject* obj0 = value0->toObject(exec);
111  if(obj0)
112  {
113  if(obj0->inherits(&PixmapBinding::info))
114  {
115  QPixmap arg0 = KJSEmbed::extractVariant<QPixmap>(exec, args, 0);
116  return new KJSEmbed::BrushBinding(exec, QBrush(arg0));
117  }
118  if(obj0->inherits(&BrushBinding::info))
119  {
120  QBrush arg0 = KJSEmbed::extractVariant<QBrush>(exec, args, 0);
121  return new KJSEmbed::BrushBinding(exec, QBrush(arg0));
122  }
123 // if(obj0->inherits(&GradientBinding::info))
124 // {
125 // QGradient arg0 = KJSEmbed::extractVariant<QGradient>(exec, args, 0);
126 // return new KJSEmbed::BrushBinding(exec, QBrush(arg0));
127 // }
128  }
129  else if(isBasic(value0))
130  {
131  Qt::BrushStyle arg0 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 0);
132  return new KJSEmbed::BrushBinding(exec, QBrush(arg0));
133  }
134  }
135  else if( args.size() == 2 )
136  {
137  KJS::JSValue* value0= args[0];
138  KJS::JSValue* value1= args[1];
139  KJS::JSObject* obj0 = value0->toObject(exec);
140  KJS::JSObject* obj1 = value1->toObject(exec);
141 
142  if(obj0 && obj1 && obj0->inherits(&ColorBinding::info) && obj1->inherits(&PixmapBinding::info))
143  {
144  QColor arg0 = KJSEmbed::extractVariant<QColor>(exec, args, 0);
145  QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
146  return new KJSEmbed::BrushBinding(exec, QBrush(arg0, arg1));
147  }
148  if(obj1 && isBasic(value0) && obj1->inherits(&PixmapBinding::info))
149  {
150  Qt::GlobalColor arg0 = (Qt::GlobalColor)KJSEmbed::extractInt(exec, args, 0);
151  QPixmap arg1 = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
152  return new KJSEmbed::BrushBinding(exec, QBrush(arg0, arg1));
153  }
154  if(obj0 && obj0->inherits(&ColorBinding::info) && isBasic(value1))
155  {
156  QColor arg0 = KJSEmbed::extractVariant<QColor>(exec, args, 0);
157  Qt::BrushStyle arg1 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 1);
158  return new KJSEmbed::BrushBinding(exec, QBrush(arg0, arg1));
159  }
160  if(isBasic(value0) && isBasic(value1))
161  {
162  Qt::GlobalColor arg0 = (Qt::GlobalColor)KJSEmbed::extractInt(exec, args, 0);
163  Qt::BrushStyle arg1 = (Qt::BrushStyle)KJSEmbed::extractInt(exec, args, 1);
164  return new KJSEmbed::BrushBinding(exec, QBrush(arg0, arg1));
165  }
166  }
167  return new KJSEmbed::BrushBinding( exec, QBrush() );
168 
169 END_CTOR
170 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Apr 16 2013 19:12:29 by doxygen 1.8.3.1 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.10.2 API Reference

Skip menu "kdelibs-4.10.2 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