void KdmRect::drawContents( TQPainter *p, const TQRect &r ) { // choose the correct rect class RectStruct::RectClass *rClass = &rect.normal; if (state == Sactive && rect.active.present) { rClass = &rect.active; } if (state == Sprelight && rect.prelight.present) { rClass = &rect.prelight; } if (rClass->alpha <= 0 || !rClass->color.isValid()) { return; } if (rClass->alpha == 1) { p->fillRect( area, TQBrush( rClass->color ) ); } else { // if (!argb_visual_available) { // Software blend only (no compositing support) TQRect backRect = r; backRect.moveBy( area.x(), area.y() ); TQPixmap backPixmap( backRect.size() ); bitBlt( &backPixmap, TQPoint( 0, 0 ), p->device(), backRect ); TQImage backImage = backPixmap.convertToImage(); KImageEffect::blend( rClass->color, backImage, rClass->alpha ); p->drawImage( backRect.x(), backRect.y(), backImage ); // area.moveBy(1,1); // } // else { // // We have compositing support! // } } }
bool Manager::animateMinimize(bool iconify) { int style = Static::instance()->animationStyle(); switch (style) { case 1: { // Double twisting double back, with pike ;) if (!iconify) // No animation for restore. return true; // Go away quick. helperShowHide(false); tqApp->syncX(); TQRect r = iconGeometry(); if (!r.isValid()) return true; // Algorithm taken from Window Maker (http://www.windowmaker.org) int sx = geometry().x(); int sy = geometry().y(); int sw = width(); int sh = height(); int dx = r.x(); int dy = r.y(); int dw = r.width(); int dh = r.height(); double steps = 12; double xstep = double((dx-sx)/steps); double ystep = double((dy-sy)/steps); double wstep = double((dw-sw)/steps); double hstep = double((dh-sh)/steps); double cx = sx; double cy = sy; double cw = sw; double ch = sh; double finalAngle = 3.14159265358979323846; double delta = finalAngle / steps; TQPainter p(workspaceWidget()); p.setRasterOp(TQt::NotROP); for (double angle = 0; ; angle += delta) { if (angle > finalAngle) angle = finalAngle; double dx = (cw / 10) - ((cw / 5) * sin(angle)); double dch = (ch / 2) * cos(angle); double midy = cy + (ch / 2); TQPoint p1(int(cx + dx), int(midy - dch)); TQPoint p2(int(cx + cw - dx), p1.y()); TQPoint p3(int(cx + dw + dx), int(midy + dch)); TQPoint p4(int(cx - dx), p3.y()); grabXServer(); p.drawLine(p1, p2); p.drawLine(p2, p3); p.drawLine(p3, p4); p.drawLine(p4, p1); p.flush(); usleep(500); p.drawLine(p1, p2); p.drawLine(p2, p3); p.drawLine(p3, p4); p.drawLine(p4, p1); ungrabXServer(); cx += xstep; cy += ystep; cw += wstep; ch += hstep; if (angle >= finalAngle) break; } } break; case 2: { // KVirc style ? Maybe. For qwertz. if (!iconify) // No animation for restore. return true; // Go away quick. helperShowHide(false); tqApp->syncX(); int stepCount = 12; TQRect r(geometry()); int dx = r.width() / (stepCount * 2); int dy = r.height() / (stepCount * 2); TQPainter p(workspaceWidget()); p.setRasterOp(TQt::NotROP); for (int step = 0; step < stepCount; step++) { r.moveBy(dx, dy); r.setWidth(r.width() - 2 * dx); r.setHeight(r.height() - 2 * dy); grabXServer(); p.drawRect(r); p.flush(); usleep(200); p.drawRect(r); ungrabXServer(); } } break; default: { TQRect icongeom = iconGeometry(); if (!icongeom.isValid()) return true; TQRect wingeom = geometry(); TQPainter p(workspaceWidget()); p.setRasterOp(TQt::NotROP); #if 0 if (iconify) p.setClipRegion(TQRegion(workspaceWidget()->rect()) - wingeom); #endif grabXServer(); p.drawLine(wingeom.bottomRight(), icongeom.bottomRight()); p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft()); p.drawLine(wingeom.topLeft(), icongeom.topLeft()); p.drawLine(wingeom.topRight(), icongeom.topRight()); p.flush(); tqApp->syncX(); usleep(30000); p.drawLine(wingeom.bottomRight(), icongeom.bottomRight()); p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft()); p.drawLine(wingeom.topLeft(), icongeom.topLeft()); p.drawLine(wingeom.topRight(), icongeom.topRight()); ungrabXServer(); } break; } return true; }
void NextClient::paintEvent( TQPaintEvent* ) { TQPainter p(widget()); // Draw black frame TQRect fr = widget()->rect(); p.setPen(TQt::black); p.drawRect(fr); // Draw title bar TQRect t = titlebar->tqgeometry(); t.setTop(1); p.drawTiledPixmap(t.x()+1, t.y()+1, t.width()-2, t.height()-2, isActive() ? *aTitlePix : *iTitlePix); qDrawShadePanel(&p, t.x(), t.y(), t.width(), t.height()-1, options()->tqcolorGroup(KDecoration::ColorTitleBar, isActive())); p.drawLine(t.x(), t.bottom(), t.right(), t.bottom()); #if 0 // Why setting up a clipping region if it is not used? (setClipping(false)) TQRegion r = fr; r = r.subtract( t ); p.setClipRegion( r ); p.setClipping(false); #endif t.setTop( 1 ); t.setHeight(t.height()-2); t.setLeft( t.left() + 4 ); t.setRight( t.right() - 2 ); p.setPen(options()->color(KDecoration::ColorFont, isActive())); p.setFont(options()->font(isActive())); p.drawText( t, AlignCenter | AlignVCenter, caption() ); // Draw resize handle if (mustDrawHandle()) { int corner = 16 + 3*handleSize/2; qDrawShadePanel(&p, fr.x() + 1, fr.bottom() - handleSize, corner-1, handleSize, options()->tqcolorGroup(KDecoration::ColorHandle, isActive()), false); p.drawTiledPixmap(fr.x() + 2, fr.bottom() - handleSize + 1, corner - 3, handleSize - 2, isActive() ? *aHandlePix : *iHandlePix); qDrawShadePanel(&p, fr.x() + corner, fr.bottom() - handleSize, fr.width() - 2*corner, handleSize, options()->tqcolorGroup(KDecoration::ColorFrame, isActive()), false); p.drawTiledPixmap(fr.x() + corner + 1, fr.bottom() - handleSize + 1, fr.width() - 2*corner - 2, handleSize - 2, isActive() ? *aFramePix : *iFramePix); qDrawShadePanel(&p, fr.right() - corner + 1, fr.bottom() - handleSize, corner - 1, handleSize, options()->tqcolorGroup(KDecoration::ColorHandle, isActive()), false); p.drawTiledPixmap(fr.right() - corner + 2, fr.bottom() - handleSize + 1, corner - 3, handleSize - 2, isActive() ? *aHandlePix : *iHandlePix); } }