1 #include <lib/gui/decoration.h>
2 #include <lib/gdi/gpixmap.h>
3 #include <lib/gdi/grc.h>
4 #include <lib/gui/eskin.h>
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
)
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;
43 borderLeft
= iLeft
->x
;
45 borderRight
= iRight
->x
;
47 borderBottom
= iBottom
->y
;
50 if ( iTopLeft->y > borderTop)
51 borderTop = iTopLeft->y;
52 if ( iTopLeft->x > borderLeft )
53 borderLeft = iTopLeft->x;
57 if ( iTopRight->y > borderTop)
58 borderTop = iTopRight->y;
59 if ( iTopLeft->x > borderRight )
60 borderRight = iTopRight->x;
64 if ( iBottomLeft->y > borderBottom )
65 borderBottom = iBottomLeft->y;
66 if ( iBottomLeft->x > borderLeft )
67 borderLeft = iBottomLeft->x;
71 if ( iBottomRight->y > borderBottom )
72 borderBottom = iBottomRight->y;
73 if ( iBottomRight->x > borderRight )
74 borderRight = iBottomRight->x;
77 return operator bool();
80 void eDecoration::drawDecoration(gPainter
*target
, ePoint size
)
82 int x
=0, xm
=size
.x(), y
, ym
;
86 target
->blit(*iBottomLeft
, ePoint(0, size
.y()-iBottomLeft
->y
));
93 target
->blit(*iBottomRight
, ePoint(xm
, size
.y()-iBottomRight
->y
), eRect(x
, size
.y()-iBottomRight
->y
, size
.x()-x
, iBottomRight
->y
));
100 target
->blit(*iBottom
, ePoint(x
, size
.y()-iBottom
->y
), eRect(x
, size
.y()-iBottom
->y
, xm
-x
, size
.y()));
110 target
->blit(*iTopLeft
, ePoint(0, 0) );
117 target
->blit(*iTopRight
, ePoint(xm
, 0), eRect(x
, 0, size
.x()-x
, size
.y()));
124 target
->blit(*iTop
, ePoint(x
, 0), eRect(x
, 0, xm
-x
, size
.y()));
134 ym
=size
.y()-iBottomLeft
->y
;
139 target
->blit(*iLeft
, ePoint(0, y
), eRect(0, y
, iLeft
->x
, ym
-y
));
147 ym
=size
.y()-iBottomRight
->y
;
152 target
->blit(*iRight
, ePoint(size
.x()-iRight
->x
, y
), eRect(size
.x()-iRight
->x
, y
, iRight
->x
, ym
-y
));