author | sandman <sandman> | 2002-11-21 19:49:00 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-21 19:49:00 (UTC) |
commit | 440f1d4d439c83368a855355cdceda43660137f2 (patch) (side-by-side diff) | |
tree | 1b7ffd5157d2c141b9f978d08e47699ea2d013ff | |
parent | 0b0ebb03a1fc0a316b52ce147d87fa89d3b5af16 (diff) | |
download | opie-440f1d4d439c83368a855355cdceda43660137f2.zip opie-440f1d4d439c83368a855355cdceda43660137f2.tar.gz opie-440f1d4d439c83368a855355cdceda43660137f2.tar.bz2 |
- pixmaps in in menubars are now drawn (this is uncommon, but resulted in
blank icons in nethack for example)
- small size optimization
- updated the QPL diff
-rw-r--r-- | noncore/styles/liquid/embeddata.h | 2 | ||||
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 20 | ||||
-rw-r--r-- | noncore/styles/liquid/opie-liquid.diff | 141 |
3 files changed, 112 insertions, 51 deletions
diff --git a/noncore/styles/liquid/embeddata.h b/noncore/styles/liquid/embeddata.h index e4ccc27..5207fb1 100644 --- a/noncore/styles/liquid/embeddata.h +++ b/noncore/styles/liquid/embeddata.h @@ -964,25 +964,25 @@ static struct EmbedImage { { 13, 28, 32, (const unsigned char*)sbslider_mid_data, 0, 0, TRUE, "sbslider_mid" }, { 13, 8, 32, (const unsigned char*)sbslider_top_data, 0, 0, TRUE, "sbslider_top" }, { 10, 11, 32, (const unsigned char*)sliderarrow_data, 0, 0, TRUE, "sliderarrow" }, { 85, 33, 32, (const unsigned char*)tab_data, 0, 0, TRUE, "tab" }, }; static int cmpEmbedImage(const void *a, const void *b) { const EmbedImage* ea = (const EmbedImage*)a; const EmbedImage* eb = (const EmbedImage*)b; return strcmp(ea->name,eb->name); } -inline const QImage& qembed_findImage(const char* name) +static const QImage& qembed_findImage(const char* name) { EmbedImage key; key.name = name; EmbedImage* r = (EmbedImage*)bsearch( &key, embed_image_vec, sizeof(embed_image_vec)/sizeof(EmbedImage), sizeof(EmbedImage), cmpEmbedImage ); QImage* img; if ( r ) { img = new QImage((uchar*)r->data, r->width, r->height, r->depth, (QRgb*)r->colorTable, r->numColors, diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index ba732aa..c8f8d20 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp @@ -1996,52 +1996,62 @@ void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, parent->erase(x, y, w, h); if(menuHandler->useShadowText()){ QColor shadow; if(p->device() && p->device()->devType() == QInternal::Widget && ((QWidget *)p->device())->inherits("QMenuBar")){ shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : g.background().dark(130); } else 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 ( )); + dummy_mask. fill ( color1 ); + dummy-> setMask ( dummy_mask ); + } + if(active){ drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); QApplication::style().drawItem(p, x+1, y+1, w, h, AlignCenter|ShowPrefix|DontClip|SingleLine, - g, mi->isEnabled(), NULL, mi->text(), + g, mi->isEnabled(), dummy, mi->text(), -1, &shadow); QApplication::style().drawItem(p, x, y, w, h, AlignCenter|ShowPrefix|DontClip|SingleLine, - g, mi->isEnabled(), NULL, mi->text(), + g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), -1, &g.text()); } else{ QApplication::style().drawItem(p, x+1, y+1, w, h, AlignCenter|ShowPrefix|DontClip|SingleLine, - g, mi->isEnabled(), NULL, mi->text(), + g, mi->isEnabled(), dummy, mi->text(), -1, &shadow); QApplication::style().drawItem(p, x, y, w, h, AlignCenter|ShowPrefix|DontClip|SingleLine, - g, mi->isEnabled(), NULL, mi->text(), + g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), -1, &g.text()); } + delete dummy; } else{ if(active) drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); QApplication::style().drawItem(p, x, y, w, h, AlignCenter|ShowPrefix|DontClip|SingleLine, - g, mi->isEnabled(), NULL, mi->text(), + g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), -1, &g.text()); } } void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, int /*lineWidth*/, const QBrush * /*fill*/) { QColor c; switch(menuHandler->transType()){ case None: case StippledBg: diff --git a/noncore/styles/liquid/opie-liquid.diff b/noncore/styles/liquid/opie-liquid.diff index 29ae6f3..d90433c 100644 --- a/noncore/styles/liquid/opie-liquid.diff +++ b/noncore/styles/liquid/opie-liquid.diff @@ -1,18 +1,18 @@ This is a patch to mosfet's liquid 0.7. Features: - Qt-only - works with Qt/E on QPE/OPIE ---- - 2002-11-18 04:47:41.000000000 +0100 +--- - 2002-11-21 20:45:47.000000000 +0100 +++ liquid.h 2002-11-18 03:32:40.000000000 +0100 @@ -2,7 +2,7 @@ #define LIQUID_STYLE_H -#include <kstyle.h> +#include <qwindowsstyle.h> #include <qpainter.h> #include <qdrawutil.h> #include <qpalette.h> @@ -20,7 +20,7 @@ * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. @@ -132,26 +132,26 @@ Features: QIntDict<QPixmap>btnDict; @@ -224,9 +187,6 @@ QIntDict<QPixmap>bevelFillDict; QIntDict<QPixmap>smallBevelFillDict; - QList<QColor>customBtnColorList; - QList<QPixmap>customBtnIconList; - QStrList customBtnLabelList; QPixmap *vsbSliderFillPix; TransMenuHandler *menuHandler; QPixmap *pixmaps[BITMAP_ITEMS]; ---- - 2002-11-18 04:47:41.000000000 +0100 -+++ liquid.cpp 2002-11-18 04:46:13.000000000 +0100 +--- - 2002-11-21 20:45:47.000000000 +0100 ++++ liquid.cpp 2002-11-21 20:27:48.000000000 +0100 @@ -2,6 +2,9 @@ * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. */ +// +// (c) 2002 Robert 'sandman' Griebl +// #ifndef INCLUDE_MENUITEM_DEF @@ -10,12 +13,10 @@ @@ -332,50 +332,50 @@ Features: - reloadSettings(); + QObjectList *ol = p-> queryList("QWidget"); + for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { + QWidget *wid = (QWidget *) it.current ( ); - // Now repaint menubar if needed - if(shadowText != oldShadow){ - it.toFirst(); - while ((w=it.current()) != 0 ){ - ++it; - if(w->inherits("QMenuBar")){ - w->repaint(); -- } -- } + wid-> setBackgroundMode( QWidget::PaletteBackground ); + } ++ delete ol; + } } - } - else if(id == MOSFET_BUTTON_CHANGE){ - qWarning("In mosfet button change"); - // really, this should be in LiquidStyle, but what the hell? ;-) - QWidgetList *list = QApplication::allWidgets(); - QWidgetListIt it( *list ); - QWidget *w; - while ((w=it.current()) != 0 ){ - ++it; - if(w->inherits("QPushButton")){ - ((LiquidStyle*)parent())->unapplyCustomAttributes((QPushButton *)w); - } - } - ((LiquidStyle*)parent())->loadCustomButtons(); - it.toFirst(); - while ((w=it.current()) != 0 ){ - ++it; - if(w->inherits("QPushButton")){ - ((LiquidStyle*)parent())->applyCustomAttributes((QPushButton *)w); -+ delete ol; - } - } +- } +- } + return(false); +} - } + +static int qt_version ( ) +{ + const char *qver = qVersion ( ); + return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); } + @@ -485,28 +485,28 @@ Features: + + case CB: + pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/); break; case CBHover: - pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); + pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/); break; - case HSlider: - pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); + case CBDown: + pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/); - break; ++ break; + case CBDownHover: + pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/); -+ break; + break; + case VSlider: - pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); + pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true ); *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); break; - case RadioOff: - pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); - break; - case Tab: - pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); - break; @@ -1563,25 +1563,25 @@ Features: - p->fillRect(x, y, w, h, - QApplication::palette().active().brush(QColorGroup::Background)); + parent->erase(x, y, w, h); p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : *getPixmap(VSlider)); } -void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int w, int h, +void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, Orientation orient, bool, bool) { p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : -@@ -2065,203 +1980,26 @@ +@@ -2065,243 +1980,76 @@ p->drawLineSegments(a); } -void LiquidStyle::drawKBarHandle(QPainter *p, int x, int y, int w, int h, - const QColorGroup &g, KToolBarPos, - QBrush *) -{ - p->setPen(g.button().dark(120)); - int x2 = x+w-1; - int y2 = y+h-1; - p->drawLine(x+1, y, x2-1, y); - p->drawLine(x+1, y2, x2-1, y2); @@ -1624,27 +1624,27 @@ Features: - p->drawLine(x+4, y+1, x+6, y+1); - // right - int x2 = x+w-1; - p->drawLine(x2-1, y+1, x2-1, y+5); - p->drawLine(x2-2, y+1, x2-2, y+3); - p->drawLine(x2-3, y+1, x2-3, y+2); - p->drawLine(x2-4, y+1, x2-6, y+1); - } - else{ - qDrawShadePanel(p, x, y, w, h, g, false, 1, - &g.brush(QColorGroup::Background)); - } -- --} +-} +- -void LiquidStyle::drawKToolBar(QPainter *p, int x, int y, int w, int h, - const QColorGroup &g, KToolBarPos, QBrush *) +void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, + QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) { - //p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); -} - -void LiquidStyle::drawKToolBarButton(QPainter *p, int x, int y, int w, int h, - const QColorGroup &g, bool sunken, - bool raised, bool enabled, bool popup, - KToolButtonType icontext, @@ -1779,54 +1779,100 @@ Features: + parent->erase(x, y, w, h); if(menuHandler->useShadowText()){ QColor shadow; if(p->device() && p->device()->devType() == QInternal::Widget && - ((QWidget *)p->device())->inherits("KMenuBar")){ - shadow = ((KMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : + ((QWidget *)p->device())->inherits("QMenuBar")){ + shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : g.background().dark(130); } else -@@ -2300,8 +2038,8 @@ + 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 ( )); ++ dummy_mask. fill ( color1 ); ++ dummy-> setMask ( dummy_mask ); ++ } ++ + if(active){ + drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); + QApplication::style().drawItem(p, x+1, y+1, w, h, + AlignCenter|ShowPrefix|DontClip|SingleLine, +- g, mi->isEnabled(), NULL, mi->text(), ++ g, mi->isEnabled(), dummy, mi->text(), + -1, &shadow); + QApplication::style().drawItem(p, x, y, w, h, + AlignCenter|ShowPrefix|DontClip|SingleLine, +- g, mi->isEnabled(), NULL, mi->text(), ++ g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), + -1, &g.text()); + } + else{ + QApplication::style().drawItem(p, x+1, y+1, w, h, + AlignCenter|ShowPrefix|DontClip|SingleLine, +- g, mi->isEnabled(), NULL, mi->text(), ++ g, mi->isEnabled(), dummy, mi->text(), + -1, &shadow); + QApplication::style().drawItem(p, x, y, w, h, + AlignCenter|ShowPrefix|DontClip|SingleLine, +- g, mi->isEnabled(), NULL, mi->text(), ++ g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), + -1, &g.text()); + } ++ delete dummy; + } + else{ + if(active) + drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); + QApplication::style().drawItem(p, x, y, w, h, + AlignCenter|ShowPrefix|DontClip|SingleLine, +- g, mi->isEnabled(), NULL, mi->text(), ++ g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), + -1, &g.text()); + } } void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, - const QColorGroup &g, int lineWidth, - const QBrush * fill) + const QColorGroup &g, int /*lineWidth*/, + const QBrush * /*fill*/) { QColor c; switch(menuHandler->transType()){ -@@ -2336,8 +2074,6 @@ +@@ -2336,8 +2084,6 @@ maxpmw = QMAX( maxpmw, 20 ); - if ( p->font() == KGlobalSettings::generalFont() ) - p->setFont( KGlobalSettings::menuFont() ); bool dis = !enabled; QColorGroup itemg = dis ? pal.disabled() : pal.active(); -@@ -2363,7 +2099,7 @@ +@@ -2363,7 +2109,7 @@ p->fillRect(x, y, w, h, menuBrush); } else{ - KPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); + QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); if(pix) p->drawPixmap(x, y, *pix, x, y, w, h); } -@@ -2508,25 +2244,6 @@ +@@ -2508,25 +2254,6 @@ return h; } -void LiquidStyle::drawKProgressBlock(QPainter *p, int x, int y, int w, int h, - const QColorGroup &g, QBrush *fill) -{ - p->setPen(g.button().dark(130)); - p->drawRect(x, y, w, h); - p->setPen(g.button().light(120)); - p->drawRect(x+1, y+1, w-2, h-2); - if(w >= 4 && h >= 4){ - QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); @@ -1834,25 +1880,25 @@ Features: - int h, s, v; - g.button().dark(120).hsv(&h, &s, &v); - pix = new QPixmap(*bevelFillPix); - adjustHSV(*pix, h, s, v); - bevelFillDict.insert(g.button().dark(120).rgb(), pix); - } - p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); - } -} void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, const QColorGroup &g, const QColor *c, -@@ -2536,29 +2253,29 @@ +@@ -2536,29 +2263,29 @@ if(p->device()->devType() == QInternal::Widget){ // if so does it use a special focus rectangle? QWidget *w = (QWidget *)p->device(); - if(w->inherits("QPushButton") || w->inherits("QSlider")){ + if(w->inherits("QPushButton") || w->inherits("QSlider") || w->inherits("QComboBox") || w->inherits("QToolButton" )){ return; } else{ - KStyle::drawFocusRect(p, r, g, c, atBorder); + QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); } } @@ -1869,43 +1915,43 @@ Features: + QWindowsStyle::polishPopupMenu(mnu); } void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, bool selected) { if(tabBar->shape() != QTabBar::RoundedAbove){ - KStyle::drawTab(p, tabBar, tab, selected); + QWindowsStyle::drawTab(p, tabBar, tab, selected); return; } QPixmap tilePix; -@@ -2671,7 +2388,7 @@ +@@ -2671,7 +2398,7 @@ vFrame = 8; // was 10 } else - KStyle::tabbarMetrics(t, hFrame, vFrame, overlap); + QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); } -@@ -2699,7 +2416,7 @@ +@@ -2699,7 +2426,7 @@ p->drawLine(x+1, y+1, x+1, y2-1); } else if(lineWidth != 2 || !sunken) - KStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); + QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); else{ QPen oldPen = p->pen(); int x2 = x+w-1; -@@ -2726,105 +2443,6 @@ +@@ -2726,105 +2453,6 @@ } } -void LiquidStyle::drawKickerAppletHandle(QPainter *p, int x, int y, int w, int h, - const QColorGroup &g, QBrush *) -{ - p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); - drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? - g.button().light(120) : g.button(), g.button()); - /* - if(h > w){ - int y2 = y+h-1; @@ -1993,25 +2039,25 @@ Features: - } - - p->setPen(g.buttonText()); - - p->drawText(br.x()+ textPos, -1, w-textPos, h, - AlignLeft|AlignVCenter, s); - } - -} void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) { -@@ -2988,110 +2606,5 @@ +@@ -2988,110 +2616,5 @@ } } -// I'm debating if to use QValueList or QList here. I like QValueList better, -// but QList handles pointers which is good for a lot of empty icons... - -void LiquidStyle::loadCustomButtons() -{ - return; // TODO - customBtnColorList.clear(); - customBtnIconList.clear(); - customBtnLabelList.clear(); @@ -2104,87 +2150,87 @@ Features: - } - } -} - -#include "liquid.moc" - - - - - /* vim: set noet sw=8 ts=8: */ ---- - 2002-11-18 04:47:41.000000000 +0100 -+++ plugin.cpp 2002-11-18 03:54:56.000000000 +0100 -@@ -1,29 +1,79 @@ +--- - 2002-11-21 20:45:47.000000000 +0100 ++++ plugin.cpp 2002-11-18 18:11:41.000000000 +0100 +@@ -1,29 +1,84 @@ +#include <qapplication.h> + #include "liquid.h" -#include <klocale.h> +#include "liquidset.h" +#include "plugin.h" + + + +LiquidInterface::LiquidInterface ( ) : ref ( 0 ) +{ + m_widget = 0; +} ++ ++LiquidInterface::~LiquidInterface ( ) ++{ ++} ++ ++QStyle *LiquidInterface::style ( ) ++{ ++ return new LiquidStyle ( ); ++} -extern "C" { - KStyle* allocate(); - int minor_version(); - int major_version(); - const char *description(); -+LiquidInterface::~LiquidInterface ( ) ++QString LiquidInterface::name ( ) const +{ ++ return qApp-> translate ( "Styles", "Liquid" ); } -KStyle* allocate() -+QStyle *LiquidInterface::style ( ) ++QString LiquidInterface::description ( ) const { - return(new LiquidStyle); -+ return new LiquidStyle ( ); ++ return qApp-> translate ( "Styles", "High Performance Liquid style by Mosfet" ); } -int minor_version() -+QString LiquidInterface::name ( ) const ++bool LiquidInterface::hasSettings ( ) const { - return(0); -+ return qApp-> translate ( "Styles", "Liquid" ); ++ return true; } -int major_version() -+QString LiquidInterface::description ( ) const ++QWidget *LiquidInterface::create ( QWidget *parent, const char *name ) { - return(1); -+ return qApp-> translate ( "Styles", "High Performance Liquid style by Mosfet" ); ++ m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" ); ++ ++ return m_widget; } -const char *description() -+bool LiquidInterface::hasSettings ( ) const ++bool LiquidInterface::accept ( ) { - return(i18n("High performance liquid plugin").utf8()); -+ return true; -+} -+ -+QWidget *LiquidInterface::create ( QWidget *parent, const char *name ) -+{ -+ m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" ); -+ -+ return m_widget; -+} -+ -+bool LiquidInterface::accept ( ) -+{ + if ( !m_widget ) + return false; + + return m_widget-> writeConfig ( ); } + +void LiquidInterface::reject ( ) +{ +} + + +QRESULT LiquidInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) @@ -2200,12 +2246,17 @@ Features: + + if ( *iface ) + (*iface)-> addRef ( ); + + return QS_OK; +} + +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( LiquidInterface ) +} + ++ ++// For Sharp ROM ++ ++extern "C" { QStyle *allocate ( ) { return new LiquidStyle ( ); } } ++extern "C" { void drawmenubaritem ( QStyle *sty, QPainter *p, int x, int y, int w, int h, QMenuItem *mi, QColorGroup &g, bool enabled, bool active ) { return ((LiquidStyle *) sty )-> drawMenuBarItem ( p, x, y, w, h, mi, g, enabled, active ); } } |