diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ae2a03c2941bf92573f89b88ef73f8aa842bea0a (patch) | |
tree | 3566563f3fb6ac3cb3496669d8f233062d3091bc /ktux/spritepm.h | |
download | tdetoys-ae2a03c2941bf92573f89b88ef73f8aa842bea0a.tar.gz tdetoys-ae2a03c2941bf92573f89b88ef73f8aa842bea0a.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdetoys@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ktux/spritepm.h')
-rw-r--r-- | ktux/spritepm.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/ktux/spritepm.h b/ktux/spritepm.h new file mode 100644 index 0000000..e9f24be --- /dev/null +++ b/ktux/spritepm.h @@ -0,0 +1,85 @@ +//--------------------------------------------------------------------------- +// +// spritepm.h +// +// Copyright (c) 1999 Martin R. Jones <[email protected]> +// + +#ifndef SPRITEPM_H +#define SPRITEPM_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qdict.h> +#include <qpixmap.h> +#include <qcanvas.h> +#include <kconfigbase.h> +#include <ksimpleconfig.h> + +//--------------------------------------------------------------------------- +// +// SpritePixmapManager stores the frames used in animations. +// +class SpritePixmapManager +{ +public: + SpritePixmapManager(); + virtual ~SpritePixmapManager(); + + void setPixmapDir(const QString &dir) + { mPixmapDir = dir; } + void reset() + { mPixmapDir = "."; mPixmaps.clear(); } + const QPixmap *load(const QString & img); + const QPixmap *pixmap(const char *img) const + { return mPixmaps.find(img); } + + static SpritePixmapManager *manager(); + +public: + QString mPixmapDir; // get pixmaps from here + QDict<QPixmap> mPixmaps; // list of pixmaps + static SpritePixmapManager *mManager; // static pointer to instance +}; + +//--------------------------------------------------------------------------- +// +class SpritePixmapSequence : public QCanvasPixmapArray +{ +public: + SpritePixmapSequence(QPtrList<QPixmap> pm, QPtrList<QPoint> hs, QMemArray<int> d); + + int delay(int i) const { return mDelays[i]; } + +protected: + QMemArray<int> mDelays; +}; + +//--------------------------------------------------------------------------- +// +// SpriteManager stores the animation sequences +// +class SpriteSequenceManager +{ +public: + SpriteSequenceManager(); + ~SpriteSequenceManager(); + + SpritePixmapSequence *load(KConfigBase &config, const QString & name); + SpritePixmapSequence *sprite(const char *name) + { return mSprites.find(name); } + + static SpriteSequenceManager *manager(); + +protected: + SpritePixmapSequence *read(KConfigBase &config); + +protected: + QDict<SpritePixmapSequence> mSprites; + static SpriteSequenceManager *mManager; +}; + +#endif // SPRITEPM_H + |