author | zecke <zecke> | 2005-02-22 23:25:19 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-22 23:25:19 (UTC) |
commit | 30857db6ca3f355aa3d50b59f03a13c82f265af2 (patch) (side-by-side diff) | |
tree | 53431b5d7108c674fe99ea214d06a60a5e494588 /library | |
parent | ff2fdaf1a8e8a17ce756c0413102b37705e0c646 (diff) | |
download | opie-30857db6ca3f355aa3d50b59f03a13c82f265af2.zip opie-30857db6ca3f355aa3d50b59f03a13c82f265af2.tar.gz opie-30857db6ca3f355aa3d50b59f03a13c82f265af2.tar.bz2 |
Instead of having the same method four time with different name and image to load
we now have a define.
This makes it more easy to change the handling of builtin decoration image
-rw-r--r-- | library/qpedecoration_qws.cpp | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index fb47c14..1afae88 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp @@ -260,136 +260,111 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e ) void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) { QPainter painter(w); QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; painter.internalGfx()->setWidgetDeviceRegion( rgn ); painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); } void QPEManager::drawTitle( QWidget *w ) { QPainter painter(w); QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; painter.internalGfx()->setWidgetDeviceRegion( rgn ); painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); decoration->paint( &painter, w ); decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); decoration->paintButton(&painter, w, QWSDecoration::Close, 0); decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); } void QPEManager::whatsThisTimeout() { if ( !QWhatsThis::inWhatsThisMode() ) { if ( inWhatsThis ) { if ( whatsThis ) { QWidget *w = whatsThis; whatsThis = 0; drawTitle( w ); } wtTimer->stop(); } else { QWhatsThis::enterWhatsThisMode(); helpState = 0; updateActive(); if ( active ) { whatsThis = active; drawTitle( active ); // check periodically to see if we've left whats this mode wtTimer->start( 250 ); } } inWhatsThis = !inWhatsThis; } } //=========================================================================== - -static QImage *okImage( int th ) -{ - static QImage *i = 0; - if ( !i || ::abs( i->height()-th ) > 4 ) { - delete i; - i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); - } - return i; -} - -static QImage *closeImage( int th ) -{ - static QImage *i = 0; - if ( !i || ::abs( i->height()-th ) > 4 ) { - delete i; - i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); - } - return i; -} - -static QImage *helpImage( int th ) -{ - static QImage *i = 0; - if ( !i || ::abs( i->height()-th ) > 4 ) { - delete i; - i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); - } - return i; -} - -static QImage *maximizeImage( int th ) -{ - static QImage *i = 0; - if ( !i || ::abs( i->height()-th ) > 4 ) { - delete i; - i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); - } - return i; -} +#define IMAGE_METHOD( methodName, imageName ) \ +static QImage* methodName( int th ) { \ + static QImage *i = 0; \ + if ( !i || ::abs( i->height()-th ) > 4 ) { \ + delete i; \ + i = new QImage(scaleButton(Resource::loadImage(#imageName),th)); \ + } \ + \ + return i; \ +} + +IMAGE_METHOD(okImage, OKButton ); +IMAGE_METHOD(closeImage, CloseButton ); +IMAGE_METHOD(helpImage, HelpButton ); +IMAGE_METHOD(maximizeImage,MaximizeButton ); int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const { switch ( m ) { case TitleHeight: if ( QApplication::desktop()->height() > 320 ) return 19; else return 15; case LeftBorder: case RightBorder: case TopBorder: case BottomBorder: return 4; case OKWidth: return okImage(metric(TitleHeight,wd))->width(); case CloseWidth: return closeImage(metric(TitleHeight,wd))->width(); case HelpWidth: return helpImage(metric(TitleHeight,wd))->width(); case MaximizeWidth: return maximizeImage(metric(TitleHeight,wd))->width(); case CornerGrabSize: return 16; } return 0; } void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const { int th = metric( TitleHeight, wd ); QRect r = wd->rect; switch ( a ) { case Border: { const QColorGroup &cg = wd->palette.active(); qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), r.y()-th-metric(TopBorder,wd), r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), cg, FALSE, &cg.brush(QColorGroup::Background)); } break; case Title: { const QColorGroup &cg = wd->palette.active(); |