rename qtgui to reflect its actual purpose

svn path=/trunk/KDE/kdebase/runtime/; revision=1051137
This commit is contained in:
Aaron J. Seigo 2009-11-18 22:39:12 +00:00
parent fc05ac9f3b
commit 8ff52246b7
16 changed files with 14 additions and 3575 deletions

View File

@ -4,19 +4,19 @@ set(simple_javascript_engine_SRCS
simplejavascriptapplet.cpp
appletinterface.cpp
uiloader.cpp
qtgui/anchorlayout.cpp
qtgui/color.cpp
qtgui/font.cpp
qtgui/filedialogproxy.cpp
qtgui/graphicsitem.cpp
qtgui/linearlayout.cpp
qtgui/painter.cpp
qtgui/pixmap.cpp
qtgui/point.cpp
qtgui/rect.cpp
qtgui/size.cpp
qtgui/timer.cpp
qtgui/url.cpp
simplebindings/anchorlayout.cpp
simplebindings/color.cpp
simplebindings/font.cpp
simplebindings/filedialogproxy.cpp
simplebindings/graphicsitem.cpp
simplebindings/linearlayout.cpp
simplebindings/painter.cpp
simplebindings/pixmap.cpp
simplebindings/point.cpp
simplebindings/rect.cpp
simplebindings/size.cpp
simplebindings/timer.cpp
simplebindings/url.cpp
)
include_directories(${PHONON_INCLUDES})

View File

