aboutsummaryrefslogtreecommitdiff
path: root/lib/gui/decoration.cpp
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2003-10-17 15:35:43 +0000
committerFelix Domke <tmbinc@elitedvb.net>2003-10-17 15:35:43 +0000
commitfc2f5b2cd655f1391f2abda1b39e37cdec98a951 (patch)
tree312efcea86a319de407a7c314fb981fb1c71019a /lib/gui/decoration.cpp
downloadenigma2-fc2f5b2cd655f1391f2abda1b39e37cdec98a951.tar.gz
enigma2-fc2f5b2cd655f1391f2abda1b39e37cdec98a951.zip
Initial revision
Diffstat (limited to 'lib/gui/decoration.cpp')
-rw-r--r--lib/gui/decoration.cpp181
1 files changed, 181 insertions, 0 deletions
diff --git a/lib/gui/decoration.cpp b/lib/gui/decoration.cpp
new file mode 100644
index 00000000..4debef98
--- /dev/null
+++ b/lib/gui/decoration.cpp
@@ -0,0 +1,181 @@
+#include <lib/gui/decoration.h>
+#include <lib/gdi/gpixmap.h>
+#include <lib/gdi/grc.h>
+#include <lib/gui/eskin.h>
+#include <lib/gui/ewidget.h>
+
+/*
+
+ +-------+-----------------+--------+
+ |TopLeft| Top |TopRight|
+ +------++-----------------+--+-----+
+ | Left| client |Right|
+ +------+---+-----------+-----+-----+
+ |BottomLeft| Bottom |BottomRight|
+ +----------+-----------+-----------+
+
+*/
+
+eDecoration::eDecoration()
+{
+ iTopLeft=iTop=iTopRight=iLeft=iRight=iBottomLeft=iBottom=iBottomRight=0;
+ borderLeft=borderTop=borderRight=borderBottom=0;
+}
+
+bool eDecoration::load(const eString& base)
+{
+ if (basename != base)
+ {
+ basename=base; // all your
+
+ eSkin::getActive()->queryImage(iTopLeft, basename + ".topLeft");
+ eSkin::getActive()->queryImage(iTop, basename + ".top");
+ eSkin::getActive()->queryImage(iTopRight, basename + ".topRight");
+ eSkin::getActive()->queryImage(iLeft, basename + ".left");
+ eSkin::getActive()->queryImage(iRight, basename + ".right");
+ eSkin::getActive()->queryImage(iBottomLeft, basename + ".bottomLeft");
+ eSkin::getActive()->queryImage(iBottom, basename + ".bottom");
+ eSkin::getActive()->queryImage(iBottomRight, basename + ".bottomRight");
+
+ borderLeft=borderTop=borderRight=borderBottom=0;
+
+ if (iTop)
+ borderTop = iTop->y;
+ if (iLeft)
+ borderLeft = iLeft->x;
+ if (iRight)
+ borderRight = iRight->x;
+ if (iBottom)
+ borderBottom = iBottom->y;
+ }
+ return operator bool();
+}
+
+void eDecoration::drawDecoration(gPainter *target, ePoint size)
+{
+ int x=0, xm=size.x(), y, ym;
+
+ if (iBottomLeft)
+ {
+ target->blit(iBottomLeft, ePoint(0, size.y()-iBottomLeft->y));
+ x+=iBottomLeft->x;
+ }
+
+ if (iBottomRight)
+ {
+ xm-=iBottomRight->x;
+ target->blit(iBottomRight, ePoint(xm, size.y()-iBottomRight->y), eRect(x, size.y()-iBottomRight->y, size.x()-x, iBottomRight->y));
+ }
+
+ if (iBottom)
+ {
+ while (x<xm)
+ {
+ target->blit(iBottom, ePoint(x, size.y()-iBottom->y), eRect(x, size.y()-iBottom->y, xm-x, size.y()));
+ x+=iBottom->x;
+ }
+ }
+
+ x=0;
+ xm=size.x();
+
+ if (iTopLeft)
+ {
+ target->blit(iTopLeft, ePoint(0, 0) );
+ x+=iTopLeft->x;
+ }
+
+ if (iTopRight)
+ {
+ xm-=iTopRight->x;
+ target->blit(iTopRight, ePoint(xm, 0), eRect(x, 0, size.x()-x, size.y()));
+ }
+
+ if (iTop)
+ {
+ while (x<xm)
+ {
+ target->blit(iTop, ePoint(x, 0), eRect(x, 0, xm-x, size.y()));
+ x+=iTop->x;
+ }
+ }
+
+ y=0; ym=size.y();
+
+ if (iTopLeft)
+ y=iTopLeft->y;
+ if (iBottomLeft)
+ ym=size.y()-iBottomLeft->y;
+ if (iLeft)
+ {
+ while (y<ym)
+ {
+ target->blit(iLeft, ePoint(0, y), eRect(0, y, iLeft->x, ym-y));
+ y+=iLeft->y;
+ }
+ }
+
+ if (iTopRight)
+ y=iTopRight->y;
+ if (iBottomRight)
+ ym=size.y()-iBottomRight->y;
+ if (iRight)
+ {
+ while (y<ym)
+ {
+ target->blit(iRight, ePoint(size.x()-iRight->x, y), eRect(size.x()-iRight->x, y, iRight->x, ym-y));
+ y+=iRight->y;
+ }
+ }
+
+ target->flush();
+}
+
+int eDecoWidget::setProperty( const eString &prop, const eString &value)
+{
+ if (prop == "loadDeco")
+ {
+ if ( value != "" )
+ strDeco=value;
+
+ loadDeco();
+ }
+ else
+ return eWidget::setProperty( prop, value );
+
+ return 0;
+}
+
+int eDecoWidget::eventFilter( const eWidgetEvent &evt )
+{
+ if ( evt.type == eWidgetEvent::changedSize )
+ {
+ if (deco)
+ {
+ crect.setLeft( deco.borderLeft );
+ crect.setTop( deco.borderTop );
+ crect.setWidth( width() - (deco.borderRight + deco.borderLeft) );
+ crect.setHeight( height() - (deco.borderBottom + deco.borderTop ) );
+ }
+ if (deco_selected)
+ {
+ crect_selected.setLeft( deco_selected.borderLeft );
+ crect_selected.setTop( deco_selected.borderTop );
+ crect_selected.setWidth( width() - (deco_selected.borderRight + deco_selected.borderLeft) );
+ crect_selected.setHeight( height() - (deco_selected.borderBottom + deco_selected.borderTop ) );
+ }
+ }
+ return 0; //always return 0... the eventHandler must been called...
+}
+
+void eDecoWidget::loadDeco()
+{
+ int i = 0;
+ if ( deco.load( strDeco ) )
+ i |= 1;
+ if ( deco_selected.load( strDeco+".selected" ) )
+ i |= 1;
+ if (i)
+ event( eWidgetEvent::changedSize );
+}
+