trunk 20080912
[gitenigma.git] / lib / gui / decoration.cpp
blob737ec2c3f63bb20618322036f490e3d104a8af75
1 #include <lib/gui/decoration.h>
2 #include <lib/gdi/gpixmap.h>
3 #include <lib/gdi/grc.h>
4 #include <lib/gui/eskin.h>
6 /*
8 +-------+-----------------+--------+
9 |TopLeft| Top |TopRight|
10 +------++-----------------+--+-----+
11 | Left| client |Right|
12 +------+---+-----------+-----+-----+
13 |BottomLeft| Bottom |BottomRight|
14 +----------+-----------+-----------+
18 eDecoration::eDecoration()
20 iTopLeft=iTop=iTopRight=iLeft=iRight=iBottomLeft=iBottom=iBottomRight=0;
21 borderLeft=borderTop=borderRight=borderBottom=0;
24 bool eDecoration::load(const eString& base)
26 if (basename != base)
28 basename=base; // all your
29 iTopLeft=eSkin::getActive()->queryImage(basename + ".topLeft");
30 iTop=eSkin::getActive()->queryImage(basename + ".top");
31 iTopRight=eSkin::getActive()->queryImage(basename + ".topRight");
32 iLeft=eSkin::getActive()->queryImage(basename + ".left");
33 iRight=eSkin::getActive()->queryImage(basename + ".right");
34 iBottomLeft=eSkin::getActive()->queryImage(basename + ".bottomLeft");
35 iBottom=eSkin::getActive()->queryImage(basename + ".bottom");
36 iBottomRight=eSkin::getActive()->queryImage(basename + ".bottomRight");
38 borderLeft=borderTop=borderRight=borderBottom=0;
40 if (iTop)
41 borderTop = iTop->y;
42 if (iLeft)
43 borderLeft = iLeft->x;
44 if (iRight)
45 borderRight = iRight->x;
46 if (iBottom)
47 borderBottom = iBottom->y;
48 /* if (iTopLeft)
50 if ( iTopLeft->y > borderTop)
51 borderTop = iTopLeft->y;
52 if ( iTopLeft->x > borderLeft )
53 borderLeft = iTopLeft->x;
55 if (iTopRight)
57 if ( iTopRight->y > borderTop)
58 borderTop = iTopRight->y;
59 if ( iTopLeft->x > borderRight )
60 borderRight = iTopRight->x;
62 if (iBottomLeft)
64 if ( iBottomLeft->y > borderBottom )
65 borderBottom = iBottomLeft->y;
66 if ( iBottomLeft->x > borderLeft )
67 borderLeft = iBottomLeft->x;
69 if (iBottomRight)
71 if ( iBottomRight->y > borderBottom )
72 borderBottom = iBottomRight->y;
73 if ( iBottomRight->x > borderRight )
74 borderRight = iBottomRight->x;
75 }*/
77 return operator bool();
80 void eDecoration::drawDecoration(gPainter *target, ePoint size)
82 int x=0, xm=size.x(), y, ym;
84 if (iBottomLeft)
86 target->blit(*iBottomLeft, ePoint(0, size.y()-iBottomLeft->y));
87 x+=iBottomLeft->x;
90 if (iBottomRight)
92 xm-=iBottomRight->x;
93 target->blit(*iBottomRight, ePoint(xm, size.y()-iBottomRight->y), eRect(x, size.y()-iBottomRight->y, size.x()-x, iBottomRight->y));
96 if (iBottom)
98 while (x<xm)
100 target->blit(*iBottom, ePoint(x, size.y()-iBottom->y), eRect(x, size.y()-iBottom->y, xm-x, size.y()));
101 x+=iBottom->x;
105 x=0;
106 xm=size.x();
108 if (iTopLeft)
110 target->blit(*iTopLeft, ePoint(0, 0) );
111 x+=iTopLeft->x;
114 if (iTopRight)
116 xm-=iTopRight->x;
117 target->blit(*iTopRight, ePoint(xm, 0), eRect(x, 0, size.x()-x, size.y()));
120 if (iTop)
122 while (x<xm)
124 target->blit(*iTop, ePoint(x, 0), eRect(x, 0, xm-x, size.y()));
125 x+=iTop->x;
129 y=0; ym=size.y();
131 if (iTopLeft)
132 y=iTopLeft->y;
133 if (iBottomLeft)
134 ym=size.y()-iBottomLeft->y;
135 if (iLeft)
137 while (y<ym)
139 target->blit(*iLeft, ePoint(0, y), eRect(0, y, iLeft->x, ym-y));
140 y+=iLeft->y;
144 if (iTopRight)
145 y=iTopRight->y;
146 if (iBottomRight)
147 ym=size.y()-iBottomRight->y;
148 if (iRight)
150 while (y<ym)
152 target->blit(*iRight, ePoint(size.x()-iRight->x, y), eRect(size.x()-iRight->x, y, iRight->x, ym-y));
153 y+=iRight->y;
157 target->flush();