You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
807 lines
20 KiB
807 lines
20 KiB
/**********************************************************************
|
|
**
|
|
**
|
|
** Definition of TTQCanvas classes
|
|
**
|
|
** Created : 991211
|
|
**
|
|
** Copyright (C) 1999-2002 Trolltech AS. All rights reserved.
|
|
**
|
|
** This file is part of the canvas module of the Qt GUI Toolkit.
|
|
**
|
|
** This file may be distributed under the terms of the Q Public License
|
|
** as defined by Trolltech AS of Norway and appearing in the file
|
|
** LICENSE.TQPL included in the packaging of this file.
|
|
**
|
|
** This file may be distributed and/or modified under the terms of the
|
|
** GNU General Public License version 2 as published by the Free Software
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
** packaging of this file.
|
|
**
|
|
** Licensees holding valid Qt Enterprise Edition licenses may use this
|
|
** file in accordance with the Qt Commercial License Agreement provided
|
|
** with the Software.
|
|
**
|
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
**
|
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|
** information about Qt Commercial License Agreements.
|
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|
**
|
|
** Contact info@trolltech.com if any conditions of this licensing are
|
|
** not clear to you.
|
|
**
|
|
**********************************************************************/
|
|
|
|
#ifndef TQCANVAS_H
|
|
#define TQCANVAS_H
|
|
|
|
#ifndef QT_H
|
|
#include "tqscrollview.h"
|
|
#include "tqpixmap.h"
|
|
#include "tqptrlist.h"
|
|
#include "tqbrush.h"
|
|
#include "tqpen.h"
|
|
#include "tqvaluelist.h"
|
|
#include "tqpointarray.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 TTQCanvasSprite;
|
|
class TTQCanvasPolygonalItem;
|
|
class TTQCanvasRectangle;
|
|
class TTQCanvasPolygon;
|
|
class TTQCanvasEllipse;
|
|
class TTQCanvasText;
|
|
class TTQCanvasLine;
|
|
class TTQCanvasChunk;
|
|
class TTQCanvas;
|
|
class TTQCanvasItem;
|
|
class TTQCanvasView;
|
|
class TTQCanvasPixmap;
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasItemList : public TTQValueList<TTQCanvasItem*> {
|
|
public:
|
|
void sort();
|
|
void drawUnique( TTQPainter& painter );
|
|
};
|
|
|
|
|
|
class TTQCanvasItemExtra;
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasItem : public Qt
|
|
{
|
|
public:
|
|
TTQCanvasItem(TTQCanvas* canvas);
|
|
virtual ~TTQCanvasItem();
|
|
|
|
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 TTQCanvasItem* ) const=0;
|
|
|
|
TTQCanvasItemList collisions(bool exact /* NO DEFAULT */ ) const;
|
|
|
|
virtual void setCanvas(TTQCanvas*);
|
|
|
|
virtual void draw(TTQPainter&)=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 TTQRect boundingRect() const=0;
|
|
virtual TTQRect boundingRectAdvanced() const;
|
|
|
|
TTQCanvas* canvas() const
|
|
{ return cnv; }
|
|
|
|
protected:
|
|
void update() { changeChunks(); }
|
|
|
|
private:
|
|
// For friendly subclasses...
|
|
|
|
friend class TTQCanvasPolygonalItem;
|
|
friend class TTQCanvasSprite;
|
|
friend class TTQCanvasRectangle;
|
|
friend class TTQCanvasPolygon;
|
|
friend class TTQCanvasEllipse;
|
|
friend class TTQCanvasText;
|
|
friend class TTQCanvasLine;
|
|
|
|
virtual TTQPointArray chunks() const;
|
|
virtual void addToChunks();
|
|
virtual void removeFromChunks();
|
|
virtual void changeChunks();
|
|
virtual bool collidesWith( const TTQCanvasSprite*,
|
|
const TTQCanvasPolygonalItem*,
|
|
const TTQCanvasRectangle*,
|
|
const TTQCanvasEllipse*,
|
|
const TTQCanvasText* ) const = 0;
|
|
// End of friend stuff
|
|
|
|
TTQCanvas* cnv;
|
|
static TTQCanvas* current_canvas;
|
|
double myx,myy,myz;
|
|
TTQCanvasItemExtra *ext;
|
|
TTQCanvasItemExtra& extra();
|
|
uint ani:1;
|
|
uint vis:1;
|
|
uint val:1;
|
|
uint sel:1;
|
|
uint ena:1;
|
|
uint act:1;
|
|
};
|
|
|
|
|
|
class TTQCanvasData;
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvas : public TQObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
TTQCanvas( TTQObject* parent = 0, const char* name = 0 );
|
|
TTQCanvas(int w, int h);
|
|
TTQCanvas( TTQPixmap p, int h, int v, int tilewidth, int tileheight );
|
|
|
|
virtual ~TTQCanvas();
|
|
|
|
virtual void setTiles( TTQPixmap tiles, int h, int v,
|
|
int tilewidth, int tileheight );
|
|
virtual void setBackgroundPixmap( const TTQPixmap& p );
|
|
TTQPixmap backgroundPixmap() const;
|
|
|
|
virtual void setBackgroundColor( const TTQColor& c );
|
|
TTQColor 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; }
|
|
TTQSize size() const
|
|
{ return TTQSize(awidth,aheight); }
|
|
TTQRect rect() const
|
|
{ return TTQRect( 0, 0, awidth, aheight ); }
|
|
bool onCanvas( int x, int y ) const
|
|
{ return x>=0 && y>=0 && x<awidth && y<aheight; }
|
|
bool onCanvas( const TTQPoint& p ) const
|
|
{ return onCanvas(p.x(),p.y()); }
|
|
bool validChunk( int x, int y ) const
|
|
{ return x>=0 && y>=0 && x<chwidth && y<chheight; }
|
|
bool validChunk( const TTQPoint& p ) const
|
|
{ return validChunk(p.x(),p.y()); }
|
|
|
|
int chunkSize() const
|
|
{ return chunksize; }
|
|
virtual void retune(int chunksize, int maxclusters=100);
|
|
|
|
bool sameChunk(int x1, int y1, int x2, int y2) const
|
|
{ return x1/chunksize==x2/chunksize && y1/chunksize==y2/chunksize; }
|
|
virtual void setChangedChunk(int i, int j);
|
|
virtual void setChangedChunkContaining(int x, int y);
|
|
virtual void setAllChanged();
|
|
virtual void setChanged(const TTQRect& area);
|
|
virtual void setUnchanged(const TTQRect& area);
|
|
|
|
// These call setChangedChunk.
|
|
void addItemToChunk(TTQCanvasItem*, int i, int j);
|
|
void removeItemFromChunk(TTQCanvasItem*, int i, int j);
|
|
void addItemToChunkContaining(TTQCanvasItem*, int x, int y);
|
|
void removeItemFromChunkContaining(TTQCanvasItem*, int x, int y);
|
|
|
|
TTQCanvasItemList allItems();
|
|
TTQCanvasItemList collisions( const TTQPoint&) const;
|
|
TTQCanvasItemList collisions( const TTQRect&) const;
|
|
TTQCanvasItemList collisions( const TTQPointArray& pa, const TTQCanvasItem* item,
|
|
bool exact) const;
|
|
|
|
void drawArea(const TTQRect&, TTQPainter* p, bool double_buffer=FALSE);
|
|
|
|
// These are for TTQCanvasView to call
|
|
virtual void addView(TTQCanvasView*);
|
|
virtual void removeView(TTQCanvasView*);
|
|
void drawCanvasArea(const TTQRect&, TTQPainter* p=0, bool double_buffer=TRUE);
|
|
void drawViewArea( TTQCanvasView* view, TTQPainter* p, const TTQRect& r, bool dbuf );
|
|
|
|
// These are for TTQCanvasItem to call
|
|
virtual void addItem(TTQCanvasItem*);
|
|
virtual void addAnimation(TTQCanvasItem*);
|
|
virtual void removeItem(TTQCanvasItem*);
|
|
virtual void removeAnimation(TTQCanvasItem*);
|
|
|
|
virtual void setAdvancePeriod(int ms);
|
|
virtual void setUpdatePeriod(int ms);
|
|
|
|
virtual void setDoubleBuffering(bool y);
|
|
|
|
signals:
|
|
void resized();
|
|
|
|
public slots:
|
|
virtual void advance();
|
|
virtual void update();
|
|
|
|
protected:
|
|
virtual void drawBackground(TTQPainter&, const TTQRect& area);
|
|
virtual void drawForeground(TTQPainter&, const TTQRect& area);
|
|
|
|
private:
|
|
void init(int w, int h, int chunksze=16, int maxclust=100);
|
|
|
|
TTQCanvasChunk& chunk(int i, int j) const;
|
|
TTQCanvasChunk& chunkContaining(int x, int y) const;
|
|
|
|
TTQRect changeBounds(const TTQRect& inarea);
|
|
void drawChanges(const TTQRect& inarea);
|
|
|
|
void ensureOffScrSize( int osw, int osh );
|
|
TTQPixmap offscr;
|
|
int awidth,aheight;
|
|
int chunksize;
|
|
int maxclusters;
|
|
int chwidth,chheight;
|
|
TTQCanvasChunk* chunks;
|
|
|
|
TTQCanvasData* d;
|
|
|
|
void initTiles(TTQPixmap p, int h, int v, int tilewidth, int tileheight);
|
|
ushort *grid;
|
|
ushort htiles;
|
|
ushort vtiles;
|
|
ushort tilew;
|
|
ushort tileh;
|
|
bool oneone;
|
|
TTQPixmap pm;
|
|
TTQTimer* update_timer;
|
|
TTQColor bgcolor;
|
|
bool debug_redraw_areas;
|
|
bool dblbuf;
|
|
|
|
friend void qt_unview(TTQCanvas* c);
|
|
|
|
#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
|
TTQCanvas( const TTQCanvas & );
|
|
TTQCanvas &operator=( const TTQCanvas & );
|
|
#endif
|
|
};
|
|
|
|
class TTQCanvasViewData;
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasView : public TQScrollView
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
|
|
TTQCanvasView(TTQWidget* parent=0, const char* name=0, WFlags f=0);
|
|
TTQCanvasView(TTQCanvas* viewing, TTQWidget* parent=0, const char* name=0, WFlags f=0);
|
|
~TTQCanvasView();
|
|
|
|
TTQCanvas* canvas() const
|
|
{ return viewing; }
|
|
void setCanvas(TTQCanvas* v);
|
|
|
|
const TTQWMatrix &worldMatrix() const;
|
|
const TTQWMatrix &inverseWorldMatrix() const;
|
|
bool setWorldMatrix( const TTQWMatrix & );
|
|
|
|
protected:
|
|
void drawContents( TTQPainter*, int cx, int cy, int cw, int ch );
|
|
TTQSize sizeHint() const;
|
|
|
|
private:
|
|
void drawContents( TTQPainter* );
|
|
TTQCanvas* viewing;
|
|
TTQCanvasViewData* d;
|
|
friend void qt_unview(TTQCanvas* c);
|
|
|
|
private slots:
|
|
void cMoving(int,int);
|
|
void updateContentsSize();
|
|
|
|
private:
|
|
#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
|
TTQCanvasView( const TTQCanvasView & );
|
|
TTQCanvasView &operator=( const TTQCanvasView & );
|
|
#endif
|
|
};
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasPixmap : public TQPixmap
|
|
{
|
|
public:
|
|
#ifndef QT_NO_IMAGEIO
|
|
TTQCanvasPixmap(const TTQString& datafilename);
|
|
#endif
|
|
TTQCanvasPixmap(const TTQImage& image);
|
|
TTQCanvasPixmap(const TTQPixmap&, const TTQPoint& hotspot);
|
|
~TTQCanvasPixmap();
|
|
|
|
int offsetX() const
|
|
{ return hotx; }
|
|
int offsetY() const
|
|
{ return hoty; }
|
|
void setOffset(int x, int y) { hotx = x; hoty = y; }
|
|
|
|
private:
|
|
#if defined(Q_DISABLE_COPY)
|
|
TTQCanvasPixmap( const TTQCanvasPixmap & );
|
|
TTQCanvasPixmap &operator=( const TTQCanvasPixmap & );
|
|
#endif
|
|
void init(const TTQImage&);
|
|
void init(const TTQPixmap& pixmap, int hx, int hy);
|
|
|
|
friend class TTQCanvasSprite;
|
|
friend class TTQCanvasPixmapArray;
|
|
friend bool qt_testCollision(const TTQCanvasSprite* s1, const TTQCanvasSprite* s2);
|
|
|
|
int hotx,hoty;
|
|
|
|
TTQImage* collision_mask;
|
|
};
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TQCanvasPixmapArray
|
|
{
|
|
public:
|
|
TTQCanvasPixmapArray();
|
|
#ifndef QT_NO_IMAGEIO
|
|
TTQCanvasPixmapArray(const TTQString& datafilenamepattern, int framecount=0);
|
|
#endif
|
|
// this form is deprecated
|
|
TTQCanvasPixmapArray(TTQPtrList<TTQPixmap>, TTQPtrList<TTQPoint> hotspots);
|
|
|
|
TTQCanvasPixmapArray(TTQValueList<TTQPixmap>, TTQPointArray hotspots = TTQPointArray() );
|
|
~TTQCanvasPixmapArray();
|
|
|
|
#ifndef QT_NO_IMAGEIO
|
|
bool readPixmaps(const TTQString& datafilenamepattern, int framecount=0);
|
|
bool readCollisionMasks(const TTQString& filenamepattern);
|
|
#endif
|
|
|
|
// deprecated
|
|
bool operator!(); // Failure check.
|
|
bool isValid() const;
|
|
|
|
TTQCanvasPixmap* image(int i) const
|
|
{ return img ? img[i] : 0; }
|
|
void setImage(int i, TTQCanvasPixmap* p);
|
|
uint count() const
|
|
{ return (uint)framecount; }
|
|
|
|
private:
|
|
#if defined(Q_DISABLE_COPY)
|
|
TTQCanvasPixmapArray( const TTQCanvasPixmapArray & );
|
|
TTQCanvasPixmapArray &operator=( const TTQCanvasPixmapArray & );
|
|
#endif
|
|
#ifndef QT_NO_IMAGEIO
|
|
bool readPixmaps(const TTQString& datafilenamepattern, int framecount, bool maskonly);
|
|
#endif
|
|
|
|
void reset();
|
|
int framecount;
|
|
TTQCanvasPixmap** img;
|
|
};
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasSprite : public TQCanvasItem
|
|
{
|
|
public:
|
|
TTQCanvasSprite(TTQCanvasPixmapArray* array, TTQCanvas* canvas);
|
|
|
|
void setSequence(TTQCanvasPixmapArray* seq);
|
|
|
|
virtual ~TTQCanvasSprite();
|
|
|
|
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 TTQCanvasItem* ) const;
|
|
|
|
TTQRect 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;
|
|
TTQCanvasPixmap* image() const
|
|
{ return images->image(frm); }
|
|
virtual TTQCanvasPixmap* imageAdvanced() const;
|
|
TTQCanvasPixmap* image(int f) const
|
|
{ return images->image(f); }
|
|
virtual void advance(int stage);
|
|
|
|
public:
|
|
void draw(TTQPainter& painter);
|
|
|
|
private:
|
|
#if defined(Q_DISABLE_COPY)
|
|
TTQCanvasSprite( const TTQCanvasSprite & );
|
|
TTQCanvasSprite &operator=( const TTQCanvasSprite & );
|
|
#endif
|
|
void addToChunks();
|
|
void removeFromChunks();
|
|
void changeChunks();
|
|
|
|
int frm;
|
|
ushort anim_val;
|
|
uint anim_state:2;
|
|
uint anim_type:14;
|
|
bool collidesWith( const TTQCanvasSprite*,
|
|
const TTQCanvasPolygonalItem*,
|
|
const TTQCanvasRectangle*,
|
|
const TTQCanvasEllipse*,
|
|
const TTQCanvasText* ) const;
|
|
|
|
friend bool qt_testCollision( const TTQCanvasSprite* s1,
|
|
const TTQCanvasSprite* s2 );
|
|
|
|
TTQCanvasPixmapArray* images;
|
|
};
|
|
|
|
class TTQPolygonalProcessor;
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasPolygonalItem : public TQCanvasItem
|
|
{
|
|
public:
|
|
TTQCanvasPolygonalItem(TTQCanvas* canvas);
|
|
virtual ~TTQCanvasPolygonalItem();
|
|
|
|
bool collidesWith( const TTQCanvasItem* ) const;
|
|
|
|
virtual void setPen(TTQPen p);
|
|
virtual void setBrush(TTQBrush b);
|
|
|
|
TTQPen pen() const
|
|
{ return pn; }
|
|
TTQBrush brush() const
|
|
{ return br; }
|
|
|
|
virtual TTQPointArray areaPoints() const=0;
|
|
virtual TTQPointArray areaPointsAdvanced() const;
|
|
TTQRect boundingRect() const;
|
|
|
|
int rtti() const;
|
|
static int RTTI;
|
|
|
|
protected:
|
|
void draw(TTQPainter &);
|
|
virtual void drawShape(TTQPainter &) = 0;
|
|
|
|
bool winding() const;
|
|
void setWinding(bool);
|
|
|
|
void invalidate();
|
|
bool isValid() const
|
|
{ return (bool)val; }
|
|
|
|
private:
|
|
void scanPolygon( const TTQPointArray& pa, int winding,
|
|
TTQPolygonalProcessor& process ) const;
|
|
TTQPointArray chunks() const;
|
|
|
|
bool collidesWith( const TTQCanvasSprite*,
|
|
const TTQCanvasPolygonalItem*,
|
|
const TTQCanvasRectangle*,
|
|
const TTQCanvasEllipse*,
|
|
const TTQCanvasText* ) const;
|
|
|
|
TTQBrush br;
|
|
TTQPen pn;
|
|
uint wind:1;
|
|
};
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasRectangle : public TQCanvasPolygonalItem
|
|
{
|
|
public:
|
|
TTQCanvasRectangle(TTQCanvas* canvas);
|
|
TTQCanvasRectangle(const TTQRect&, TTQCanvas* canvas);
|
|
TTQCanvasRectangle(int x, int y, int width, int height, TTQCanvas* canvas);
|
|
|
|
~TTQCanvasRectangle();
|
|
|
|
int width() const;
|
|
int height() const;
|
|
void setSize(int w, int h);
|
|
TTQSize size() const
|
|
{ return TTQSize(w,h); }
|
|
TTQPointArray areaPoints() const;
|
|
TTQRect rect() const
|
|
{ return TTQRect(int(x()),int(y()),w,h); }
|
|
|
|
bool collidesWith( const TTQCanvasItem* ) const;
|
|
|
|
int rtti() const;
|
|
static int RTTI;
|
|
|
|
protected:
|
|
void drawShape(TTQPainter &);
|
|
TTQPointArray chunks() const;
|
|
|
|
private:
|
|
bool collidesWith( const TTQCanvasSprite*,
|
|
const TTQCanvasPolygonalItem*,
|
|
const TTQCanvasRectangle*,
|
|
const TTQCanvasEllipse*,
|
|
const TTQCanvasText* ) const;
|
|
|
|
int w, h;
|
|
};
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasPolygon : public TQCanvasPolygonalItem
|
|
{
|
|
public:
|
|
TTQCanvasPolygon(TTQCanvas* canvas);
|
|
~TTQCanvasPolygon();
|
|
void setPoints(TTQPointArray);
|
|
TTQPointArray points() const;
|
|
void moveBy(double dx, double dy);
|
|
|
|
TTQPointArray areaPoints() const;
|
|
|
|
int rtti() const;
|
|
static int RTTI;
|
|
|
|
protected:
|
|
void drawShape(TTQPainter &);
|
|
TTQPointArray poly;
|
|
};
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasSpline : public TQCanvasPolygon
|
|
{
|
|
public:
|
|
TTQCanvasSpline(TTQCanvas* canvas);
|
|
~TTQCanvasSpline();
|
|
|
|
void setControlPoints(TTQPointArray, bool closed=TRUE);
|
|
TTQPointArray controlPoints() const;
|
|
bool closed() const;
|
|
|
|
int rtti() const;
|
|
static int RTTI;
|
|
|
|
private:
|
|
void recalcPoly();
|
|
TTQPointArray bez;
|
|
bool cl;
|
|
};
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasLine : public TQCanvasPolygonalItem
|
|
{
|
|
public:
|
|
TTQCanvasLine(TTQCanvas* canvas);
|
|
~TTQCanvasLine();
|
|
void setPoints(int x1, int y1, int x2, int y2);
|
|
|
|
TTQPoint startPoint() const
|
|
{ return TTQPoint(x1,y1); }
|
|
TTQPoint endPoint() const
|
|
{ return TTQPoint(x2,y2); }
|
|
|
|
int rtti() const;
|
|
static int RTTI;
|
|
|
|
void setPen(TTQPen p);
|
|
|
|
protected:
|
|
void drawShape(TTQPainter &);
|
|
TTQPointArray areaPoints() const;
|
|
|
|
private:
|
|
int x1,y1,x2,y2;
|
|
};
|
|
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasEllipse : public TQCanvasPolygonalItem
|
|
{
|
|
|
|
public:
|
|
TTQCanvasEllipse( TTQCanvas* canvas );
|
|
TTQCanvasEllipse( int width, int height, TTQCanvas* canvas );
|
|
TTQCanvasEllipse( int width, int height, int startangle, int angle,
|
|
TTQCanvas* canvas );
|
|
|
|
~TTQCanvasEllipse();
|
|
|
|
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; }
|
|
TTQPointArray areaPoints() const;
|
|
|
|
bool collidesWith( const TTQCanvasItem* ) const;
|
|
|
|
int rtti() const;
|
|
static int RTTI;
|
|
|
|
protected:
|
|
void drawShape(TTQPainter &);
|
|
|
|
private:
|
|
bool collidesWith( const TTQCanvasSprite*,
|
|
const TTQCanvasPolygonalItem*,
|
|
const TTQCanvasRectangle*,
|
|
const TTQCanvasEllipse*,
|
|
const TTQCanvasText* ) const;
|
|
int w, h;
|
|
int a1, a2;
|
|
};
|
|
|
|
|
|
class TTQCanvasTextExtra;
|
|
|
|
class TQM_EXPORT_CANVAS TTQCanvasText : public TQCanvasItem
|
|
{
|
|
public:
|
|
TTQCanvasText(TTQCanvas* canvas);
|
|
TTQCanvasText(const TTQString&, TTQCanvas* canvas);
|
|
TTQCanvasText(const TTQString&, TTQFont, TTQCanvas* canvas);
|
|
|
|
virtual ~TTQCanvasText();
|
|
|
|
void setText( const TTQString& );
|
|
void setFont( const TTQFont& );
|
|
void setColor( const TTQColor& );
|
|
TTQString text() const;
|
|
TTQFont font() const;
|
|
TTQColor color() const;
|
|
|
|
void moveBy(double dx, double dy);
|
|
|
|
int textFlags() const
|
|
{ return flags; }
|
|
void setTextFlags(int);
|
|
|
|
TTQRect boundingRect() const;
|
|
|
|
bool collidesWith( const TTQCanvasItem* ) const;
|
|
|
|
int rtti() const;
|
|
static int RTTI;
|
|
|
|
protected:
|
|
virtual void draw(TTQPainter&);
|
|
|
|
private:
|
|
#if defined(Q_DISABLE_COPY)
|
|
TTQCanvasText( const TTQCanvasText & );
|
|
TTQCanvasText &operator=( const TTQCanvasText & );
|
|
#endif
|
|
void addToChunks();
|
|
void removeFromChunks();
|
|
void changeChunks();
|
|
|
|
void setRect();
|
|
TTQRect brect;
|
|
TTQString txt;
|
|
int flags;
|
|
TTQFont fnt;
|
|
TTQColor col;
|
|
TTQCanvasTextExtra* extra;
|
|
|
|
bool collidesWith( const TTQCanvasSprite*,
|
|
const TTQCanvasPolygonalItem*,
|
|
const TTQCanvasRectangle*,
|
|
const TTQCanvasEllipse*,
|
|
const TTQCanvasText* ) const;
|
|
};
|
|
|
|
#define Q_DEFINED_QCANVAS
|
|
#include "tqwinexport.h"
|
|
#endif // QT_NO_CANVAS
|
|
|
|
#endif // TQCANVAS_H
|