-rw-r--r-- | noncore/styles/flat/flat.cpp | 18 | ||||
-rw-r--r-- | noncore/styles/fresh/fresh.cpp | 18 | ||||
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 129 | ||||
-rw-r--r-- | noncore/styles/phase/phasestyle.cpp | 14 | ||||
-rw-r--r-- | noncore/styles/theme/othemestyle.cpp | 53 | ||||
-rw-r--r-- | noncore/styles/web/webstyle.cpp | 126 | ||||
-rw-r--r-- | noncore/styles/web/webstyle.h | 2 |
7 files changed, 252 insertions, 108 deletions
diff --git a/noncore/styles/flat/flat.cpp b/noncore/styles/flat/flat.cpp index f3bacf9..c164ecc 100644 --- a/noncore/styles/flat/flat.cpp +++ b/noncore/styles/flat/flat.cpp @@ -373,7 +373,7 @@ void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && btn->hasFocus() ) mode = QIconSet::Active; - QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); + QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Automatic, mode ); int pixw = pixmap.width(); int pixh = pixmap.height(); p->drawPixmap( x+2, y+h/2-pixh/2, pixmap ); @@ -391,8 +391,8 @@ QRect FlatStyle::comboButtonRect( int x, int y, int w, int h) { return QRect(x+2, y+2, w-4-13, h-4); } - - + + QRect FlatStyle::comboButtonFocusRect( int x, int y, int w, int h) { return QRect(x+2, y+2, w-4-14, h-4); @@ -892,7 +892,7 @@ int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* m */ int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) { -#ifndef QT_NO_MENUDATA +#ifndef QT_NO_MENUDATA int h = 0; if ( mi->isSeparator() ) // separator height h = motifSepHeight; @@ -902,7 +902,7 @@ int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFo h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; if ( !mi->isSeparator() && mi->iconSet() != 0 ) { - h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); + h = QMAX( h, mi->iconSet()->pixmap().height() + 2*motifItemFrame ); } if ( mi->custom() ) h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; @@ -914,7 +914,7 @@ void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int const QPalette& pal, bool act, bool enabled, int x, int y, int w, int h) { -#ifndef QT_NO_MENUDATA +#ifndef QT_NO_MENUDATA const QColorGroup & g = pal.active(); bool dis = !enabled; QColorGroup itemg = dis ? pal.disabled() : pal.active(); @@ -954,7 +954,11 @@ void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; if (act && !dis ) mode = QIconSet::Active; - QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode ); + QPixmap pixmap; + if ( mode == QIconSet::Disabled ) + pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = mi->iconSet()->pixmap(); int pixw = pixmap.width(); int pixh = pixmap.height(); if ( act && !dis ) { diff --git a/noncore/styles/fresh/fresh.cpp b/noncore/styles/fresh/fresh.cpp index 831b620..856f68b 100644 --- a/noncore/styles/fresh/fresh.cpp +++ b/noncore/styles/fresh/fresh.cpp @@ -147,8 +147,8 @@ QRect FreshStyle::comboButtonRect( int x, int y, int w, int h) { return QRect(x+1, y+1, w-2-14, h-2); } - - + + QRect FreshStyle::comboButtonFocusRect( int x, int y, int w, int h) { return QRect(x+2, y+2, w-4-14, h-4); @@ -528,7 +528,7 @@ void FreshStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected tb->colorGroup().brush( QColorGroup::Button )); //do shading; will not work for pixmap brushes - QColor bg = tb->colorGroup().button(); + QColor bg = tb->colorGroup().button(); // int h,s,v; // bg.hsv( &h, &s, &v ); int n = r.height()/2; @@ -638,7 +638,7 @@ int FreshStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* */ int FreshStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) { -#ifndef QT_NO_MENUDATA +#ifndef QT_NO_MENUDATA int h = 0; if ( mi->isSeparator() ) // separator height h = motifSepHeight; @@ -648,7 +648,7 @@ int FreshStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QF h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; if ( !mi->isSeparator() && mi->iconSet() != 0 ) { - h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); + h = QMAX( h, mi->iconSet()->pixmap().height() + 2*motifItemFrame ); } if ( mi->custom() ) h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; @@ -660,7 +660,7 @@ void FreshStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int const QPalette& pal, bool act, bool enabled, int x, int y, int w, int h) { -#ifndef QT_NO_MENUDATA +#ifndef QT_NO_MENUDATA const QColorGroup & g = pal.active(); bool dis = !enabled; QColorGroup itemg = dis ? pal.disabled() : pal.active(); @@ -702,7 +702,11 @@ void FreshStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; if (act && !dis ) mode = QIconSet::Active; - QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode ); + QPixmap pixmap; + if ( mode == QIconSet::Disabled ) + pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = mi->iconSet()->pixmap(); int pixw = pixmap.width(); int pixh = pixmap.height(); if ( act && !dis ) { diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index 51814e7..77cf198 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp @@ -3,7 +3,7 @@ */ // -// (c) 2002 Robert 'sandman' Griebl +// (c) 2002 Robert 'sandman' Griebl // @@ -12,7 +12,7 @@ #endif #include "liquid.h" -#include "effects.h" +#include "effects.h" #include "htmlmasks.h" #include "embeddata.h" @@ -99,7 +99,7 @@ void TransMenuHandler::reloadSettings() opacity = 20; else if ( opacity > 20 ) opacity = 20; - + shadowText = config. readBoolEntry("ShadowText", true); } @@ -137,16 +137,16 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) } pixDict.insert(p->winId(), pix); - - if ( !p->inherits("QPopupMenu")) + + 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); + wid-> setBackgroundOrigin(QWidget::ParentOrigin); } delete ol; } @@ -154,16 +154,16 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) else if(ev->type() == QEvent::Hide){ if(type == TransStippleBg || type == TransStippleBtn || type == Custom){ -// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl; +// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl; pixDict.remove(p->winId()); - if ( !p->inherits("QPopupMenu")) + 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; @@ -173,7 +173,7 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) } - + LiquidStyle::LiquidStyle() :QWindowsStyle() @@ -499,7 +499,7 @@ QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, QImage img(qembed_findImage(label)); img.detach(); if(img.isNull()){ // shouldn't happen, been tested - owarn << "Invalid embedded label " << label << "" << oendl; + owarn << "Invalid embedded label " << label << "" << oendl; return(NULL); } if(img.depth() != 32) @@ -599,10 +599,10 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item) break; case TabDown: pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/); - break; + break; case TabFocus: pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/); - break; + break; case CB: pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/); @@ -801,16 +801,16 @@ void LiquidStyle::polish(QWidget *w) } if(w->inherits("QPopupMenu")) w->setBackgroundMode(QWidget::NoBackground); - else if(w-> testWFlags(Qt::WType_Popup) && - !w->inherits("QListBox") && + else if(w-> testWFlags(Qt::WType_Popup) && + !w->inherits("QListBox") && ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { w->installEventFilter(menuHandler); } - + if(w->isTopLevel()){ return; } - + if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) { w->installEventFilter(this); } @@ -865,7 +865,7 @@ void LiquidStyle::polish(QWidget *w) if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> palette().active().brush(QColorGroup::Background).pixmap()){ - owarn << "No parent pixmap for child widget " << w->className() << "" << oendl; + owarn << "No parent pixmap for child widget " << w->className() << "" << oendl; return; } if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && @@ -878,7 +878,7 @@ void LiquidStyle::polish(QWidget *w) } } if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) - w-> setBackgroundOrigin ( QWidget::ParentOrigin ); + w-> setBackgroundOrigin ( QWidget::ParentOrigin ); else if ( w-> inherits("QFrame") ) w->setBackgroundOrigin ( QWidget::WidgetOrigin ); @@ -897,7 +897,7 @@ void LiquidStyle::unPolish(QWidget *w) if(w->inherits("QPopupMenu")) w->setBackgroundMode(QWidget::PaletteButton); - else if(w-> testWFlags(Qt::WType_Popup) && + else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox") && ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { w->removeEventFilter(menuHandler); @@ -959,15 +959,15 @@ void LiquidStyle::polish(QApplication *app) app->setEffectEnabled(UI_AnimateMenu, false); if(menuFade) app->setEffectEnabled(UI_FadeMenu, false); - + qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); - + Config config ( "qpe" ); config. setGroup ( "Liquid-Style" ); - -// if ( config. readBoolEntry ( "WinDecoration", true )) + +// if ( config. readBoolEntry ( "WinDecoration", true )) // QApplication::qwsSetDecoration ( new LiquidDecoration ( )); - + flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); } @@ -978,26 +978,26 @@ void LiquidStyle::unPolish(QApplication *app) app->setEffectEnabled(UI_FadeMenu, menuFade); qt_set_draw_menu_bar_impl ( 0 ); - + // QApplication::qwsSetDecoration ( new QPEDecoration ( )); } /* !! HACK !! Beware - * + * * TT forgot to make the QProgressBar widget styleable in Qt 2.x - * So the only way to customize the drawing, is to intercept the + * So the only way to customize the drawing, is to intercept the * paint event - since we have to use protected functions, we need * to derive a "hack" class from QProgressBar and do the painting * in there. - * + * * - sandman */ class HackProgressBar : public QProgressBar { public: HackProgressBar ( ); - + void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix ) { QPainter p( this ); @@ -1031,8 +1031,8 @@ public: if(bw >= 4 && h >= 4 && pix) p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); - - if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { + + if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { QString pstr; pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); p. setPen ( g.text());//g.highlightedText ( )); @@ -1054,7 +1054,7 @@ public: class HackToolButton : public QToolButton { public: HackToolButton ( ); - + void paint ( QPaintEvent *ev ) { erase ( ev-> region ( )); @@ -1098,7 +1098,7 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) } else if(obj->inherits("QToolButton")){ QToolButton *btn = (QToolButton *)obj; - if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () + if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () if(btn->isEnabled()){ highlightWidget = btn; btn->repaint(false); @@ -1138,7 +1138,7 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); } */ - int x = 0; + int x = 0; int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; if(isRadio) drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), @@ -1193,7 +1193,7 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) if ( ev->type() == QEvent::Paint ) { HackProgressBar *p = (HackProgressBar *) obj; const QColorGroup &g = p-> colorGroup ( ); - + QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); if(!pix){ int h, s, v; @@ -1203,9 +1203,9 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) bevelFillDict.insert(g.button().dark(120).rgb(), pix); } p-> paint ((QPaintEvent *) ev, g, pix ); - return true; + return true; } - } + } return false ; } @@ -1303,7 +1303,11 @@ void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && btn->hasFocus() ) mode = QIconSet::Active; - QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); + QPixmap pixmap; + if ( mode == QIconSet::Disabled ) + pixmap = btn->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = btn->iconSet()->pixmap(); int pixw = pixmap.width(); int pixh = pixmap.height(); @@ -1311,7 +1315,7 @@ void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) x1 += pixw + 8; w -= pixw + 8; } - + if(act){ QFont font = btn->font(); font.setBold(true); @@ -1405,7 +1409,7 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, ( qApp-> focusWidget ( ) == painter-> device ( )) || ( edit && - ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) && + ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) && ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) || qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( )) ) @@ -1413,11 +1417,11 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, ) { isActive = true; } - + bool isMasked = false; if(painter->device()->devType() == QInternal::Widget) isMasked = ((QWidget*)painter->device())->autoMask(); - // TODO: Do custom code, don't just call drawRoundButton into a pixmap + // TODO: Do custom code, don't just call drawRoundButton into a pixmap QPixmap tmpPix(w, h); QPainter p(&tmpPix); @@ -1478,7 +1482,7 @@ QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { return QRect ( ); - + // return(QRect(x+5, y+3, w-(h/3)-13, h-5)); } @@ -1633,14 +1637,14 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, *getPixmap(HSBSliderTop)); painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, 13, *getPixmap(HSBSliderMid)); - painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, + painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, *getPixmap(HSBSliderBtm)); } else if(sliderR.width() >= 8){ int m = sliderR.width()/2; painter.drawPixmap(sliderR.x(), sliderR.y()+1, *getPixmap(HSBSliderTop), 0, 0, m, 13); - painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, + painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); } else{ @@ -1648,7 +1652,7 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, sliderR.width(), 13); painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, - sliderR.width()-2, 11, + sliderR.width()-2, 11, *getPixmap(HSBSliderMid), 0, 1); } } @@ -1976,18 +1980,18 @@ void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x, void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) -{ +{ if(active){ - x -= 2; // Bug in Qt/E + x -= 2; // Bug in Qt/E y -= 2; w += 2; h += 2; } - + QWidget *parent = (QWidget *)p->device(); p->setBrushOrigin(parent->pos()); parent->erase(x, y, w, h); - + if(menuHandler->useShadowText()){ QColor shadow; if(p->device() && p->device()->devType() == QInternal::Widget && @@ -1999,7 +2003,7 @@ void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, shadow = g.background().dark(130); QPixmap *dummy = 0; - + if ( mi-> pixmap ( ) && !mi-> pixmap ( )-> isNull ( )) { dummy = new QPixmap ( mi-> pixmap ( )-> size ( )); QBitmap dummy_mask ( dummy-> size ( )); @@ -2155,7 +2159,11 @@ static const int windowsRightBorder = 12; QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; if (!dis) mode = QIconSet::Active; - QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); + QPixmap pixmap; + if ( mode == QIconSet::Disabled ) + pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = mi->iconSet()->pixmap(); int pixw = pixmap.width(); int pixh = pixmap.height(); QRect cr(x, y, checkcol, h); @@ -2236,8 +2244,7 @@ int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, h = mi->pixmap()->height(); if (mi->iconSet()) - h = QMAX(mi->iconSet()-> - pixmap(QIconSet::Small, QIconSet::Normal).height(), h); + h = QMAX(mi->iconSet()->pixmap().height(), h); h = QMAX(fm.height() + 4, h); @@ -2430,7 +2437,7 @@ void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h, p->setPen(g.mid()); p->drawLine(x, y, x2, y); p->drawLine(x, y, x, y2); - + p->setPen(g.midlight()); p->drawLine(x+1, y2-1, x2-1, y2-1); p->drawLine(x2-1, y+1, x2-1, y2-1); @@ -2488,11 +2495,11 @@ void LiquidStyle::intensity(QPixmap &pix, float percent) image.numColors(); unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : (unsigned int *)image.colorTable(); - + bool brighten = (percent >= 0); if(percent < 0) percent = -percent; - + if(brighten){ // keep overflow check out of loops for(i=0; i < segColors; ++i){ tmp = (int)(i*percent); @@ -2509,7 +2516,7 @@ void LiquidStyle::intensity(QPixmap &pix, float percent) segTbl[i] = tmp; } } - + if(brighten){ // same here for(i=0; i < pixels; ++i){ r = qRed(data[i]); diff --git a/noncore/styles/phase/phasestyle.cpp b/noncore/styles/phase/phasestyle.cpp index 746354e..c2b9de8 100644 --- a/noncore/styles/phase/phasestyle.cpp +++ b/noncore/styles/phase/phasestyle.cpp @@ -390,7 +390,10 @@ void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) { } #endif - pixmap = button->iconSet()->pixmap(QIconSet::Small, mode); + if ( mode == QIconSet::Disabled ) + pixmap = button->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = button->iconSet()->pixmap(); if (button->text().isEmpty() && !button->pixmap()) { painter->drawPixmap(x+w/2 - pixmap.width()/2, y+h/2 - pixmap.height()/2, pixmap); @@ -569,8 +572,7 @@ int PhaseStyle::popupMenuItemHeight ( bool , + ITEMVMARGIN*2 + ITEMFRAME*2 ); } if ( mi->iconSet() ) - h = QMAX(h, mi->iconSet()-> - pixmap(QIconSet::Small, QIconSet::Normal ).height() + h = QMAX(h, mi->iconSet()->pixmap().height() + ITEMFRAME*2 ); } @@ -661,7 +663,11 @@ void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable, mode = enabled ? QIconSet::Active : QIconSet::Disabled; else mode = enabled ? QIconSet::Normal : QIconSet::Disabled; - QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode ); + QPixmap pixmap; + if ( mode == QIconSet::Disabled ) + pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = mi->iconSet()->pixmap(); QRect pmrect(0, 0, pixmap.width(), pixmap.height() ); QRect cr(x, y, maxpmw, h ); pmrect.moveCenter( cr.center() ); diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp index 98e7253..106d206 100644 --- a/noncore/styles/theme/othemestyle.cpp +++ b/noncore/styles/theme/othemestyle.cpp @@ -37,20 +37,20 @@ QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); /* !! HACK !! Beware - * + * * TT forgot to make the QProgressBar widget styleable in Qt 2.x - * So the only way to customize the drawing, is to intercept the + * So the only way to customize the drawing, is to intercept the * paint event - since we have to use protected functions, we need * to derive a "hack" class from QProgressBar and do the painting * in there. - * + * * - sandman */ class HackProgressBar : public QProgressBar { public: HackProgressBar ( ); - + void paint ( QPaintEvent *event, OThemeStyle *style ) { QPainter p( this ); @@ -75,9 +75,9 @@ public: total = 1; int perc = prog * 100 / total; - style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc ); + style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc ); - if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) { + if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) { QString pstr; pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); p. setPen ( colorGroup().text());//g.highlightedText ( )); @@ -109,13 +109,13 @@ void OThemeStyle::polish( QApplication * /*app*/ ) void OThemeStyle::polish( QPalette &p ) { oldPalette = p; - + QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); if ( bgcolor. isValid ( )) bg = bgcolor; - if ( isColor ( Background )) + if ( isColor ( Background )) bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); p = QPalette ( bg, bg ); @@ -124,18 +124,18 @@ void OThemeStyle::polish( QPalette &p ) p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); if ( fgcolor. isValid ( )) { - p. setColor ( QColorGroup::Foreground, fgcolor ); + p. setColor ( QColorGroup::Foreground, fgcolor ); p. setColor ( QColorGroup::ButtonText, fgcolor ); } if ( selfgcolor. isValid ( )) - p. setColor ( QColorGroup::HighlightedText, selfgcolor ); + p. setColor ( QColorGroup::HighlightedText, selfgcolor ); if ( selbgcolor. isValid ( )) - p. setColor ( QColorGroup::Highlight, selbgcolor ); - if ( winfgcolor. isValid ( )) - p. setColor ( QColorGroup::Text, winfgcolor ); + p. setColor ( QColorGroup::Highlight, selbgcolor ); + if ( winfgcolor. isValid ( )) + p. setColor ( QColorGroup::Text, winfgcolor ); if ( winbgcolor. isValid ( )) - p. setColor ( QColorGroup::Base, winbgcolor ); - + p. setColor ( QColorGroup::Base, winbgcolor ); + } @@ -1183,7 +1183,7 @@ void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && btn->hasFocus() ) mode = QIconSet::Active; - QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode ); + QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Automatic, mode ); int pixw = pixmap.width(); int pixh = pixmap.height(); @@ -1246,8 +1246,7 @@ int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi, h = h2 > h ? h2 : h; } if ( mi->iconSet() ) { - h2 = mi->iconSet() -> - pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset; + h2 = mi->iconSet() ->pixmap().height() + offset; h = h2 > h ? h2 : h; } h2 = fm.height() + offset; @@ -1325,7 +1324,11 @@ void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; if ( act && !dis ) mode = QIconSet::Active; - QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); + QPixmap pixmap; + if ( mode == QIconSet::Disabled ) + pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = mi->iconSet()->pixmap(); int pixw = pixmap.width(); int pixh = pixmap.height(); QRect cr( x, y, checkcol, h ); @@ -1434,11 +1437,11 @@ void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, #endif void OThemeStyle::drawMenuBarItem( QPainter *p, int x, int y, int w, int h, - QMenuItem *mi, const QColorGroup &g, + QMenuItem *mi, const QColorGroup &g, bool /*enabled*/, bool active ) { if(active){ - x -= 2; // Bug in Qt/E + x -= 2; // Bug in Qt/E y -= 2; w += 2; h += 2; @@ -1464,11 +1467,11 @@ void OThemeStyle::drawProgressBar ( QPainter *p, int x, int y, int w, int h, con bg.setColor( cg->color( QColorGroup::Background ) ); if ( isPixmap( ProgressBg ) ) bg.setPixmap( *uncached( ProgressBg ) ); - + int pw = w * percent / 100; - - p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO - + + p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO + drawBaseButton( p, x, y, pw, h, *cg, false, false, ProgressBar ); } diff --git a/noncore/styles/web/webstyle.cpp b/noncore/styles/web/webstyle.cpp index cd3cf08..7b58d89 100644 --- a/noncore/styles/web/webstyle.cpp +++ b/noncore/styles/web/webstyle.cpp @@ -43,6 +43,15 @@ static int _savedFrameLineWidth; static int _savedFrameMidLineWidth; static ulong _savedFrameStyle; +static const int ITEMFRAME = 1; // menu stuff +static const int ITEMHMARGIN = 3; +static const int ITEMVMARGIN = 0; + +static const int ARROWMARGIN = 6; +static const int RIGHTBORDER = 10; +static const int MINICONSIZE = 12; + + static QColor contrastingForeground(const QColor & fg, const QColor & bg) { int h, s, vbg, vfg; @@ -969,7 +978,7 @@ WebStyle::drawPopupMenuItem QPainter * p, bool checkable, int maxpmw, - int tab, + int tabwidth, QMenuItem * mi, const QPalette & pal, bool act, @@ -981,7 +990,118 @@ WebStyle::drawPopupMenuItem ) { // TODO - QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h); + //QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h); + if ( !mi ) + return; + + QRect rect(x, y, w, h ); + int x2, y2; + x2 = rect.right(); + y2 = rect.bottom(); + const QColorGroup& g = pal.active(); + QColorGroup itemg = !enabled ? pal.disabled() : pal.active(); + + if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20); + + if (act && enabled ) + p->fillRect(x, y, w, h, g.highlight() ); + else + p->fillRect(x, y, w, h, g.background() ); + + // draw seperator + if (mi->isSeparator() ) { + p->setPen( g.dark() ); + p->drawLine( x+8, y+1, x+w-8, y+1 ); + + p->setPen( g.mid() ); + p->drawLine( x+8, y, x+w-8, y ); + p->drawPoint(x+w,y+1); + + p->setPen( g.midlight() ); + p->drawLine( x+8, y-1, x+w-8, y-1 ); + p->drawPoint(x+8, y ); + return; + } + + // draw icon + QIconSet::Mode mode; + if ( mi->iconSet() && !mi->isChecked() ) { + if ( act ) + mode = enabled ? QIconSet::Active : QIconSet::Disabled; + else + mode = enabled ? QIconSet::Normal : QIconSet::Disabled; + QPixmap pixmap; + if ( mode == QIconSet::Disabled ) + pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = mi->iconSet()->pixmap(); + QRect pmrect(0, 0, pixmap.width(), pixmap.height() ); + QRect cr(x, y, maxpmw, h ); + pmrect.moveCenter( cr.center() ); + p->drawPixmap(pmrect.topLeft(), pixmap); + } + + // draw check + if(mi->isChecked() ) { + drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled ); + } + + + // draw text + int xm = maxpmw + 2; + int xp = x + xm; + int tw = w -xm - 2; + + p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) : + g.mid() ); + + + if ( mi->custom() ) { + p->save(); + mi->custom()->paint(p, g, act, enabled, + xp, y+1, tw, h-2 ); + p->restore(); + }else { // draw label + QString text = mi->text(); + if (!text.isNull() ) { + int t = text.find('\t'); + const int tflags = AlignVCenter | DontClip | + ShowPrefix | SingleLine | + AlignLeft; + + if (t >= 0) { + int tabx = x + w - tabwidth - RIGHTBORDER - + ITEMHMARGIN - ITEMFRAME; + p->drawText(tabx, y+ITEMVMARGIN, tabwidth, + h-2*ITEMVMARGIN, tflags, + text.mid(t+1) ); + text = text.left(t ); + } + + // draw left label + p->drawText(xp, y+ITEMVMARGIN, + tw, h-2*ITEMVMARGIN, + tflags, text, t); + }else if ( mi->pixmap() ) { // pixmap as label + QPixmap pixmap = *mi->pixmap(); + if ( pixmap.depth() == 1 ) + p->setBackgroundMode( OpaqueMode ); + + int dx = ((w-pixmap.width() ) /2 ) + + ((w - pixmap.width()) %2 ); + p->drawPixmap(x+dx, y+ITEMFRAME, pixmap ); + + if ( pixmap.depth() == 1 ) + p->setBackgroundMode( TransparentMode ); + } + } + + if ( mi->popup() ) { // draw submenu arrow + int dim = (h-2*ITEMFRAME) / 2; + drawArrow( p, RightArrow, false, + x+w-ARROWMARGIN-ITEMFRAME-dim, + y+h/2-dim/2, dim, dim, g, enabled ); + } } void @@ -1168,7 +1288,7 @@ WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm) { h = QMAX ( - i->iconSet()->pixmap(QIconSet::Small, QIconSet::Normal).height(), + i->iconSet()->pixmap().height(), h ); } diff --git a/noncore/styles/web/webstyle.h b/noncore/styles/web/webstyle.h index 83ab784..d6f153b 100644 --- a/noncore/styles/web/webstyle.h +++ b/noncore/styles/web/webstyle.h @@ -215,7 +215,7 @@ class WebStyle : public QWindowsStyle { QPainter *, bool checkable, int maxpmw, - int tab, + int tabwidth, QMenuItem *, const QPalette &, bool act, |