From fc2f5b2cd655f1391f2abda1b39e37cdec98a951 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 17 Oct 2003 15:35:43 +0000 Subject: Initial revision --- lib/gui/decoration.cpp | 181 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 lib/gui/decoration.cpp (limited to 'lib/gui/decoration.cpp') 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 +#include +#include +#include +#include + +/* + + +-------+-----------------+--------+ + |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 (xblit(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 (xblit(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 (yblit(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 (yblit(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 ); +} + -- cgit v1.2.3