@ -1,2 +1,2 @@
#! /usr/bin/env bash
$XGETTEXT *.cpp qtgui/*.cpp -o $podir/plasma_scriptengine_qscript.pot
$XGETTEXT *.cpp simplebindings/*.cpp -o $podir/plasma_scriptengine_qscript.pot

View File

@ -1,168 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
* Copyright 2009 Artur Duque de Souza <asouza@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtGui/QGraphicsWidget>
#include <QtGui/QGraphicsAnchorLayout>
#include <Plasma/Applet>
#include "../backportglobal.h"
#include "../appletinterface.h"
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
Q_DECLARE_METATYPE(QGraphicsWidget*)
Q_DECLARE_METATYPE(QGraphicsAnchor*)
Q_DECLARE_METATYPE(QGraphicsLayoutItem*)
DECLARE_POINTER_METATYPE(QGraphicsAnchorLayout)
// QGraphicsAnchorLayout
DECLARE_VOID_NUMBER_METHOD(QGraphicsAnchorLayout, setSpacing)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsAnchorLayout, horizontalSpacing, setHorizontalSpacing)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsAnchorLayout, verticalSpacing, setVerticalSpacing)
DECLARE_VOID_NUMBER_METHOD(QGraphicsAnchorLayout, removeAt)
/////////////////////////////////////////////////////////////
QGraphicsLayoutItem *convertToLayoutItem (QScriptContext *ctx, int index = 0)
{
QObject *object = ctx->argument(index).toQObject();
QGraphicsLayoutItem *item = qobject_cast<QGraphicsWidget*>(object);
if (!item) {
item = qscriptvalue_cast<QGraphicsAnchorLayout*>(ctx->argument(index));
}
if (!item) {
AppletInterface *interface = qobject_cast<AppletInterface*>(object);
if (!interface) {
interface = qobject_cast<AppletInterface*>(ctx->engine()->globalObject().property("plasmoid").toQObject());
}
if (interface) {
item = interface->applet();
}
}
return item;
}
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
QGraphicsLayoutItem *parent = convertToLayoutItem(ctx);
if (!parent) {
return ctx->throwError(i18n("The parent must be a QGraphicsLayoutItem"));
}
return qScriptValueFromValue(eng, new QGraphicsAnchorLayout(parent));
}
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, addAnchor) {
QGraphicsLayoutItem *item1 = convertToLayoutItem(ctx, 0);
QGraphicsLayoutItem *item2 = convertToLayoutItem(ctx, 2);
if (!item1 || !item2) {
return eng->undefinedValue();
}
QGraphicsAnchor *anchor = self->addAnchor(item1, static_cast<Qt::AnchorPoint>(ctx->argument(1).toInt32()),
item2, static_cast<Qt::AnchorPoint>(ctx->argument(3).toInt32()));
return eng->newQObject(anchor, QScriptEngine::QtOwnership);
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, anchor) {
QGraphicsLayoutItem *item1 = convertToLayoutItem(ctx, 0);
QGraphicsLayoutItem *item2 = convertToLayoutItem(ctx, 2);
if (!item1 || !item2) {
return eng->undefinedValue();
}
QGraphicsAnchor *anchor = self->anchor(item1, static_cast<Qt::AnchorPoint>(ctx->argument(1).toInt32()),
item2, static_cast<Qt::AnchorPoint>(ctx->argument(3).toInt32()));
return eng->newQObject(anchor, QScriptEngine::QtOwnership);
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, addCornerAnchors) {
QGraphicsLayoutItem *item1 = convertToLayoutItem(ctx, 0);
QGraphicsLayoutItem *item2 = convertToLayoutItem(ctx, 2);
if (!item1 || !item2) {
return eng->undefinedValue();
}
self->addCornerAnchors(item1, static_cast<Qt::Corner>(ctx->argument(1).toInt32()),
item2, static_cast<Qt::Corner>(ctx->argument(3).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, addAnchors) {
QGraphicsLayoutItem *item1 = convertToLayoutItem(ctx, 0);
QGraphicsLayoutItem *item2 = convertToLayoutItem(ctx, 1);
if (!item1 || !item2) {
return eng->undefinedValue();
}
self->addAnchors(item1, item2, static_cast<Qt::Orientation>(ctx->argument(2).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, toString) {
return QScriptValue(eng, "QGraphicsAnchorLayout");
} END_DECLARE_METHOD
/////////////////////////////////////////////////////////////
class PrototypeAnchorLayout : public QGraphicsAnchorLayout
{
public:
PrototypeAnchorLayout()
{ }
};
QScriptValue constructAnchorLayoutClass(QScriptEngine *eng)
{
QScriptValue proto =
QScript::wrapPointer<QGraphicsAnchorLayout>(eng,
new QGraphicsAnchorLayout(),
QScript::UserOwnership);
ADD_METHOD(proto, setSpacing);
ADD_GET_SET_METHODS(proto, horizontalSpacing, setHorizontalSpacing);
ADD_GET_SET_METHODS(proto, verticalSpacing, setVerticalSpacing);
ADD_METHOD(proto, removeAt);
ADD_METHOD(proto, addAnchor);
ADD_METHOD(proto, anchor);
ADD_METHOD(proto, addAnchors);
ADD_METHOD(proto, addCornerAnchors);
ADD_METHOD(proto, toString);
QScript::registerPointerMetaType<QGraphicsAnchorLayout>(eng, proto);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
return ctorFun;
}

View File

@ -1,136 +0,0 @@
/*
* Copyright 2009 Aaron J. Seigo
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtGui/QColor>
#include "../backportglobal.h"
Q_DECLARE_METATYPE(QColor*)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 0) {
return qScriptValueFromValue(eng, QColor());
} else if (ctx->argumentCount() == 1) {
QString namedColor = ctx->argument(0).toString();
return qScriptValueFromValue(eng, QColor(namedColor));
}
int r = 0;
int g = 0;
int b = 0;
int a = 255;
if (ctx->argumentCount() == 3) {
r = ctx->argument(0).toInt32();
g = ctx->argument(1).toInt32();
b = ctx->argument(2).toInt32();
}
if (ctx->argumentCount() == 4) {
a = ctx->argument(3).toInt32();
}
return qScriptValueFromValue(eng, QColor(r, g, b, a));
}
// red, green, blue, alpha, setRed, setGreen, setBlue, setAlpha, isValid, toString, name
static QScriptValue red(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, red);
return QScriptValue(eng, self->red());
}
static QScriptValue setRed(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QColor, setRed);
QScriptValue arg = ctx->argument(0);
self->setRed(arg.toInt32());
return arg;
}
static QScriptValue green(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, green);
return QScriptValue(eng, self->green());
}
static QScriptValue setGreen(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QColor, setGreen);
QScriptValue arg = ctx->argument(0);
self->setGreen(arg.toInt32());
return arg;
}
static QScriptValue blue(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, blue);
return QScriptValue(eng, self->blue());
}
static QScriptValue setBlue(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QColor, setBlue);
QScriptValue arg = ctx->argument(0);
self->setBlue(arg.toInt32());
return arg;
}
static QScriptValue alpha(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, alpha);
return QScriptValue(eng, self->alpha());
}
static QScriptValue setAlpha(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QColor, setAlpha);
QScriptValue arg = ctx->argument(0);
self->setAlpha(arg.toInt32());
return arg;
}
static QScriptValue isValid(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QColor, isValid);
return QScriptValue(eng, self->isValid());
}
QScriptValue constructColorClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QColor());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("red", eng->newFunction(red), getter);
proto.setProperty("setRed", eng->newFunction(setRed));
proto.setProperty("green", eng->newFunction(green), getter);
proto.setProperty("setGreen", eng->newFunction(setGreen));
proto.setProperty("blue", eng->newFunction(blue), getter);
proto.setProperty("setBlue", eng->newFunction(setBlue));
proto.setProperty("alpha", eng->newFunction(alpha, getter));
proto.setProperty("setAlpha", eng->newFunction(setAlpha));
proto.setProperty("isValid", eng->newFunction(red), getter);
eng->setDefaultPrototype(qMetaTypeId<QColor>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QColor*>(), proto);
return eng->newFunction(ctor, proto);
}

View File

@ -1,176 +0,0 @@
/*
* Copyright 2009 Aaron J. Seigo
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "filedialogproxy.h"
#include <QScriptEngine>
#include <KDebug>
FileDialogProxy::FileDialogProxy(KFileDialog::OperationMode mode, QObject *parent)
: QObject(parent),
m_dialog(new KFileDialog(KUrl("~"), QString(), 0))
{
kDebug() << "hello beautiful";
m_dialog->setOperationMode(mode);
connect(m_dialog, SIGNAL(okClicked()), this, SLOT(dialogFinished()));
}
FileDialogProxy::~FileDialogProxy()
{
kDebug() << "bye bye";
delete m_dialog;
}
KUrl FileDialogProxy::selectedUrl() const
{
return m_dialog->selectedUrl();
}
void FileDialogProxy::setUrl(const KUrl &url)
{
m_dialog->setUrl(url);
}
KUrl::List FileDialogProxy::selectedUrls() const
{
return m_dialog->selectedUrls();
}
KUrl FileDialogProxy::baseUrl() const
{
return m_dialog->baseUrl();
}
QString FileDialogProxy::selectedFile() const
{
return m_dialog->selectedFile();
}
QStringList FileDialogProxy::selectedFiles() const
{
return m_dialog->selectedFiles();
}
QString FileDialogProxy::filter() const
{
return m_dialog->currentFilter();
}
void FileDialogProxy::setFilter(const QString &filter)
{
m_dialog->setFilter(filter);
}
bool FileDialogProxy::localOnly() const
{
return m_dialog->mode() & KFile::LocalOnly;
}
void FileDialogProxy::setLocalOnly(bool localOnly)
{
if (localOnly) {
m_dialog->setMode(m_dialog->mode() ^ KFile::LocalOnly);
} else {
m_dialog->setMode(m_dialog->mode() | KFile::LocalOnly);
}
}
bool FileDialogProxy::directoriesOnly() const
{
return m_dialog->mode() & KFile::Directory;
}
void FileDialogProxy::setDirectoriesOnly(bool directoriesOnly)
{
if (directoriesOnly) {
m_dialog->setMode(m_dialog->mode() ^ KFile::Directory);
} else {
m_dialog->setMode(m_dialog->mode() | KFile::Directory);
}
}
bool FileDialogProxy::existingOnly() const
{
return m_dialog->mode() & KFile::ExistingOnly;
}
void FileDialogProxy::setExistingOnly(bool existingOnly)
{
if (existingOnly) {
m_dialog->setMode(m_dialog->mode() ^ KFile::ExistingOnly);
} else {
m_dialog->setMode(m_dialog->mode() | KFile::ExistingOnly);
}
}
void FileDialogProxy::show()
{
m_dialog->show();
}
void FileDialogProxy::dialogFinished()
{
emit finished(this);
}
Q_DECLARE_METATYPE(FileDialogProxy *)
typedef FileDialogProxy* FileDialogProxyPtr;
QScriptValue qScriptValueFromFileDialogProxy(QScriptEngine *engine, const FileDialogProxyPtr &fd)
{
return engine->newQObject(const_cast<FileDialogProxy *>(fd));
}
void fileDialogProxyFromQScriptValue(const QScriptValue &scriptValue, FileDialogProxyPtr &fd)
{
QObject *obj = scriptValue.toQObject();
fd = static_cast<FileDialogProxy *>(obj);
}
void FileDialogProxy::registerWithRuntime(QScriptEngine *engine)
{
QScriptValue global = engine->globalObject();
qScriptRegisterMetaType<FileDialogProxy*>(engine, qScriptValueFromFileDialogProxy, fileDialogProxyFromQScriptValue);
global.setProperty("OpenFileDialog", engine->newFunction(FileDialogProxy::fileDialogOpen));
global.setProperty("SaveFileDialog", engine->newFunction(FileDialogProxy::fileDialogSave));
}
QScriptValue FileDialogProxy::fileDialogSave(QScriptContext *context, QScriptEngine *engine)
{
QObject *parent = 0;
if (context->argumentCount()) {
parent = context->argument(0).toQObject();
}
FileDialogProxy *fd = new FileDialogProxy(KFileDialog::Saving, parent);
return engine->newQObject(fd, QScriptEngine::ScriptOwnership, QScriptEngine::ExcludeSuperClassContents);
}
QScriptValue FileDialogProxy::fileDialogOpen(QScriptContext *context, QScriptEngine *engine)
{
QObject *parent = 0;
if (context->argumentCount()) {
parent = context->argument(0).toQObject();
}
FileDialogProxy *fd = new FileDialogProxy(KFileDialog::Opening, parent);
return engine->newQObject(fd, QScriptEngine::ScriptOwnership, QScriptEngine::ExcludeSuperClassContents);
}
#include "filedialogproxy.moc"

View File

@ -1,84 +0,0 @@
/*
* Copyright 2009 Aaron J. Seigo
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FILEDIALOGPROXY_H
#define FILEDIALOGPROXY_H
#include <QObject>
#include <QScriptValue>
#include <KFileDialog>
class QScriptEngine;
class QScriptContext;
class FileDialogProxy : public QObject
{
Q_OBJECT
Q_PROPERTY(KUrl url READ selectedUrl WRITE setUrl)
Q_PROPERTY(KUrl::List urls READ selectedUrls)
Q_PROPERTY(KUrl baseUrl READ baseUrl)
Q_PROPERTY(QString file READ selectedFile)
Q_PROPERTY(QStringList files READ selectedFiles)
Q_PROPERTY(QString filter READ filter WRITE setFilter)
Q_PROPERTY(bool localOnly READ localOnly WRITE setLocalOnly)
Q_PROPERTY(bool directoriesOnly READ directoriesOnly WRITE setDirectoriesOnly)
Q_PROPERTY(bool existingOnly READ existingOnly WRITE setExistingOnly)
public:
FileDialogProxy(KFileDialog::OperationMode mode, QObject *parent = 0);
~FileDialogProxy();
KUrl selectedUrl() const;
void setUrl(const KUrl &url);
KUrl::List selectedUrls() const;
KUrl baseUrl() const;
QString selectedFile() const;
QStringList selectedFiles() const;
QString filter() const;
void setFilter(const QString &filter);
bool localOnly() const;
void setLocalOnly(bool localOnly);
bool directoriesOnly() const;
void setDirectoriesOnly(bool directoriesOnly);
bool existingOnly() const;
void setExistingOnly(bool existingOnly);
static void registerWithRuntime(QScriptEngine *global);
static QScriptValue fileDialogSave(QScriptContext *context, QScriptEngine *engine);
static QScriptValue fileDialogOpen(QScriptContext *context, QScriptEngine *engine);
public Q_SLOTS:
void show();
Q_SIGNALS:
void finished(FileDialogProxy *);
private Q_SLOTS:
void dialogFinished();
private:
KFileDialog *m_dialog;
};
#endif

View File

@ -1,413 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtGui/QFont>
#include "../backportglobal.h"
Q_DECLARE_METATYPE(QFont*)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 0)
return qScriptValueFromValue(eng, QFont());
QString family = ctx->argument(0).toString();
if (ctx->argumentCount() == 1) {
QFont *other = qscriptvalue_cast<QFont*>(ctx->argument(0));
if (other)
return qScriptValueFromValue(eng, QFont(*other));
return qScriptValueFromValue(eng, QFont(family));
}
int pointSize = ctx->argument(1).toInt32();
if (ctx->argumentCount() == 2)
return qScriptValueFromValue(eng, QFont(family, pointSize));
int weight = ctx->argument(2).toInt32();
if (ctx->argumentCount() == 3)
return qScriptValueFromValue(eng, QFont(family, pointSize, weight));
bool italic = ctx->argument(3).toBoolean();
return qScriptValueFromValue(eng, QFont(family, pointSize, weight, italic));
}
static QScriptValue bold(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, bold);
return QScriptValue(eng, self->bold());
}
static QScriptValue defaultFamily(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, defaultFamily);
return QScriptValue(eng, self->defaultFamily());
}
static QScriptValue exactMatch(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, exactMatch);
return QScriptValue(eng, self->exactMatch());
}
static QScriptValue family(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, family);
return QScriptValue(eng, self->family());
}
static QScriptValue fixedPitch(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, fixedPitch);
return QScriptValue(eng, self->fixedPitch());
}
static QScriptValue fromString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, fromString);
return QScriptValue(eng, self->fromString(ctx->argument(0).toString()));
}
static QScriptValue handle(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QFont.prototype.handle is not implemented");
}
static QScriptValue isCopyOf(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, isCopyOf);
QFont *other = qscriptvalue_cast<QFont*>(ctx->argument(0));
if (!other) {
return ctx->throwError(QScriptContext::TypeError,
"QFont.prototype.isCopyOf: argument is not a Font");
}
return QScriptValue(eng, self->isCopyOf(*other));
}
static QScriptValue italic(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, italic);
return QScriptValue(eng, self->italic());
}
static QScriptValue kerning(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, kerning);
return QScriptValue(eng, self->kerning());
}
static QScriptValue key(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, key);
return QScriptValue(eng, self->key());
}
static QScriptValue lastResortFamily(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, lastResortFamily);
return QScriptValue(eng, self->lastResortFamily());
}
static QScriptValue lastResortFont(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, lastResortFont);
return QScriptValue(eng, self->lastResortFont());
}
static QScriptValue overline(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, overline);
return QScriptValue(eng, self->overline());
}
static QScriptValue pixelSize(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, pixelSize);
return QScriptValue(eng, self->pixelSize());
}
static QScriptValue pointSize(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, pointSize);
return QScriptValue(eng, self->pointSize());
}
static QScriptValue pointSizeF(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, pointSizeF);
return QScriptValue(eng, self->pointSizeF());
}
static QScriptValue rawMode(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, rawMode);
return QScriptValue(eng, self->rawMode());
}
static QScriptValue rawName(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, rawName);
return QScriptValue(eng, self->rawName());
}
static QScriptValue resolve(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, resolve);
QFont *other = qscriptvalue_cast<QFont*>(ctx->argument(0));
if (!other) {
return ctx->throwError(QScriptContext::TypeError,
"QFont.prototype.isCopyOf: argument is not a Font");
}
return qScriptValueFromValue(eng, self->resolve(*other));
}
static QScriptValue setBold(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setBold);
QScriptValue arg = ctx->argument(0);
self->setBold(arg.toBoolean());
return arg;
}
static QScriptValue setFamily(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setFamily);
QScriptValue arg = ctx->argument(0);
self->setFamily(arg.toString());
return arg;
}
static QScriptValue setFixedPitch(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setFixedPitch);
QScriptValue arg = ctx->argument(0);
self->setFixedPitch(arg.toBoolean());
return arg;
}
static QScriptValue setItalic(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setItalic);
QScriptValue arg = ctx->argument(0);
self->setItalic(arg.toBoolean());
return arg;
}
static QScriptValue setKerning(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setKerning);
QScriptValue arg = ctx->argument(0);
self->setKerning(arg.toBoolean());
return arg;
}
static QScriptValue setOverline(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setOverline);
QScriptValue arg = ctx->argument(0);
self->setOverline(arg.toBoolean());
return arg;
}
static QScriptValue setPixelSize(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setPixelSize);
QScriptValue arg = ctx->argument(0);
self->setPixelSize(arg.toInt32());
return arg;
}
static QScriptValue setPointSize(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setPointSize);
QScriptValue arg = ctx->argument(0);
self->setPointSize(arg.toInt32());
return arg;
}
static QScriptValue setPointSizeF(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setPointSizeF);
QScriptValue arg = ctx->argument(0);
self->setPointSizeF(arg.toNumber());
return arg;
}
static QScriptValue setRawMode(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setRawMode);
QScriptValue arg = ctx->argument(0);
self->setRawMode(arg.toBoolean());
return arg;
}
static QScriptValue setRawName(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setRawName);
QScriptValue arg = ctx->argument(0);
self->setRawName(arg.toString());
return arg;
}
static QScriptValue setStretch(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setStretch);
QScriptValue arg = ctx->argument(0);
self->setStretch(arg.toInt32());
return arg;
}
static QScriptValue setStrikeOut(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setStrikeOut);
QScriptValue arg = ctx->argument(0);
self->setStrikeOut(arg.toBoolean());
return arg;
}
static QScriptValue setStyle(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QFont.setStyle");
}
static QScriptValue setStyleHint(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QFont.setStyleHint");
}
static QScriptValue setStyleStrategy(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QFont.setStyleStrategy");
}
static QScriptValue setUnderline(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setUnderline);
QScriptValue arg = ctx->argument(0);
self->setUnderline(arg.toBoolean());
return arg;
}
static QScriptValue setWeight(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QFont, setWeight);
QScriptValue arg = ctx->argument(0);
self->setWeight(arg.toInt32());
return arg;
}
static QScriptValue stretch(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, stretch);
return QScriptValue(eng, self->stretch());
}
static QScriptValue strikeOut(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, strikeOut);
return QScriptValue(eng, self->strikeOut());
}
static QScriptValue style(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QFont.prototype.style is not implemented");
}
static QScriptValue styleHint(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QFont.prototype.styleHint is not implemented");
}
static QScriptValue styleStrategy(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QFont.prototype.styleStrategy is not implemented");
}
static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, toString);
return QScriptValue(eng, self->toString());
}
static QScriptValue underline(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, underline);
return QScriptValue(eng, self->underline());
}
static QScriptValue weight(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QFont, weight);
return QScriptValue(eng, self->weight());
}
QScriptValue constructFontClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QFont());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("bold", eng->newFunction(bold), getter);
proto.setProperty("defaultFamily", eng->newFunction(defaultFamily));
proto.setProperty("exactMatch", eng->newFunction(exactMatch));
proto.setProperty("family", eng->newFunction(family), getter);
proto.setProperty("fixedPitch", eng->newFunction(fixedPitch), getter);
proto.setProperty("fromString", eng->newFunction(fromString));
proto.setProperty("handle", eng->newFunction(handle));
proto.setProperty("isCopyOf", eng->newFunction(isCopyOf));
proto.setProperty("italic", eng->newFunction(italic), getter);
proto.setProperty("kerning", eng->newFunction(kerning), getter);
proto.setProperty("key", eng->newFunction(key), getter);
proto.setProperty("lastResortFamily", eng->newFunction(lastResortFamily));
proto.setProperty("lastResortFont", eng->newFunction(lastResortFont));
proto.setProperty("overline", eng->newFunction(overline), getter);
proto.setProperty("pixelSize", eng->newFunction(pixelSize), getter);
proto.setProperty("pointSize", eng->newFunction(pointSize), getter);
proto.setProperty("pointSizeF", eng->newFunction(pointSizeF), getter);
proto.setProperty("rawMode", eng->newFunction(rawMode), getter);
proto.setProperty("rawName", eng->newFunction(rawName), getter);
proto.setProperty("resolve", eng->newFunction(resolve));
proto.setProperty("bold", eng->newFunction(setBold), setter);
proto.setProperty("bamily", eng->newFunction(setFamily), setter);
proto.setProperty("fixedPitch", eng->newFunction(setFixedPitch), setter);
proto.setProperty("italic", eng->newFunction(setItalic), setter);
proto.setProperty("kerning", eng->newFunction(setKerning), setter);
proto.setProperty("overline", eng->newFunction(setOverline), setter);
proto.setProperty("pixelSize", eng->newFunction(setPixelSize), setter);
proto.setProperty("pointSize", eng->newFunction(setPointSize), setter);
proto.setProperty("pointSizeF", eng->newFunction(setPointSizeF), setter);
proto.setProperty("rawMode", eng->newFunction(setRawMode), setter);
proto.setProperty("rawName", eng->newFunction(setRawName), setter);
proto.setProperty("stretch", eng->newFunction(setStretch), setter);
proto.setProperty("strikeOut", eng->newFunction(setStrikeOut), setter);
proto.setProperty("setStyle", eng->newFunction(setStyle));
proto.setProperty("setStyleHint", eng->newFunction(setStyleHint));
proto.setProperty("setStyleStrategy", eng->newFunction(setStyleStrategy));
proto.setProperty("underline", eng->newFunction(setUnderline), setter);
proto.setProperty("weight", eng->newFunction(setWeight), setter);
proto.setProperty("stretch", eng->newFunction(stretch), getter);
proto.setProperty("strikeOut", eng->newFunction(strikeOut), getter);
proto.setProperty("style", eng->newFunction(style));
proto.setProperty("styleHint", eng->newFunction(styleHint));
proto.setProperty("styleStrategy", eng->newFunction(styleStrategy));
proto.setProperty("toString", eng->newFunction(toString));
proto.setProperty("underline", eng->newFunction(underline), getter);
proto.setProperty("weight", eng->newFunction(weight), getter);
eng->setDefaultPrototype(qMetaTypeId<QFont>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QFont*>(), proto);
return eng->newFunction(ctor, proto);
}

View File

@ -1,412 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtGui/QCursor>
#include <QtGui/QGraphicsItem>
#include <QtGui/QGraphicsScene>
#include "../backportglobal.h"
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
Q_DECLARE_METATYPE(QList<QGraphicsItem*>)
Q_DECLARE_METATYPE(QPainterPath)
#ifndef QT_NO_CURSOR
Q_DECLARE_METATYPE(QCursor)
#endif
Q_DECLARE_METATYPE(QGraphicsItemGroup*)
Q_DECLARE_METATYPE(QPainter*)
Q_DECLARE_METATYPE(QStyleOptionGraphicsItem*)
Q_DECLARE_METATYPE(QGraphicsPathItem*)
Q_DECLARE_METATYPE(QGraphicsRectItem*)
Q_DECLARE_METATYPE(QGraphicsEllipseItem*)
Q_DECLARE_METATYPE(QGraphicsPolygonItem*)
Q_DECLARE_METATYPE(QGraphicsLineItem*)
Q_DECLARE_METATYPE(QGraphicsPixmapItem*)
Q_DECLARE_METATYPE(QGraphicsTextItem*)
Q_DECLARE_METATYPE(QGraphicsSimpleTextItem*)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, acceptDrops, setAcceptDrops)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, acceptsHoverEvents, setAcceptsHoverEvents)
DECLARE_GET_METHOD(QGraphicsItem, boundingRect)
DECLARE_GET_METHOD(QGraphicsItem, children)
DECLARE_GET_METHOD(QGraphicsItem, childrenBoundingRect)
#ifndef QT_NO_CURSOR
DECLARE_GET_SET_METHODS(QGraphicsItem, QCursor, cursor, setCursor)
DECLARE_BOOLEAN_GET_METHOD(QGraphicsItem, hasCursor)
#endif
DECLARE_GET_SET_METHODS(QGraphicsItem, QGraphicsItemGroup*, group, setGroup)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, handlesChildEvents, setHandlesChildEvents)
DECLARE_BOOLEAN_GET_METHOD(QGraphicsItem, hasFocus)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, isEnabled, setEnabled)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, isSelected, setSelected)
DECLARE_BOOLEAN_GET_SET_METHODS(QGraphicsItem, isVisible, setVisible)
DECLARE_GET_METHOD(QGraphicsItem, opaqueArea)
DECLARE_GET_METHOD(QGraphicsItem, pos)
DECLARE_QOBJECT_GET_METHOD(QGraphicsItem, scene)
DECLARE_GET_METHOD(QGraphicsItem, sceneBoundingRect)
DECLARE_GET_METHOD(QGraphicsItem, scenePos)
DECLARE_GET_METHOD(QGraphicsItem, sceneTransform)
DECLARE_GET_METHOD(QGraphicsItem, shape)
#ifndef QT_NO_TOOLTIP
DECLARE_STRING_GET_SET_METHODS(QGraphicsItem, toolTip, setToolTip)
#endif
DECLARE_GET_METHOD(QGraphicsItem, topLevelItem)
DECLARE_GET_SET_METHODS(QGraphicsItem, QTransform, transform, setTransform)
DECLARE_NUMBER_GET_METHOD(QGraphicsItem, type)
DECLARE_NUMBER_GET_METHOD(QGraphicsItem, x)
DECLARE_NUMBER_GET_METHOD(QGraphicsItem, y)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsItem, zValue, setZValue)
DECLARE_BOOLEAN_1ARG_METHOD(QGraphicsItem, QPointF, contains)
DECLARE_VOID_METHOD(QGraphicsItem, clearFocus)
DECLARE_VOID_METHOD(QGraphicsItem, hide)
DECLARE_BOOLEAN_1ARG_METHOD(QGraphicsItem, QGraphicsItem*, isAncestorOf)
DECLARE_BOOLEAN_1ARG_METHOD(QGraphicsItem, QGraphicsItem*, isObscuredBy)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsItem, moveBy)
DECLARE_VOID_METHOD(QGraphicsItem, resetTransform)
#ifndef QT_NO_CURSOR
DECLARE_VOID_METHOD(QGraphicsItem, unsetCursor)
#endif
DECLARE_VOID_METHOD(QGraphicsItem, show)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsItem, translate)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsItem, scale)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsItem, shear)
DECLARE_VOID_1ARG_METHOD(QGraphicsItem, QGraphicsItem*, installSceneEventFilter)
DECLARE_VOID_1ARG_METHOD(QGraphicsItem, QGraphicsItem*, removeSceneEventFilter)
DECLARE_VOID_NUMBER_METHOD(QGraphicsItem, rotate)
/////////////////////////////////////////////////////////////
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *)
{
return ctx->throwError("QGraphicsItem cannot be instantiated");
}
BEGIN_DECLARE_METHOD(QGraphicsItem, acceptedMouseButtons) {
return QScriptValue(eng, static_cast<int>(self->acceptedMouseButtons()));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, advance) {
self->advance(ctx->argument(0).toInt32());
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, collidesWithItem) {
QGraphicsItem *other = qscriptvalue_cast<QGraphicsItem*>(ctx->argument(0));
if (!other) {
return ctx->throwError(QScriptContext::TypeError,
"QGraphicsItem.prototype.collidesWithItem: argument is not a GraphicsItem");
}
if (ctx->argument(1).isUndefined())
return QScriptValue(eng, self->collidesWithItem(other));
else
return QScriptValue(eng, self->collidesWithItem(other, static_cast<Qt::ItemSelectionMode>(ctx->argument(1).toInt32())));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, collidesWithPath) {
QPainterPath path = qscriptvalue_cast<QPainterPath>(ctx->argument(0));
if (ctx->argument(1).isUndefined())
return QScriptValue(eng, self->collidesWithPath(path));
else
return QScriptValue(eng, self->collidesWithPath(path, static_cast<Qt::ItemSelectionMode>(ctx->argument(1).toInt32())));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, collidingItems) {
if (ctx->argument(0).isUndefined())
return qScriptValueFromValue(eng, self->collidingItems());
else
return qScriptValueFromValue(eng, self->collidingItems(static_cast<Qt::ItemSelectionMode>(ctx->argument(0).toInt32())));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, data) {
return eng->newVariant(self->data(ctx->argument(0).toInt32()));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, ensureVisible) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.ensureVisible is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, flags) {
return QScriptValue(eng, static_cast<int>(self->flags()));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, isObscured) {
if (ctx->argumentCount() == 0) {
return QScriptValue(eng, self->isObscured());
} else if (ctx->argumentCount() > 1) {
return QScriptValue(eng, self->isObscured(ctx->argument(0).toInt32(),
ctx->argument(1).toInt32(),
ctx->argument(2).toInt32(),
ctx->argument(3).toInt32()));
} else {
return QScriptValue(eng, self->isObscured(qscriptvalue_cast<QRectF>(ctx->argument(0))));
}
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapFromItem) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapFromItem is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapFromParent) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapFromParent is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapFromScene) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapFromScene is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapToItem) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapToItem is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapToParent) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapToParent is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, mapToScene) {
Q_UNUSED(eng);
return ctx->throwError("QGraphicsItem.prototype.mapToScene is not implemented");
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, paint) {
self->paint(qscriptvalue_cast<QPainter*>(ctx->argument(0)),
qscriptvalue_cast<QStyleOptionGraphicsItem*>(ctx->argument(1)),
qscriptvalue_cast<QWidget*>(ctx->argument(2)));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, parentItem) {
QGraphicsItem *parent = self->parentItem();
if (!parent)
return eng->nullValue();
QScriptValue ret = qScriptValueFromValue(eng, parent);
QScriptValue proto;
switch (parent->type()) {
case 2:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsPathItem*>());
break;
case 3:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsRectItem*>());
break;
case 4:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsEllipseItem*>());
break;
case 5:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsPolygonItem*>());
break;
case 6:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsLineItem*>());
break;
case 7:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsPixmapItem*>());
break;
case 8:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsTextItem*>());
break;
case 9:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsSimpleTextItem*>());
break;
case 10:
proto = eng->defaultPrototype(qMetaTypeId<QGraphicsItemGroup*>());
break;
}
if (proto.isValid())
ret.setPrototype(proto);
return ret;
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setAcceptedMouseButtons) {
self->setAcceptedMouseButtons(static_cast<Qt::MouseButtons>(ctx->argument(0).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setData) {
self->setData(ctx->argument(0).toInt32(), ctx->argument(1).toVariant());
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setFlag) {
QGraphicsItem::GraphicsItemFlag flag = static_cast<QGraphicsItem::GraphicsItemFlag>(ctx->argument(0).toInt32());
if (ctx->argument(1).isUndefined())
self->setFlag(flag);
else
self->setFlag(flag, ctx->argument(1).toBoolean());
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setFlags) {
self->setFlags(static_cast<QGraphicsItem::GraphicsItemFlags>(ctx->argument(0).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setFocus) {
if (ctx->argument(0).isUndefined())
self->setFocus();
else
self->setFocus(static_cast<Qt::FocusReason>(ctx->argument(0).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setParentItem) {
QScriptValue arg = ctx->argument(0);
QGraphicsItem *item = qscriptvalue_cast<QGraphicsItem*>(arg);
self->setParentItem(item);
if (item)
QScript::maybeReleaseOwnership(ctx->thisObject());
else if (!self->scene())
QScript::maybeTakeOwnership(ctx->thisObject());
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, setPos) {
if (ctx->argumentCount() > 1)
self->setPos(ctx->argument(0).toNumber(), ctx->argument(1).toNumber());
else
self->setPos(qscriptvalue_cast<QPointF>(ctx->argument(0)));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, update) {
if (ctx->argumentCount() > 1) {
self->update(ctx->argument(0).toNumber(),
ctx->argument(1).toNumber(),
ctx->argument(2).toNumber(),
ctx->argument(3).toNumber());
} else {
self->update(qscriptvalue_cast<QRectF>(ctx->argument(0)));
}
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, toString) {
return QScriptValue(eng, "QGraphicsItem");
} END_DECLARE_METHOD
/////////////////////////////////////////////////////////////
class PrototypeGraphicsItem : public QGraphicsItem
{
public:
PrototypeGraphicsItem()
{ }
QRectF boundingRect() const
{ return QRectF(); }
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
{ }
};
QScriptValue constructGraphicsItemClass(QScriptEngine *eng)
{
QScriptValue proto = QScript::wrapGVPointer<QGraphicsItem>(eng, new PrototypeGraphicsItem());
ADD_GET_SET_METHODS(proto, acceptDrops, setAcceptDrops);
ADD_GET_SET_METHODS(proto, acceptsHoverEvents, setAcceptsHoverEvents);
ADD_GET_METHOD(proto, boundingRect);
ADD_GET_METHOD(proto, children);
ADD_GET_METHOD(proto, childrenBoundingRect);
#ifndef QT_NO_CURSOR
ADD_GET_SET_METHODS(proto, cursor, setCursor);
ADD_GET_METHOD(proto, hasCursor);
#endif
ADD_GET_SET_METHODS(proto, group, setGroup);
ADD_GET_SET_METHODS(proto, handlesChildEvents, setHandlesChildEvents);
ADD_GET_METHOD(proto, hasFocus);
ADD_GET_SET_METHODS(proto, isEnabled, setEnabled);
ADD_GET_SET_METHODS(proto, isSelected, setSelected);
ADD_GET_SET_METHODS(proto, isVisible, setVisible);
ADD_GET_METHOD(proto, opaqueArea);
ADD_GET_METHOD(proto, pos);
ADD_GET_METHOD(proto, scene);
ADD_GET_METHOD(proto, sceneBoundingRect);
ADD_GET_METHOD(proto, scenePos);
ADD_GET_METHOD(proto, sceneTransform);
ADD_GET_METHOD(proto, shape);
#ifndef QT_NO_TOOLTIP
ADD_GET_SET_METHODS(proto, toolTip, setToolTip);
#endif
ADD_GET_METHOD(proto, topLevelItem);
ADD_GET_SET_METHODS(proto, transform, setTransform);
ADD_GET_METHOD(proto, type);
ADD_GET_METHOD(proto, x);
ADD_GET_METHOD(proto, y);
ADD_GET_SET_METHODS(proto, zValue, setZValue);
ADD_METHOD(proto, acceptedMouseButtons);
ADD_METHOD(proto, advance);
ADD_METHOD(proto, clearFocus);
ADD_METHOD(proto, collidesWithItem);
ADD_METHOD(proto, collidesWithPath);
ADD_METHOD(proto, collidingItems);
ADD_METHOD(proto, contains);
ADD_METHOD(proto, data);
ADD_METHOD(proto, ensureVisible);
ADD_METHOD(proto, flags);
ADD_METHOD(proto, hide);
ADD_METHOD(proto, installSceneEventFilter);
ADD_METHOD(proto, isAncestorOf);
ADD_METHOD(proto, isObscured);
ADD_METHOD(proto, isObscuredBy);
ADD_METHOD(proto, mapFromItem);
ADD_METHOD(proto, mapFromParent);
ADD_METHOD(proto, mapFromScene);
ADD_METHOD(proto, mapToItem);
ADD_METHOD(proto, mapToParent);
ADD_METHOD(proto, mapToScene);
ADD_METHOD(proto, moveBy);
ADD_METHOD(proto, paint);
ADD_METHOD(proto, parentItem);
ADD_METHOD(proto, removeSceneEventFilter);
ADD_METHOD(proto, resetTransform);
ADD_METHOD(proto, rotate);
ADD_METHOD(proto, scale);
ADD_METHOD(proto, setAcceptedMouseButtons);
ADD_METHOD(proto, setData);
ADD_METHOD(proto, setFlag);
ADD_METHOD(proto, setFlags);
ADD_METHOD(proto, setFocus);
ADD_METHOD(proto, setParentItem);
ADD_METHOD(proto, setPos);
ADD_METHOD(proto, shear);
ADD_METHOD(proto, show);
ADD_METHOD(proto, toString);
ADD_METHOD(proto, translate);
#ifndef QT_NO_CURSOR
ADD_METHOD(proto, unsetCursor);
#endif
ADD_METHOD(proto, update);
QScript::registerPointerMetaType<QGraphicsItem>(eng, proto);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIsMovable);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIsSelectable);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIsFocusable);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemClipsToShape);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemClipsChildrenToShape);
ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIgnoresTransformations);
return ctorFun;
}

View File

@ -1,186 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtGui/QGraphicsWidget>
#include <QtGui/QGraphicsGridLayout>
#include <QtGui/QGraphicsLinearLayout>
#include <Plasma/Applet>
#include "../backportglobal.h"
#include "../appletinterface.h"
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
Q_DECLARE_METATYPE(QGraphicsWidget*)
Q_DECLARE_METATYPE(QGraphicsGridLayout*)
Q_DECLARE_METATYPE(QGraphicsLayoutItem*)
DECLARE_POINTER_METATYPE(QGraphicsLinearLayout)
DECLARE_VOID_NUMBER_METHOD(QGraphicsLinearLayout, removeAt)
DECLARE_VOID_NUMBER_METHOD(QGraphicsLinearLayout, addStretch)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsLinearLayout, insertStretch)
DECLARE_VOID_NUMBER_NUMBER_METHOD(QGraphicsLinearLayout, setItemSpacing)
DECLARE_VOID_QUAD_NUMBER_METHOD(QGraphicsLinearLayout, setContentsMargins)
DECLARE_NUMBER_GET_SET_METHODS(QGraphicsLinearLayout, spacing, setSpacing)
/////////////////////////////////////////////////////////////
QGraphicsLayoutItem *layoutItem(QScriptContext *ctx, int index = 0)
{
QObject *object = ctx->argument(index).toQObject();
QGraphicsLayoutItem *item = qobject_cast<QGraphicsWidget*>(object);
if (!item) {
item = qscriptvalue_cast<QGraphicsLinearLayout*>(ctx->argument(index));
}
if (!item) {
item = qscriptvalue_cast<QGraphicsGridLayout*>(ctx->argument(index));
}
if (!item) {
AppletInterface *interface = qobject_cast<AppletInterface*>(object);
if (!interface) {
interface = qobject_cast<AppletInterface*>(ctx->engine()->globalObject().property("plasmoid").toQObject());
}
if (interface) {
item = interface->applet();
}
}
return item;
}
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
QGraphicsLayoutItem *parent = layoutItem(ctx);
if (!parent) {
return ctx->throwError(i18n("The parent must be a QGraphicsLayoutItem"));
}
return qScriptValueFromValue(eng, new QGraphicsLinearLayout(parent));
}
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, orientation) {
return QScriptValue(eng, static_cast<int>(self->orientation()));
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, setOrientation) {
self->setOrientation(static_cast<Qt::Orientation>(ctx->argument(0).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, setAlignment) {
QGraphicsLayoutItem *item = layoutItem(ctx);
if (!item) {
return eng->undefinedValue();
}
self->setAlignment(item, static_cast<Qt::Alignment>(ctx->argument(1).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, insertItem) {
QGraphicsLayoutItem *item = layoutItem(ctx, 1);
if (!item) {
return eng->undefinedValue();
}
self->insertItem(ctx->argument(0).toInt32(), item);
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, removeItem) {
QGraphicsLayoutItem *item = layoutItem(ctx);
if (!item) {
return eng->undefinedValue();
}
self->removeItem(item);
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, setStretchFactor) {
QGraphicsLayoutItem *item = ctx->argument(0).toVariant().value<QGraphicsLayoutItem*>();
if (!item) {
return eng->undefinedValue();
}
self->setStretchFactor(item, static_cast<Qt::Orientation>(ctx->argument(1).toInt32()));
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsLinearLayout, addItem) {
QGraphicsLayoutItem *item = layoutItem(ctx);
if (!item) {
return ctx->throwError(QScriptContext::TypeError,
"QGraphicsLinearLayout.prototype.addItem: argument is not a GraphicsLayoutItem");
}
self->addItem(item);
return eng->undefinedValue();
} END_DECLARE_METHOD
BEGIN_DECLARE_METHOD(QGraphicsItem, toString) {
return QScriptValue(eng, "QGraphicsLinearLayout");
} END_DECLARE_METHOD
/////////////////////////////////////////////////////////////
class PrototypeLinearLayout : public QGraphicsLinearLayout
{
public:
PrototypeLinearLayout()
{ }
};
QScriptValue constructLinearLayoutClass(QScriptEngine *eng)
{
// QScriptValue proto = QScript::wrapGVPointer<QGraphicsLinearLayout>(eng, new QGraphicsLinearLayout(), );
QScriptValue proto = QScript::wrapPointer<QGraphicsLinearLayout>(eng, new QGraphicsLinearLayout(), QScript::UserOwnership);
ADD_GET_SET_METHODS(proto, spacing, setSpacing);
ADD_GET_SET_METHODS(proto, orientation, setOrientation);
ADD_METHOD(proto, removeAt);
ADD_METHOD(proto, addStretch);
ADD_METHOD(proto, setStretchFactor);
ADD_METHOD(proto, setAlignment);
ADD_METHOD(proto, insertStretch);
ADD_METHOD(proto, setItemSpacing);
ADD_METHOD(proto, setContentsMargins);
ADD_METHOD(proto, addItem);
ADD_METHOD(proto, removeItem);
ADD_METHOD(proto, insertItem);
ADD_METHOD(proto, toString);
QScript::registerPointerMetaType<QGraphicsLinearLayout>(eng, proto);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
//ADD_ENUM_VALUE(ctorFun, QGraphicsItem, ItemIsMovable);
return ctorFun;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,76 +0,0 @@
/*
* Copyright 2009 Aaron J. Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtGui/QPixmap>
#include "../backportglobal.h"
#include "../simplejavascriptapplet.h"
Q_DECLARE_METATYPE(QPixmap*)
Q_DECLARE_METATYPE(QPixmap)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 1 && ctx->argument(0).isString()) {
// a path on disk in the package
return qScriptValueFromValue(eng, QPixmap(SimpleJavaScriptApplet::findImageFile(eng, ctx->argument(0).toString())));
}
if (ctx->argumentCount() == 2) {
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
return qScriptValueFromValue(eng, QPixmap(x, y));
}
return qScriptValueFromValue(eng, QPixmap());
}
static QScriptValue rect(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPixmap, rect)
return qScriptValueFromValue(eng, QRectF(self->rect()));
}
static QScriptValue isNull(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPixmap, isNull);
return QScriptValue(eng, self->isNull());
}
static QScriptValue scaled(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPixmap, scaled);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
return qScriptValueFromValue(eng, self->scaled(x, y));
}
QScriptValue constructQPixmapClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QPixmap());
proto.setProperty("isNull", eng->newFunction(isNull));
proto.setProperty("rect", eng->newFunction(rect));
proto.setProperty("scaled", eng->newFunction(scaled));
eng->setDefaultPrototype(qMetaTypeId<QPixmap>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QPixmap*>(), proto);
return eng->newFunction(ctor, proto);
}

View File

@ -1,97 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtCore/QPoint>
#include "../backportglobal.h"
Q_DECLARE_METATYPE(QPoint*)
Q_DECLARE_METATYPE(QPoint)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 2)
{
int x = ctx->argument(0).toInt32();
int y = ctx->argument(1).toInt32();
return qScriptValueFromValue(eng, QPoint(x, y));
}
return qScriptValueFromValue(eng, QPoint());
}
static QScriptValue isNull(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPoint, isNull);
return QScriptValue(eng, self->isNull());
}
static QScriptValue manhattanLength(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPoint, manhattanLength);
return QScriptValue(eng, self->manhattanLength());
}
static QScriptValue x(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPoint, x);
return QScriptValue(eng, self->x());
}
static QScriptValue y(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPoint, y);
return QScriptValue(eng, self->y());
}
static QScriptValue setX(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QPoint, setX);
int x = ctx->argument(0).toInt32();
self->setX(x);
return QScriptValue();
}
static QScriptValue setY(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QPoint, setY);
int y = ctx->argument(0).toInt32();
self->setY(y);
return QScriptValue();
}
QScriptValue constructQPointClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QPoint());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("isNull", eng->newFunction(isNull));
proto.setProperty("manhattanLength", eng->newFunction(manhattanLength));
proto.setProperty("x", eng->newFunction(x));
proto.setProperty("y", eng->newFunction(y));
proto.setProperty("setX", eng->newFunction(setX));
proto.setProperty("setY", eng->newFunction(setY));
eng->setDefaultPrototype(qMetaTypeId<QPoint>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QPoint*>(), proto);
return eng->newFunction(ctor, proto);
}

View File

@ -1,349 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtCore/QRectF>
#include "../backportglobal.h"
Q_DECLARE_METATYPE(QRectF*)
Q_DECLARE_METATYPE(QRectF)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 4)
{
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
qreal width = ctx->argument(2).toNumber();
qreal height = ctx->argument(3).toNumber();
return qScriptValueFromValue(eng, QRectF(x, y, width, height));
}
return qScriptValueFromValue(eng, QRectF());
}
static QScriptValue adjust(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, adjust);
qreal dx1 = ctx->argument(0).toNumber();
qreal dy1 = ctx->argument(1).toNumber();
qreal dx2 = ctx->argument(2).toNumber();
qreal dy2 = ctx->argument(3).toNumber();
self->adjust(dx1, dy1, dx2, dy2);
return QScriptValue();
}
static QScriptValue adjusted(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, adjusted);
qreal dx1 = ctx->argument(0).toNumber();
qreal dy1 = ctx->argument(1).toNumber();
qreal dx2 = ctx->argument(2).toNumber();
qreal dy2 = ctx->argument(3).toNumber();
QRectF tmp = self->adjusted(dx1, dy1, dx2, dy2);
return qScriptValueFromValue(eng, tmp);
}
static QScriptValue bottom(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, bottom);
return QScriptValue(eng, self->bottom());
}
static QScriptValue top(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, top);
return QScriptValue(eng, self->top());
}
static QScriptValue contains(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, contains);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
return QScriptValue(eng, self->contains(x, y));
}
static QScriptValue height(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, height);
return QScriptValue(eng, self->height());
}
static QScriptValue isEmpty(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, isEmpty);
return QScriptValue(eng, self->isEmpty());
}
static QScriptValue isNull(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, isNull);
return QScriptValue(eng, self->isNull());
}
static QScriptValue isValid(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, isValid);
return QScriptValue(eng, self->isValid());
}
static QScriptValue left(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, left);
return QScriptValue(eng, self->left());
}
static QScriptValue moveBottom(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveBottom);
qreal bottom = ctx->argument(0).toNumber();
self->moveBottom(bottom);
return QScriptValue();
}
static QScriptValue moveLeft(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveLeft);
qreal left = ctx->argument(0).toNumber();
self->moveBottom(left);
return QScriptValue();
}
static QScriptValue moveRight(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveRight);
qreal right = ctx->argument(0).toNumber();
self->moveBottom(right);
return QScriptValue();
}
static QScriptValue moveTo(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveTo);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
self->moveTo(x, y);
return QScriptValue();
}
static QScriptValue moveTop(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveTop);
qreal top = ctx->argument(0).toNumber();
self->moveTop(top);
return QScriptValue();
}
static QScriptValue right(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, right);
return QScriptValue(eng, self->right());
}
static QScriptValue setBottom(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setBottom);
qreal bottom = ctx->argument(0).toNumber();
self->setBottom(bottom);
return QScriptValue();
}
static QScriptValue setCoords(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setCoords);
qreal x1 = ctx->argument(0).toNumber();
qreal y1 = ctx->argument(1).toNumber();
qreal x2 = ctx->argument(2).toNumber();
qreal y2 = ctx->argument(3).toNumber();
self->setCoords(x1, y1, x2, y2);
return QScriptValue();
}
static QScriptValue setHeight(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setHeight);
qreal height = ctx->argument(0).toNumber();
self->setHeight(height);
return QScriptValue();
}
static QScriptValue setLeft(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setLeft);
qreal left = ctx->argument(0).toNumber();
self->setLeft(left);
return QScriptValue();
}
static QScriptValue setRect(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setRect);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
qreal width = ctx->argument(2).toNumber();
qreal height = ctx->argument(3).toNumber();
self->setRect(x, y, width, height);
return QScriptValue();
}
static QScriptValue setRight(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setRight);
qreal right = ctx->argument(0).toNumber();
self->setRight(right);
return QScriptValue();
}
static QScriptValue setTop(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setTop);
qreal top = ctx->argument(0).toNumber();
self->setTop(top);
return QScriptValue();
}
static QScriptValue setWidth(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setWidth);
qreal width = ctx->argument(0).toNumber();
self->setWidth(width);
return QScriptValue();
}
static QScriptValue setX(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setX);
qreal x = ctx->argument(0).toNumber();
self->setX(x);
return QScriptValue();
}
static QScriptValue setY(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setY);
qreal y = ctx->argument(0).toNumber();
self->setY(y);
return QScriptValue();
}
static QScriptValue translate(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, translate);
qreal dx = ctx->argument(0).toNumber();
qreal dy = ctx->argument(1).toNumber();
self->translate(dx, dy);
return QScriptValue();
}
static QScriptValue width(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, width);
return QScriptValue(eng, self->width());
}
static QScriptValue x(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, x);
return QScriptValue(eng, self->x());
}
static QScriptValue y(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, y);
return QScriptValue(eng, self->y());
}
/* Not Implemented Yet */
// QPointF bottomLeft () const
// QPointF bottomRight () const
// QPointF center () const
// bool contains ( const QPointF & point ) const
// bool contains ( const QRectF & rectangle ) const
// void getCoords ( qreal * x1, qreal * y1, qreal * x2, qreal * y2 ) const
// void getRect ( qreal * x, qreal * y, qreal * width, qreal * height ) const
// QRectF intersected ( const QRectF & rectangle ) const
// bool intersects ( const QRectF & rectangle ) const
// void moveBottomLeft ( const QPointF & position )
// void moveBottomRight ( const QPointF & position )
// void moveCenter ( const QPointF & position )
// void moveTo ( const QPointF & position )
// void moveTopLeft ( const QPointF & position )
// void moveTopRight ( const QPointF & position )
// QRectF normalized () const
// void setBottomLeft ( const QPointF & position )
// void setBottomRight ( const QPointF & position )
// void setSize ( const QSizeF & size )
// void setTopLeft ( const QPointF & position )
// void setTopRight ( const QPointF & position )
// QSizeF size () const
// QRect toAlignedRect () const
// QRect toRect () const
// QPointF topLeft () const
// QPointF topRight () const
// void translate ( const QPointF & offset )
// QRectF translated ( qreal dx, qreal dy ) const
// QRectF translated ( const QPointF & offset ) const
// QRectF united ( const QRectF & rectangle ) const
QScriptValue constructQRectFClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QRectF());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("adjust", eng->newFunction(adjust));
proto.setProperty("bottom", eng->newFunction(bottom));
proto.setProperty("contains", eng->newFunction(contains));
proto.setProperty("height", eng->newFunction(height));
proto.setProperty("isEmpty", eng->newFunction(isEmpty));
proto.setProperty("isNull", eng->newFunction(isNull));
proto.setProperty("isValid", eng->newFunction(isValid));
proto.setProperty("left", eng->newFunction(left));
proto.setProperty("moveBottom", eng->newFunction(moveBottom));
proto.setProperty("moveLeft", eng->newFunction(moveLeft));
proto.setProperty("moveRight", eng->newFunction(moveRight));
proto.setProperty("moveTo", eng->newFunction(moveTo));
proto.setProperty("moveTop", eng->newFunction(moveTop));
proto.setProperty("right", eng->newFunction(right));
proto.setProperty("setBottom", eng->newFunction(setBottom));
proto.setProperty("setCoords", eng->newFunction(setCoords));
proto.setProperty("setHeight", eng->newFunction(setHeight));
proto.setProperty("setLeft", eng->newFunction(setLeft));
proto.setProperty("setRect", eng->newFunction(setRect));
proto.setProperty("setRight", eng->newFunction(setRight));
proto.setProperty("setTop", eng->newFunction(setTop));
proto.setProperty("setWidth", eng->newFunction(setWidth));
proto.setProperty("setX", eng->newFunction(setX));
proto.setProperty("setY", eng->newFunction(setY));
proto.setProperty("top", eng->newFunction(top));
proto.setProperty("translate", eng->newFunction(translate));
proto.setProperty("width", eng->newFunction(width));
proto.setProperty("x", eng->newFunction(x));
proto.setProperty("y", eng->newFunction(y));
eng->setDefaultPrototype(qMetaTypeId<QRectF>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QRectF*>(), proto);
return eng->newFunction(ctor, proto);
}

