• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

point.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2007 Richard J. Moore <rich@kde.org>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License version 2 as
00006  *   published by the Free Software Foundation
00007  *
00008  *   This program is distributed in the hope that it will be useful,
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *   GNU General Public License for more details
00012  *
00013  *   You should have received a copy of the GNU Library General Public
00014  *   License along with this program; if not, write to the
00015  *   Free Software Foundation, Inc.,
00016  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017  */
00018 
00019 #include <QtScript/QScriptValue>
00020 #include <QtScript/QScriptEngine>
00021 #include <QtScript/QScriptContext>
00022 #include <QtCore/QPoint>
00023 #include "../backportglobal.h"
00024 
00025 Q_DECLARE_METATYPE(QPoint*)
00026 Q_DECLARE_METATYPE(QPoint)
00027 
00028 static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
00029 {
00030     if (ctx->argumentCount() == 2)
00031     {
00032         int x = ctx->argument(0).toInt32();
00033         int y = ctx->argument(1).toInt32();
00034         return qScriptValueFromValue(eng, QPoint(x, y));
00035     }
00036 
00037     return qScriptValueFromValue(eng, QPoint());
00038 }
00039 
00040 static QScriptValue isNull(QScriptContext *ctx, QScriptEngine *eng)
00041 {
00042     DECLARE_SELF(QPoint, isNull);
00043     return QScriptValue(eng, self->isNull());
00044 }
00045 
00046 static QScriptValue manhattanLength(QScriptContext *ctx, QScriptEngine *eng)
00047 {
00048     DECLARE_SELF(QPoint, manhattanLength);
00049     return QScriptValue(eng, self->manhattanLength());
00050 }
00051 
00052 static QScriptValue x(QScriptContext *ctx, QScriptEngine *eng)
00053 {
00054     DECLARE_SELF(QPoint, x);
00055     return QScriptValue(eng, self->x());
00056 }
00057 
00058 static QScriptValue y(QScriptContext *ctx, QScriptEngine *eng)
00059 {
00060     DECLARE_SELF(QPoint, y);
00061     return QScriptValue(eng, self->y());
00062 }
00063 
00064 static QScriptValue setX(QScriptContext *ctx, QScriptEngine *)
00065 {
00066     DECLARE_SELF(QPoint, setX);
00067     int x = ctx->argument(0).toInt32();
00068     self->setX(x);
00069     return QScriptValue();
00070 }
00071 
00072 static QScriptValue setY(QScriptContext *ctx, QScriptEngine *)
00073 {
00074     DECLARE_SELF(QPoint, setY);
00075     int y = ctx->argument(0).toInt32();
00076     self->setY(y);
00077     return QScriptValue();
00078 }
00079 
00080 QScriptValue constructQPointClass(QScriptEngine *eng)
00081 {
00082     QScriptValue proto = qScriptValueFromValue(eng, QPoint());
00083     QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
00084     QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
00085 
00086     proto.setProperty("isNull", eng->newFunction(isNull));
00087     proto.setProperty("manhattanLength", eng->newFunction(manhattanLength));
00088     proto.setProperty("x", eng->newFunction(x));
00089     proto.setProperty("y", eng->newFunction(y));
00090     proto.setProperty("setX", eng->newFunction(setX));
00091     proto.setProperty("setY", eng->newFunction(setY));
00092 
00093     eng->setDefaultPrototype(qMetaTypeId<QPoint>(), proto);
00094     eng->setDefaultPrototype(qMetaTypeId<QPoint*>(), proto);
00095 
00096     return eng->newFunction(ctor, proto);
00097 }

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal