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

Plasma

rect.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/QRectF>
00023 #include "../backportglobal.h"
00024 
00025 Q_DECLARE_METATYPE(QRectF*)
00026 Q_DECLARE_METATYPE(QRectF)
00027 
00028 static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
00029 {
00030     if (ctx->argumentCount() == 4)
00031     {
00032         qreal x = ctx->argument(0).toNumber();
00033         qreal y = ctx->argument(1).toNumber();
00034         qreal width = ctx->argument(2).toNumber();
00035         qreal height = ctx->argument(3).toNumber();
00036         return qScriptValueFromValue(eng, QRectF(x, y, width, height));
00037     }
00038 
00039     return qScriptValueFromValue(eng, QRectF());
00040 }
00041 
00042 static QScriptValue adjust(QScriptContext *ctx, QScriptEngine *)
00043 {
00044     DECLARE_SELF(QRectF, adjust);
00045     qreal dx1 = ctx->argument(0).toNumber();
00046     qreal dy1 = ctx->argument(1).toNumber();
00047     qreal dx2 = ctx->argument(2).toNumber();
00048     qreal dy2 = ctx->argument(3).toNumber();
00049 
00050     self->adjust(dx1, dy1, dx2, dy2);
00051     return QScriptValue();
00052 }
00053 
00054 static QScriptValue adjusted(QScriptContext *ctx, QScriptEngine *eng)
00055 {
00056     DECLARE_SELF(QRectF, adjusted);
00057     qreal dx1 = ctx->argument(0).toNumber();
00058     qreal dy1 = ctx->argument(1).toNumber();
00059     qreal dx2 = ctx->argument(2).toNumber();
00060     qreal dy2 = ctx->argument(3).toNumber();
00061 
00062     QRectF tmp = self->adjusted(dx1, dy1, dx2, dy2);
00063     return qScriptValueFromValue(eng, tmp);
00064 }
00065 
00066 static QScriptValue bottom(QScriptContext *ctx, QScriptEngine *eng)
00067 {
00068     DECLARE_SELF(QRectF, bottom);
00069     return QScriptValue(eng, self->bottom());
00070 }
00071 
00072 static QScriptValue top(QScriptContext *ctx, QScriptEngine *eng)
00073 {
00074     DECLARE_SELF(QRectF, top);
00075     return QScriptValue(eng, self->top());
00076 }
00077 
00078 static QScriptValue contains(QScriptContext *ctx, QScriptEngine *eng)
00079 {
00080     DECLARE_SELF(QRectF, contains);
00081     qreal x = ctx->argument(0).toNumber();
00082     qreal y = ctx->argument(1).toNumber();
00083     return QScriptValue(eng, self->contains(x, y));
00084 }
00085 
00086 static QScriptValue height(QScriptContext *ctx, QScriptEngine *eng)
00087 {
00088     DECLARE_SELF(QRectF, height);
00089     return QScriptValue(eng, self->height());
00090 }
00091 
00092 static QScriptValue isEmpty(QScriptContext *ctx, QScriptEngine *eng)
00093 {
00094     DECLARE_SELF(QRectF, isEmpty);
00095     return QScriptValue(eng, self->isEmpty());
00096 }
00097 
00098 static QScriptValue isNull(QScriptContext *ctx, QScriptEngine *eng)
00099 {
00100     DECLARE_SELF(QRectF, isNull);
00101     return QScriptValue(eng, self->isNull());
00102 }
00103 
00104 static QScriptValue isValid(QScriptContext *ctx, QScriptEngine *eng)
00105 {
00106     DECLARE_SELF(QRectF, isValid);
00107     return QScriptValue(eng, self->isValid());
00108 }
00109 
00110 static QScriptValue left(QScriptContext *ctx, QScriptEngine *eng)
00111 {
00112     DECLARE_SELF(QRectF, left);
00113     return QScriptValue(eng, self->left());
00114 }
00115 
00116 static QScriptValue moveBottom(QScriptContext *ctx, QScriptEngine *)
00117 {
00118     DECLARE_SELF(QRectF, moveBottom);
00119     qreal bottom = ctx->argument(0).toNumber();
00120     self->moveBottom(bottom);
00121     return QScriptValue();
00122 }
00123 
00124 static QScriptValue moveLeft(QScriptContext *ctx, QScriptEngine *)
00125 {
00126     DECLARE_SELF(QRectF, moveLeft);
00127     qreal left = ctx->argument(0).toNumber();
00128     self->moveBottom(left);
00129     return QScriptValue();
00130 }
00131 
00132 static QScriptValue moveRight(QScriptContext *ctx, QScriptEngine *)
00133 {
00134     DECLARE_SELF(QRectF, moveRight);
00135     qreal right = ctx->argument(0).toNumber();
00136     self->moveBottom(right);
00137     return QScriptValue();
00138 }
00139 
00140 
00141 static QScriptValue moveTo(QScriptContext *ctx, QScriptEngine *)
00142 {
00143     DECLARE_SELF(QRectF, moveTo);
00144     qreal x = ctx->argument(0).toNumber();
00145     qreal y = ctx->argument(1).toNumber();
00146     self->moveTo(x, y);
00147     return QScriptValue();
00148 }
00149 
00150 static QScriptValue moveTop(QScriptContext *ctx, QScriptEngine *)
00151 {
00152     DECLARE_SELF(QRectF, moveTop);
00153     qreal top = ctx->argument(0).toNumber();
00154     self->moveTop(top);
00155     return QScriptValue();
00156 }
00157 
00158 static QScriptValue right(QScriptContext *ctx, QScriptEngine *eng)
00159 {
00160     DECLARE_SELF(QRectF, right);
00161     return QScriptValue(eng, self->right());
00162 }
00163 
00164 static QScriptValue setBottom(QScriptContext *ctx, QScriptEngine *)
00165 {
00166     DECLARE_SELF(QRectF, setBottom);
00167     qreal bottom = ctx->argument(0).toNumber();
00168     self->setBottom(bottom);
00169     return QScriptValue();
00170 }
00171 
00172 static QScriptValue setCoords(QScriptContext *ctx, QScriptEngine *)
00173 {
00174     DECLARE_SELF(QRectF, setCoords);
00175     qreal x1 = ctx->argument(0).toNumber();
00176     qreal y1 = ctx->argument(1).toNumber();
00177     qreal x2 = ctx->argument(2).toNumber();
00178     qreal y2 = ctx->argument(3).toNumber();
00179     self->setCoords(x1, y1, x2, y2);
00180     return QScriptValue();
00181 }
00182 
00183 static QScriptValue setHeight(QScriptContext *ctx, QScriptEngine *)
00184 {
00185     DECLARE_SELF(QRectF, setHeight);
00186     qreal height = ctx->argument(0).toNumber();
00187     self->setHeight(height);
00188     return QScriptValue();
00189 }
00190 
00191 static QScriptValue setLeft(QScriptContext *ctx, QScriptEngine *)
00192 {
00193     DECLARE_SELF(QRectF, setLeft);
00194     qreal left = ctx->argument(0).toNumber();
00195     self->setLeft(left);
00196     return QScriptValue();
00197 }
00198 
00199 static QScriptValue setRect(QScriptContext *ctx, QScriptEngine *)
00200 {
00201     DECLARE_SELF(QRectF, setRect);
00202     qreal x = ctx->argument(0).toNumber();
00203     qreal y = ctx->argument(1).toNumber();
00204     qreal width = ctx->argument(2).toNumber();
00205     qreal height = ctx->argument(3).toNumber();
00206     self->setRect(x, y, width, height);
00207     return QScriptValue();
00208 }
00209 
00210 static QScriptValue setRight(QScriptContext *ctx, QScriptEngine *)
00211 {
00212     DECLARE_SELF(QRectF, setRight);
00213     qreal right = ctx->argument(0).toNumber();
00214     self->setRight(right);
00215     return QScriptValue();
00216 }
00217 
00218 static QScriptValue setTop(QScriptContext *ctx, QScriptEngine *)
00219 {
00220     DECLARE_SELF(QRectF, setTop);
00221     qreal top = ctx->argument(0).toNumber();
00222     self->setTop(top);
00223     return QScriptValue();
00224 }
00225 
00226 static QScriptValue setWidth(QScriptContext *ctx, QScriptEngine *)
00227 {
00228     DECLARE_SELF(QRectF, setWidth);
00229     qreal width = ctx->argument(0).toNumber();
00230     self->setWidth(width);
00231     return QScriptValue();
00232 }
00233 
00234 static QScriptValue setX(QScriptContext *ctx, QScriptEngine *)
00235 {
00236     DECLARE_SELF(QRectF, setX);
00237     qreal x = ctx->argument(0).toNumber();
00238     self->setX(x);
00239     return QScriptValue();
00240 }
00241 
00242 static QScriptValue setY(QScriptContext *ctx, QScriptEngine *)
00243 {
00244     DECLARE_SELF(QRectF, setY);
00245     qreal y = ctx->argument(0).toNumber();
00246     self->setY(y);
00247     return QScriptValue();
00248 }
00249 
00250 static QScriptValue translate(QScriptContext *ctx, QScriptEngine *)
00251 {
00252     DECLARE_SELF(QRectF, translate);
00253     qreal dx = ctx->argument(0).toNumber();
00254     qreal dy = ctx->argument(1).toNumber();
00255     self->translate(dx, dy);
00256     return QScriptValue();
00257 }
00258 
00259 static QScriptValue width(QScriptContext *ctx, QScriptEngine *eng)
00260 {
00261     DECLARE_SELF(QRectF, width);
00262     return QScriptValue(eng, self->width());
00263 }
00264 
00265 static QScriptValue x(QScriptContext *ctx, QScriptEngine *eng)
00266 {
00267     DECLARE_SELF(QRectF, x);
00268     return QScriptValue(eng, self->x());
00269 }
00270 
00271 static QScriptValue y(QScriptContext *ctx, QScriptEngine *eng)
00272 {
00273     DECLARE_SELF(QRectF, y);
00274     return QScriptValue(eng, self->y());
00275 }
00276 
00277 /* Not Implemented Yet */
00278 // QPointF bottomLeft () const
00279 // QPointF bottomRight () const
00280 // QPointF center () const
00281 // bool contains ( const QPointF & point ) const
00282 // bool contains ( const QRectF & rectangle ) const
00283 // void getCoords ( qreal * x1, qreal * y1, qreal * x2, qreal * y2 ) const
00284 // void getRect ( qreal * x, qreal * y, qreal * width, qreal * height ) const
00285 // QRectF intersected ( const QRectF & rectangle ) const
00286 // bool intersects ( const QRectF & rectangle ) const
00287 // void moveBottomLeft ( const QPointF & position )
00288 // void moveBottomRight ( const QPointF & position )
00289 // void moveCenter ( const QPointF & position )
00290 // void moveTo ( const QPointF & position )
00291 // void moveTopLeft ( const QPointF & position )
00292 // void moveTopRight ( const QPointF & position )
00293 // QRectF normalized () const
00294 // void setBottomLeft ( const QPointF & position )
00295 // void setBottomRight ( const QPointF & position )
00296 // void setSize ( const QSizeF & size )
00297 // void setTopLeft ( const QPointF & position )
00298 // void setTopRight ( const QPointF & position )
00299 // QSizeF size () const
00300 // QRect toAlignedRect () const
00301 // QRect toRect () const
00302 // QPointF topLeft () const
00303 // QPointF topRight () const
00304 // void translate ( const QPointF & offset )
00305 // QRectF translated ( qreal dx, qreal dy ) const
00306 // QRectF translated ( const QPointF & offset ) const
00307 // QRectF united ( const QRectF & rectangle ) const
00308 
00309 QScriptValue constructQRectFClass(QScriptEngine *eng)
00310 {
00311     QScriptValue proto = qScriptValueFromValue(eng, QRectF());
00312     QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
00313     QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
00314 
00315     proto.setProperty("adjust", eng->newFunction(adjust));
00316     proto.setProperty("bottom", eng->newFunction(bottom));
00317     proto.setProperty("contains", eng->newFunction(contains));
00318     proto.setProperty("height", eng->newFunction(height));
00319     proto.setProperty("isEmpty", eng->newFunction(isEmpty));
00320     proto.setProperty("isNull", eng->newFunction(isNull));
00321     proto.setProperty("isValid", eng->newFunction(isValid));
00322     proto.setProperty("left", eng->newFunction(left));
00323     proto.setProperty("moveBottom", eng->newFunction(moveBottom));
00324     proto.setProperty("moveLeft", eng->newFunction(moveLeft));
00325     proto.setProperty("moveRight", eng->newFunction(moveRight));
00326     proto.setProperty("moveTo", eng->newFunction(moveTo));
00327     proto.setProperty("moveTop", eng->newFunction(moveTop));
00328     proto.setProperty("right", eng->newFunction(right));
00329     proto.setProperty("setBottom", eng->newFunction(setBottom));
00330     proto.setProperty("setCoords", eng->newFunction(setCoords));
00331     proto.setProperty("setHeight", eng->newFunction(setHeight));
00332     proto.setProperty("setLeft", eng->newFunction(setLeft));
00333     proto.setProperty("setRect", eng->newFunction(setRect));
00334     proto.setProperty("setRight", eng->newFunction(setRight));
00335     proto.setProperty("setTop", eng->newFunction(setTop));
00336     proto.setProperty("setWidth", eng->newFunction(setWidth));
00337     proto.setProperty("setX", eng->newFunction(setX));
00338     proto.setProperty("setY", eng->newFunction(setY));
00339     proto.setProperty("top", eng->newFunction(top));
00340     proto.setProperty("translate", eng->newFunction(translate));
00341     proto.setProperty("width", eng->newFunction(width));
00342     proto.setProperty("x", eng->newFunction(x));
00343     proto.setProperty("y", eng->newFunction(y));
00344 
00345     eng->setDefaultPrototype(qMetaTypeId<QRectF>(), proto);
00346     eng->setDefaultPrototype(qMetaTypeId<QRectF*>(), proto);
00347 
00348     return eng->newFunction(ctor, proto);
00349 }

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
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
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