View File

@ -1,63 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtCore/QSizeF>
#include "../backportglobal.h"
Q_DECLARE_METATYPE(QSizeF*)
Q_DECLARE_METATYPE(QSizeF)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 2)
{
qreal width = ctx->argument(1).toNumber();
qreal height = ctx->argument(1).toNumber();
return qScriptValueFromValue(eng, QSizeF(width, height));
}
return qScriptValueFromValue(eng, QSizeF());
}
static QScriptValue width(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QSizeF, width);
return QScriptValue(eng, self->width());
}
static QScriptValue height(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QSizeF, height);
return QScriptValue(eng, self->height());
}
QScriptValue constructQSizeFClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QSizeF());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("width", eng->newFunction(width));
proto.setProperty("height", eng->newFunction(height));
return eng->newFunction(ctor, proto);
}

View File

@ -1,81 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <QtScript/QScriptable>
#include <QtCore/QTimer>
#include "../backportglobal.h"
Q_DECLARE_METATYPE(QTimer*)
static QScriptValue newTimer(QScriptEngine *eng, QTimer *timer)
{
return eng->newQObject(timer, QScriptEngine::AutoOwnership);
}
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
return newTimer(eng, new QTimer(qscriptvalue_cast<QObject*>(ctx->argument(0))));
}
static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QTimer, toString);
return QScriptValue(eng, QString::fromLatin1("QTimer(interval=%0)")
.arg(self->interval()));
}
static QScriptValue singleShot(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QTimer, start);
if (ctx->argumentCount()) {
self->setSingleShot(ctx->argument(0).toBool());
}
return QScriptValue(eng, self->isSingleShot());
}
static QScriptValue interval(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QTimer, interval);
if (ctx->argumentCount()) {
self->setInterval(ctx->argument(0).toInt32());
}
return QScriptValue(eng, self->interval());
}
static QScriptValue isActive(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QTimer, isActive);
return QScriptValue(eng, self->isActive());
}
QScriptValue constructTimerClass(QScriptEngine *eng)
{
QScriptValue proto = newTimer(eng, new QTimer());
ADD_METHOD(proto, toString);
eng->setDefaultPrototype(qMetaTypeId<QTimer*>(), proto);
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("singleShot", eng->newFunction(singleShot), getter | setter);
proto.setProperty("interval", eng->newFunction(interval), getter | setter);
proto.setProperty("isActive", eng->newFunction(isActive), getter);
return eng->newFunction(ctor, proto);
}

