Use the generic paintText() method

svn path=/trunk/KDE/kdebase/workspace/; revision=707702
icc-effect-5.14.5
Rivo Laks 2007-09-02 18:32:13 +00:00
parent d618ba8d23
commit 4911fdce81
2 changed files with 6 additions and 63 deletions

View File

@ -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

View File

@ -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
};