1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#ifndef PIX_H
#define PIX_H
#include "gfxinterface.h"
#include <map>
// Picture defined by two pixmaps: one for colors; one for tranparency (shape).
// The constructors loads it in the X server and it can then be displayed an
// arbitrary number of times.
class Pix {
Pixmap pixmap_, shapemask_;
Coord dim_;
Pix(const Pix &); // no copy
Pix & operator=(const Pix &); // no assign
friend class PixKeeper;
Pix(const char *const * xpm);
~Pix();
public:
int Width() const { return dim_.x; }
int Height() const { return dim_.y; }
Coord Dim() const { return dim_; }
void Draw(Coord pos) const;
void Mask(Coord pos) const;
void Move(Coord from, Coord to) const;
};
// Singleton that initializes and keep Pix's.
class PixKeeper {
static PixKeeper * singleton_;
PixKeeper() {}
~PixKeeper();
PixKeeper(const PixKeeper &); // no copy
PixKeeper & operator=(const PixKeeper &); // no copy
typedef std::map<const char *const *, const Pix *> PixCtn;
PixCtn pixes_;
public:
static PixKeeper & Instance();
static void DestroyInstance();
const Pix * Get(const char *const * pix_data);
};
#endif
|