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

kjsembed

  • kjsembed
  • kjsembed
color.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 "color.h"
23
24#include <QtCore/QDebug>
25#include <QtGui/QColor>
26
27using namespace KJSEmbed;
28
29const KJS::ClassInfo ColorBinding::info = { "QColor", &VariantBinding::info, 0, 0 };
30ColorBinding::ColorBinding( KJS::ExecState *exec, const QColor &value )
31 : VariantBinding(exec, value )
32{
33 StaticBinding::publish( exec, this, Color::methods() );
34 StaticBinding::publish( exec, this, VariantFactory::methods() );
35}
36
37START_VARIANT_METHOD( callSetAlpha, QColor )
38 value.setAlpha( KJSEmbed::extractInt(exec, args, 0) );
39END_VARIANT_METHOD
40
41START_VARIANT_METHOD( callSetBlue, QColor )
42 value.setBlue( KJSEmbed::extractInt(exec, args, 0) );
43END_VARIANT_METHOD
44
45START_VARIANT_METHOD( callSetGreen, QColor )
46 value.setGreen( KJSEmbed::extractInt(exec, args, 0) );
47END_VARIANT_METHOD
48
49START_VARIANT_METHOD( callSetRed, QColor )
50 value.setRed( KJSEmbed::extractInt(exec, args, 0) );
51END_VARIANT_METHOD
52
53START_VARIANT_METHOD( callSetRgb, QColor )
54 value.setRgb( KJSEmbed::extractInt(exec, args, 0),
55 KJSEmbed::extractInt(exec, args, 1),
56 KJSEmbed::extractInt(exec, args, 2),
57 KJSEmbed::extractInt(exec, args, 3, 255));
58END_VARIANT_METHOD
59
60START_VARIANT_METHOD( callSetCmyk, QColor )
61 value.setCmyk( KJSEmbed::extractInt(exec, args, 0),
62 KJSEmbed::extractInt(exec, args, 1),
63 KJSEmbed::extractInt(exec, args, 2),
64 KJSEmbed::extractInt(exec, args, 3),
65 KJSEmbed::extractInt(exec, args, 4,255));
66END_VARIANT_METHOD
67
68START_VARIANT_METHOD( callSetHsv, QColor )
69 value.setHsv( KJSEmbed::extractInt(exec, args, 0),
70 KJSEmbed::extractInt(exec, args, 1),
71 KJSEmbed::extractInt(exec, args, 2),
72 KJSEmbed::extractInt(exec, args, 3,255));
73END_VARIANT_METHOD
74
75START_VARIANT_METHOD( callSetNamedColor, QColor )
76 value.setNamedColor( KJSEmbed::extractQString(exec, args, 0) );
77END_VARIANT_METHOD
78
79
80START_VARIANT_METHOD( callAlpha, QColor )
81 value.setAlpha( KJSEmbed::extractInt(exec, args, 0) );
82END_VARIANT_METHOD
83
84START_VARIANT_METHOD( callBlue, QColor )
85 result = KJSEmbed::createInt( exec, value.blue() );
86END_VARIANT_METHOD
87
88START_VARIANT_METHOD( callCyan, QColor )
89 result = KJSEmbed::createInt( exec, value.cyan() );
90END_VARIANT_METHOD
91
92START_VARIANT_METHOD( callGreen, QColor )
93 result = KJSEmbed::createInt( exec, value.green() );
94END_VARIANT_METHOD
95
96START_VARIANT_METHOD( callHue, QColor )
97 result = KJSEmbed::createInt( exec, value.hue() );
98END_VARIANT_METHOD
99
100START_VARIANT_METHOD( callMagenta, QColor )
101 result = KJSEmbed::createInt( exec, value.magenta() );
102END_VARIANT_METHOD
103
104START_VARIANT_METHOD( callRed, QColor )
105 result = KJSEmbed::createInt( exec, value.red() );
106END_VARIANT_METHOD
107
108START_VARIANT_METHOD( callYellow, QColor )
109 result = KJSEmbed::createInt( exec, value.yellow() );
110END_VARIANT_METHOD
111
112START_VARIANT_METHOD( callSaturation, QColor )
113 result = KJSEmbed::createInt( exec, value.saturation() );
114END_VARIANT_METHOD
115
116START_VARIANT_METHOD( callDark, QColor )
117 QColor darkColor = value.dark( KJSEmbed::extractInt( exec, args, 0, 200));
118 result = KJSEmbed::createVariant(exec, "QColor", darkColor);
119END_VARIANT_METHOD
120
121START_VARIANT_METHOD( callLight, QColor )
122 QColor darkColor = value.light( KJSEmbed::extractInt( exec, args, 0, 200));
123 result = KJSEmbed::createVariant(exec, "QColor", darkColor);
124END_VARIANT_METHOD
125
126START_VARIANT_METHOD( callConvertTo, QColor )
127 QColor otherColor = value.convertTo( (QColor::Spec)KJSEmbed::extractInt( exec, args, 0));
128 result = KJSEmbed::createVariant(exec, "QColor", otherColor);
129END_VARIANT_METHOD
130
131START_VARIANT_METHOD( callSpec, QColor )
132 result = KJS::jsNumber( value.spec() );
133END_VARIANT_METHOD
134
135START_METHOD_LUT( Color )
136 {"setAlpha", 1, KJS::DontDelete|KJS::ReadOnly, &callSetAlpha},
137 {"setBlue", 1, KJS::DontDelete|KJS::ReadOnly, &callSetBlue},
138 {"setGreen", 1, KJS::DontDelete|KJS::ReadOnly, &callSetGreen},
139 {"setRed", 1, KJS::DontDelete|KJS::ReadOnly, &callSetRed},
140 {"setRgb", 4, KJS::DontDelete|KJS::ReadOnly, &callSetRgb},
141 {"setCmyk", 5, KJS::DontDelete|KJS::ReadOnly, &callSetCmyk},
142 {"setHsv", 4, KJS::DontDelete|KJS::ReadOnly, &callSetHsv},
143 {"setNamedColor", 1, KJS::DontDelete|KJS::ReadOnly, &callSetNamedColor},
144 {"alpha", 0, KJS::DontDelete|KJS::ReadOnly, &callAlpha},
145 {"blue", 0, KJS::DontDelete|KJS::ReadOnly, &callBlue},
146 {"cyan", 0, KJS::DontDelete|KJS::ReadOnly, &callCyan},
147 {"green", 0, KJS::DontDelete|KJS::ReadOnly, &callGreen},
148 {"hue", 0, KJS::DontDelete|KJS::ReadOnly, &callHue},
149 {"magenta", 0, KJS::DontDelete|KJS::ReadOnly, &callMagenta},
150 {"red", 0, KJS::DontDelete|KJS::ReadOnly, &callRed},
151 {"saturation", 0, KJS::DontDelete|KJS::ReadOnly, &callSaturation},
152 {"yellow", 0, KJS::DontDelete|KJS::ReadOnly, &callYellow},
153 {"light", 1, KJS::DontDelete|KJS::ReadOnly, &callLight},
154 {"dark", 1, KJS::DontDelete|KJS::ReadOnly, &callDark},
155 {"convertTo", 1, KJS::DontDelete|KJS::ReadOnly, &callConvertTo},
156 {"spec", 0, KJS::DontDelete|KJS::ReadOnly, &callSpec}
157END_METHOD_LUT
158
159
160START_ENUM_LUT( Color )
161 {"Rgb",QColor::Rgb},
162 {"Hsv",QColor::Hsv},
163 {"Cmyk",QColor::Cmyk},
164 {"Invalid",QColor::Invalid}
165END_ENUM_LUT
166
167NO_STATICS( Color )
168
169START_CTOR( Color, QColor, 0)
170 if( args.size() == 1 )
171 {
172 return new KJSEmbed::ColorBinding( exec, QColor( KJSEmbed::extractQString(exec,args,0 ) ) );
173 }
174 else if( args.size() >= 3 )
175 {
176 return new KJSEmbed::ColorBinding(exec,
177 QColor( KJSEmbed::extractInt( exec, args, 0 ),
178 KJSEmbed::extractInt( exec, args, 1 ),
179 KJSEmbed::extractInt( exec, args, 2 )) );
180 }
181
182 if( args.size() == 4 )
183 {
184 return new KJSEmbed::ColorBinding(exec,
185 QColor( KJSEmbed::extractInt( exec, args, 0 ),
186 KJSEmbed::extractInt( exec, args, 1 ),
187 KJSEmbed::extractInt( exec, args, 2 ),
188 KJSEmbed::extractInt( exec, args, 3 )) );
189 }
190
191 return new KJSEmbed::ColorBinding( exec, QColor() );
192END_CTOR
193
194//kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
START_METHOD_LUT
#define START_METHOD_LUT(TYPE)
Definition: binding_support.h:127
START_ENUM_LUT
#define START_ENUM_LUT(TYPE)
Definition: binding_support.h:139
END_CTOR
#define END_CTOR
Definition: binding_support.h:166
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
START_CTOR
#define START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:157
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
END_ENUM_LUT
#define END_ENUM_LUT
Definition: binding_support.h:143
KJSEmbed::ColorBinding
Definition: color.h:35
KJSEmbed::ColorBinding::info
static const KJS::ClassInfo info
Definition: color.h:39
KJSEmbed::ColorBinding::ColorBinding
ColorBinding(KJS::ExecState *exec, const QColor &value)
Definition: color.cpp:30
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:89
KJSEmbed::VariantBinding::info
static const KJS::ClassInfo info
Definition: variant_binding.h:123
KJSEmbed::VariantFactory::methods
static const Method * methods()
Definition: variant_binding.h:251
setNamedColor
END_VARIANT_METHOD value setNamedColor(KJSEmbed::extractQString(exec, args, 0))
setAlpha
value setAlpha(KJSEmbed::extractInt(exec, args, 0))
darkColor
END_VARIANT_METHOD QColor darkColor
Definition: color.cpp:117
setBlue
END_VARIANT_METHOD value setBlue(KJSEmbed::extractInt(exec, args, 0))
setRgb
END_VARIANT_METHOD value setRgb(KJSEmbed::extractInt(exec, args, 0), KJSEmbed::extractInt(exec, args, 1), KJSEmbed::extractInt(exec, args, 2), KJSEmbed::extractInt(exec, args, 3, 255))
setGreen
END_VARIANT_METHOD value setGreen(KJSEmbed::extractInt(exec, args, 0))
setHsv
END_VARIANT_METHOD value setHsv(KJSEmbed::extractInt(exec, args, 0), KJSEmbed::extractInt(exec, args, 1), KJSEmbed::extractInt(exec, args, 2), KJSEmbed::extractInt(exec, args, 3, 255))
setRed
END_VARIANT_METHOD value setRed(KJSEmbed::extractInt(exec, args, 0))
result
END_VARIANT_METHOD result
Definition: color.cpp:85
otherColor
END_VARIANT_METHOD QColor otherColor
Definition: color.cpp:127
setCmyk
END_VARIANT_METHOD value setCmyk(KJSEmbed::extractInt(exec, args, 0), KJSEmbed::extractInt(exec, args, 1), KJSEmbed::extractInt(exec, args, 2), KJSEmbed::extractInt(exec, args, 3), KJSEmbed::extractInt(exec, args, 4, 255))
color.h
if
if(file->open((QIODevice::OpenModeFlag) KJSEmbed::extractInt(exec, args, 0)))
Definition: fileio.cpp:64
KJSEmbed
Definition: application.h:33
KJSEmbed::extractQString
QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue=QString())
Extracts a QString from an argument list.
Definition: binding_support.cpp:34
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
KJSEmbed::createInt
KJS::JSValue * createInt(KJS::ExecState *exec, int value)
Create a new KJS::JSValue with the value of the integer.
Definition: binding_support.cpp:94
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
KJS
Implement QString-KJS::UString conversion methods.
Definition: kjs_object_model.h:29
value
QVariant value
Definition: settings.cpp:35
START_VARIANT_METHOD
#define START_VARIANT_METHOD(METHODNAME, TYPE)
A simple variant syle method.
Definition: variant_binding.h:42
END_VARIANT_METHOD
#define END_VARIANT_METHOD
End a variant method started by START_VARIANT_METHOD.
Definition: variant_binding.h:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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.14.38 API Reference

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