From 4911fdce81510fd136254395de437ef0e120a5a7 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Sun, 2 Sep 2007 18:32:13 +0000 Subject: [PATCH] Use the generic paintText() method svn path=/trunk/KDE/kdebase/workspace/; revision=707702 --- effects/boxswitch.cpp | 63 +++++-------------------------------------- effects/boxswitch.h | 6 ----- 2 files changed, 6 insertions(+), 63 deletions(-) diff --git a/effects/boxswitch.cpp b/effects/boxswitch.cpp index dd5681bdc6..c9ce83e5d4 100644 --- a/effects/boxswitch.cpp +++ b/effects/boxswitch.cpp @@ -91,7 +91,9 @@ void BoxSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da paintWindowThumbnail( w ); paintWindowIcon( w ); } - paintText( text_area, selected_window->caption()); + int maxwidth = text_area.width(); + QColor color = KColorScheme( KColorScheme::Window ).foreground(); + effects->paintText( selected_window->caption(), text_area.center(), maxwidth, color ); } else { @@ -108,7 +110,9 @@ void BoxSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da paintDesktopThumbnail( painting_desktop ); } - paintText( text_area, effects->desktopName( selected_desktop )); + int maxwidth = text_area.width(); + QColor color = KColorScheme( KColorScheme::Window ).foreground(); + effects->paintText( effects->desktopName( selected_desktop ), text_area.center(), maxwidth, color ); painting_desktop = 0; } } @@ -615,59 +619,4 @@ void BoxSwitchEffect::paintWindowIcon( EffectWindow* w ) #endif } -void BoxSwitchEffect::paintText( QRect area, QString text ) - { - QPainter p; - - textPixmap = QPixmap( area.width(), area.height()); - textPixmap.fill( Qt::transparent ); - - p.begin( &textPixmap ); - p.setRenderHint( QPainter::TextAntialiasing ); - p.setPen( KColorScheme( KColorScheme::Window ).foreground()); - p.drawText( 0, 0, textPixmap.width(), textPixmap.height(), - Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingleLine, - p.fontMetrics().elidedText( text, Qt::ElideMiddle, textPixmap.width())); - p.end(); - -#ifdef HAVE_OPENGL - if( effects->compositingType() == OpenGLCompositing ) - { - textTexture.load( textPixmap, GL_TEXTURE_RECTANGLE_ARB ); - glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT ); - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - textTexture.bind(); - const float verts[ 4 * 2 ] = - { - area.x(), area.y(), - area.x(), area.y() + area.height(), - area.x() + area.width(), area.y() + area.height(), - area.x() + area.width(), area.y() - }; - const float texcoords[ 4 * 2 ] = - { - 0, textPixmap.height(), - 0, 0, - textPixmap.width(), 0, - textPixmap.width(), textPixmap.height() - }; - renderGLGeometry( 4, verts, texcoords ); - textTexture.unbind(); - glPopAttrib(); - } -#endif -#ifdef HAVE_XRENDER - if( effects->compositingType() == XRenderCompositing ) - { - if( textPicture != None ) - XRenderFreePicture( display(), textPicture ); - textPicture = XRenderCreatePicture( display(), textPixmap.handle(), alphaFormat, 0, NULL ); - XRenderComposite( display(), textPixmap.depth() == 32 ? PictOpOver : PictOpSrc, - textPicture, None, effects->xrenderBufferPicture(), - 0, 0, 0, 0, area.x(), area.y(), area.width(), area.height()); - } -#endif - } - } // namespace diff --git a/effects/boxswitch.h b/effects/boxswitch.h index 7f9c7e648e..6824b3a443 100644 --- a/effects/boxswitch.h +++ b/effects/boxswitch.h @@ -59,7 +59,6 @@ class BoxSwitchEffect void paintWindowThumbnail( EffectWindow* w ); void paintDesktopThumbnail( int iDesktop ); void paintWindowIcon( EffectWindow* w ); - void paintText( QRect area, QString text ); bool mActivated; Window mInput; @@ -70,7 +69,6 @@ class BoxSwitchEffect int highlight_margin; // TODO graphical background QSize item_max_size; // maximum item display size (including highlight) QRect text_area; - QPixmap textPixmap; QHash< EffectWindow*, ItemInfo* > windows; EffectWindowList original_windows; @@ -81,12 +79,8 @@ class BoxSwitchEffect int painting_desktop; -#ifdef HAVE_OPENGL - GLTexture textTexture; -#endif #ifdef HAVE_XRENDER XRenderPictFormat* alphaFormat; - Picture textPicture; #endif };