yes! ich habs kaputt gemacht! (doesn't compile anymore, doesn't work anymore,
[enigma2.git] / lib / gdi / gpixmap.h
1 #ifndef __gpixmap_h
2 #define __gpixmap_h
3
4 #include <pthread.h>
5 #include <lib/base/estring.h>
6 #include <lib/base/object.h>
7 #include <lib/base/elock.h>
8 #include <lib/gdi/erect.h>
9 #include <lib/gdi/fb.h>
10
11 struct gColor
12 {
13         int color;
14         gColor(int color): color(color)
15         {
16         }
17         gColor(): color(0)
18         {
19         }
20         operator int() const { return color; }
21         bool operator==(const gColor &o) const { return o.color==color; }
22 };
23
24 struct gRGB
25 {
26         int b, g, r, a;
27         gRGB(int r, int g, int b, int a=0): b(b), g(g), r(r), a(a)
28         {
29         }
30         gRGB(unsigned long val): b(val&0xFF), g((val>>8)&0xFF), r((val>>16)&0xFF), a((val>>24)&0xFF)            // ARGB
31         {
32         }
33         gRGB()
34         {
35         }
36         bool operator < (const gRGB &c) const
37         {
38                 if (b < c.b)
39                         return 1;
40                 if (b == c.b)
41                 {
42                         if (g < c.g)
43                                 return 1;
44                         if (g == c.g)
45                         {
46                                 if (r < c.r)
47                                         return 1;
48                                 if (r == c.r)
49                                         return a < c.a;
50                         }
51                 }
52                 return 0;
53         }
54         bool operator==(const gRGB &c) const
55         {
56                 return (b == c.b) && (g == c.g) && (r == c.r) && (a == c.a);
57         }
58 };
59
60 struct gPalette
61 {
62         int start, colors;
63         gRGB *data;
64         gColor findColor(const gRGB &rgb) const;
65 };
66
67 struct gLookup
68 {
69         int size;
70         gColor *lookup;
71         gLookup(int size, const gPalette &pal, const gRGB &start, const gRGB &end);
72         gLookup();
73         ~gLookup() { delete [] lookup; }
74         void build(int size, const gPalette &pal, const gRGB &start, const gRGB &end);
75 };
76
77 /**
78  * \brief A softreference to a font.
79  *
80  * The font is specified by a name and a size.
81  * \c gFont is part of the \ref gdi.
82  */
83 class gFont: public virtual iObject
84 {
85 DECLARE_REF;
86 public:
87
88         eString family;
89         int pointSize;
90         
91         /**
92          * \brief Constructs a font with the given name and size.
93          * \param family The name of the font, for example "NimbusSansL-Regular Sans L Regular".
94          * \param pointSize the size of the font in PIXELS.
95          */
96         gFont(const eString &family, int pointSize):
97                         family(family), pointSize(pointSize)
98         {
99         }
100         
101         virtual ~gFont()
102         {
103         }
104         
105         gFont()
106                 :pointSize(0)
107         {
108         }
109 };
110
111 struct gSurface
112 {
113         int type;
114         int x, y, bpp, bypp, stride;
115         gPalette clut;
116         
117         void *data;
118         virtual ~gSurface();
119 };
120
121 struct gSurfaceSystem: gSurface
122 {
123         gSurfaceSystem(eSize size, int bpp);
124         ~gSurfaceSystem();
125 };
126
127 struct gPixmap: public iObject
128 {
129 DECLARE_REF;
130 public:
131         gSurface *surface;
132         
133         eLock contentlock;
134         int final;
135         
136         gPixmap *lock();
137         void unlock();
138         
139         eSize getSize() const { return eSize(surface->x, surface->y); }
140         
141         void fill(const eRect &area, const gColor &color);
142         
143         enum
144         {
145                 blitAlphaTest=1
146         };
147         void blit(const gPixmap &src, ePoint pos, const eRect &clip=eRect(), int flags=0);
148         
149         void mergePalette(const gPixmap &target);
150         void line(ePoint start, ePoint end, gColor color);
151         void finalLock();
152         gPixmap(gSurface *surface);
153         gPixmap(eSize, int bpp);
154         virtual ~gPixmap();
155 };
156
157 #endif