author | sandman <sandman> | 2002-11-24 18:30:51 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-24 18:30:51 (UTC) |
commit | 1b2c3ce0d94f033e8ffe1aa8575b210cdfb3c1ec (patch) (side-by-side diff) | |
tree | d816c0e06c067403b6e75515a27dde632ebb88a8 | |
parent | d6b3ed253bf86b63bb7a805cfea93b8d489135d1 (diff) | |
download | opie-1b2c3ce0d94f033e8ffe1aa8575b210cdfb3c1ec.zip opie-1b2c3ce0d94f033e8ffe1aa8575b210cdfb3c1ec.tar.gz opie-1b2c3ce0d94f033e8ffe1aa8575b210cdfb3c1ec.tar.bz2 |
Valgrind complaint
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index c8f8d20..daac22c 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp @@ -1,374 +1,375 @@ /*- * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. */ // // (c) 2002 Robert 'sandman' Griebl // #ifndef INCLUDE_MENUITEM_DEF #define INCLUDE_MENUITEM_DEF #endif #include <qmenudata.h> #include "liquid.h" //#include "liquiddeco.h" #include <qapplication.h> #include <qpe/config.h> #include "effects.h" #include <qpalette.h> #include <qbitmap.h> #include <qtabbar.h> #include <qpopupmenu.h> #include <qobjectlist.h> #include <qimage.h> #include <qtimer.h> #include <qpixmapcache.h> #include <qradiobutton.h> #include <qcombobox.h> #include <qdrawutil.h> #include <qwidgetlist.h> #include <qtoolbutton.h> #include <qheader.h> #include <unistd.h> #include <qmenubar.h> #include <qprogressbar.h> #include <qlineedit.h> #include <stdio.h> #include "htmlmasks.h" #include "embeddata.h" typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) { QImage img(pix.convertToImage()); QImageEffect::fade(img, 0.9, color); int x, y; int r, g, b; for(y=0; y < img.height(); y+=3){ unsigned int *data = (unsigned int *) img.scanLine(y); for(x=0; x < img.width(); ++x){ r = qRed(data[x]); g = qGreen(data[x]); b = qBlue(data[x]); if(r-10) r-=10; if(g-10) g-=10; if(b-10) b-=10; data[x] = qRgb(r, g, b); } } pix.convertFromImage(img); } TransMenuHandler::TransMenuHandler(QObject *parent) : QObject(parent) { pixDict.setAutoDelete(true); reloadSettings(); } void TransMenuHandler::reloadSettings() { pixDict.clear(); Config config ( "qpe" ); config. setGroup ( "Liquid-Style" ); type = config. readNumEntry("Type", TransStippleBg); color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); opacity = config. readNumEntry("Opacity", 10); if ( opacity < -20 ) opacity = 20; else if ( opacity > 20 ) opacity = 20; shadowText = config. readBoolEntry("ShadowText", true); } bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) { QWidget *p = (QWidget *)obj; if(ev->type() == QEvent::Show){ if(type == TransStippleBg || type == TransStippleBtn || type == Custom){ QApplication::syncX(); QPixmap *pix = new QPixmap; if(p->testWFlags(Qt::WType_Popup)){ QRect r(p->x(), p->y(), p->width(), p->height()); QRect deskR = QApplication::desktop()->rect(); if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ r.setBottom(deskR.bottom()); r.setRight(deskR.right()); } *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), r.width(), r.height()); } else{ // tear off menu pix->resize(p->width(), p->height()); pix->fill(Qt::black.rgb()); } if(type == TransStippleBg){ stripePixmap(*pix, p->colorGroup().background()); } else if(type == TransStippleBtn){ stripePixmap(*pix, p->colorGroup().button()); } else{ QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); } pixDict.insert(p->winId(), pix); if ( !p->inherits("QPopupMenu")) p->setBackgroundPixmap(*pix); QObjectList *ol = p-> queryList("QWidget"); for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { QWidget *wid = (QWidget *) it.current ( ); wid-> setBackgroundPixmap(*pix); wid-> setBackgroundOrigin(QWidget::ParentOrigin); } delete ol; } } else if(ev->type() == QEvent::Hide){ if(type == TransStippleBg || type == TransStippleBtn || type == Custom){ // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); pixDict.remove(p->winId()); if ( !p->inherits("QPopupMenu")) p->setBackgroundMode(QWidget::PaletteBackground); QObjectList *ol = p-> queryList("QWidget"); for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { QWidget *wid = (QWidget *) it.current ( ); wid-> setBackgroundMode( QWidget::PaletteBackground ); } delete ol; } } return(false); } static int qt_version ( ) { const char *qver = qVersion ( ); return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); } LiquidStyle::LiquidStyle() :QWindowsStyle() { setName ( "LiquidStyle" ); oldqte = ( qt_version ( ) < 234 ); flatTBButtons = false; + currentHeader = 0; btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); btnMaskBmp.setMask(btnMaskBmp); htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); headerHoverID = -1; highlightWidget = NULL; setButtonDefaultIndicatorWidth(0); btnDict.setAutoDelete(true); bevelFillDict.setAutoDelete(true); smallBevelFillDict.setAutoDelete(true); rMatrix.rotate(270.0); btnBorderPix = new QPixmap; btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); btnBlendPix = new QPixmap; btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); bevelFillPix = new QPixmap; bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); smallBevelFillPix = new QPixmap; smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); // new stuff vsbSliderFillPix = menuPix = NULL; menuHandler = new TransMenuHandler(this); setScrollBarExtent(15, 15); int i; for(i=0; i < BITMAP_ITEMS; ++i){ pixmaps[i] = NULL; } oldSliderThickness = sliderThickness(); setSliderThickness(11); } LiquidStyle::~LiquidStyle() { if(btnBorderPix) delete btnBorderPix; if(btnBlendPix) delete btnBlendPix; if(bevelFillPix) delete bevelFillPix; if(smallBevelFillPix) delete smallBevelFillPix; if(vsbSliderFillPix) delete vsbSliderFillPix; if(menuPix) delete menuPix; setScrollBarExtent(16, 16); setSliderThickness(oldSliderThickness); int i; for(i=0; i < BITMAP_ITEMS; ++i){ if(pixmaps[i]) delete pixmaps[i]; } } void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, const QColor &c, const QColor &bg) { QPen oldPen = p->pen(); // headers need this int x2 = x+w-1; int y2 = y+h-1; // outer dark rect p->setPen(c.dark(130)); p->drawLine(x, y+2, x, y2-2); // l p->drawLine(x2, y+2, x2, y2-2); // r p->drawLine(x+2, y, x2-2, y); // t p->drawLine(x+2, y2, x2-2, y2); // b p->drawPoint(x+1, y+1); // tl p->drawPoint(x2-1, y+1); // tr p->drawPoint(x+1, y2-1); // bl p->drawPoint(x2-1, y2-1); // br // inner top light lines p->setPen(c.light(105)); p->drawLine(x+2, y+1, x2-2, y+1); p->drawLine(x+1, y+2, x2-1, y+2); p->drawLine(x+1, y+3, x+2, y+3); p->drawLine(x2-2, y+3, x2-1, y+3); p->drawPoint(x+1, y+4); p->drawPoint(x2-1, y+4); // inner bottom light lines p->setPen(c.light(110)); p->drawLine(x+2, y2-1, x2-2, y2-1); p->drawLine(x+1, y2-2, x2-1, y2-2); p->drawLine(x+1, y2-3, x+2, y2-3); p->drawLine(x2-2, y2-3, x2-1, y2-3); p->drawPoint(x+1, y2-4); p->drawPoint(x2-1, y2-4); // inner left mid lines //p->setPen(c.light(105)); p->setPen(c); p->drawLine(x+1, y+5, x+1, y2-5); p->drawLine(x+2, y+4, x+2, y2-4); // inner right mid lines p->drawLine(x2-1, y+5, x2-1, y2-5); p->drawLine(x2-2, y+4, x2-2, y2-4); // fill QPixmap *pix; if(h >= 32){ pix = bevelFillDict.find(c.rgb()); if(!pix){ int h, s, v; c.hsv(&h, &s, &v); pix = new QPixmap(*bevelFillPix); adjustHSV(*pix, h, s, v); bevelFillDict.insert(c.rgb(), pix); } } else{ pix = smallBevelFillDict.find(c.rgb()); if(!pix){ int h, s, v; c.hsv(&h, &s, &v); pix = new QPixmap(*smallBevelFillPix); adjustHSV(*pix, h, s, v); smallBevelFillDict.insert(c.rgb(), pix); } } p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); // blend int red, green, blue; QColor btnColor(c.dark(130)); red = (btnColor.red() >> 1) + (bg.red() >> 1); green = (btnColor.green() >> 1) + (bg.green() >> 1); blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); btnColor.setRgb(red, green, blue); p->setPen(btnColor); p->drawPoint(x+1, y); p->drawPoint(x, y+1); p->drawPoint(x+1, y2); p->drawPoint(x, y2-1); p->drawPoint(x2-1, y); p->drawPoint(x2, y+1); p->drawPoint(x2-1, y2); p->drawPoint(x2, y2-1); p->setPen(oldPen); } void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, const QColor &back, int x, int y, int w, int h, bool supportPushDown, bool pushedDown, bool autoDefault, bool isMasked) { if(w < 21 || h < 21){ drawClearBevel(painter, x, y, w, h, c, back); return; } if(supportPushDown){ --w, --h; } /* We don't make the round buttons smaller, since they don't look as good if(autoDefault){ w = w-buttonDefaultIndicatorWidth()*2; h = h-buttonDefaultIndicatorWidth()*2; }*/ QPixmap *pix = btnDict.find(c.rgb()); if(!pix){ int h, s, v; c.hsv(&h, &s, &v); pix = new QPixmap(*btnBorderPix); adjustHSV(*pix, h, s, v); btnDict.insert(c.rgb(), pix); } int x2 = x+w-1; int y2 = y+h-1; int bx2 = pix->width()-1; int by2 = pix->height()-1; QPixmap tmpPix(w, h); QPixmap tilePix; QPainter p; p.begin(&tmpPix); // do the fill p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br |