File indexing completed on 2024-10-13 09:32:36

0001 /*
0002  *  This file is part of the KDE libraries
0003  *  Copyright (C) 2013 Bernd Buschinski <b.buschinski@googlemail.com>
0004  *
0005  *  This library is free software; you can redistribute it and/or
0006  *  modify it under the terms of the GNU Lesser General Public
0007  *  License as published by the Free Software Foundation; either
0008  *  version 2 of the License, or (at your option) any later version.
0009  *
0010  *  This library is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  *  Lesser General Public License for more details.
0014  *
0015  *  You should have received a copy of the GNU Lesser General Public
0016  *  License along with this library; if not, write to the Free Software
0017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018  */
0019 
0020 #ifndef KJS_CLIENTRECT_H
0021 #define KJS_CLIENTRECT_H
0022 
0023 #include "ecma/kjs_dom.h"
0024 
0025 #include <kjs/object.h>
0026 
0027 #include <QRect>
0028 #include <QList>
0029 
0030 namespace KJS
0031 {
0032 
0033 class ClientRect : public JSObject
0034 {
0035 public:
0036     ClientRect(ExecState *exec, float left, float top, float width, float height);
0037     ClientRect(ExecState *exec, const QRectF &rect);
0038     enum {
0039         Top, Right, Bottom, Left, Width, Height
0040     };
0041     JSValue *getValueProperty(ExecState *exec, int token) const;
0042 
0043     using KJS::JSObject::getOwnPropertySlot;
0044     bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
0045 
0046     float top() const;
0047     float left() const;
0048     float width() const;
0049     float height() const;
0050     float right() const;
0051     float bottom() const;
0052 
0053     void setTop(float top);
0054     void setLeft(float left);
0055     void setWidth(float width);
0056     void setHeight(float height);
0057 
0058 private:
0059     const ClassInfo *classInfo() const override
0060     {
0061         return &info;
0062     }
0063     static const ClassInfo info;
0064 
0065     QRectF m_rect;
0066 };
0067 
0068 class ClientRectList : public JSObject
0069 {
0070 public:
0071     ClientRectList(ExecState *exec);
0072     ClientRectList(ExecState *exec, const QList<QRectF> &list);
0073     enum {
0074         Length
0075     };
0076 
0077     JSValue *getValueProperty(ExecState *exec, int token) const;
0078     bool getOwnPropertySlot(ExecState *exec, unsigned int index, PropertySlot &slot) override;
0079     bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
0080 
0081     unsigned length() const;
0082     ClientRect *item(unsigned index);
0083     void append(ClientRect *item);
0084 
0085 private:
0086     const ClassInfo *classInfo() const override
0087     {
0088         return &info;
0089     }
0090     static const ClassInfo info;
0091 
0092     WTF::Vector< ProtectedPtr<ClientRect> > m_list;
0093 };
0094 
0095 }
0096 
0097 #endif //KJS_CLIENTRECT_H