View File

@ -1,125 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
#include <KUrl>
#include "../backportglobal.h"
Q_DECLARE_METATYPE(KUrl*)
//Q_DECLARE_METATYPE(KUrl) unneeded; found in kurl.h
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 1)
{
QString url = ctx->argument(0).toString();
return qScriptValueFromValue(eng, KUrl(url));
}
return qScriptValueFromValue(eng, KUrl());
}
static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(KUrl, toString);
return QScriptValue(eng, self->prettyUrl());
}
static QScriptValue protocol(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(KUrl, protocol);
if (ctx->argumentCount()) {
QString v = ctx->argument(0).toString();
self->setProtocol(v);
}
return QScriptValue(eng, self->protocol());
}
static QScriptValue setProtocol(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(KUrl, setProtocol);
QString v = ctx->argument(0).toString();
self->setProtocol(v);
return QScriptValue();
}
static QScriptValue host(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(KUrl, protocol);
if (ctx->argumentCount()) {
QString v = ctx->argument(0).toString();
self->setHost(v);
}
return QScriptValue(eng, self->host());
}
static QScriptValue path(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(KUrl, path);
if (ctx->argumentCount()) {
QString v = ctx->argument(0).toString();
self->setPath(v);
}
return QScriptValue(eng, self->path());
}
static QScriptValue user(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(KUrl, user);
if (ctx->argumentCount()) {
QString v = ctx->argument(0).toString();
self->setUser(v);
}
return QScriptValue(eng, self->user());
}
static QScriptValue password(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(KUrl, password);
if (ctx->argumentCount()) {
QString v = ctx->argument(0).toString();
self->setPassword(v);
}
return QScriptValue(eng, self->password());
}
QScriptValue constructKUrlClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, KUrl());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("toString", eng->newFunction(toString), getter);
proto.setProperty("protocol", eng->newFunction(protocol), getter | setter);
proto.setProperty("host", eng->newFunction(host), getter | setter);
proto.setProperty("path", eng->newFunction(path), getter | setter);
proto.setProperty("user", eng->newFunction(user), getter | setter);
proto.setProperty("password", eng->newFunction(password), getter | setter);
eng->setDefaultPrototype(qMetaTypeId<KUrl*>(), proto);
eng->setDefaultPrototype(qMetaTypeId<KUrl>(), proto);
return eng->newFunction(ctor, proto);
}