browsercore/core/scriptobjects.h
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
equal deleted inserted replaced
-1:000000000000 0:1450b09d0cfd
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SCRIPTOBJECTS_H
       
    20 #define SCRIPTOBJECTS_H
       
    21 
       
    22 #include <QObject>
       
    23 #include <QRect>
       
    24 
       
    25 #include "BWFGlobal.h"
       
    26 
       
    27 // -------------------------------------------------------
       
    28 
       
    29 /*!
       
    30   Wrapper for QRect that can be passed to javascript.
       
    31 */
       
    32 class BWF_EXPORT ScriptRect : public QObject, public QRect {
       
    33     Q_OBJECT
       
    34   public:
       
    35     ScriptRect(const QRect &rect) : QRect(rect) { setObjectName("scriptrect"); }
       
    36 
       
    37     int getx() const { return x(); }
       
    38     Q_PROPERTY(int x READ getx)
       
    39     int gety() const { return y(); }
       
    40     Q_PROPERTY(int y READ gety)
       
    41     int getwidth() const { return width(); }
       
    42     Q_PROPERTY(int width READ getwidth)
       
    43     int getheight() const { return height(); }
       
    44     Q_PROPERTY(int height READ getheight)
       
    45 };
       
    46 
       
    47 // -------------------------------------------------------
       
    48 
       
    49 /*!
       
    50   Wrapper for QRectF that can be passed to javascript.
       
    51 */
       
    52 class BWF_EXPORT ScriptRectF : public QObject, public QRectF {
       
    53     Q_OBJECT
       
    54   public:
       
    55     ScriptRectF(const QRectF &rect) : QRectF(rect) { setObjectName("scriptrectf"); }
       
    56 
       
    57     qreal getx() const { return x(); }
       
    58     Q_PROPERTY(qreal x READ getx)
       
    59     qreal gety() const { return y(); }
       
    60     Q_PROPERTY(qreal y READ gety)
       
    61     qreal getwidth() const { return width(); }
       
    62     Q_PROPERTY(qreal width READ getwidth)
       
    63     qreal getheight() const { return height(); }
       
    64     Q_PROPERTY(qreal height READ getheight)
       
    65 };
       
    66 
       
    67 // -------------------------------------------------------
       
    68 
       
    69 /*!
       
    70   Wrapper for QPoint that can be passed to javascript.
       
    71 */
       
    72 class BWF_EXPORT ScriptPoint : public QObject, public QPoint {
       
    73     Q_OBJECT
       
    74   public:
       
    75     ScriptPoint() { setObjectName("scriptpoint"); }
       
    76     ScriptPoint(QObject *parent, const QPoint &p, const QString &objName = QString::null) 
       
    77       : QObject(parent), QPoint(p) 
       
    78       { setObjectName(objName.isNull() ? "scriptpoint" : objName); }
       
    79     ScriptPoint(const QPoint &p) : QPoint(p) { setObjectName("scriptpoint"); }
       
    80 
       
    81     int getx() const { return x(); }
       
    82     Q_PROPERTY(int x READ getx)
       
    83     int gety() const { return y(); }
       
    84     Q_PROPERTY(int y READ gety)
       
    85 };
       
    86 
       
    87 // -------------------------------------------------------
       
    88 
       
    89 /*!
       
    90   Wrapper for QPointF that can be passed to javascript.
       
    91 */
       
    92 class BWF_EXPORT ScriptPointF : public QObject, public QPointF {
       
    93     Q_OBJECT
       
    94   public:
       
    95     ScriptPointF(const QPointF &p) : QPointF(p) { setObjectName("scriptrect"); }
       
    96 
       
    97     qreal getx() const { return x(); }
       
    98     Q_PROPERTY(qreal x READ getx)
       
    99     qreal gety() const { return y(); }
       
   100     Q_PROPERTY(qreal y READ gety)
       
   101 };
       
   102 
       
   103 // -------------------------------------------------------
       
   104 
       
   105 /*!
       
   106   Wrapper for QSize that can be passed to javascript.
       
   107 */
       
   108 class BWF_EXPORT ScriptSize : public QObject, public QSize {
       
   109     Q_OBJECT
       
   110   public:
       
   111     ScriptSize(const QSize &size) : QSize(size) { setObjectName("scriptsize"); }
       
   112 
       
   113     int getwidth() const { return width(); }
       
   114     Q_PROPERTY(int width READ getwidth)
       
   115     int getheight() const { return height(); }
       
   116     Q_PROPERTY(int height READ getheight)
       
   117 };
       
   118 
       
   119 #endif // SCRIPTOBJECTS_H