From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- src/canvas/ntqcanvas.h | 816 +++++++++++++++++++++++++++++++++++++++++++++++ src/canvas/qcanvas.cpp | 44 +-- src/canvas/qcanvas.h | 816 ----------------------------------------------- src/canvas/qt_canvas.pri | 2 +- 4 files changed, 839 insertions(+), 839 deletions(-) create mode 100644 src/canvas/ntqcanvas.h delete mode 100644 src/canvas/qcanvas.h (limited to 'src/canvas') diff --git a/src/canvas/ntqcanvas.h b/src/canvas/ntqcanvas.h new file mode 100644 index 00000000..b104fd8a --- /dev/null +++ b/src/canvas/ntqcanvas.h @@ -0,0 +1,816 @@ +/********************************************************************** +** +** Definition of TQCanvas classes +** +** Created : 991211 +** +** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the canvas module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCANVAS_H +#define TQCANVAS_H + +#ifndef QT_H +#include "ntqscrollview.h" +#include "ntqpixmap.h" +#include "ntqptrlist.h" +#include "ntqbrush.h" +#include "ntqpen.h" +#include "ntqvaluelist.h" +#include "ntqpointarray.h" +#endif // QT_H + +#if !defined( QT_MODULE_CANVAS ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_CANVAS ) +#define TQM_EXPORT_CANVAS +#define TQM_TEMPLATE_EXTERN_CANVAS +#else +#define TQM_EXPORT_CANVAS Q_EXPORT +#define TQM_TEMPLATE_EXTERN_CANVAS Q_TEMPLATE_EXTERN +#endif + +#ifndef QT_NO_CANVAS + + +class TQCanvasSprite; +class TQCanvasPolygonalItem; +class TQCanvasRectangle; +class TQCanvasPolygon; +class TQCanvasEllipse; +class TQCanvasText; +class TQCanvasLine; +class TQCanvasChunk; +class TQCanvas; +class TQCanvasItem; +class TQCanvasView; +class TQCanvasPixmap; + +#if defined(Q_TEMPLATEDLL) && ( !defined(Q_CC_BOR) || !defined(QT_MAKEDLL) || defined(Q_EXPORT_TEMPLATES) ) +// MOC_SKIP_BEGIN +TQM_TEMPLATE_EXTERN_CANVAS template class TQM_EXPORT_CANVAS TQValueListIterator< TQCanvasItem* >; +TQM_TEMPLATE_EXTERN_CANVAS template class TQM_EXPORT_CANVAS TQValueList< TQCanvasItem* >; +// MOC_SKIP_END +#endif + +class TQM_EXPORT_CANVAS TQCanvasItemList : public TQValueList { +public: + void sort(); + void drawUnique( TQPainter& painter ); + TQCanvasItemList operator+(const TQCanvasItemList &l) const; +}; + + +class TQCanvasItemExtra; + +class TQM_EXPORT_CANVAS TQCanvasItem : public TQt +{ +public: + TQCanvasItem(TQCanvas* canvas); + virtual ~TQCanvasItem(); + + double x() const + { return myx; } + double y() const + { return myy; } + double z() const + { return myz; } // (depth) + + virtual void moveBy(double dx, double dy); + void move(double x, double y); + void setX(double a) { move(a,y()); } + void setY(double a) { move(x(),a); } + void setZ(double a) { myz=a; changeChunks(); } + + bool animated() const; + virtual void setAnimated(bool y); + virtual void setVelocity( double vx, double vy); + void setXVelocity( double vx ) { setVelocity(vx,yVelocity()); } + void setYVelocity( double vy ) { setVelocity(xVelocity(),vy); } + double xVelocity() const; + double yVelocity() const; + virtual void advance(int stage); + + virtual bool collidesWith( const TQCanvasItem* ) const=0; + + TQCanvasItemList collisions(bool exact /* NO DEFAULT */ ) const; + + virtual void setCanvas(TQCanvas*); + + virtual void draw(TQPainter&)=0; + + void show(); + void hide(); + + virtual void setVisible(bool yes); + bool isVisible() const + { return (bool)vis; } + virtual void setSelected(bool yes); + bool isSelected() const + { return (bool)sel; } + virtual void setEnabled(bool yes); + bool isEnabled() const + { return (bool)ena; } + virtual void setActive(bool yes); + bool isActive() const + { return (bool)act; } +#ifndef QT_NO_COMPAT + bool visible() const + { return (bool)vis; } + bool selected() const + { return (bool)sel; } + bool enabled() const + { return (bool)ena; } + bool active() const + { return (bool)act; } +#endif + + enum RttiValues { + Rtti_Item = 0, + Rtti_Sprite = 1, + Rtti_PolygonalItem = 2, + Rtti_Text = 3, + Rtti_Polygon = 4, + Rtti_Rectangle = 5, + Rtti_Ellipse = 6, + Rtti_Line = 7, + Rtti_Spline = 8 + }; + + virtual int rtti() const; + static int RTTI; + + virtual TQRect boundingRect() const=0; + virtual TQRect boundingRectAdvanced() const; + + TQCanvas* canvas() const + { return cnv; } + +protected: + void update() { changeChunks(); } + +private: + // For friendly subclasses... + + friend class TQCanvasPolygonalItem; + friend class TQCanvasSprite; + friend class TQCanvasRectangle; + friend class TQCanvasPolygon; + friend class TQCanvasEllipse; + friend class TQCanvasText; + friend class TQCanvasLine; + + virtual TQPointArray chunks() const; + virtual void addToChunks(); + virtual void removeFromChunks(); + virtual void changeChunks(); + virtual bool collidesWith( const TQCanvasSprite*, + const TQCanvasPolygonalItem*, + const TQCanvasRectangle*, + const TQCanvasEllipse*, + const TQCanvasText* ) const = 0; + // End of friend stuff + + TQCanvas* cnv; + static TQCanvas* current_canvas; + double myx,myy,myz; + TQCanvasItemExtra *ext; + TQCanvasItemExtra& extra(); + uint ani:1; + uint vis:1; + uint val:1; + uint sel:1; + uint ena:1; + uint act:1; +}; + + +class TQCanvasData; + +class TQM_EXPORT_CANVAS TQCanvas : public TQObject +{ + Q_OBJECT +public: + TQCanvas( TQObject* parent = 0, const char* name = 0 ); + TQCanvas(int w, int h); + TQCanvas( TQPixmap p, int h, int v, int tilewidth, int tileheight ); + + virtual ~TQCanvas(); + + virtual void setTiles( TQPixmap tiles, int h, int v, + int tilewidth, int tileheight ); + virtual void setBackgroundPixmap( const TQPixmap& p ); + TQPixmap backgroundPixmap() const; + + virtual void setBackgroundColor( const TQColor& c ); + TQColor backgroundColor() const; + + virtual void setTile( int x, int y, int tilenum ); + int tile( int x, int y ) const + { return grid[x+y*htiles]; } + + int tilesHorizontally() const + { return htiles; } + int tilesVertically() const + { return vtiles; } + + int tileWidth() const + { return tilew; } + int tileHeight() const + { return tileh; } + + virtual void resize(int width, int height); + int width() const + { return awidth; } + int height() const + { return aheight; } + TQSize size() const + { return TQSize(awidth,aheight); } + TQRect rect() const + { return TQRect( 0, 0, awidth, aheight ); } + bool onCanvas( int x, int y ) const + { return x>=0 && y>=0 && x=0 && y>=0 && x, TQPtrList hotspots); + + TQCanvasPixmapArray(TQValueList, TQPointArray hotspots = TQPointArray() ); + ~TQCanvasPixmapArray(); + +#ifndef QT_NO_IMAGEIO + bool readPixmaps(const TQString& datafilenamepattern, int framecount=0); + bool readCollisionMasks(const TQString& filenamepattern); +#endif + + // deprecated + bool operator!(); // Failure check. + bool isValid() const; + + TQCanvasPixmap* image(int i) const + { return img ? img[i] : 0; } + void setImage(int i, TQCanvasPixmap* p); + uint count() const + { return (uint)framecount; } + +private: +#if defined(Q_DISABLE_COPY) + TQCanvasPixmapArray( const TQCanvasPixmapArray & ); + TQCanvasPixmapArray &operator=( const TQCanvasPixmapArray & ); +#endif +#ifndef QT_NO_IMAGEIO + bool readPixmaps(const TQString& datafilenamepattern, int framecount, bool maskonly); +#endif + + void reset(); + int framecount; + TQCanvasPixmap** img; +}; + + +class TQM_EXPORT_CANVAS TQCanvasSprite : public TQCanvasItem +{ +public: + TQCanvasSprite(TQCanvasPixmapArray* array, TQCanvas* canvas); + + void setSequence(TQCanvasPixmapArray* seq); + + virtual ~TQCanvasSprite(); + + void move(double x, double y); + virtual void move(double x, double y, int frame); + void setFrame(int); + enum FrameAnimationType { Cycle, Oscillate }; + virtual void setFrameAnimation(FrameAnimationType=Cycle, int step=1, int state=0); + int frame() const + { return frm; } + int frameCount() const + { return images->count(); } + + int rtti() const; + static int RTTI; + + bool collidesWith( const TQCanvasItem* ) const; + + TQRect boundingRect() const; + + // is there a reason for these to be protected? Lars +//protected: + + int width() const; + int height() const; + + int leftEdge() const; + int topEdge() const; + int rightEdge() const; + int bottomEdge() const; + + int leftEdge(int nx) const; + int topEdge(int ny) const; + int rightEdge(int nx) const; + int bottomEdge(int ny) const; + TQCanvasPixmap* image() const + { return images->image(frm); } + virtual TQCanvasPixmap* imageAdvanced() const; + TQCanvasPixmap* image(int f) const + { return images->image(f); } + virtual void advance(int stage); + +public: + void draw(TQPainter& painter); + +private: +#if defined(Q_DISABLE_COPY) + TQCanvasSprite( const TQCanvasSprite & ); + TQCanvasSprite &operator=( const TQCanvasSprite & ); +#endif + void addToChunks(); + void removeFromChunks(); + void changeChunks(); + + int frm; + ushort anim_val; + uint anim_state:2; + uint anim_type:14; + bool collidesWith( const TQCanvasSprite*, + const TQCanvasPolygonalItem*, + const TQCanvasRectangle*, + const TQCanvasEllipse*, + const TQCanvasText* ) const; + + friend bool qt_testCollision( const TQCanvasSprite* s1, + const TQCanvasSprite* s2 ); + + TQCanvasPixmapArray* images; +}; + +class TQPolygonalProcessor; + +class TQM_EXPORT_CANVAS TQCanvasPolygonalItem : public TQCanvasItem +{ +public: + TQCanvasPolygonalItem(TQCanvas* canvas); + virtual ~TQCanvasPolygonalItem(); + + bool collidesWith( const TQCanvasItem* ) const; + + virtual void setPen(TQPen p); + virtual void setBrush(TQBrush b); + + TQPen pen() const + { return pn; } + TQBrush brush() const + { return br; } + + virtual TQPointArray areaPoints() const=0; + virtual TQPointArray areaPointsAdvanced() const; + TQRect boundingRect() const; + + int rtti() const; + static int RTTI; + +protected: + void draw(TQPainter &); + virtual void drawShape(TQPainter &) = 0; + + bool winding() const; + void setWinding(bool); + + void invalidate(); + bool isValid() const + { return (bool)val; } + +private: + void scanPolygon( const TQPointArray& pa, int winding, + TQPolygonalProcessor& process ) const; + TQPointArray chunks() const; + + bool collidesWith( const TQCanvasSprite*, + const TQCanvasPolygonalItem*, + const TQCanvasRectangle*, + const TQCanvasEllipse*, + const TQCanvasText* ) const; + + TQBrush br; + TQPen pn; + uint wind:1; +}; + + +class TQM_EXPORT_CANVAS TQCanvasRectangle : public TQCanvasPolygonalItem +{ +public: + TQCanvasRectangle(TQCanvas* canvas); + TQCanvasRectangle(const TQRect&, TQCanvas* canvas); + TQCanvasRectangle(int x, int y, int width, int height, TQCanvas* canvas); + + ~TQCanvasRectangle(); + + int width() const; + int height() const; + void setSize(int w, int h); + TQSize size() const + { return TQSize(w,h); } + TQPointArray areaPoints() const; + TQRect rect() const + { return TQRect(int(x()),int(y()),w,h); } + + bool collidesWith( const TQCanvasItem* ) const; + + int rtti() const; + static int RTTI; + +protected: + void drawShape(TQPainter &); + TQPointArray chunks() const; + +private: + bool collidesWith( const TQCanvasSprite*, + const TQCanvasPolygonalItem*, + const TQCanvasRectangle*, + const TQCanvasEllipse*, + const TQCanvasText* ) const; + + int w, h; +}; + + +class TQM_EXPORT_CANVAS TQCanvasPolygon : public TQCanvasPolygonalItem +{ +public: + TQCanvasPolygon(TQCanvas* canvas); + ~TQCanvasPolygon(); + void setPoints(TQPointArray); + TQPointArray points() const; + void moveBy(double dx, double dy); + + TQPointArray areaPoints() const; + + int rtti() const; + static int RTTI; + +protected: + void drawShape(TQPainter &); + TQPointArray poly; +}; + + +class TQM_EXPORT_CANVAS TQCanvasSpline : public TQCanvasPolygon +{ +public: + TQCanvasSpline(TQCanvas* canvas); + ~TQCanvasSpline(); + + void setControlPoints(TQPointArray, bool closed=TRUE); + TQPointArray controlPoints() const; + bool closed() const; + + int rtti() const; + static int RTTI; + +private: + void recalcPoly(); + TQPointArray bez; + bool cl; +}; + + +class TQM_EXPORT_CANVAS TQCanvasLine : public TQCanvasPolygonalItem +{ +public: + TQCanvasLine(TQCanvas* canvas); + ~TQCanvasLine(); + void setPoints(int x1, int y1, int x2, int y2); + + TQPoint startPoint() const + { return TQPoint(x1,y1); } + TQPoint endPoint() const + { return TQPoint(x2,y2); } + + int rtti() const; + static int RTTI; + + void setPen(TQPen p); + void moveBy(double dx, double dy); + +protected: + void drawShape(TQPainter &); + TQPointArray areaPoints() const; + +private: + int x1,y1,x2,y2; +}; + + +class TQM_EXPORT_CANVAS TQCanvasEllipse : public TQCanvasPolygonalItem +{ + +public: + TQCanvasEllipse( TQCanvas* canvas ); + TQCanvasEllipse( int width, int height, TQCanvas* canvas ); + TQCanvasEllipse( int width, int height, int startangle, int angle, + TQCanvas* canvas ); + + ~TQCanvasEllipse(); + + int width() const; + int height() const; + void setSize(int w, int h); + void setAngles(int start, int length); + int angleStart() const + { return a1; } + int angleLength() const + { return a2; } + TQPointArray areaPoints() const; + + bool collidesWith( const TQCanvasItem* ) const; + + int rtti() const; + static int RTTI; + +protected: + void drawShape(TQPainter &); + +private: + bool collidesWith( const TQCanvasSprite*, + const TQCanvasPolygonalItem*, + const TQCanvasRectangle*, + const TQCanvasEllipse*, + const TQCanvasText* ) const; + int w, h; + int a1, a2; +}; + + +class TQCanvasTextExtra; + +class TQM_EXPORT_CANVAS TQCanvasText : public TQCanvasItem +{ +public: + TQCanvasText(TQCanvas* canvas); + TQCanvasText(const TQString&, TQCanvas* canvas); + TQCanvasText(const TQString&, TQFont, TQCanvas* canvas); + + virtual ~TQCanvasText(); + + void setText( const TQString& ); + void setFont( const TQFont& ); + void setColor( const TQColor& ); + TQString text() const; + TQFont font() const; + TQColor color() const; + + void moveBy(double dx, double dy); + + int textFlags() const + { return flags; } + void setTextFlags(int); + + TQRect boundingRect() const; + + bool collidesWith( const TQCanvasItem* ) const; + + int rtti() const; + static int RTTI; + +protected: + virtual void draw(TQPainter&); + +private: +#if defined(Q_DISABLE_COPY) + TQCanvasText( const TQCanvasText & ); + TQCanvasText &operator=( const TQCanvasText & ); +#endif + void addToChunks(); + void removeFromChunks(); + void changeChunks(); + + void setRect(); + TQRect brect; + TQString txt; + int flags; + TQFont fnt; + TQColor col; + TQCanvasTextExtra* extra; + + bool collidesWith( const TQCanvasSprite*, + const TQCanvasPolygonalItem*, + const TQCanvasRectangle*, + const TQCanvasEllipse*, + const TQCanvasText* ) const; +}; + +#define Q_DEFINED_QCANVAS +#include "ntqwinexport.h" +#endif // QT_NO_CANVAS + +#endif // TQCANVAS_H diff --git a/src/canvas/qcanvas.cpp b/src/canvas/qcanvas.cpp index 167e0209..7b337fb4 100644 --- a/src/canvas/qcanvas.cpp +++ b/src/canvas/qcanvas.cpp @@ -38,16 +38,16 @@ ** **********************************************************************/ -#include "qcanvas.h" +#include "ntqcanvas.h" #ifndef QT_NO_CANVAS -#include "qapplication.h" -#include "qbitmap.h" -#include "qimage.h" -#include "qptrdict.h" -#include "qpainter.h" -#include "qpolygonscanner.h" -#include "qtimer.h" -#include "qtl.h" +#include "ntqapplication.h" +#include "ntqbitmap.h" +#include "ntqimage.h" +#include "ntqptrdict.h" +#include "ntqpainter.h" +#include "ntqpolygonscanner.h" +#include "ntqtimer.h" +#include "ntqtl.h" #include @@ -436,7 +436,7 @@ static int scm(int a, int b) /*! - \class TQCanvas qcanvas.h + \class TQCanvas ntqcanvas.h \brief The TQCanvas class provides a 2D area that can contain TQCanvasItem objects. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -1844,7 +1844,7 @@ class TQCanvasItemExtra { /*! - \class TQCanvasItem qcanvas.h + \class TQCanvasItem ntqcanvas.h \brief The TQCanvasItem class provides an abstract graphic object on a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -2484,7 +2484,7 @@ static bool collision_double_dispatch( const TQCanvasSprite* s1, /*! - \class TQCanvasSprite qcanvas.h + \class TQCanvasSprite ntqcanvas.h \brief The TQCanvasSprite class provides an animated canvas item on a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -2801,7 +2801,7 @@ TQRect TQCanvasItem::boundingRectAdvanced() const } /*! - \class TQCanvasPixmap qcanvas.h + \class TQCanvasPixmap ntqcanvas.h \brief The TQCanvasPixmap class provides pixmaps for TQCanvasSprites. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -2931,7 +2931,7 @@ TQCanvasPixmap::~TQCanvasPixmap() */ /*! - \class TQCanvasPixmapArray qcanvas.h + \class TQCanvasPixmapArray ntqcanvas.h \brief The TQCanvasPixmapArray class provides an array of TQCanvasPixmaps. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -3457,7 +3457,7 @@ void TQCanvasSprite::draw(TQPainter& painter) } /*! - \class TQCanvasView qcanvas.h + \class TQCanvasView ntqcanvas.h \brief The TQCanvasView class provides an on-screen view of a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -3726,7 +3726,7 @@ TQSize TQCanvasView::sizeHint() const // ### TQt 4.0 customer request: operate on doubles rather than int. // ### I know, almost impossible due to the use of TQRegion etc. /*! - \class TQCanvasPolygonalItem qcanvas.h + \class TQCanvasPolygonalItem ntqcanvas.h \brief The TQCanvasPolygonalItem class provides a polygonal canvas item on a TQCanvas. \if defined(commercial) @@ -4135,7 +4135,7 @@ void TQCanvasPolygonalItem::setBrush(TQBrush b) /*! - \class TQCanvasPolygon qcanvas.h + \class TQCanvasPolygon ntqcanvas.h \brief The TQCanvasPolygon class provides a polygon on a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -4228,7 +4228,7 @@ void TQCanvasPolygon::moveBy(double dx, double dy) } /*! - \class TQCanvasSpline qcanvas.h + \class TQCanvasSpline ntqcanvas.h \brief The TQCanvasSpline class provides multi-bezier splines on a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -4390,7 +4390,7 @@ TQPointArray TQCanvasPolygon::areaPoints() const // points -- that way for some uses just the constructor call would be // required? /*! - \class TQCanvasLine qcanvas.h + \class TQCanvasLine ntqcanvas.h \brief The TQCanvasLine class provides a line on a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -4534,7 +4534,7 @@ void TQCanvasLine::moveBy(double dx, double dy) } /*! - \class TQCanvasRectangle qcanvas.h + \class TQCanvasRectangle ntqcanvas.h \brief The TQCanvasRectangle class provides a rectangle on a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -4672,7 +4672,7 @@ void TQCanvasRectangle::drawShape(TQPainter & p) /*! - \class TQCanvasEllipse qcanvas.h + \class TQCanvasEllipse ntqcanvas.h \brief The TQCanvasEllipse class provides an ellipse or ellipse segment on a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. @@ -4859,7 +4859,7 @@ void TQCanvasEllipse::drawShape(TQPainter & p) /*! - \class TQCanvasText qcanvas.h + \class TQCanvasText ntqcanvas.h \brief The TQCanvasText class provides a text object on a TQCanvas. \if defined(commercial) It is part of the TQt Enterprise Edition. diff --git a/src/canvas/qcanvas.h b/src/canvas/qcanvas.h deleted file mode 100644 index 37c30816..00000000 --- a/src/canvas/qcanvas.h +++ /dev/null @@ -1,816 +0,0 @@ -/********************************************************************** -** -** Definition of TQCanvas classes -** -** Created : 991211 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the canvas module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQCANVAS_H -#define TQCANVAS_H - -#ifndef QT_H -#include "qscrollview.h" -#include "qpixmap.h" -#include "qptrlist.h" -#include "qbrush.h" -#include "qpen.h" -#include "qvaluelist.h" -#include "qpointarray.h" -#endif // QT_H - -#if !defined( QT_MODULE_CANVAS ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_CANVAS ) -#define TQM_EXPORT_CANVAS -#define TQM_TEMPLATE_EXTERN_CANVAS -#else -#define TQM_EXPORT_CANVAS Q_EXPORT -#define TQM_TEMPLATE_EXTERN_CANVAS Q_TEMPLATE_EXTERN -#endif - -#ifndef QT_NO_CANVAS - - -class TQCanvasSprite; -class TQCanvasPolygonalItem; -class TQCanvasRectangle; -class TQCanvasPolygon; -class TQCanvasEllipse; -class TQCanvasText; -class TQCanvasLine; -class TQCanvasChunk; -class TQCanvas; -class TQCanvasItem; -class TQCanvasView; -class TQCanvasPixmap; - -#if defined(Q_TEMPLATEDLL) && ( !defined(Q_CC_BOR) || !defined(QT_MAKEDLL) || defined(Q_EXPORT_TEMPLATES) ) -// MOC_SKIP_BEGIN -TQM_TEMPLATE_EXTERN_CANVAS template class TQM_EXPORT_CANVAS TQValueListIterator< TQCanvasItem* >; -TQM_TEMPLATE_EXTERN_CANVAS template class TQM_EXPORT_CANVAS TQValueList< TQCanvasItem* >; -// MOC_SKIP_END -#endif - -class TQM_EXPORT_CANVAS TQCanvasItemList : public TQValueList { -public: - void sort(); - void drawUnique( TQPainter& painter ); - TQCanvasItemList operator+(const TQCanvasItemList &l) const; -}; - - -class TQCanvasItemExtra; - -class TQM_EXPORT_CANVAS TQCanvasItem : public TQt -{ -public: - TQCanvasItem(TQCanvas* canvas); - virtual ~TQCanvasItem(); - - double x() const - { return myx; } - double y() const - { return myy; } - double z() const - { return myz; } // (depth) - - virtual void moveBy(double dx, double dy); - void move(double x, double y); - void setX(double a) { move(a,y()); } - void setY(double a) { move(x(),a); } - void setZ(double a) { myz=a; changeChunks(); } - - bool animated() const; - virtual void setAnimated(bool y); - virtual void setVelocity( double vx, double vy); - void setXVelocity( double vx ) { setVelocity(vx,yVelocity()); } - void setYVelocity( double vy ) { setVelocity(xVelocity(),vy); } - double xVelocity() const; - double yVelocity() const; - virtual void advance(int stage); - - virtual bool collidesWith( const TQCanvasItem* ) const=0; - - TQCanvasItemList collisions(bool exact /* NO DEFAULT */ ) const; - - virtual void setCanvas(TQCanvas*); - - virtual void draw(TQPainter&)=0; - - void show(); - void hide(); - - virtual void setVisible(bool yes); - bool isVisible() const - { return (bool)vis; } - virtual void setSelected(bool yes); - bool isSelected() const - { return (bool)sel; } - virtual void setEnabled(bool yes); - bool isEnabled() const - { return (bool)ena; } - virtual void setActive(bool yes); - bool isActive() const - { return (bool)act; } -#ifndef QT_NO_COMPAT - bool visible() const - { return (bool)vis; } - bool selected() const - { return (bool)sel; } - bool enabled() const - { return (bool)ena; } - bool active() const - { return (bool)act; } -#endif - - enum RttiValues { - Rtti_Item = 0, - Rtti_Sprite = 1, - Rtti_PolygonalItem = 2, - Rtti_Text = 3, - Rtti_Polygon = 4, - Rtti_Rectangle = 5, - Rtti_Ellipse = 6, - Rtti_Line = 7, - Rtti_Spline = 8 - }; - - virtual int rtti() const; - static int RTTI; - - virtual TQRect boundingRect() const=0; - virtual TQRect boundingRectAdvanced() const; - - TQCanvas* canvas() const - { return cnv; } - -protected: - void update() { changeChunks(); } - -private: - // For friendly subclasses... - - friend class TQCanvasPolygonalItem; - friend class TQCanvasSprite; - friend class TQCanvasRectangle; - friend class TQCanvasPolygon; - friend class TQCanvasEllipse; - friend class TQCanvasText; - friend class TQCanvasLine; - - virtual TQPointArray chunks() const; - virtual void addToChunks(); - virtual void removeFromChunks(); - virtual void changeChunks(); - virtual bool collidesWith( const TQCanvasSprite*, - const TQCanvasPolygonalItem*, - const TQCanvasRectangle*, - const TQCanvasEllipse*, - const TQCanvasText* ) const = 0; - // End of friend stuff - - TQCanvas* cnv; - static TQCanvas* current_canvas; - double myx,myy,myz; - TQCanvasItemExtra *ext; - TQCanvasItemExtra& extra(); - uint ani:1; - uint vis:1; - uint val:1; - uint sel:1; - uint ena:1; - uint act:1; -}; - - -class TQCanvasData; - -class TQM_EXPORT_CANVAS TQCanvas : public TQObject -{ - Q_OBJECT -public: - TQCanvas( TQObject* parent = 0, const char* name = 0 ); - TQCanvas(int w, int h); - TQCanvas( TQPixmap p, int h, int v, int tilewidth, int tileheight ); - - virtual ~TQCanvas(); - - virtual void setTiles( TQPixmap tiles, int h, int v, - int tilewidth, int tileheight ); - virtual void setBackgroundPixmap( const TQPixmap& p ); - TQPixmap backgroundPixmap() const; - - virtual void setBackgroundColor( const TQColor& c ); - TQColor backgroundColor() const; - - virtual void setTile( int x, int y, int tilenum ); - int tile( int x, int y ) const - { return grid[x+y*htiles]; } - - int tilesHorizontally() const - { return htiles; } - int tilesVertically() const - { return vtiles; } - - int tileWidth() const - { return tilew; } - int tileHeight() const - { return tileh; } - - virtual void resize(int width, int height); - int width() const - { return awidth; } - int height() const - { return aheight; } - TQSize size() const - { return TQSize(awidth,aheight); } - TQRect rect() const - { return TQRect( 0, 0, awidth, aheight ); } - bool onCanvas( int x, int y ) const - { return x>=0 && y>=0 && x=0 && y>=0 && x, TQPtrList hotspots); - - TQCanvasPixmapArray(TQValueList, TQPointArray hotspots = TQPointArray() ); - ~TQCanvasPixmapArray(); - -#ifndef QT_NO_IMAGEIO - bool readPixmaps(const TQString& datafilenamepattern, int framecount=0); - bool readCollisionMasks(const TQString& filenamepattern); -#endif - - // deprecated - bool operator!(); // Failure check. - bool isValid() const; - - TQCanvasPixmap* image(int i) const - { return img ? img[i] : 0; } - void setImage(int i, TQCanvasPixmap* p); - uint count() const - { return (uint)framecount; } - -private: -#if defined(Q_DISABLE_COPY) - TQCanvasPixmapArray( const TQCanvasPixmapArray & ); - TQCanvasPixmapArray &operator=( const TQCanvasPixmapArray & ); -#endif -#ifndef QT_NO_IMAGEIO - bool readPixmaps(const TQString& datafilenamepattern, int framecount, bool maskonly); -#endif - - void reset(); - int framecount; - TQCanvasPixmap** img; -}; - - -class TQM_EXPORT_CANVAS TQCanvasSprite : public TQCanvasItem -{ -public: - TQCanvasSprite(TQCanvasPixmapArray* array, TQCanvas* canvas); - - void setSequence(TQCanvasPixmapArray* seq); - - virtual ~TQCanvasSprite(); - - void move(double x, double y); - virtual void move(double x, double y, int frame); - void setFrame(int); - enum FrameAnimationType { Cycle, Oscillate }; - virtual void setFrameAnimation(FrameAnimationType=Cycle, int step=1, int state=0); - int frame() const - { return frm; } - int frameCount() const - { return images->count(); } - - int rtti() const; - static int RTTI; - - bool collidesWith( const TQCanvasItem* ) const; - - TQRect boundingRect() const; - - // is there a reason for these to be protected? Lars -//protected: - - int width() const; - int height() const; - - int leftEdge() const; - int topEdge() const; - int rightEdge() const; - int bottomEdge() const; - - int leftEdge(int nx) const; - int topEdge(int ny) const; - int rightEdge(int nx) const; - int bottomEdge(int ny) const; - TQCanvasPixmap* image() const - { return images->image(frm); } - virtual TQCanvasPixmap* imageAdvanced() const; - TQCanvasPixmap* image(int f) const - { return images->image(f); } - virtual void advance(int stage); - -public: - void draw(TQPainter& painter); - -private: -#if defined(Q_DISABLE_COPY) - TQCanvasSprite( const TQCanvasSprite & ); - TQCanvasSprite &operator=( const TQCanvasSprite & ); -#endif - void addToChunks(); - void removeFromChunks(); - void changeChunks(); - - int frm; - ushort anim_val; - uint anim_state:2; - uint anim_type:14; - bool collidesWith( const TQCanvasSprite*, - const TQCanvasPolygonalItem*, - const TQCanvasRectangle*, - const TQCanvasEllipse*, - const TQCanvasText* ) const; - - friend bool qt_testCollision( const TQCanvasSprite* s1, - const TQCanvasSprite* s2 ); - - TQCanvasPixmapArray* images; -}; - -class TQPolygonalProcessor; - -class TQM_EXPORT_CANVAS TQCanvasPolygonalItem : public TQCanvasItem -{ -public: - TQCanvasPolygonalItem(TQCanvas* canvas); - virtual ~TQCanvasPolygonalItem(); - - bool collidesWith( const TQCanvasItem* ) const; - - virtual void setPen(TQPen p); - virtual void setBrush(TQBrush b); - - TQPen pen() const - { return pn; } - TQBrush brush() const - { return br; } - - virtual TQPointArray areaPoints() const=0; - virtual TQPointArray areaPointsAdvanced() const; - TQRect boundingRect() const; - - int rtti() const; - static int RTTI; - -protected: - void draw(TQPainter &); - virtual void drawShape(TQPainter &) = 0; - - bool winding() const; - void setWinding(bool); - - void invalidate(); - bool isValid() const - { return (bool)val; } - -private: - void scanPolygon( const TQPointArray& pa, int winding, - TQPolygonalProcessor& process ) const; - TQPointArray chunks() const; - - bool collidesWith( const TQCanvasSprite*, - const TQCanvasPolygonalItem*, - const TQCanvasRectangle*, - const TQCanvasEllipse*, - const TQCanvasText* ) const; - - TQBrush br; - TQPen pn; - uint wind:1; -}; - - -class TQM_EXPORT_CANVAS TQCanvasRectangle : public TQCanvasPolygonalItem -{ -public: - TQCanvasRectangle(TQCanvas* canvas); - TQCanvasRectangle(const TQRect&, TQCanvas* canvas); - TQCanvasRectangle(int x, int y, int width, int height, TQCanvas* canvas); - - ~TQCanvasRectangle(); - - int width() const; - int height() const; - void setSize(int w, int h); - TQSize size() const - { return TQSize(w,h); } - TQPointArray areaPoints() const; - TQRect rect() const - { return TQRect(int(x()),int(y()),w,h); } - - bool collidesWith( const TQCanvasItem* ) const; - - int rtti() const; - static int RTTI; - -protected: - void drawShape(TQPainter &); - TQPointArray chunks() const; - -private: - bool collidesWith( const TQCanvasSprite*, - const TQCanvasPolygonalItem*, - const TQCanvasRectangle*, - const TQCanvasEllipse*, - const TQCanvasText* ) const; - - int w, h; -}; - - -class TQM_EXPORT_CANVAS TQCanvasPolygon : public TQCanvasPolygonalItem -{ -public: - TQCanvasPolygon(TQCanvas* canvas); - ~TQCanvasPolygon(); - void setPoints(TQPointArray); - TQPointArray points() const; - void moveBy(double dx, double dy); - - TQPointArray areaPoints() const; - - int rtti() const; - static int RTTI; - -protected: - void drawShape(TQPainter &); - TQPointArray poly; -}; - - -class TQM_EXPORT_CANVAS TQCanvasSpline : public TQCanvasPolygon -{ -public: - TQCanvasSpline(TQCanvas* canvas); - ~TQCanvasSpline(); - - void setControlPoints(TQPointArray, bool closed=TRUE); - TQPointArray controlPoints() const; - bool closed() const; - - int rtti() const; - static int RTTI; - -private: - void recalcPoly(); - TQPointArray bez; - bool cl; -}; - - -class TQM_EXPORT_CANVAS TQCanvasLine : public TQCanvasPolygonalItem -{ -public: - TQCanvasLine(TQCanvas* canvas); - ~TQCanvasLine(); - void setPoints(int x1, int y1, int x2, int y2); - - TQPoint startPoint() const - { return TQPoint(x1,y1); } - TQPoint endPoint() const - { return TQPoint(x2,y2); } - - int rtti() const; - static int RTTI; - - void setPen(TQPen p); - void moveBy(double dx, double dy); - -protected: - void drawShape(TQPainter &); - TQPointArray areaPoints() const; - -private: - int x1,y1,x2,y2; -}; - - -class TQM_EXPORT_CANVAS TQCanvasEllipse : public TQCanvasPolygonalItem -{ - -public: - TQCanvasEllipse( TQCanvas* canvas ); - TQCanvasEllipse( int width, int height, TQCanvas* canvas ); - TQCanvasEllipse( int width, int height, int startangle, int angle, - TQCanvas* canvas ); - - ~TQCanvasEllipse(); - - int width() const; - int height() const; - void setSize(int w, int h); - void setAngles(int start, int length); - int angleStart() const - { return a1; } - int angleLength() const - { return a2; } - TQPointArray areaPoints() const; - - bool collidesWith( const TQCanvasItem* ) const; - - int rtti() const; - static int RTTI; - -protected: - void drawShape(TQPainter &); - -private: - bool collidesWith( const TQCanvasSprite*, - const TQCanvasPolygonalItem*, - const TQCanvasRectangle*, - const TQCanvasEllipse*, - const TQCanvasText* ) const; - int w, h; - int a1, a2; -}; - - -class TQCanvasTextExtra; - -class TQM_EXPORT_CANVAS TQCanvasText : public TQCanvasItem -{ -public: - TQCanvasText(TQCanvas* canvas); - TQCanvasText(const TQString&, TQCanvas* canvas); - TQCanvasText(const TQString&, TQFont, TQCanvas* canvas); - - virtual ~TQCanvasText(); - - void setText( const TQString& ); - void setFont( const TQFont& ); - void setColor( const TQColor& ); - TQString text() const; - TQFont font() const; - TQColor color() const; - - void moveBy(double dx, double dy); - - int textFlags() const - { return flags; } - void setTextFlags(int); - - TQRect boundingRect() const; - - bool collidesWith( const TQCanvasItem* ) const; - - int rtti() const; - static int RTTI; - -protected: - virtual void draw(TQPainter&); - -private: -#if defined(Q_DISABLE_COPY) - TQCanvasText( const TQCanvasText & ); - TQCanvasText &operator=( const TQCanvasText & ); -#endif - void addToChunks(); - void removeFromChunks(); - void changeChunks(); - - void setRect(); - TQRect brect; - TQString txt; - int flags; - TQFont fnt; - TQColor col; - TQCanvasTextExtra* extra; - - bool collidesWith( const TQCanvasSprite*, - const TQCanvasPolygonalItem*, - const TQCanvasRectangle*, - const TQCanvasEllipse*, - const TQCanvasText* ) const; -}; - -#define Q_DEFINED_QCANVAS -#include "qwinexport.h" -#endif // QT_NO_CANVAS - -#endif // TQCANVAS_H diff --git a/src/canvas/qt_canvas.pri b/src/canvas/qt_canvas.pri index 779a5215..ad3ee30b 100644 --- a/src/canvas/qt_canvas.pri +++ b/src/canvas/qt_canvas.pri @@ -1,6 +1,6 @@ # Qt canvas module canvas { - HEADERS += $$CANVAS_H/qcanvas.h + HEADERS += $$CANVAS_H/ntqcanvas.h SOURCES += $$CANVAS_CPP/qcanvas.cpp } -- cgit v1.2.1