diff options
Diffstat (limited to 'style')
-rw-r--r-- | style/Makefile.am | 16 | ||||
-rw-r--r-- | style/baghira.cpp | 3384 | ||||
-rw-r--r-- | style/baghira.h | 627 | ||||
-rw-r--r-- | style/baghira.themerc | 6 | ||||
-rw-r--r-- | style/bitmaps.h | 21 | ||||
-rw-r--r-- | style/configure.in.in | 5 | ||||
-rw-r--r-- | style/eventfilter.cpp | 990 | ||||
-rw-r--r-- | style/fracts.h | 74 | ||||
-rwxr-xr-x | style/generatePixmaps.sh | 54 | ||||
-rw-r--r-- | style/optionHandler.cpp | 251 | ||||
-rw-r--r-- | style/polish.cpp | 878 | ||||
-rw-r--r-- | style/utils.cpp | 1418 |
12 files changed, 7724 insertions, 0 deletions
diff --git a/style/Makefile.am b/style/Makefile.am new file mode 100644 index 0000000..2094915 --- /dev/null +++ b/style/Makefile.am @@ -0,0 +1,16 @@ +AM_CPPFLAGS = -DQT_PLUGIN + +INCLUDES = -I$(top_srcdir)/kdefx $(all_includes) +noinst_HEADERS = baghira.h pixmaps.h bitmaps.h +METASOURCES = AUTO +kde_style_LTLIBRARIES = baghira.la +baghira_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module +baghira_la_LIBADD = -lkdefx -lXtst $(LIB_KDEUI) +baghira_la_SOURCES = baghira.cpp optionHandler.cpp polish.cpp utils.cpp +lnkdir = $(kde_datadir)/kstyle/themes +lnk_DATA = baghira.themerc +EXTRA_DIST = $(lnk_DATA) +pixmaps.h: $(srcdir)/generatePixmaps.sh + $(SHELL) $(srcdir)/generatePixmaps.sh $(top_srcdir) +CLEANFILES = pixmaps.h +baghira.lo: pixmaps.h diff --git a/style/baghira.cpp b/style/baghira.cpp new file mode 100644 index 0000000..bae1611 --- /dev/null +++ b/style/baghira.cpp @@ -0,0 +1,3384 @@ +#include "baghira.h" +#include "bitmaps.h" +#include "pixmaps.h" +//#include "../deco/baghiradecobuttons.h" + +#include <qapplication.h> +#include <qbitmap.h> +#include <qbrush.h> +#include <qbutton.h> +#include <qcleanuphandler.h> +#include <qcolor.h> +#include <qcombobox.h> +//#include <qevent.h> +#include <qfont.h> +#include <qframe.h> +#include <qgroupbox.h> +#include <qheader.h> +#include <qiconset.h> +#include <qimage.h> +#include <qlayout.h> +#include <qlistbox.h> +#include <qlistview.h> +#include <qmenubar.h> +#include <qobject.h> +#include <qobjectlist.h> +#include <qpaintdevice.h> +#include <qpainter.h> +#include <qpalette.h> +#include <qpen.h> +#include <qpoint.h> +#include <qpopupmenu.h> +#include <qpushbutton.h> +//#include <qrangecontrol.h> +#include <qrect.h> +#include <qscrollbar.h> +#include <qscrollview.h> +#include <qsize.h> +#include <qslider.h> +#include <qstring.h> +#include <qstyleplugin.h> +#include <qtabbar.h> +#include <qtabwidget.h> +#include <qvariant.h> +#include <ktoolbar.h> +#include <ktoolbarbutton.h> +#include <kwordwrap.h> +#include "config.h" + +#define PRINTDEVICE(p) qWarning("device is %s", (p->device()->devType() == QInternal::Widget) ?\ +"Widget": (p->device()->devType() == QInternal::Pixmap) ?\ +"Pixmap": (p->device()->devType() == QInternal::Printer) ?\ +"Printer": (p->device()->devType() == QInternal::Picture) ?\ +"Picture": (p->device()->devType() == QInternal::UndefinedDevice) ?\ +"UndefinedDevice": "fuckdevice!" ); + +#define GCC_VERSION (__GNUC__ * 10000 \ ++ __GNUC_MINOR__ * 100 \ ++ __GNUC_PATCHLEVEL__) + +static const int windowsItemFrame = 1; // menu item frame width +static const int windowsSepHeight = 2; // separator item height +static const int windowsItemHMargin = 3; // menu item hor text margin +static const int windowsItemVMargin = 1; // menu item ver text margin +static const int windowsArrowHMargin = 6; // arrow horizontal margin +static const int windowsTabSpacing = 12; // space between text and tab +static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark +static const int windowsRightBorder = 12; // right border on windows +static const int windowsCheckMarkWidth = 12; // checkmarks width on windows + +// options +int OptionHandler::menuBackground; +int OptionHandler::menuOpacity; +bool OptionHandler::menuColorButton; +bool OptionHandler::shadowText; +//color +QColor OptionHandler::customButtonColor, OptionHandler::menuStripeColor_; +//widgets +bool OptionHandler::customWidgetColor; +QColor OptionHandler::customColors[ 10 ]; +//menu +bool OptionHandler::useCustomMenuColor; +QColor OptionHandler::color, OptionHandler::color2, OptionHandler::colorHigh, OptionHandler::fgColor, OptionHandler::fgColorHigh; +//Panel +// bool OptionHandler::panelCustom; +// QColor OptionHandler::customPanelColor; +//incativeButton +int OptionHandler::inactiveButtonColor; +QColor OptionHandler::customInactiveButtonColor; + +//Design +//stipples +bool OptionHandler::bgStipple, /*OptionHandler::panelStipple,*/ OptionHandler::bevelHighlights_, OptionHandler::drawMenuStripe_, OptionHandler::glossyMenus_; +Style OptionHandler::style_; +int OptionHandler::contrast; +//shadows +bool OptionHandler::groupboxshadow; +int OptionHandler::shadowDarkness; +//istviews; +bool OptionHandler::drawDotlines, OptionHandler::useCustomExpanderColor; +int OptionHandler::expanderStyle; +QColor OptionHandler::expanderColor, OptionHandler::dotlineColor; +int OptionHandler::dotlineStyle; +//slider +bool OptionHandler::squeezesbslider; +bool OptionHandler::shadowsbslider; +bool OptionHandler::animateSlider; +bool OptionHandler::animateProgress; +//toolbar +bool OptionHandler::reverseBtnColor, OptionHandler::tbFrame; +//tweaks +bool OptionHandler::centerTabs; +bool OptionHandler::smoothListViewHeaders; +bool OptionHandler::smootherLVH; +bool OptionHandler::icyButtons; +Style OptionHandler::_buttonStyle; +int OptionHandler::progressBar; +bool OptionHandler::removeKickerBevel; +Style OptionHandler::_toolbuttonStyle; +bool OptionHandler::drawProgressLabel; +QColor OptionHandler::brushTint; +QColor OptionHandler::aDecoColor1_; +QColor OptionHandler::aDecoColor2_; +QColor OptionHandler::titleColor_[2]; +QColor OptionHandler::titleButtonColor_[3]; +bool OptionHandler::tintBrush; +tabStyle OptionHandler::tabStyle_; +unsigned long OptionHandler::wmDesign; +bool OptionHandler::animateButton; +int OptionHandler::custCols[8]; + +QPixmap LiquidStyle::popupBack; + +//============ + +class KAccessToolBarButton : public KToolBarButton +{ +// to get me access to the toolbbar + friend class LiquidStyle; +public: + KAccessToolBarButton( QWidget* parent=0, const char* name=0 ) + : KToolBarButton( parent, name ) {} +}; + + +class LiquidStylePlugin : public QStylePlugin { + public: + LiquidStylePlugin() { + ; + } + ~LiquidStylePlugin() { + ; + } + + QStringList keys() const { + return ( QStringList() << "Baghira" ); + } + QStyle *create( const QString & ); + }; + +QStyle *LiquidStylePlugin::create( const QString &s ) { + if ( s.lower() == "baghira" ) + return ( new LiquidStyle() ); + return ( 0 ); + } + +Q_EXPORT_PLUGIN( LiquidStylePlugin ) + +static const int itemFrame = 1; +static const int itemHMargin = 3; +static const int itemVMargin = 1; +static const int arrowHMargin = 6; +static const int rightBorder = 12; + + +LiquidStyle::LiquidStyle() : KStyle( AllowMenuTransparency | FilledFrameWorkaround, ThreeButtonScrollBar ) +{ + QIntDict<ButtonFadeInfo>bfi(31);// assuming 31 btns will be enough - a pointer list would be more accurate, but we need to lookup this every 50ms... + QIntDict<ButtonTile>btnShadowedDict(223);// we need around 10/color, 3 colors/button assuming 10 different colors (e.g. kcalc) + QIntDict<ButtonTile>buttonGlowDict(109); + QIntDict<ButtonTile>buttonDict(331); + headerHoverID = -1; + headerSortID = -1; + hoveredTabIndex = -1; + currentTabBar = 0L; + paintWidget = 0L; + highlightWidget = 0L; + currentTaskContainer = 0L; + taskContainerHover = false; + isTaskContainer = false; + isHTMLButton = false; + inExitPolish = false; + inactiveRoundFrame = 0L; + activeRoundFrame = 0L; + eventKiller = new EventKiller; + bmShower = 0L; // only if b/m + + btnDict.setAutoDelete( true ); + btnShadowedDict.setAutoDelete( true ); + bfi.setAutoDelete( true ); +// inverseTabDict.setAutoDelete( true ); +// tabDict.setAutoDelete( true ); + initialPaletteLoaded = false; + qtrcModificationTime = 0; + + // animations kram! + progAnimShift = 0; + prog2AnimShift = 0; + sliderAnimShift = 0; + QTimer* timer = new QTimer( this ); + timer->start(50, false); +// if (optionHandler->AnimateProgress()) + connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressPos())); + activeScroller = NULL; + //-------------------------------------- + + tooltipPalette = qApp->palette(); + tooltipPalette.setBrush( QColorGroup::Background, QColor( 255, 255, 220 ) ); + tooltipPalette.setBrush( QColorGroup::Foreground, Qt::black ); + + rMatrix.rotate( 90.0 ); + lMatrix.rotate( 270.0 ); + iMatrix.rotate( 180.0 ); + mMatrix.setMatrix ( -1, 0, 0, 1, 0, 0); + m2Matrix.setMatrix ( 1, 0, 0, -1, 0, 0); + + optionHandler = new OptionHandler( this ); + if (optionHandler->style() != Milk && optionHandler->AnimateSlider()) + connect(timer, SIGNAL(timeout()), this, SLOT(updateSliderPos())); + if (optionHandler->style() == Brushed) + bmShower = new BMShower(this); + + switch (optionHandler->buttonStyle()) + { + case Jaguar: + btnBorderImg = new QImage( uic_findImage("button-jaguar") ); + btnShadowImg = new QImage( uic_findImage( "button-shadow" ) ); + buttonGlow = new QImage( uic_findImage( "button-glow" ) ); + combo = new QImage( uic_findImage("combo-jaguar") ); + comboShadow = new QImage( uic_findImage( "combo-shadow" ) ); + if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders()) + rectbutton = new QImage( uic_findImage( "rectbutton" ) ); + else rectbutton = 0L; + break; + case Panther: + case Tiger: + btnBorderImg = new QImage( uic_findImage("button-base") ); + btnShadowImg = new QImage( uic_findImage( "button-shadow" ) ); + buttonGlow = new QImage( uic_findImage( "button-glow" ) ); + combo = new QImage( uic_findImage("combo") ); + comboShadow = new QImage( uic_findImage( "combo-shadow" ) ); + if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders()) + rectbutton = new QImage( uic_findImage( "rectbutton" ) ); + else rectbutton = 0L; + break; + case Brushed: + btnBorderImg = 0L; + btnShadowImg = 0L; + buttonGlow = 0L; + rectbutton = new QImage( uic_findImage( "rectbutton" ) ); + switch (optionHandler->toolbuttonStyle()) + { + case Jaguar: + combo = new QImage( uic_findImage("combo-jaguar") ); + comboShadow = new QImage( uic_findImage( "combo-shadow" ) ); + break; + case Panther: + case Tiger: + case Brushed: + combo = new QImage( uic_findImage("combo") ); + comboShadow = new QImage( uic_findImage( "combo-shadow" ) ); + break; + case Milk: + combo = new QImage( uic_findImage("combo-milk") ); + comboShadow = new QImage( uic_findImage( "combo-shadow" ) ); + default: + break; + } + break; + case Milk: + btnBorderImg = new QImage( uic_findImage("button-milk") ); + btnShadowImg = 0L; + buttonGlow = 0L; + combo = new QImage( uic_findImage("combo-milk") ); + comboShadow = new QImage( uic_findImage( "combo-shadow" ) ); + if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders()) + rectbutton = new QImage( uic_findImage( "rectbutton" ) ); + else rectbutton = 0L; + default: + break; + } + + if ( btnBorderImg && btnBorderImg->depth() < 32 ) + * btnBorderImg = btnBorderImg->convertDepth( 32 ); + + if ( btnShadowImg && btnShadowImg->depth() < 32 ) + * btnShadowImg = btnShadowImg->convertDepth( 32 ); + + if ( buttonGlow && buttonGlow->depth() < 32 ) + * buttonGlow = buttonGlow->convertDepth( 32 ); + + if ( combo && combo->depth() < 32 ) + * combo = combo->convertDepth( 32 ); + + if ( comboShadow && comboShadow->depth() < 32 ) + * comboShadow = comboShadow->convertDepth( 32 ); + + if ( rectbutton && rectbutton->depth() < 32 ) + * rectbutton = rectbutton->convertDepth( 32 ); + + if (optionHandler->style() == Milk) + { + slider_top = new QImage( uic_findImage( "sbslider_top-milk" ) ); + slider_btm = new QImage( uic_findImage( "sbslider_btm-milk" ) ); + } + else + { + slider_top = new QImage( uic_findImage( "sbslider_top" ) ); + slider_btm = new QImage( uic_findImage( "sbslider_btm" ) ); + } + + if ( slider_top->depth() < 32 ) + * slider_top = slider_top->convertDepth( 32 ); + + if ( slider_btm->depth() < 32 ) + * slider_btm = slider_btm->convertDepth( 32 ); + + if (optionHandler->shadowSbSlider()) + { + slider_top_shd = new QImage( uic_findImage( "sbslider_top_shd" ) ); + if ( slider_top_shd->depth() < 32 ) + * slider_top_shd = slider_top_shd->convertDepth( 32 ); + + slider_btm_shd = new QImage( uic_findImage( "sbslider_btm_shd" ) ); + if ( slider_btm_shd->depth() < 32 ) + * slider_btm_shd = slider_btm_shd->convertDepth( 32 ); + } + else + { + slider_top_shd = 0L; + slider_btm_shd = 0L; + } + + roundFrame = new QImage( uic_findImage( "roundFrame" ) ); + if ( roundFrame->depth() < 32 ) + * roundFrame = roundFrame->convertDepth( 32 ); + + menuPix = NULL; + tmpBtnPix = NULL; + + int i; + for ( i = 0; i < BITMAP_ITEMS; ++i ) { + pixmaps[ i ] = NULL; + } + + sbLeft = new QBitmap( 6, 7, sbarrow_left_bits, true ); + sbLeft->setMask( *sbLeft ); + sbRight = new QBitmap( 6, 7, sbarrow_right_bits, true ); + sbRight->setMask( *sbRight ); + sbUp = new QBitmap( 7, 6, sbarrow_up_bits, true ); + sbUp->setMask( *sbUp ); + sbDown = new QBitmap( 7, 6, sbarrow_down_bits, true ); + sbDown->setMask( *sbDown ); + checkmark = new QBitmap( 6, 7, checkmark_bits, true ); + checkmark->setMask( *checkmark ); + + isKicker = ( qstrcmp( qApp->argv() [ 0 ], "kicker" ) == 0 ) || + ( qstrcmp( qApp->argv() [ 0 ], "appletproxy" ) == 0 ); + isOOO = !qstrcmp( qApp->argv() [ 0 ], "soffice.bin" ); + + groupShadow = new QPixmap( 64, 64 ); + QColor c; + optionHandler->custCols[0] != -1 ? c = QColor(optionHandler->custCols[0]) : c= QColor(qApp->palette().color(QPalette::Active, isKicker?QColorGroup::Button:QColorGroup::Background)); + + groupShadow->fill( ( c.dark( 100 + optionHandler->ShadowDarkness() ) ).rgb() ); + if ( (optionHandler->style() != Brushed) && optionHandler->useBgStipple() ) { + QPainter p; + p.begin( groupShadow ); + p.setPen( c.dark( 100 + optionHandler->ShadowDarkness() + (int)(optionHandler->stippleContrast()/2) ) ); + for ( int i = 1; i < 64; i += 4 ) { + p.drawLine( 0, i, 63, i ); + p.drawLine( 0, i+2, 63, i+2 ); + } + p.setPen( c.dark( 100 + optionHandler->ShadowDarkness() + optionHandler->stippleContrast()) ); + for ( int i = 2; i < 63; i += 4 ) { + p.drawLine( 0, i, 63, i ); + } + } + + if (optionHandler->style() == Brushed) + { + plainBrush = optionHandler->TintBrush() ? + *tintBrush(uic_findImage( "brushed-tile" ), optionHandler->BrushTint()) : + uic_findImage( "brushed-tile" ); + gradBrush = optionHandler->TintBrush() ? + *tintBrush(uic_findImage( "brushed-gradient" ), optionHandler->BrushTint()) : + uic_findImage( "brushed-gradient" ); + } +} + +LiquidStyle::~LiquidStyle() { +// btnDict.setAutoDelete(true); + btnDict.clear(); +// btnShadowedDict.setAutoDelete(true); + btnShadowedDict.clear(); +// buttonGlowDict.setAutoDelete(true); + buttonGlowDict.clear(); +// comboDict.setAutoDelete(true); + comboDict.clear(); +// comboShadowedDict.setAutoDelete(true); + comboShadowedDict.clear(); +// if (! tabDict.isEmpty()) tabDict.clear(); +// if (! inverseTabDict.isEmpty()) inverseTabDict.clear(); +// rectBtnDict.setAutoDelete(true); + rectBtnDict.clear(); +// progress2Dict.setAutoDelete(true); + progress2Dict.clear(); +// bfi.setAutoDelete(true); + bfi.clear(); +// fadeColorMap.setAutoDelete(true); + fadeColorMap.clear(); + + delete optionHandler; + + delete sbUp; + delete sbDown; + delete sbLeft; + delete sbRight; + delete checkmark; + + + if ( btnBorderImg ) + delete btnBorderImg; + if ( btnShadowImg ) + delete btnShadowImg; + if (combo) + delete combo; + if (comboShadow) + delete comboShadow; + if (buttonGlow) + delete buttonGlow; + delete slider_top; + delete slider_btm; + if (slider_top_shd) + delete slider_top_shd; + if (slider_btm_shd) + delete slider_btm_shd; + if (rectbutton) + delete rectbutton; + delete roundFrame; + + if ( tmpBtnPix ) + delete tmpBtnPix; + if ( menuPix ) + delete menuPix; + + int i; + for ( i = 0; i < BITMAP_ITEMS; ++i ) { + if ( pixmaps[ i ] ) + delete pixmaps[ i ]; + } + if ( groupShadow ) + delete groupShadow; + + } + +inline void LiquidStyle::updateProgressPos() +{ + progAnimShift = (progAnimShift + 1) % 20; + prog2AnimShift = (prog2AnimShift + 1) % 38; + //Update the registered progressbars. + QMap<QWidget*, int>::iterator iter; + for (iter = progAnimWidgets.begin(); iter != progAnimWidgets.end(); iter++) + { + if ( !::qt_cast<QProgressBar*>(iter.key()) ) + continue; + (iter.key())->repaint(false); + } +} + +inline void LiquidStyle::updateSliderPos(){ + sliderAnimShift = (sliderAnimShift + 1) % 32; + if (activeScroller) + activeScroller->repaint(false); +} + +void LiquidStyle::progressBarDestroyed(QObject* obj){ + progAnimWidgets.remove(static_cast<QWidget*>(obj)); +} + +bool LiquidStyle::isPlain() const { + return ( !optionHandler->useBgStipple() ); + } + + +void LiquidStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, + const QRect &r, const QColorGroup &cg, + SFlags flags, const QStyleOption &opt ) const +{ + bool down = flags & Style_Down; + bool on = flags & Style_On; + + switch ( pe ) + { + case PE_TabBarBase: + { + bool isDialog = false; + if (p->device() && p->device()->devType() == QInternal::Widget) + { + QWidget *w = (QWidget*)p->device(); + if (w && ::qt_cast<QTabWidget*>(w) && w->children()) + { + QObjectListIt it( *w->children() ); // iterate over the buttons + QObject *obj; + QTabBar *tabBar = 0L; + while ( (obj = it.current()) != 0 ) + { + ++it; + if (::qt_cast<QTabBar*>(obj)) + { + tabBar = (QTabBar*)obj; + break; + } + } + if (!tabBar || !tabBar->isVisible()) + break; + } + isDialog = optionHandler->TabStyle() == Clever && w->topLevelWidget()->inherits("QDialog"); + } + if (isDialog || optionHandler->TabStyle() == Chooser) + { + int x = r.x(); int right = r.right(); int bottom = r.bottom(); int y2 = r.y() + 1; + QColor bright( cg.background().dark( 110 ) ); + QColor mid( cg.background().dark( 130 ) ); + QColor dark( cg.background().dark( 150 ) ); + p->setPen( dark ); + p->drawLine( x + 6, y2, right - 6, y2 ); + p->drawPoint(x+3,y2+1);p->drawPoint(x+4,y2+1); + p->drawPoint(x+2,y2+2); + p->drawPoint(x+1,y2+3); + p->drawPoint(right-3,y2+1);p->drawPoint(right-4,y2+1); + p->drawPoint(right-2,y2+2); + p->drawPoint(right-1,y2+3); + p->drawLine(x,y2+5,x,bottom); + p->drawLine(right,y2+5,right,bottom); + + p->setPen( mid ); + p->drawPoint(x+4, y2);p->drawPoint(x+5,y2); + p->drawPoint(right-4, y2);p->drawPoint(right-5,y2); + p->drawPoint(x+2, y2+1); + p->drawPoint(right-2, y2+1); + p->drawLine(x+5,y2 + 1, right - 5, y2 + 1); + p->drawPoint(x+1,y2+2); + p->drawPoint(right-1,y2+2); + p->drawPoint(x+2,y2+3); + p->drawPoint(right-2,y2+3); + p->drawPoint(x,y2+4);p->drawPoint(x+1,y2+4); + p->drawPoint(right,y2+4);p->drawPoint(right+1,y2+4); + + p->setPen(bright); + p->drawPoint(x+3,y2);p->drawPoint(right-3,y2); + p->drawLine(x+4,y2+2,right-4,y2+2); + p->drawPoint(x,y2+3);p->drawPoint(x+3,y2+3); + p->drawPoint(right,y2+3);p->drawPoint(right-3,y2+3); + p->drawPoint(x+2,y2+4);p->drawPoint(right-2,y2+4); + p->drawLine(x+1,y2+5,x+1,bottom); + p->drawLine(right-1,y2+5,right-1,bottom); + break; + } + else + { + drawCombo( p, cg, cg.button(), r.x()+1, r.y()+1, r.width()-2, r.height()+1, false, false, false, center); + QPen oldPen = p->pen(); +// p->setClipping ( false ); + p->setPen( cg.button().dark( 158 ) ); + p->drawRect(r); +// p->fillRect(r, Qt::red); +// p->flush(); + p->setPen(oldPen); + } + break; + } + case PE_ButtonCommand: + case PE_ButtonDefault: + { + bool sunken = on || down; + bool hover = flags & Style_MouseOver; + bool focused = flags & Style_HasFocus; + QColor newColor = sunken ? cg.button().dark( 110 ) : hover || focused ? cg.button() : optionHandler->InactiveButtonColor(); + if (optionHandler->AnimateButton() && (sunken || hover || focused)) + { + ButtonFadeInfo *bfi_ = /*(::qt_cast<QWidget*>(*/opt.widget()/*))*/ ? bfi[opt.widget()->winId()] : 0L; + if (bfi_) + { + int index = bfi_->index; + newColor = mapFadeColor(newColor, index); + } + } + + if (optionHandler->buttonStyle() == Brushed) + { + drawRectangularButton( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full); + } + else if ( ( r.width() < 21 || r.height() < 25 )) + { + drawCombo( p, cg, newColor, r.x(), r.y(), r.width(), r.height()+2, sunken, hover, false, center, isHTMLButton ); + QPen oldpen(p->pen()); + p->setPen( newColor.dark(150)); + p->drawRect(r.x(), r.y(), r.width(), r.height()); + if (sunken) + { + p->setPen(newColor.dark(180)); + p->drawRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2); + } + p->setPen(oldpen); + break; + } + else if (optionHandler->buttonStyle() == Milk) + drawCombo( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full, isHTMLButton ); + else + { + drawRoundButton( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, btnOffset.x(), btnOffset.y() ); + } + break; + } + case PE_ButtonBevel: + case PE_ButtonDropDown: + { + bool sunken = on || down; + bool hover = flags & Style_MouseOver; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full); + else + drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full ); + break; + } + case PE_ButtonTool: + { + bool sunken = on || down; + bool hover = flags & Style_MouseOver; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full); + else + drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full ); + break; + } + case PE_HeaderSection: + { + bool sunken = on || down; + bool hover = flags & Style_MouseOver; + QPen oldpen(p->pen()); + if ( isTaskContainer ) // is kicker? + { + if (optionHandler->SmoothListViewHeaders()) + { + drawCombo( p, cg, sunken ? cg.button() : taskContainerHover ? cg.button().light( 110 ) : cg.background(), r.x(), r.y(), r.width(), isKicker ? r.height() + 2 : r.height(), sunken, hover, false, optionHandler->SmootherLVH() ? full : center ); + if (isKicker && !optionHandler->SmootherLVH()) + { + p->setPen(cg.background().dark(150)); + p->drawRect(r.x(), r.y(), r.width(), r.height()); + if (sunken) + { + p->setPen(cg.background().dark(200)); + p->drawRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2); + } + } + } + else + { + drawRectangularButton( p, cg, sunken ? cg.button() : taskContainerHover ? cg.button().light( 110 ) : cg.background(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center); + p->setPen(cg.background().dark(150)); + p->drawLine(r.x(),r.y()+1,r.x(),r.height()-2); + } + const_cast<LiquidStyle*>( this ) ->isTaskContainer = false; + const_cast<LiquidStyle*>( this ) ->taskContainerHover = false; + } + else + { + if ( (p->device() && p->device()->devType() == QInternal::Widget) && ::qt_cast<QHeader*>((QWidget*)p->device()) ) + { + QHeader *header = (QHeader*)p->device(); + int id = header->orientation() == Qt::Horizontal ? header->sectionAt( r.x() + 2 + header->offset() ) : header->sectionAt( r.y() + 2 + header->offset() ); + hover = ((id != -1) && ((currentHeader == header && id == headerHoverID ) || id == headerSortID)); + if (header->mapToIndex(id) == header->count()-1 && (r.bottom() < header->rect().bottom() || r.right() < header->rect().right())) + { + bool hadClip = p->hasClipping(); + p->setClipping( false ); + if (header->orientation() == Qt::Horizontal) + p->fillRect(r.right()+1, r.y(), header->width()-r.right(), r.height(), cg.base()); + else + p->fillRect(r.x(), r.bottom()+1, r.width(), header->height()-r.bottom(), cg.base()); + p->setClipping( hadClip ); + } + } + if (optionHandler->SmoothListViewHeaders()) + { + drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center); + } + else + drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center); + } + p->setPen(oldpen); + break; + } + case PE_FocusRect: + { + p->drawWinFocusRect( r ); + break; + } + case PE_ScrollBarSlider: + case PE_ScrollBarAddPage: + case PE_ScrollBarSubPage: + { + QColor sbBgColor = optionHandler->useCustomColors() ? + optionHandler->customColor( CustomSBGroove ) : + qApp->palette().active().background(); + + bool isActive = optionHandler->ScrollerActive(); + bool isHover = currentScrollBar->hasMouse(); + bool isPressed = currentScrollBar->draggingSlider(); + bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue(); + + // horizontal slider + if ( flags & Style_Horizontal ) + { + int extent = currentScrollBar->height(); + QRect bgR( extent, 0, currentScrollBar->width() - extent * 3 + 1, extent ); + if ( sbBuffer.size() != currentScrollBar->size() ) + const_cast<LiquidStyle*>( this )->sbBuffer.resize( currentScrollBar->size() ); + QPainter painter; + painter.begin( &sbBuffer ); + // pixmaps + if (drawSlider) + { + painter.drawPixmap( bgR.x(), bgR.y() + 1, *getPixmap( HSBSliderBtmBg ) ); + painter.drawTiledPixmap( bgR.x() + 7, bgR.y() + 1, bgR.width() - 15, 13, *getPixmap( HSBSliderMidBg ) ); + painter.drawPixmap( bgR.right() - 8, bgR.y() + 1, *getPixmap( HSBSliderTopBg ) ); + } + else + painter.drawTiledPixmap( bgR.x(), bgR.y() + 1, bgR.width(), 13, *getPixmap( HSBSliderMidBg ) ); + + // lines + painter.setPen( sbBgColor.dark( 110 ) ); + painter.drawLine( bgR.x(), bgR.y(), bgR.right(), bgR.y()); + painter.drawLine( bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); + + if ( pe == PE_ScrollBarSlider && drawSlider) + { + int offset = isPressed * ( optionHandler->squeezeSbSlider() + optionHandler->shadowSbSlider()*2); + int offset2 = optionHandler->shadowSbSlider()*2 + (isPressed && optionHandler->squeezeSbSlider()); + + painter.drawPixmap( r.x() + offset, r.y() + 1, + isPressed ? *getPixmap( HSBSliderBtmPressed ) : + (isHover || isActive || isOOO) ? *getPixmap( HSBSliderBtmActive ) : + *getPixmap( HSBSliderBtm)); + + painter.drawPixmap( r.right() - 6 - offset2, r.y() + 1, + isPressed ? *getPixmap( HSBSliderTopPressed ) : + (isHover || isActive || isOOO) ? *getPixmap( HSBSliderTopActive ) : + *getPixmap( HSBSliderTop ) ); + // mid part last, as i have to redefine clip section + painter.setClipRect(r.x() + 7 + offset2, r.y() + 1, r.width() - 14 - 2*offset2, 13, QPainter::CoordPainter); + painter.drawTiledPixmap( r.x() + 7 + offset2 + ((isHover && !isPressed) ? (sliderAnimShift - 32) : 0), r.y() + 1, r.width() - 14 - 2*offset2 - ((isHover && !isPressed) ? + (sliderAnimShift - 32) : 0), 13, isPressed ? *getPixmap( HSBSliderMidPressed ) : + (isHover || isActive || isOOO) ? *getPixmap( HSBSliderMidActive ) : + *getPixmap( HSBSliderMid ), isPressed?r.x() : 0, 0); + } + + painter.end(); + } + + // vertical slider + else + { + int extent = currentScrollBar->width(); + QRect bgR( 0, extent, extent, currentScrollBar->height() - extent * 3 + 1 ); + + if ( sbBuffer.size() != currentScrollBar->size() ) + const_cast<LiquidStyle*>( this ) -> sbBuffer.resize( currentScrollBar->size() ); + QPainter painter; + painter.begin( &sbBuffer ); // set painter to pixelbuffer + if (drawSlider) + { + // top slidergroove rounder + painter.drawPixmap( bgR.x() + 1, bgR.y(), *getPixmap( VSBSliderTopBg ) ); + // the groove + painter.drawTiledPixmap( bgR.x() + 1, bgR.y() + 8, 13, bgR.height() - 15, *getPixmap( VSBSliderMidBg ) ); + // bottom slidergroove rounder + painter.drawPixmap( bgR.x() + 1, bgR.bottom() - 7, *getPixmap( VSBSliderBtmBg ) ); + } + else + painter.drawTiledPixmap( bgR.x() + 1, bgR.y(), 13, bgR.height(), *getPixmap( VSBSliderMidBg ) ); + + painter.setPen( sbBgColor.dark( 110 ) ); + painter.drawLine( bgR.x(), bgR.y(), bgR.x(), bgR.bottom() ); + painter.drawLine( bgR.right(), bgR.y(), bgR.right(), bgR.bottom() ); + + // here we are, now the slider + if ( pe == PE_ScrollBarSlider && drawSlider ) + { + int offset = isPressed * ( optionHandler->squeezeSbSlider() + optionHandler->shadowSbSlider()*2); + int offset2 = (isPressed * optionHandler->squeezeSbSlider()) + optionHandler->shadowSbSlider()*2; + + painter.drawPixmap( r.x() + 1, r.y() + offset, isPressed ? + *getPixmap( VSBSliderTopPressed ) : + (isHover || isActive || isOOO) ? *getPixmap( VSBSliderTopActive ) : + *getPixmap( VSBSliderTop)); + painter.drawPixmap( r.x() + 1, r.bottom() - 6 - offset2, isPressed ? + *getPixmap( VSBSliderBtmPressed ) : + (isHover || isActive || isOOO) ? *getPixmap( VSBSliderBtmActive ) : + *getPixmap( VSBSliderBtm ) ); + // mid part last, as i have to redefine clipping section + painter.setClipRect(r.x() + 1, r.y() + 7+offset2, 13, r.height() - 14 - 2*offset2, QPainter::CoordPainter); + painter.drawTiledPixmap( r.x() + 1, r.y() + 7 + offset2 - ((isHover && !isPressed) ? sliderAnimShift : 0), + 13, r.height() - 14 - 2*offset2 + ((isHover && !isPressed) ? + sliderAnimShift : 0), isPressed ? *getPixmap( VSBSliderMidPressed ) : + (isHover || isActive || isOOO) ? *getPixmap( VSBSliderMidActive ) : + *getPixmap( VSBSliderMid ),0,isPressed?r.y():0 ); + } + painter.end(); + } + p->drawPixmap( r.x(), r.y(), sbBuffer, r.x(), r.y(), r.width(), r.height() ); + break; + } + case PE_ScrollBarAddLine: + { + QColor c( optionHandler->useCustomColors() ? + optionHandler->customColor( CustomSBGroove ) : + qApp->palette().active().background() ); + QColor pixColor = flags & Style_Down ? qApp->palette().active().button() : c; + + bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue(); + + if ( flags & Style_Horizontal ) + { + p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg)); + p->setPen( c.dark( 110 ) ); + p->drawLine( r.x(), r.y(), r.right(), r.y()); + p->drawLine( r.x(), r.bottom(), r.right(), r.bottom()); + } + else + { + p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg)); + p->setPen( c.dark( 110 ) ); + p->drawLine( r.x(), r.y(), r.x(), r.bottom()); + p->drawLine( r.right(), r.y(), r.right(), r.bottom()); + } + if (drawSlider) + { + p->setPen( flags & Style_Down ? cg.button() : QColor(85,85,85) ); + p->setBrush( flags & Style_Down ? cg.button() : QColor(85,85,85) ); + p->drawPixmap( r.x() + 4, r.y() + 4, flags & Style_Horizontal ? *sbRight : *sbDown ); + } + break; + } + case PE_ScrollBarSubLine: + { + QColor c( optionHandler->useCustomColors() ? + optionHandler->customColor( CustomSBGroove ) : + qApp->palette().active().background() ); + QColor pixColor = flags & Style_Down ? qApp->palette().active().button() : c; + bool top = flags & Style_Horizontal ? r.x() == 0 : r.y() == 0; + + bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue(); + + if ( flags & Style_Horizontal ) + { + if ( top ) + { + p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg)); + } + else + { + p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg)); + } + p->setPen( c.dark( 110 ) ); + p->drawLine( r.x(), r.y(), r.right(), r.y()); + p->drawLine( r.x(), r.bottom(), r.right(), r.bottom()); + } + else + { + if ( top ) + { + p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg)); + } + else + { + p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg)); + } + p->setPen( c.dark( 110 ) ); + p->drawLine( r.x(), r.y(), r.x(), r.bottom()); + p->drawLine( r.right(), r.y(), r.right(), r.bottom()); + } + if (drawSlider) + { + p->setPen( flags & Style_Down ? cg.button() : QColor(85,85,85) ); + p->setBrush( flags & Style_Down ? cg.button() : QColor(85,85,85) ); + if (currentScrollBar->minValue() < currentScrollBar->maxValue()) p->drawPixmap( r.x() + 4, r.y() + 4, flags & Style_Horizontal ? *sbLeft : *sbUp ); + } + break; + } + case PE_Indicator: + { + bool hover = flags & Style_MouseOver; + bool pressed = flags & Style_Down; +// bool isMasked = p->device() && p->device() ->devType() == QInternal::Widget && ( ( QWidget * ) p->device() ) ->autoMask(); +#if 0 + if ( isMasked ) + { + if ( !( flags & Style_Off ) ) + p->drawPixmap( r.x(), r.y(), + hover ? *getPixmap( HTMLCBDownHover ) : + *getPixmap( HTMLCBDown ) ); + else + p->drawPixmap( r.x(), r.y(), hover ? + *getPixmap( HTMLCBHover ) : *getPixmap( HTMLCB ) ); + } + else +#endif + { + if ( flags & Style_On ) + p->drawPixmap( r.x(), r.y(), + pressed ? *getPixmap( CBDownPressed ) : + hover ? *getPixmap( CBDownHover ) : + *getPixmap( CBDown ) ); + else if ( flags & Style_Off ) + p->drawPixmap( r.x(), r.y(), + pressed ? *getPixmap( CBPressed ) : + hover ? *getPixmap( CBHover ) : + *getPixmap( CB ) ); + else //tristate + p->drawPixmap( r.x(), r.y(), + pressed ? *getPixmap( CBTriPressed ) : + hover ? *getPixmap( CBTriHover ) : + *getPixmap( CBTri ) ); + } + break; + } + case PE_IndicatorMask: + { + p->fillRect( r, Qt::color1 ); + break; + } + case PE_ExclusiveIndicator: + { + bool hover = flags & Style_MouseOver; + bool pressed = flags & Style_Down; + + if ( on || down ) + p->drawPixmap( r.x(), r.y(), + pressed ? *getPixmap( RadioOnPressed ) : + hover ? *getPixmap( RadioOnHover ) : + *getPixmap( RadioOn ) ); + else + p->drawPixmap( r.x(), r.y(), + pressed ? *getPixmap( RadioOffPressed ) : + hover ? *getPixmap( RadioOffHover ) : + *getPixmap( RadioOff ) ); + break; + } + case PE_ExclusiveIndicatorMask: + { + break; + } + case PE_Splitter: + case PE_DockWindowResizeHandle: + { + QPen oldpen(p->pen()); + QBrush oldbrush(p->brush()); + if (highlightWidget == p->device()) + { + if (flags & Style_Horizontal) + { //vertical? + p->setPen(cg.mid()); + p->drawLine(r.x(), r.y(), r.x(), r.bottom()); + p->drawLine(r.right(), r.y(), r.right(), r.bottom()); + p->setPen(cg.button().dark(140)); + p->setBrush(cg.button().dark(140)); + p->drawEllipse(r.x()+1,r.y() + (int)(r.height() / 2.5), 4, 4); + } + else + { + p->setPen(cg.mid()); + p->drawLine(r.x(), r.y(), r.right(), r.y()); + p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); + p->setPen(cg.button().dark(140)); + p->setBrush(cg.button().dark(140)); + p->drawEllipse(r.x()+r.width()/2,r.y() + 1, 4, 4); + } + + } + else + { + if (flags & Style_Horizontal) + { + p->setPen(cg.mid()); + p->drawLine(r.x(), r.y(), r.x(), r.bottom()); + p->drawLine(r.right(), r.y(), r.right(), r.bottom()); + p->setPen(cg.background().dark(130)); + p->setBrush(cg.background().dark(150)); + p->drawEllipse(r.x()+1,r.y() + (int)(r.height() / 2.5), 4, 4); + } + else + { + p->setPen(cg.mid()); + p->drawLine(r.x(), r.y(), r.right(), r.y()); + p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); + p->setPen(cg.background().dark(130)); + p->setBrush(cg.background().dark(150)); + p->drawEllipse(r.x()+r.width()/2,r.y() + 1, 4, 4); + } + } + p->setPen(oldpen); + p->setBrush(oldbrush); + break; + } +// case PE_BoxFrame: + case PE_PanelGroupBox: + case PE_GroupBoxFrame: + { + QColor bgColor; + QWidget* w = (p->device() && p->device()->devType() == QInternal::Widget) ? + (QWidget*)(p->device()) : 0; + QGroupBox* gb = ::qt_cast<QGroupBox*>(w); + + optionHandler->drawGroupBoxShadow() ? + bgColor = QColor(cg.background().dark( 100 + optionHandler->ShadowDarkness() )) : + bgColor = QColor(cg.background()); + QColor bright( bgColor.dark( 110 ) ); + QColor mid( bgColor.dark( 130 ) ); + QColor dark( bgColor.dark( 150 ) ); + + int titleHeight = (gb && !gb->title().isEmpty() && pe == PE_PanelGroupBox) ? + p->fontMetrics().height()+(gb->isCheckable()?4:1) : 0; + + int x = r.x(); int right = r.right(); int bottom = r.bottom(); + int y2 = r.y(); + + /*** + ok, to get the sunken look somwhat efficient and less glitchy + we reset the groupbox brush and only repaint the title + (saves us from several is item in groupbox checks as well) + only problem left: draw the parents brush on the title window aligned... + ***/ + + if (gb && titleHeight) + { + bool hadClip = p->hasClipping(); + QRegion oldClip = p->clipRegion(); + if (gb->parentWidget()) + { + const QPixmap *pix = gb->parentWidget()->paletteBackgroundPixmap(); + + if (optionHandler->drawGroupBoxShadow()) + { + QPointArray pa1(3); + pa1.setPoint(0, x,y2); + pa1.setPoint(1, x+5,y2); + pa1.setPoint(2, x,y2+5); + QPointArray pa2(3); + pa2.setPoint(0, right-5,y2); + pa2.setPoint(1, right,y2); + pa2.setPoint(2, right,y2+5); + QPointArray pa3(3); + pa3.setPoint(0, right,bottom-5); + pa3.setPoint(1, right,bottom); + pa3.setPoint(2, right-5,bottom); + QPointArray pa4(3); + pa4.setPoint(0, x+5,bottom); + pa4.setPoint(1, x,bottom); + pa4.setPoint(2, x,bottom-5); + + QRegion reg2(0,0, r.right(), titleHeight); + p->setClipRegion(QRegion(pa1)+QRegion(pa2)+QRegion(pa3)+QRegion(pa4)+reg2); + } + else + p->setClipRect(0,0,r.right(),titleHeight); + pix ? p->drawTiledPixmap( QRect( 0, 0, w->width(), w->height()), *pix, w->backgroundOffset()) : p->fillRect(QRect(0, 0, w->width(), w->height()),w->parentWidget()->backgroundBrush()); + } + if (gb && !gb->isCheckable()) + { + QString title = gb->title(); + QFont font( p->font() ); + font.setBold( true ); + p->setFont( font ); + drawItem( p, QRect(10,0,r.width(),titleHeight), ShowPrefix, cg, flags & Style_Enabled, 0, title, -1, &cg.text() ); + } + p->setClipRegion(oldClip); + p->setClipping(hadClip); + } + + //outer rect + // top + p->setPen( dark ); + if (pe == PE_PanelGroupBox) + { + p->drawLine( x + 6, y2, right - 6, y2 ); + // left points + p->drawPoint(x+3,y2+1);p->drawPoint(x+4,y2+1); + p->drawPoint(x+2,y2+2); + p->drawPoint(x+1,y2+3); + // right points + p->drawPoint(right-3,y2+1);p->drawPoint(right-4,y2+1); + p->drawPoint(right-2,y2+2); + p->drawPoint(right-1,y2+3); + // vertcal outer lines + p->drawLine(x,y2+5,x,bottom-5); + p->drawLine(right,y2+5,right,bottom-5); + } + else + { + // vertcal outer lines + p->drawLine(x,y2,x,bottom-5); + p->drawLine(right,y2,right,bottom-5); + } + + p->setPen( mid ); + if (pe == PE_PanelGroupBox) + { + // top stuff + p->drawPoint(x+4, y2);p->drawPoint(x+5,y2); + p->drawPoint(right-4, y2);p->drawPoint(right-5,y2); + p->drawPoint(x+2, y2+1); + p->drawPoint(right-2, y2+1); + p->drawLine(x+5,y2 + 1, right - 5, y2 + 1); + p->drawPoint(x+1,y2+2); + p->drawPoint(right-1,y2+2); + p->drawPoint(x+2,y2+3); + p->drawPoint(right-2,y2+3); + p->drawPoint(x,y2+4);p->drawPoint(x+1,y2+4); + p->drawPoint(right,y2+4);p->drawPoint(right+1,y2+4); + } + // bottom stuff + p->drawPoint(x,bottom - 4); p->drawPoint(x+1,bottom - 4); + p->drawPoint(right,bottom - 4); p->drawPoint(right-1,bottom - 4); + p->drawPoint(x+1,bottom - 3); + p->drawPoint(right-1,bottom - 3); + p->drawPoint(x+1,bottom - 2); p->drawPoint(x+2,bottom - 2); + p->drawPoint(right-1,bottom - 2); p->drawPoint(right-2,bottom - 2); + p->drawPoint(x+2, bottom - 1); p->drawPoint(x+3, bottom - 1); + p->drawPoint(right-2, bottom - 1); p->drawPoint(right-3, bottom - 1); + p->drawLine(x + 4, bottom,right - 4, bottom); + + p->setPen(bright); + // top stuff + if (pe == PE_PanelGroupBox) + { + p->drawPoint(x+3,y2);p->drawPoint(right-3,y2); + p->drawLine(x+4,y2+2,right-4,y2+2); + p->drawPoint(x,y2+3);p->drawPoint(x+3,y2+3); + p->drawPoint(right,y2+3);p->drawPoint(right-3,y2+3); + p->drawPoint(x+2,y2+4);p->drawPoint(right-2,y2+4); + // vertical lines + p->drawLine(x+1,y2+5,x+1,bottom-5); + p->drawLine(right-1,y2+5,right-1,bottom-5); + } + else + { + // vertical lines + p->drawLine(x+1,y2,x+1,bottom-5); + p->drawLine(right-1,y2,right-1,bottom-5); + } + // bottom stuff + p->drawPoint(x, bottom-3);p->drawPoint(right, bottom-3); + p->drawPoint(x+3, bottom);p->drawPoint(right-3, bottom); + + break; + } + case PE_StatusBarSection: + { + break; + } + case PE_WindowFrame: + { + drawEditFrame( p, r, cg, false, false, true ); + break; + } + case PE_Panel: + { + bool sunken = flags & Style_Sunken; + if (!(isKicker && optionHandler->RemoveKickerBevel())) + sunken ? drawEditFrame( p, r, cg ) : drawEditFrame( p, r, cg, false, false, true ); + break; + } + case PE_PanelTabWidget: + { + // don't ask + bool isDialog = optionHandler->TabStyle() == Clever && + (p->device() && p->device()->devType() == QInternal::Widget)&& + ((QWidget*)p->device())->topLevelWidget()->inherits("QDialog"); + + QColor bright( cg.background().dark( 110 ) ); + QColor mid( cg.background().dark( 130 ) ); + QColor dark( cg.background().dark( 150 ) ); + int x = r.x(); int right = r.right(); int bottom = r.bottom(); int y2 = r.y(); + if (isDialog || optionHandler->TabStyle() == Chooser) + { + //outer rect + // top + p->setPen( dark ); + // vertcal outer lines + p->drawLine(x,y2,x,bottom-5); + p->drawLine(right,y2,right,bottom-5); + + p->setPen( mid ); + // bottom stuff + p->drawPoint(x,bottom - 4); p->drawPoint(x+1,bottom - 4); + p->drawPoint(right,bottom - 4); p->drawPoint(right-1,bottom - 4); + p->drawPoint(x+1,bottom - 3); + p->drawPoint(right-1,bottom - 3); + p->drawPoint(x+1,bottom - 2); p->drawPoint(x+2,bottom - 2); + p->drawPoint(right-1,bottom - 2); p->drawPoint(right-2,bottom - 2); + p->drawPoint(x+2, bottom - 1); p->drawPoint(x+3, bottom - 1); + p->drawPoint(right-2, bottom - 1); p->drawPoint(right-3, bottom - 1); + p->drawLine(x + 4, bottom,right - 4, bottom); + + p->setPen(bright); + // top stuff + // vertical lines + p->drawLine(x+1,y2,x+1,bottom-5); + p->drawLine(right-1,y2,right-1,bottom-5); + + // bottom stuff + p->drawPoint(x, bottom-3);p->drawPoint(right, bottom-3); + p->drawPoint(x+3, bottom);p->drawPoint(right-3, bottom); + break; + } + else + { + p->setPen( mid ); + p->drawLine( x, y2, x, bottom-2 ); + p->drawLine( right, y2, right, bottom-2 ); + p->setPen( dark ); + p->drawLine( x, bottom-1, right, bottom-1 ); + p->drawLine( x, bottom, right, bottom ); + break; + } + } + case PE_PanelLineEdit: + { + bool focused = flags & Style_HasFocus; + bool isHTML = p->device() && p->device()->devType() == QInternal::Widget && isHTMLWidget((QWidget*)p->device()); + drawEditFrame( p, r, cg, isHTML, focused, false); + break; + } + case PE_PanelPopup: + { + int x, y, w , h; + r.rect( &x, &y, &w, &h ); + QColor c( optionHandler->UseCustomMenuColor()? + optionHandler->Color(): + optionHandler->MenuColorButton()? + optionHandler->buttonColor(): + optionHandler->bgColor() ); + p->setPen( c.dark( 140 ) ); + p->drawRect( x, y, w, h ); + p->setPen( c.light( 120 ) ); + p->drawRect( x + 1, y + 1, w - 2, h - 2 ); + break; + } + case PE_PanelMenuBar: + { + break; + } + case PE_PanelDockWindow: + { + break; + } + case PE_Separator: + case PE_DockWindowSeparator: + { + break; //don't draw anything + if (!(p->device() && p->device()->devType() == QInternal::Widget && ::qt_cast<QToolBar*>((QWidget*)p->device()))) + { + if ( !( flags & Style_Horizontal ) ) + { + p->setPen( cg.mid() ); + p->drawLine( 4, r.height() / 2, r.width() - 5, r.height() / 2 ); + p->setPen( cg.light() ); + p->drawLine( 4, r.height() / 2 + 1, r.width() - 5, r.height() / 2 + 1 ); + } + else + { + p->setPen( cg.mid() ); + p->drawLine( r.width() / 2, 4, r.width() / 2, r.height() - 5 ); + p->setPen( cg.light() ); + p->drawLine( r.width() / 2 + 1, 4, r.width() / 2 + 1, r.height() - 5 ); + } + } + break; + } + case PE_SpinWidgetUp: + case PE_SpinWidgetDown: + { + bool sunken = on || down; + bool hover = flags & Style_MouseOver; + int x = r.x() + ( r.width() - 7 ) / 2; + int y = pe == PE_SpinWidgetDown ? r.y() + 1 : r.bottom() - 7; + QPen oldPen( p->pen() ); + QBrush oldBrush( p->brush() ); + p->setPen( sunken ? cg.button() : hover ? cg.mid() : cg.text() ); + p->setBrush( sunken ? cg.button() : hover ? cg.mid() : cg.text() ); + p->drawPixmap( x, y, pe == PE_SpinWidgetUp ? *sbUp : *sbDown ); + p->setBrush( oldBrush ); + p->setPen( oldPen ); + break; + } + case PE_CheckMark: + { + QPen oldPen( p->pen() ); + p->setPen( flags & Style_On ? cg.highlightedText() : optionHandler->textColor() ); + p->drawPixmap(r.x() + r.width()/2 - 4,r.y() + r.height()/2 - 4,*checkmark); + p->setPen( oldPen ); + break; + } + default: + { + if ( (pe >= PE_ArrowUp && pe <= PE_ArrowLeft ) || pe == PE_HeaderArrow) + { + QBrush oldBrush(p->brush()); + QColor tmpC = flags & Style_Enabled ? (flags & Style_Down || flags & Style_Sunken) && pe != PE_HeaderArrow ? cg.light() : cg.buttonText() : cg.mid(); + if (tmpC == Qt::black) tmpC = QColor(85,85,85); + p->setBrush(tmpC); + int x = r.width() > 7 ? r.x() + r.width()/2 - 4 : r.right() - 7; + int y = r.height() > 7 ? r.y() + r.height()/2 - 4 : r.bottom() - 7; + + switch ( pe ) + { + case PE_ArrowRight: + { + p->drawPixmap(x,y,*sbRight); + break; + } + case PE_ArrowUp: + { + p->drawPixmap(x,y,*sbUp); + break; + } + case PE_ArrowDown: + { + p->drawPixmap(x,y,*sbDown); + break; + } + case PE_HeaderArrow: + { + if (flags & Style_Up) + p->drawPixmap(x,y,*sbUp); + else + p->drawPixmap(x,y,*sbDown); + break; + } + default: + { + p->drawPixmap(x,y,*sbLeft); + break; + } + } + p->setBrush( oldBrush ); + } + else + KStyle::drawPrimitive( pe, p, r, cg, flags, opt ); + } + } // general switch +} + +void LiquidStyle::drawKStylePrimitive( KStylePrimitive kpe, QPainter* p, + const QWidget* widget, const QRect &r, + const QColorGroup &cg, SFlags flags, + const QStyleOption &opt ) const +{ + switch ( kpe ) + { + case KPE_ToolBarHandle: + { + if (widget && widget->parentWidget() && widget->parentWidget()->hasMouse()) + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + w = (int)((w-3)/2); + QColor c( (optionHandler->style() == Brushed) ? cg.background() : cg.background().dark(120) ); + p->setPen(c); + p->setBrush(c); + for (int i = 0; i < h-3; i += 5 ) + p->drawEllipse(x+w,y+i,3,3); + } + break; + } + case KPE_GeneralHandle: + { + if (!widget) + break; + if ( widget->inherits( "AppletHandleDrag" ) ) + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + w = (int)((w-3)/2); + QColor c( widget->hasMouse() ? cg.button() : cg.background().dark(110) ); + p->setPen(c); + p->setBrush(c); + for (int i = 0; i < h-3; i += 5 ) + p->drawEllipse(x+w,y+i,3,3); + break; + } + else if (widget->hasMouse()) + { + if (optionHandler->style() == Brushed) + { + drawCombo( p, cg, cg.button(), r.x(), r.y(), r.width(), r.height()+2, false, false, false, center); + } + else + { + p->fillRect(r,cg.button()); + p->setPen(cg.button().dark( 100 + optionHandler->stippleContrast() )); + int x=r.x(); + int y=r.y(); + int w=r.width(); + int h=r.height(); + for (int i = y;i < y+h; i += 4 ) + { + p->drawLine( x, i, x+w, i ); + p->drawLine( x, i + 1, x+w, i + 1 ); + } + } + } + else if (optionHandler->style() == Brushed && widget->parentWidget()) // needs alignment + { + p->drawTiledPixmap(r, *widget->paletteBackgroundPixmap(), widget->parentWidget()->backgroundOffset()); + } + break; + } + case KPE_SliderGroove: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + if (qstrcmp( qApp->argv() [ 0 ], "kmix" ) == 0) x = x+3; + if ( ( ( const QSlider * ) widget ) ->orientation() == Qt::Horizontal ) + { + int x2 = x + w - 1; + y = y + ( h - 5 ) / 2; + p->setPen( cg.background().dark( 135 ) ); + p->drawLine( x + 1, y, x2 - 1, y ); //1 + p->drawLine( x, y + 4, x2, y + 4 ); //5 + p->setPen( cg.background().dark( 150 ) ); + p->drawLine( x, y + 1, x2, y + 1 ); //2 + p->setPen( cg.background().dark( 115 ) ); + p->drawLine( x, y + 2, x2, y + 2 ); //3 + p->drawLine( x, y + 3, x2, y + 3 ); //4 + p->setPen( cg.background().light( 130 ) ); + p->drawLine( x + 1, y + 5, x2 - 1, y + 5 ); //6 + } + else + { + int y2 = y + h - 1; + x = x + ( w - 5 ) / 2; + p->setPen( cg.background().dark( 135 ) ); + p->drawLine( x, y + 1, x, y2 - 1 ); + p->drawLine( x + 4, y, x + 4, y2 ); + p->setPen( cg.background().dark( 150 ) ); + p->drawLine( x + 1, y, x + 1, y2 ); + p->setPen( cg.background().dark( 115 ) ); + p->drawLine( x + 2, y, x + 2, y2 ); + p->drawLine( x + 3, y, x + 3, y2 ); + p->setPen( cg.background().light( 130 ) ); + p->drawLine( x + 5, y + 1, x + 5, y2 - 1 ); + } + break; + } + case KPE_SliderHandle: + { + if (!widget) + { + p->drawPixmap( r.x(), r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff)); + break; + } + if ((( const QSlider * ) widget ) ->orientation() == Qt::Horizontal) + (widget && widget->height() < 17) ? p->drawPixmap( r.x(), r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff)) : p->drawPixmap( r.x(), (optionHandler->style() == Milk) ? r.y() : r.y()+2, *getPixmap( flags & Style_Enabled ? HSlider : HSliderInactive)); + else + { + bool right = (( const QSlider * ) widget )->tickmarks() == QSlider::NoMarks || (( const QSlider * ) widget )->tickmarks() == QSlider::Right; + (widget && widget->width() < 17) ? p->drawPixmap( r.x()+2, r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff)) : p->drawPixmap( (optionHandler->style() == Milk) ? r.x() : right ? r.x()+5 : r.x()-3, r.y(), *getPixmap( flags & Style_Enabled ? (right ? VSlider : VSliderAbove) : (right ? VSliderInactive : VSliderAboveInactive))); + } + break; + } + case KPE_ListViewExpander: + { + p->fillRect(r,Qt::green); + // int radius = ( r.width() - 4 ) / 2; + // int centerx = r.x() + r.width() / 2; + // int centery = r.y() + r.height() / 2; + // + // int red, green, blue; + // red = ( cg.dark().red() >> 1 ) + ( cg.base().red() >> 1 ); + // green = ( cg.dark().green() >> 1 ) + ( cg.base().green() >> 1 ); + // blue = ( cg.dark().blue() >> 1 ) + ( cg.base().blue() >> 1 ); + // QColor blendColor( red, green, blue ); + // + // p->setPen( cg.dark() ); + // p->drawLine( r.x() + 1, r.y(), r.right() - 1, r.y() ); + // p->drawLine( r.x() + 1, r.bottom(), r.right() - 1, r.bottom() ); + // p->drawLine( r.x(), r.y() + 1, r.x(), r.bottom() - 1 ); + // p->drawLine( r.right(), r.y() + 1, r.right(), r.bottom() - 1 ); + // p->setPen( blendColor ); + // p->drawPoint( r.x(), r.y() ); + // p->drawPoint( r.right(), r.y() ); + // p->drawPoint( r.x(), r.bottom() ); + // p->drawPoint( r.right(), r.bottom() ); + // p->setPen( cg.light() ); + // p->drawRect( r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2 ); + // p->fillRect( r.x() + 2, r.y() + 2, r.width() - 4, r.height() - 4, + // cg.background() ); + // p->setPen( cg.text() ); + // p->drawLine( centerx - radius, centery, centerx + radius, centery ); + // if ( flags & Style_On ) + // p->drawLine( centerx, centery - radius, centerx, centery + radius ); + break; + } + default: + KStyle::drawKStylePrimitive( kpe, p, widget, r, cg, flags, opt ); + } +} + +void LiquidStyle::drawControl( ControlElement element, QPainter *p, + const QWidget *widget, const QRect &r, + const QColorGroup &cg, SFlags flags, + const QStyleOption &opt ) const +{ + switch ( element ) + { + case CE_ProgressBarGroove: + { + p->setPen(cg.background().dark(160)); + p->drawRect(r); + drawCombo( p, cg, cg.background(), r.x()+1, r.y()+1, r.width()-2, r.height()+1, false, false, false, center ); + break; + } + case CE_ProgressBarContents: + { +// qWarning("%s - %s,%s : %s,%s",qApp->argv()[0],widget->className(),widget->name(),widget->parentWidget()->className(),widget->parentWidget()->name()); + const QProgressBar *progress = ( const QProgressBar * ) widget; + QRect contentsR( subRect( SR_ProgressBarContents, widget ) ); + double val = progress->progress(); + bool reverse = QApplication::reverseLayout(); + val = val / progress->totalSteps(); + if ( val > 0.0 ) + { + int w = QMIN( contentsR.width(), ( int ) (val * contentsR.width() ) ); + if ( w > 1 ) + { + int x = contentsR.x(); + int y = contentsR.y(); + QRect progressRect; + if (reverse) + progressRect = QRect(x+(contentsR.width()-w), y, w, contentsR.height()+1); + else + progressRect = QRect(x, y, w, contentsR.height()+1); + if (optionHandler->ProgressBar() == liquid) + { + int x2 = x + w - 1; + int y2 = contentsR.bottom(); + //Clip to the old rectangle + p->setClipRect(progressRect, QPainter::CoordPainter); + //Expand + progressRect.setLeft(progressRect.x() - progAnimShift); + p->setPen(cg.button().dark(120)); + p->drawLine(x, y, x2, y); + p->drawLine(x, y, x, y2); + p->drawLine(x+1, y2+1, x2-1, y2+1); + p->setPen(cg.button().dark(110)); + p->drawLine(x2, y, x2, y2); + p->drawLine(x, y2, x2, y2); + QPixmap * pix = getPixmap( Progress ); + p->drawTiledPixmap(/*x+1, y+1, w-2, contentsR.height()-2*/progressRect, *pix); + } + else if (optionHandler->ProgressBar() == baghira) + { + drawCombo( p, cg, cg.button(), r.x()-1, r.y()-1, w, contentsR.height()+5, false, false, false, center); + } + else + { + ButtonTile *progress2Tile = progress2Dict.find( cg.button().rgb() ); + if ( !progress2Tile ) + { + QPixmap *pix = getPixmap(progress2); + progress2Tile = separateTiles( pix, 0, 15, 38, 1, 0, true); + if ( !progress2Tile ) + { + qWarning( "Progress tile is NULL!" ); + return ; + } + else + { + LiquidStyle *ptr = const_cast<LiquidStyle*>( this ); + ptr->progress2Dict.insert( cg.button().rgb(), progress2Tile ); + } + } + //Clip to the old rectangle + p->setClipRect(progressRect, QPainter::CoordPainter); + //Expand + progressRect.setLeft(progressRect.x() - 38 + prog2AnimShift); + int h; /*x, y, w;*/ + progressRect.rect(&x, &y, &w, &h); + bool tooSmall = h < 32; + int mid = h/2; + p->drawTiledPixmap(x,tooSmall ? mid + 1 : progressRect.bottom()-15,w,16, *progress2Tile->pixmap(TileBtm)); + p->drawTiledPixmap(x,tooSmall ? mid : y+15,w,tooSmall ? 1 : h-31, *progress2Tile->pixmap(TileMiddle)); + p->drawTiledPixmap(x,tooSmall ? mid - 15 : y,w,15, *progress2Tile->pixmap(TileTop)); + } + } + } + break; + }/* + case CE_ToolButtonLabel: + { + const QToolButton *toolbutton = (const QToolButton *) widget; + QRect rect = r; + Qt::ArrowType arrowType = opt.isDefault() + ? Qt::DownArrow : opt.arrowType(); + + int shiftX = 0; + int shiftY = 0; + if (flags & (Style_Down | Style_On)) { + shiftX = pixelMetric(PM_ButtonShiftHorizontal, widget); + shiftY = pixelMetric(PM_ButtonShiftVertical, widget); + } + + if (!opt.isDefault()) + { + PrimitiveElement pe; + switch (arrowType) + { + case Qt::LeftArrow: pe = PE_ArrowLeft; break; + case Qt::RightArrow: pe = PE_ArrowRight; break; + case Qt::UpArrow: pe = PE_ArrowUp; break; + default: + case Qt::DownArrow: pe = PE_ArrowDown; break; + } + + rect.moveBy(shiftX, shiftY); + drawPrimitive(pe, p, rect, cg, flags, opt); + } + else + { + QColor btext = Qt::black;//(flags & (Style_Down | Style_On)) ? qApp->palette().color(QPalette::Active,QColorGroup::ButtonText) : toolbutton->paletteForegroundColor(); + + if (toolbutton->iconSet().isNull() && + ! toolbutton->text().isNull() && + ! toolbutton->usesTextLabel()) { + int alignment = AlignCenter | ShowPrefix; + if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0)) + alignment |= NoAccel; + + rect.moveBy(shiftX, shiftY); + drawItem(p, rect, alignment, cg, + flags & Style_Enabled, 0, toolbutton->text(), + toolbutton->text().length(), &btext); + } else { + QPixmap pm; + QIconSet::Size size = + toolbutton->usesBigPixmap() ? QIconSet::Large : QIconSet::Small; + QIconSet::State state = + toolbutton->isOn() ? QIconSet::On : QIconSet::Off; + QIconSet::Mode mode; + if (! toolbutton->isEnabled()) + mode = QIconSet::Disabled; + else if (flags & (Style_Down | Style_On) || + (flags & Style_Raised) && (flags & Style_AutoRaise)) + mode = QIconSet::Active; + else + mode = QIconSet::Normal; + pm = toolbutton->iconSet().pixmap( size, mode, state ); + + if ( toolbutton->usesTextLabel() ) + { + p->setFont( toolbutton->font() ); + QRect pr = rect, tr = rect; + int alignment = ShowPrefix; + if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0)) + alignment |= NoAccel; + + if ( toolbutton->textPosition() == QToolButton::Under ) + { + int fh = p->fontMetrics().height(); + pr.addCoords( 0, 1, 0, -fh-3 ); + tr.addCoords( 0, pr.bottom(), 0, -3 ); + pr.moveBy(shiftX, shiftY); + drawItem( p, pr, AlignCenter, cg, TRUE, &pm, QString::null ); + alignment |= AlignCenter; + } + else + { + pr.setWidth( pm.width() + 8 ); + tr.addCoords( pr.right(), 0, 0, 0 ); + pr.moveBy(shiftX, shiftY); + + drawItem( p, pr, AlignCenter, cg, TRUE, &pm, QString::null ); + alignment |= AlignLeft | AlignVCenter; + } + + tr.moveBy(shiftX, shiftY); + drawItem( p, tr, alignment, cg, + flags & Style_Enabled, 0, toolbutton->textLabel(), + toolbutton->textLabel().length(), &btext); + } + else + { + rect.moveBy(shiftX, shiftY); + drawItem( p, rect, AlignCenter, cg, TRUE, &pm, QString::null ); + } + } + } + + break; + }*/ + +/* + case CE_HeaderLabel: + { + QRect rect = r; + const QHeader* header = (const QHeader *) widget; + int section = opt.headerSection(); + + QIconSet* icon = header->iconSet( section ); + if ( icon ) { + QPixmap pixmap = icon->pixmap( QIconSet::Small, + flags & Style_Enabled ? + QIconSet::Normal : QIconSet::Disabled ); + int pixw = pixmap.width(); + int pixh = pixmap.height(); + // "pixh - 1" because of tricky integer division + + QRect pixRect = rect; + pixRect.setY( rect.center().y() - (pixh - 1) / 2 ); + drawItem ( p, pixRect, AlignVCenter, cg, flags & Style_Enabled, + &pixmap, QString::null ); + rect.setLeft( rect.left() + pixw + 2 ); + } + drawItem ( p, rect, AlignVCenter, cg, flags & Style_Enabled, + 0, header->label( section ), -1, (isTaskContainer && (flags & Style_MouseOver)) ? &(qApp->palette().color(QPalette::Active,QColorGroup::ButtonText)) : &(cg.buttonText()) ); + break; + }*/ + case CE_ProgressBarLabel: + { + if (optionHandler->DrawProgressLabel()) + { + QRect contentsR( subRect( SR_ProgressBarContents, widget ) ); + if ( !contentsR.isValid() ) + return ; + QFont font( p->font() ); + font.setBold( true ); + p->setFont( font ); + p->setPen( widget->colorGroup().buttonText() ); + p->setClipRect(r, QPainter::CoordPainter); + p->drawText( contentsR, AlignCenter, ( ( const QProgressBar * ) widget ) ->progressString() ); + } + break; + } + case CE_TabBarTab: + { // new style with tiled pixmaps + if ( !widget || !widget->parentWidget(true) ) + break; + const QTabBar *tabBar = ( const QTabBar * ) widget; + bool selected = flags & Style_Selected; + bool hover = currentTabBar && currentTabBar == tabBar && tabBar->indexOf(opt.tab()->identifier()) == hoveredTabIndex; + + myPosition pos; + if (tabBar->count() == 1) + pos = full; + else if ((tabBar->indexOf(opt.tab()->identifier()) == 0)) + pos = left; + else if (tabBar->indexOf(opt.tab()->identifier()) == tabBar->count() - 1) + pos = right; + else + pos = center; + + QColor c; + if (hover || selected) + { + if (optionHandler->useCustomColors()) + c = optionHandler->customColor(CustomTabOn); + else + c = optionHandler->buttonColor(); + } + else + { + if (optionHandler->useCustomColors()) + c = optionHandler->customColor(CustomTabOff); + else + c = optionHandler->InactiveButtonColor(); + } + + bool isDialog = optionHandler->TabStyle() == Clever && widget->topLevelWidget()->inherits("QDialog"); + if (isDialog || optionHandler->TabStyle() == Chooser) + drawCombo( p, cg, c, r.x(), r.y(), r.width(), r.height(), false, false, false, pos ); + else + { + LiquidStyle *ptr = const_cast<LiquidStyle*>( this ); + bool above = tabBar->shape() == QTabBar::RoundedAbove || tabBar->shape() == QTabBar::TriangularAbove; + QPixmap *pix; + if (above) + pix = selected ? getPixmap( TabDown ) : getPixmap( Tab ); + else + pix = selected ? getPixmap( belowTabDown ) : getPixmap( belowTab ); + ButtonTile *tabTile = above ? tabDict.find( c.rgb() ) : inverseTabDict.find(c.rgb()); + if ( !tabTile ) + tabTile = separateTiles( pix, 9, 15, 67, 1, 0, false); + if ( !tabTile ) + { + qWarning( "Tab tile is NULL!" ); + return ; + } + else + above ? ptr->tabDict.insert( c.rgb(), tabTile ) : ptr->inverseTabDict.insert( c.rgb(), tabTile ); + + int offset; + selected ? offset = 0 : offset = 2; + + if ( r.width() > 18 ) + { + p->drawTiledPixmap( r.x() + 9, r.y() + offset, r.width() - 18, 15, *tabTile->pixmap( TileTop ) ); + p->drawTiledPixmap( r.x() + 9, r.height() - 11, r.width() - 18, 11, *tabTile->pixmap( TileBtm ) ); + } + if ( r.height() + offset > 26 ) + { + p->drawTiledPixmap( r.x() + 0, r.y() + 15 + offset, 9, r.height() - 26 - offset, *tabTile->pixmap( TileLeft ) ); + p->drawTiledPixmap( r.right() - 8, r.y() + 15 + offset, 9, r.height() - 26 - offset, *tabTile->pixmap( TileRight ) ); + } + if ( r.width() > 18 && r.height() + offset > 22 ) + p->drawTiledPixmap( r.x() + 9, r.y() + 15 + offset, r.width() - 18, r.height() - 26 - offset, *tabTile->pixmap( TileMiddle ) ); + p->drawPixmap( r.x() + 0, r.y() + offset, *tabTile->pixmap( TileTopLeft ) ); + p->drawPixmap( r.right() - 8, r.y() + offset, *tabTile->pixmap( TileTopRight ) ); + p->drawPixmap( r.x() + 0, r.height() - 11, *tabTile->pixmap( TileBtmLeft ) ); + p->drawPixmap( r.right() - 8, r.height() - 11, *tabTile->pixmap( TileBtmRight ) ); + + p->setPen( optionHandler->buttonColor()); + bool drawPoint = optionHandler->CenterTabs() || pos == center || pos == right; + if ( selected ) + { + if (drawPoint) p->drawPoint(r.x(), above ? r.bottom() : r.y()); + p->drawPoint(r.right(), above ? r.bottom() : r.y()); + } + else + { + p->drawLine( r.x() + drawPoint ? 0 : 1, above ? r.bottom() : r.y(), r.right(), above ? r.bottom() : r.y() ); + p->setPen( optionHandler->buttonColor().dark( 158 )); + p->drawLine( r.x() + drawPoint ? 0 : 1, above ? r.bottom()-1 : r.y()+1, r.right(), above ? r.bottom()-1 : r.y() + 1 ); + } + } + break; + } + case CE_TabBarLabel: + { + if ( opt.isDefault() ) + return ; + QTab *t = opt.tab(); + const QTabBar * tb = ( const QTabBar * ) widget; + if ( ( tb->currentTab() != t->identifier() )) + { + if (optionHandler->TabStyle() == TrueTab || + (optionHandler->TabStyle() == Clever && !(widget->topLevelWidget()->inherits("QDialog")))) + { + drawItem( p, QRect( r.x(), r.y() + 1, r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ ); + break; + } + drawItem( p, QRect( r.x(), r.y(), r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ ); + break; + } + drawItem( p, QRect( r.x(), r.y(), r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ ); + break; + } + case CE_PushButton: + { + // if (_htmlWidgetWId == widget->winId()) + // return; + QPushButton *btn = ( QPushButton* ) widget; + const_cast<LiquidStyle*>( this ) ->isHTMLButton = isHTMLWidget( btn ); + ButtonFadeInfo *bfi_ = bfi[btn->winId()]; + if ( widget == highlightWidget || (bfi_ && !bfi_->fadeIn) ) + flags |= Style_MouseOver; + if (btn->isDefault()) + flags |= Style_HasFocus; + // Qt messes this up with WindowOrigin, so we do it ourselves :P + if ( !isPlain() && !btn->autoMask() ) + const_cast<LiquidStyle*>( this ) ->btnOffset = btn->backgroundOffset(); + const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<QWidget*>( widget ); + drawPrimitive( PE_ButtonDefault, p, r, cg, flags, QStyleOption( btn )); + const_cast<LiquidStyle*>( this ) ->paintWidget = 0L; + const_cast<LiquidStyle*>( this ) ->isHTMLButton = false; + break; + } + case CE_PushButtonLabel: + { + // if (_htmlWidgetWId == widget->winId()) + // return; + const QPushButton *btn = ( const QPushButton* ) widget; + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + if ( btn->isOn() || btn->isDown() ) + flags |= Style_Sunken; + + int xoff = x; + if ( btn->iconSet() && !btn->iconSet() ->isNull() ) + { + QIconSet::Mode mode = btn->isEnabled() ? QIconSet::Normal : QIconSet::Disabled; + if ( mode == QIconSet::Normal && btn->hasFocus() ) + mode = QIconSet::Active; + + QIconSet::State state = QIconSet::Off; + if ( btn->isToggleButton() && btn->isOn() ) + state = QIconSet::On; + + QPixmap pix( btn->iconSet() ->pixmap( QIconSet::Small, mode, state ) ); + xoff += (x<6?8:2); + if (btn->text().isEmpty() && !btn->pixmap()) + p->drawPixmap( x + w/2 - pix.width()/2, y + h / 2 - pix.height() / 2, pix ); + else + p->drawPixmap( x<6?6:x, y + ( h - pix.height() ) / 2, pix ); + } + + if ( btn->isMenuButton() ) + { + drawPrimitive( PE_ArrowDown, p, QRect( w-14, (int)(h/2), 7, 7 ) , cg, flags, opt ); + w -= 14; + } + QColor tmp; + + tmp = btn->isDown() && !optionHandler->IcyButtons() ? btn->colorGroup().highlightedText() : btn->colorGroup().buttonText(); + drawItem( p, QRect( xoff, optionHandler->style() == Milk ? y-1 : y, w, h ), AlignCenter | ShowPrefix, cg, btn->isEnabled(), btn->pixmap(), btn->text(), -1, &tmp ); + break; + } + case CE_MenuBarItem: + { + QMenuItem *mi = opt.menuItem(); + bool active = flags & Style_Active; + bool focused = flags & Style_HasFocus; + + if ( active && focused ) + { + optionHandler->glossyMenus() ? + drawCombo( p, cg, cg.highlight(), r.x(), r.y()-1, r.width(), r.height() + 5, false, false, false, center ) : + p->fillRect(r,cg.highlight()); + } + + // QColor tmpColor( cg.background().dark( 120 ) ); + if ( optionHandler->useShadowText() && !( active && focused )) + { + p->setPen(cg.background().dark( 120 )); + p->drawText(r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, mi->text()); + } + // drawItem( p, QRect( r.x() + 1, r.y() + 1, r.width(), r.height() ), AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, &tmpColor ); + + // drawItem( p, r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, active && focused ? &(cg.highlightedText()) : &(cg.text()) ); + p->setPen(active && focused ? cg.highlightedText() : cg.text()); + p->drawText(r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, mi->text()); + break; + } + case CE_PopupMenuItem: + { + int x,y,w, h; + r.rect( &x, &y, &w, &h ); + + const QPopupMenu *popupmenu = ( const QPopupMenu * ) widget; + QMenuItem *mi = opt.menuItem(); + + int tab = opt.tabWidth(); + int maxpmw = opt.maxIconWidth(); + bool dis = mi && !mi->isEnabled(); + bool checkable = popupmenu->isCheckable(); + bool act = flags & Style_Active; + bool enabled = flags & Style_Enabled; + int checkcol = maxpmw; + + QColor menuBgColor( optionHandler->UseCustomMenuColor() ? optionHandler->Color() : optionHandler->bgColor() ); + + if ( checkable ) + checkcol = QMAX( maxpmw, 20 ); + + if ( mi && mi->isSeparator() ) + { + p->setPen( menuBgColor.dark( 130 ) ); + p->drawLine( x + 1, y, x + w - 1, y ); + p->setPen( menuBgColor.light( 120 ) ); + p->drawLine( x+1, y + 1, x + w - 1 , y + 1 ); + return ; + } + if ( act && mi && enabled) + { + optionHandler->glossyMenus() ? + drawCombo( p, cg, cg.highlight(), r.x(), r.y(), r.width(), r.height() + 2, false/*sunken*/, false/*hover*/, false, center ) : + p->fillRect(x,y,w,h,cg.highlight()); + } + else + { + if (popupBack.isNull()) + p->fillRect( x, y, w, h, popupmenu->backgroundBrush() ); + else + p->drawTiledPixmap( x, y, w, h, popupBack ); + + if (act) + { + p->setPen(cg.highlight()); + p->drawRect(x,y,w,h); + } + } + if ( !mi ) + return ; + + // Menu contents drawing code based on Qt's styles. Qt is property of + // TrollTech: www.trolltech.com. Used with permission. + int xpos = x; + QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r ); + int xvis = vrect.x(); + + // icon + if (optionHandler->drawMenuStripe()) + p->fillRect(x,y,h,h, optionHandler->menuStripeColor()); + if ( mi->iconSet() ) + { + QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; + if ( act && !dis ) + mode = QIconSet::Active; + QPixmap pixmap; + if ( checkable && mi->isChecked() ) + pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode, QIconSet::On ); + else + pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); + int pixw = pixmap.width(); + int pixh = pixmap.height(); + QRect pmr( 0, 0, pixw, pixh ); + pmr.moveCenter( vrect.center() ); + p->setPen( cg.text() ); + p->drawPixmap( pmr.topLeft(), pixmap ); + } + else if ( checkable ) + { + if ( mi->isChecked() ) + { + int xp = xpos + windowsItemFrame; + + SFlags cflags = Style_Default; + if ( !dis ) + cflags |= Style_Enabled; + if ( act ) + cflags |= Style_On; + drawPrimitive( PE_CheckMark, p, visualRect( QRect( xp, y + windowsItemFrame, checkcol - 2 * windowsItemFrame, h - 2 * windowsItemFrame ), r ), cg, cflags ); + } + } + QColor discol; + if ( dis ) + { + discol = cg.text(); + p->setPen( discol ); + } + + int xm = windowsItemFrame + checkcol + windowsItemHMargin; + xpos += xm; + + vrect = visualRect( QRect( xpos, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin ), r ); + xvis = vrect.x(); + if ( mi->custom() ) + { + p->save(); + if ( dis && !act ) + { + p->setPen( cg.light() ); + mi->custom() ->paint( p, cg, act, !dis, xvis + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin ); + p->setPen( discol ); + } + mi->custom() ->paint( p, cg, act, !dis, xvis, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin ); + p->restore(); + } + + // Text + QString s = mi->text(); + if ( !s.isNull() ) + { + QColor textColor, shadowColor; + shadowColor = optionHandler->bgColor().dark( 130 ); + + if ( dis ) + textColor = shadowColor.light( 115 ); + else if (/*!optionHandler->glossyMenus() && */act && mi) + textColor = cg.highlightedText(); + else if ( optionHandler->UseCustomMenuColor()) + textColor = optionHandler->textColor(); + else + textColor = cg.text(); + + int t = s.find( '\t' ); + int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; + text_flags |= ( QApplication::reverseLayout() ? AlignRight : AlignLeft ); + if ( t >= 0 ) + { // draw tab text + int xp; + xp = x + w - tab - 20 - windowsItemHMargin - windowsItemFrame + 1; + QString tabStr( s.right( s.length() - t - 1 ) ); + if ( !tabStr.isEmpty() ) + { + if ( optionHandler->useShadowText() ) + { + p->setPen( shadowColor ); + p->drawText( xp + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, tabStr ); + } + p->setPen( textColor ); + p->drawText( xp, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, tabStr ); + } + s = s.left( t ); + } + if ( optionHandler->useShadowText() && !(act && mi) ) + { + p->setPen( shadowColor ); + p->drawText( xvis + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, s, t ); + } + p->setPen( textColor ); + p->drawText( xvis, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, s, t ); + } + else if ( mi->pixmap() ) + // draw pixmap + { + QPixmap * pixmap = mi->pixmap(); + if ( pixmap->depth() == 1 ) + p->setBackgroundMode( OpaqueMode ); + p->drawPixmap( xvis, y + windowsItemFrame, *pixmap ); + if ( pixmap->depth() == 1 ) + p->setBackgroundMode( TransparentMode ); + } + // Child menu + if ( mi->popup() ) + { + int dim = (int)((float)( h - 2 * windowsItemFrame ) / 2); + PrimitiveElement arrow; + arrow = ( QApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight ); + xpos = x + w - windowsArrowHMargin - windowsItemFrame/* - dim*/-8; + vrect = visualRect( QRect( xpos, y + h / 2 - dim / 2, /*dim*/8, dim ), r ); + if ( act ) + { + if ( !dis ) + discol = cg.highlightedText(); + QColorGroup g2( discol, cg.highlight(), white, white, dis ? discol : white, discol, white ); + drawPrimitive( arrow, p, vrect, g2, Style_Enabled ); + } + else + { + if ( !dis ) + discol = optionHandler->textColor(); + QColorGroup g2( discol, cg.background(), white, white, dis ? discol : white, discol, white ); + drawPrimitive( arrow, p, vrect, g2, mi->isEnabled() ? Style_Enabled : Style_Default ); + } + } + break; + } + /* + case CE_ToolBoxTab: + { + break; + }*/ + default: + KStyle::drawControl( element, p, widget, r, cg, flags, opt ); + } +} + + +// void LiquidStyle::drawControlMask( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& opt ) const { +// switch ( element ) { +// case CE_PushButton: { +// p->fillRect( r, Qt::color1 ); +// break; +// } +// default: +// KStyle::drawControlMask( element, p, widget, r, opt ); +// break; +// } +// } + +// void LiquidStyle::drawComplexControlMask( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption &opt ) const { +// // switch ( control ) { +// // case CC_ComboBox: { +// // drawControlMask( CE_PushButton, p, widget, r, opt ); +// // break; +// // } +// // default: +// KStyle::drawComplexControlMask( control, p, widget, r, opt ); +// // } +// } + +void LiquidStyle::drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags, SCFlags controls, SCFlags active, const QStyleOption &opt ) const +{ + switch ( control ) + { + case CC_ComboBox: + { + bool sunken = (active & SC_ComboBoxArrow);// || (flags & Style_Active) || (flags & Style_Sunken) || (active & SC_ComboBoxListBoxPopup); + bool hovered = (widget == highlightWidget) || (flags & Style_HasFocus); + // bool isHtml = isHTMLWidget( widget ); + const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<QWidget*>( widget ); + QPen oldPen( p->pen() ); + if ( controls & SC_ComboBoxArrow ) + { + if ( controls & SC_ComboBoxEditField && ( ( const QComboBox * ) widget ) ->editable()) + { // editable? +#if 0 + if ( optionHandler->buttonStyle() == Brushed ) + { // rectangular? + drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full/*, isHtml*/); + p->fillRect( r.x() + 6, r.y() +2, r.width()-32, r.height() - 7, cg.background()); + p->setPen( oldPen ); + return ; + } + else +#endif + { // round frame + drawRoundFrame( p, r, cg, (flags & Style_HasFocus) || sunken , widget->backgroundOffset()); + p->setPen(cg.mid()); + p->drawPixmap(r.right() - 16, r.height()/2 - 2, *sbDown); + p->setPen( oldPen ); + // return; + } +#if 0 + else + { // default! + drawCombo( p, cg, active == SC_ComboBoxArrow ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full ); + p->fillRect( r.x() + 6, r.y() +2, r.width()-32, r.height() - 7, cg.background()); + p->setPen( oldPen ); + return; + } +#endif + } + else + { // end editable - default handling + if ( optionHandler->buttonStyle() == Brushed ) + { // retangular? + drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full, isHTMLWidget( widget )); + // p->setPen( oldPen ); + // return ; + } + else + { //default plain good old combobox... ;) + drawCombo( p, cg, active == SC_ComboBoxArrow ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full, isHTMLWidget( widget ) ); + // p->setPen( oldPen ); + // return; + } + } + } + const_cast<LiquidStyle*>( this ) ->paintWidget = 0L; + break; + } + case CC_ToolButton: + { + const QToolButton *toolbutton = ( const QToolButton * ) widget; + const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<QWidget*>( widget ); + const KAccessToolBarButton *toolbutton2 = 0L; + QRect button, menuarea; + button = querySubControlMetrics( control, widget, SC_ToolButton, opt ); + menuarea = querySubControlMetrics( control, widget, SC_ToolButtonMenu, opt ); + if (::qt_cast<KToolBarButton*>(toolbutton)) + { + toolbutton2 = (const KAccessToolBarButton*)toolbutton; +#if GCC_VERSION < 40000 + if (toolbutton2->iconTextMode() == 3) + button.setBottom(button.bottom() - p->fontMetrics().height() - 1); +#endif + } + else if (toolbutton->usesTextLabel() && toolbutton->textPosition() == QToolButton::BelowIcon) + button.setBottom(button.bottom() - p->fontMetrics().height()); + menuarea.setX(menuarea.x() - 1); + SFlags bflags = flags, mflags = flags; + + if ( active & SC_ToolButton ) + bflags |= Style_Down; + if ( active & SC_ToolButtonMenu ) + mflags |= Style_Down; + + if ( widget == highlightWidget ) + bflags |= Style_MouseOver; + if ( controls & SC_ToolButton ) + { + bool sunken = mflags & ( Style_Down /*| Style_On*/ ); + bool hover = bflags & (Style_MouseOver | Style_On ); + + if ( !optionHandler->useToolButtonFrame())// || !(toolbutton->parentWidget() && ( ::qt_cast<QToolBar*>(toolbutton->parentWidget()) || toolbutton->parentWidget()->inherits("KonqFrameTabs")))) + { + if ((!(hover || sunken) || (toolbutton->usesTextLabel() && toolbutton->textPosition() == QToolButton::BelowIcon)) && toolbutton->parentWidget() && !::qt_cast<QToolBar*>(toolbutton->parent()) && toolbutton->parentWidget()->paletteBackgroundPixmap() && !toolbutton->parentWidget()->paletteBackgroundPixmap()->isNull()) + { + QPixmap pixmap = *(toolbutton->parentWidget()->paletteBackgroundPixmap()); + if (hover || sunken) + p->drawTiledPixmap( r.x(), button.bottom()+1, r.width(), p->fontMetrics().height(), pixmap, toolbutton->x(), toolbutton->y()+button.height() ); + else + p->drawTiledPixmap( r, pixmap, toolbutton->pos() ); + } + if (hover || sunken) + { + const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<QWidget*>( widget ); + if (optionHandler->toolbuttonStyle() != Brushed) + drawCombo( p, cg, sunken ? cg.button().light( 110 ) : + (hover || (cg.button() != qApp->palette().active().button())) ? cg.button() : + optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(), + button.height(), sunken, hover, false, full ); + else + drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(), + button.x(), button.y(), button.width(), button.height(), + sunken, hover, false); + const_cast<LiquidStyle*>( this ) ->paintWidget = 0L; + } + } + else + { + myPosition pos = full; + KToolBar *bar = NULL; + + if (toolbutton2 && toolbutton2->parentWidget() && ::qt_cast<KToolBar*>(toolbutton2->parentWidget()) ) + { //position calculation - would be nice if ktoolbarbutton provided this as flag + bar = (KToolBar*)toolbutton2->parentWidget(); + int buttonId = toolbutton2->id(); + int buttonIndex = bar->itemIndex(buttonId); + + // ok, this is a very hackish heck of a hack... + // kbookmarkbar (e.g. used by konqueror) accesses the iterator of the toolbar + // this confuses the iterator of the toolbar a bit, as it is used from the bookmark stuff and my function at the same time (seems, as if kbookmarkbar acts on shown toolbars) + // unfortunately, there's no way to figure out if it does for this specific toolbar + // so i check for the toolbars name, knowing this will work for current konqueror - but may fail on further versions + // even worse - the stuff is hardcoded (assuming first item to be left aligned, last one right and the rest centered) + // this is crap at all - so if the best thing would be to patch qtoolbutton to provide conjuncted buttons - i'll ask them (maybe qt4) + if (bar && ( qstrcmp( bar->name(), "bookmarkToolBar" ) == 0 )) + { + return; + buttonIndex == 0 ? + pos = left : + buttonIndex == bar->count() - 1 ? + pos = right : + pos = center; + } + else if (bar->orientation() == Qt::Horizontal) + { + if (buttonIndex == 0) + { + KToolBarButton *tmpButton = bar->getButton(bar->idAt(buttonIndex+1)); + (tmpButton && tmpButton->x() == toolbutton2->x()+toolbutton2->width()) ? pos = left : pos = full; + } + else if (buttonIndex == bar->count() - 1) + { + KToolBarButton *tmpButton = NULL; + tmpButton = bar->getButton(bar->idAt(buttonIndex-1)); + (tmpButton && tmpButton->x() + tmpButton->width() == toolbutton2->x()) ? pos = right : pos = full; + } + else + { + KToolBarButton *tmpButton1 = bar->getButton(bar->idAt(buttonIndex-1)); + KToolBarButton *tmpButton2 = bar->getButton(bar->idAt(buttonIndex+1)); + tmpButton1 && tmpButton1->x() + tmpButton1->width() == toolbutton2->x() ? + pos = center : pos = left; + if (!(tmpButton2 && tmpButton2->x() == toolbutton2->x()+toolbutton2->width())) + pos == left ? pos = full : pos = right; + } + } + else + { + if (buttonIndex == 0) + { + KToolBarButton *tmpButton = bar->getButton(bar->idAt(buttonIndex+1)); + (tmpButton && tmpButton->y() == toolbutton2->y()+toolbutton2->height()) ? + pos = left : pos = full; + } + else if (buttonIndex == bar->count() - 1) + { + KToolBarButton *tmpButton = NULL; + tmpButton = bar->getButton(bar->idAt(buttonIndex-1)); + (tmpButton && tmpButton->y() + tmpButton->height() == toolbutton2->y()) ? + pos = right : pos = full; + } + else + { + KToolBarButton *tmpButton1 = bar->getButton(bar->idAt(buttonIndex-1)); + KToolBarButton *tmpButton2 = bar->getButton(bar->idAt(buttonIndex+1)); + tmpButton1 && tmpButton1->y() + tmpButton1->height() == toolbutton2->y() ? + pos = center : pos = left; + if (!(tmpButton2 && tmpButton2->y() == toolbutton2->y()+toolbutton2->height())) + pos == left ? pos = full : pos = right; + } + } + } + + if (optionHandler->toolbuttonStyle() != Brushed) + { + (bar && bar->orientation() == Qt::Vertical) ? + drawCombo( p, cg, sunken ? cg.button().light( 110 ) : (hover || (cg.button() != qApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), (pos == full || pos == left) ? button.y() : button.y() - 7, button.width(), (pos == full) ? button.height()+2 : (pos == center) ? button.height()+16 : button.height()+9, sunken, hover, false, center ) : + drawCombo( p, cg, sunken ? cg.button().light( 110 ) : (hover || (cg.button() != qApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(), button.height()/*+2*/, sunken, hover, false, pos ); + } + else + { + (bar && bar->orientation() == Qt::Vertical) ? + drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : (hover || (cg.button() != qApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), (pos == full || pos == left) ? button.y() : button.y()-4, button.width(), (pos == full) ? button.height() : (pos == center) ? button.height()+8 : button.height()+4, sunken, hover, false) : + drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : (hover || (cg.button() != qApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(), button.height(), sunken, hover, false, pos); + } + } + } + // Draw a toolbutton menu indicator if required + if ( controls & SC_ToolButtonMenu ) + { + if ( mflags & ( Style_Down | Style_On | Style_Raised ) ) + drawPrimitive( PE_ButtonDropDown, p, menuarea, cg, mflags, opt ); + drawPrimitive( PE_ArrowDown, p, menuarea, cg, mflags, opt ); + } +#if 0 + if ( toolbutton->hasFocus() && !toolbutton->focusProxy() ) + { + QRect fr = toolbutton->rect(); + fr.addCoords( 3, 3, -3, -3 ); + drawPrimitive( PE_FocusRect, p, fr, cg ); + } +#endif + const_cast<LiquidStyle*>( this ) ->paintWidget = 0L; + break; + } + case CC_ScrollBar: + { + const_cast<LiquidStyle*>( this ) ->currentScrollBar = ( QScrollBar * ) widget; + KStyle::drawComplexControl( control, p, widget, r, cg, flags, controls, active, opt ); + break; + } + case CC_SpinWidget: { + const QSpinWidget * sw = (const QSpinWidget *) widget; + SFlags flags; + PrimitiveElement pe; + + if ( controls & SC_SpinWidgetFrame ) + drawEditFrame( p, r, cg, false, sw->hasFocus()); + + if ( controls & SC_SpinWidgetUp ) { + flags = Style_Default | Style_Enabled; + if (active == SC_SpinWidgetUp ) { + flags |= Style_On; + flags |= Style_Sunken; + } else + flags |= Style_Raised; + pe = PE_SpinWidgetUp; + + QRect re = sw->upRect(); + QColorGroup ucg = sw->isUpEnabled() ? cg : sw->palette().disabled(); + p->fillRect(re, ucg.base()); + drawPrimitive(pe, p, re, ucg, flags); + } + + if ( controls & SC_SpinWidgetDown ) { + flags = Style_Default | Style_Enabled; + if (active == SC_SpinWidgetDown ) { + flags |= Style_On; + flags |= Style_Sunken; + } else + flags |= Style_Raised; + pe = PE_SpinWidgetDown; + + QRect re = sw->downRect(); + QColorGroup dcg = sw->isDownEnabled() ? cg : sw->palette().disabled(); + p->fillRect(re, dcg.base()); + drawPrimitive(pe, p, re, dcg, flags); + } + break; } + + // SLIDER - KDE code for double buffering + // ------------------------------------------------------------------- + case CC_Slider: { + const QSlider* slider = (const QSlider*)widget; + QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, opt); + QRect handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, opt); + + // Double-buffer slider for no flicker + QPixmap pix(widget->size()); + QPainter p2; + p2.begin(&pix); + if ( slider->parentWidget() && + (slider->parentWidget()->paletteBackgroundPixmap() && !slider->parentWidget()->paletteBackgroundPixmap()->isNull() )) { + QPixmap pixmap = *(slider->parentWidget()->backgroundPixmap()); + if (QWidget *topDaddy = slider->topLevelWidget()){ + QPoint zero = QPoint(0,0); +#if 0 + zero = slider->mapTo(topDaddy, zero); + int zxmpw = zero.x()%pixmap.width(); + int zymph; +#endif + // probably due to argb mismatches in drawpixmap, this fails on kompmgr startups + p2.drawTiledPixmap(r, pixmap, slider->mapTo(topDaddy, zero)); +#if 0 + for (int dx = 0; dx < pix.width(); dx += pixmap.width()) + { + zymph = zero.y()%pixmap.height(); + for (int dy = 0; dy < pix.height(); dy += pixmap.height()) + { + copyBlt (&pix, dx, dy, &pixmap, + zxmpw, zymph, + pix.width()-dx>pixmap.width()-zxmpw?pixmap.width()-zxmpw:pix.width()-dx, pix.height()-dy>pixmap.height()-zymph?pixmap.height()-zymph:pix.height()-dy); + zymph=0; + } + zxmpw=0; + } +#endif + } else + { + // probably due to argb mismatches in drawpixmap, this fails on kompmgr startups + p2.drawTiledPixmap(r, pixmap, slider->pos()); +#if 0 + for (int dx = 0; dx < pix.width(); dx += pixmap.width()) + for (int dy = 0; dy < pix.height(); dy += pixmap.height()) + copyBlt (&pix, dx, dy, &pixmap, 0, 0, + pix.width()-dx>pixmap.width()?pixmap.width():pix.width()-dx, pix.height()-dy>pixmap.height()?pixmap.height():pix.height()-dy); +#endif + } + // p2.begin(&pix); + } else{ + // p2.begin(&pix); + pix.fill(cg.background()); + } + + // Draw slider groove + if ((controls & SC_SliderGroove) && groove.isValid()) { + drawKStylePrimitive( KPE_SliderGroove, &p2, widget, groove, cg, flags, opt ); + + // Draw the focus rect around the groove + /* if (slider->hasFocus()) + drawPrimitive(PE_FocusRect, &p2, groove, cg);*/ + } + + // Draw the tickmarks + if (controls & SC_SliderTickmarks) + QCommonStyle::drawComplexControl(control, &p2, widget, + r, cg, flags, SC_SliderTickmarks, active, opt); + + // Draw the slider handle + if ((controls & SC_SliderHandle) && handle.isValid()) { + if (active == SC_SliderHandle) + flags |= Style_Active; + drawKStylePrimitive( KPE_SliderHandle, &p2, widget, handle, cg, flags, opt ); + } + + p2.end(); + bitBlt((QWidget*)widget, r.x(), r.y(), &pix); + break; + } + +#ifndef QT_NO_LISTVIEW + case CC_ListView: { + if ( controls & SC_ListView ) { + QCommonStyle::drawComplexControl( control, p, widget, r, cg, flags, controls, active, opt ); + } + if ( controls & ( SC_ListViewBranch | SC_ListViewExpand ) ) { + if ( opt.isDefault() ) + break; + + QListViewItem *item = opt.listViewItem(); + QListViewItem *child = item->firstChild(); + QListView* v = item->listView(); + bool drawDotlines = optionHandler->DrawDotlines(); + static QBitmap *verticalLine = 0, *horizontalLine = 0; + static QCleanupHandler<QBitmap> qlv_cleanup_bitmap; + int dotoffset = 0; + + if (drawDotlines && (optionHandler->DotlineStyle() == Dots)){ + if ( !verticalLine ) { + // make 128*1 and 1*128 bitmaps that can be used for + // drawing the right sort of lines. + verticalLine = new QBitmap( 1, 128, TRUE ); + horizontalLine = new QBitmap( 128, 1, TRUE ); + QPointArray a( 64 ); + QPainter p; + p.begin( verticalLine ); + int i; + for( i=0; i<64; i++ ) + a.setPoint( i, 0, i*2+1 ); + p.setPen( optionHandler->DotlineColor() ); + p.drawPoints( a ); + p.end(); + QApplication::flushX(); + verticalLine->setMask( *verticalLine ); + p.begin( horizontalLine ); + for( i=0; i<64; i++ ) + a.setPoint( i, i*2+1, 0 ); + p.setPen( optionHandler->DotlineColor() ); + p.drawPoints( a ); + p.end(); + QApplication::flushX(); + horizontalLine->setMask( *horizontalLine ); + qlv_cleanup_bitmap.add( &verticalLine ); + qlv_cleanup_bitmap.add( &horizontalLine ); + } + } + + + int y = r.y(); + int c; + QPointArray dotlines; + if ( drawDotlines && active == SC_All && controls == SC_ListViewExpand ) { + c = 2; + dotlines.resize( 2 ); + dotlines[ 0 ] = QPoint( r.right(), r.top() ); + dotlines[ 1 ] = QPoint( r.right(), r.bottom() ); + } + else { + int linetop = 0, linebot = 0; + // each branch needs at most two lines, ie. four end points + dotoffset = (item->itemPos() + item->height() - y) %2; + dotlines.resize( item->childCount() * 4 ); + c = 0; + + // skip the stuff above the exposed rectangle + while ( child && y + child->height() <= 0 ) { + y += child->totalHeight(); + child = child->nextSibling(); + } + + int bx = r.width() / 2; + + // paint stuff in the magical area + while ( child && y < r.height() ) { + int lh; + if ( !item->multiLinesEnabled() ) + lh = child ? child->height() : 0; + else + lh = p->fontMetrics().height() + 2 * v->itemMargin(); + lh = QMAX( lh, QApplication::globalStrut().height() ); + if ( lh % 2 > 0 ) + lh++; + linebot = y + lh / 2; + if ( ( child->isExpandable() || child->childCount() ) && ( child->height() > 0 ) ) { + if ( optionHandler->ExpanderStyle() == MS ) { // f****** M$ +/- style :-( + // needs a box + p->setPen( optionHandler->DotlineColor() ); + p->drawRect( bx - 4, linebot - 4, 9, 9 ); + // plus or minus + p->setPen( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() ); + p->drawLine( bx - 2, linebot, bx + 2, linebot ); + if ( !child->isOpen() ) + p->drawLine( bx, linebot - 2, bx, linebot + 2 ); + } else { // ultracool triangles ;-) + QPointArray a; + p->setPen( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() ); + if ( child->isOpen() ) { + a.setPoints( 3, bx - 4, linebot - 2, + bx, linebot + 2, + bx + 4, linebot - 2 ); + } //DownArrow + else { + a.setPoints( 3, bx - 2, linebot - 4, + bx + 2, linebot, + bx - 2, linebot + 4 ); + } //RightArrow + p->setBrush( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() ); + p->drawPolygon( a ); + + p->setBrush( NoBrush ); + } + // dotlinery + if ( drawDotlines ) { + dotlines[ c++ ] = QPoint( bx, linetop ); + dotlines[ c++ ] = QPoint( bx, linebot - (/* optionHandler->plusMinus() ? 4 : */5 ) ); + dotlines[ c++ ] = QPoint( bx + 5, linebot ); + dotlines[ c++ ] = QPoint( r.width(), linebot ); + linetop = linebot + 5; + } + } else { + // just dotlinery + if ( drawDotlines ) { + dotlines[ c++ ] = QPoint( bx + 2, linebot ); + dotlines[ c++ ] = QPoint( r.width(), linebot ); + } + } + + y += child->totalHeight(); + child = child->nextSibling(); + } + + // Expand line height to edge of rectangle if there's a + // child, and it's visible + if ( child && ( child->height() > 0 ) ) { + linebot = r.height(); + } + + if ( drawDotlines ) { + if ( linetop < linebot ) { + dotlines[ c++ ] = QPoint( bx, linetop ); + dotlines[ c++ ] = QPoint( bx, linebot ); + } + } + } + + if ( drawDotlines && optionHandler->DotlineStyle() == Line) { + int line; // index into dotlines + p->setPen( optionHandler->DotlineColor() ); + + if ( controls & SC_ListViewBranch ) + for ( line = 0; line < c; line += 2 ) { + p->drawLine( dotlines[ line ].x(), dotlines[ line ].y(), + dotlines[ line + 1 ].x(), dotlines[ line + 1 ].y() ); + } + + } + else if (drawDotlines && (optionHandler->DotlineStyle() == Dots)) { + int line; // index into dotlines + if ( controls & SC_ListViewBranch ){ + p->setPen( optionHandler->DotlineColor() ); + for( line = 0; line < c; line += 2 ) { + // assumptions here: lines are horizontal or vertical. + // lines always start with the numerically lowest + // coordinate. + + // point ... relevant coordinate of current point + // end ..... same coordinate of the end of the current line + // other ... the other coordinate of the current point/line + if ( dotlines[line].y() == dotlines[line+1].y() ) { + int end = dotlines[line+1].x(); + int point = dotlines[line].x(); + int other = dotlines[line].y(); + while( point < end ) { + int i = 128; + if ( i+point > end ) + i = end-point; + p->drawPixmap( point, other, *horizontalLine, 0, 0, i, 1 ); + point += i; + } + } + else { + int end = dotlines[line+1].y(); + int point = dotlines[line].y(); + int other = dotlines[line].x(); + int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0; + while( point < end ) { + int i = 128; + if ( i+point > end ) + i = end-point; + p->drawPixmap( other, point, *verticalLine, 0, pixmapoffset, 1, i ); + point += i; + } + } + } + } + } + } + + break; + } +#endif // QT_NO_LISTVIEW + +#ifndef QT_NO_TITLEBAR + case CC_TitleBar: + { + switch (optionHandler->style()) + { + case Jaguar: + if (!widget->isActiveWindow()) p->drawTiledPixmap(r, *getPixmap( TitleBar )); + p->setPen(optionHandler->titleColor(1).dark(180)); + p->drawLine(r.left(), r.bottom(), r.right(), r.bottom()); + break; + case Panther: + case Tiger: + case Milk: + { + if (widget->isActiveWindow()) p->drawTiledPixmap(r, *getPixmap( TitleBar )); + p->setPen(optionHandler->titleColor(1).dark(180)); + p->drawLine(r.left(), r.bottom(), r.right(), r.bottom()); + break; + } + case Brushed: + break; + } + if ( controls & SC_TitleBarLabel ) + { + QRect ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarLabel ), widget ); + p->setPen( cg.text() ); + p->drawText(ir.x()+2, ir.y(), ir.width()-2, ir.height(), AlignCenter | AlignVCenter | SingleLine, widget->caption() ); + } + + QRect ir; + bool down = FALSE; + QPixmap pm; + + if ( controls & SC_TitleBarCloseButton ) + { + ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarCloseButton ), widget ); + down = active & SC_TitleBarCloseButton; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(0).dark(120) : optionHandler->titleButtonColor(0), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full); + else + drawCombo( p, cg, down ? optionHandler->titleButtonColor(0).dark(120) : optionHandler->titleButtonColor(0), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full ); + } + if ( controls & SC_TitleBarSysMenu ) + { + ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarSysMenu ), widget ); + down = active & SC_TitleBarSysMenu; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full); + else + drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full ); + } + + if ( controls & SC_TitleBarMaxButton ) + { + ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarMaxButton ), widget ); + down = active & SC_TitleBarMaxButton; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(2).dark(120) : optionHandler->titleButtonColor(2), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full); + else + drawCombo( p, cg, down ? optionHandler->titleButtonColor(2).dark(120) : optionHandler->titleButtonColor(2), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full ); + } + + if ( controls & SC_TitleBarMinButton ) + { + ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarMinButton ), widget ); + down = active & SC_TitleBarMinButton; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full); + else + drawCombo( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full ); + } + if ( controls & SC_TitleBarNormalButton ) + { + ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarNormalButton ), widget ); + down = active & SC_TitleBarNormalButton; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full); + else + drawCombo( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full ); + } + + if ( controls & SC_TitleBarShadeButton ) + { + ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarShadeButton ), widget ); + down = active & SC_TitleBarShadeButton; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full); + else + drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full ); + } + + if ( controls & SC_TitleBarUnshadeButton ) + { + ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarUnshadeButton ), widget ); + down = active & SC_TitleBarUnshadeButton; + if (optionHandler->buttonStyle() == Brushed) + drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full); + else + drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full ); + } + break; + } +#endif //QT_NO_TITLEBAR + + default: + KStyle::drawComplexControl( control, p, widget, + r, cg, flags, controls, active, opt ); + break; + } +} + +int LiquidStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption & opt, QStyleHintReturn * shr) const +{ + switch (sh) + { + case QStyle::SH_GUIStyle: + // if (w && ::qt_cast<QMenuBar*>(w)) + // return WindowsStyle; + return MacStyle; + case QStyle::SH_TabBar_Alignment: + if (optionHandler->CenterTabs() && !QApplication::reverseLayout()) + return AlignHCenter; + else + return KStyle::styleHint(sh, w, opt, shr); + default: + return KStyle::styleHint(sh, w, opt, shr); + } +} + +QRect LiquidStyle::subRect( SubRect r, const QWidget *widget ) const { + if (r == SR_ComboBoxFocusRect){ + return querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxEditField ); + } + return ( KStyle::subRect( r, widget ) ); +} + +int LiquidStyle::pixelMetric( PixelMetric m, const QWidget *widget ) const +{ + switch ( m ) + { + case PM_ButtonMargin: + return ( 5 ); + case PM_ButtonDefaultIndicator: + return ( 0 ); + case PM_ExclusiveIndicatorWidth: + case PM_ExclusiveIndicatorHeight: + return ( 16 ); + case PM_IndicatorWidth: + case PM_IndicatorHeight: + return ( 16 ); + case PM_ScrollBarExtent: + return ( 15 ); + case PM_ScrollBarSliderMin: + if (isOOO) return 10; return ( 40 ); + case PM_SplitterWidth: + return 6; + case PM_SliderControlThickness: + return(15); + case PM_SliderThickness: + return ( 22 ); + /* if (widget && (widget->width() < widget->height() && widget->width() < 17) || (widget->width() > widget->height() && widget->height() < 17)) + return (16);*/ + case PM_SliderLength: + return ( optionHandler->style() == Milk ? 15 : 13 ); + case PM_TabBarTabOverlap: + return 0; + case PM_DefaultFrameWidth: + { + /* + if (widget && ::qt_cast<QFrame*>(widget) && ((QFrame*)widget)->frameShape() == QFrame::LineEditPanel) + return 6;*/ + if (widget && widget->parentWidget() && ::qt_cast<QTabWidget*>(widget->parentWidget()) && widget->parentWidget()->parentWidget() && (widget->parentWidget()->parentWidget()->inherits("KonqMainWindow") || widget->parentWidget()->parentWidget()->inherits("KonqFrameContainer"))) //for the konqueror statusbar offset, thanks konqueror team... ... ... f***f***f***!!! + return 0; + return 2; + } + case PM_TabBarBaseOverlap: + case PM_TabBarBaseHeight: + { + if (!widget || !::qt_cast<QTabWidget*>(widget) || !widget->children()) + return 0; + QObjectListIt it( *widget->children() ); // iterate over the buttons + QObject *obj; + QTabBar *tabBar = 0L; + while ( (obj = it.current()) != 0 ) + { + ++it; + if (::qt_cast<QTabBar*>(obj)) + { + tabBar = (QTabBar*)obj; + break; + } + } + if (!tabBar || !tabBar->isVisible()) + return 0; + if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("QDialog"))) + return 12; + if (m == PM_TabBarBaseOverlap) + return 2; + return 7; + } + case PM_TabBarTabHSpace: + if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("QDialog"))) return 18; + return 24; + case PM_TabBarTabVSpace: + { + if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("QDialog"))) return 6; + return 10; + } + case PM_TabBarTabShiftHorizontal: + return 0; + case PM_TabBarTabShiftVertical: + if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("QDialog"))) return 0; + return 2; + case PM_ButtonShiftHorizontal: + return 0; + case PM_ButtonShiftVertical: + return 0; + default: + return KStyle::pixelMetric( m, widget ); + } +} + +QSize LiquidStyle::sizeFromContents( ContentsType contents, + const QWidget *widget, + const QSize &contentSize, + const QStyleOption& opt ) const { + switch ( contents ) { + case CT_PushButton: { + // this is a little funky - we give values not based on pixelMetric + // because we want a custom width/height and we can only give one + // value in pixelMetric (used in sizeHint). Odd but works well + const QPushButton * button = ( const QPushButton* ) widget; + + int w = contentSize.width() + 26 > 80 ? contentSize.width() + 26 : 80; + int h = contentSize.height() > 24 ? contentSize.height() : 25; + + if ( button->text().isEmpty() ) + return ( QSize( contentSize.width() + 2 * pixelMetric( PM_ButtonMargin, widget ), h ) ); + + return ( QSize( w, h ) ); + } + + case CT_ToolButton: { + if (widget->parentWidget() && ::qt_cast<QTabWidget*>(widget->parentWidget())){ + return QSize(contentSize.width() + 6, contentSize.height() + 5); + } + else{ + int w = contentSize.width() + 6; + int sh = contentSize.height() + 5; + int sw = (int)(1.3*sh); + if (w < sw) + return QSize(sw, sh); + else + return QSize(w, sh); + } + } + + case CT_Slider: { + int h = contentSize.height() > 24 ? contentSize.height() : 24; + return ( QSize( contentSize.width(), h ) ); + } + + case CT_ComboBox: { + // QSize sz = KStyle::sizeFromContents( contents, widget, contentSize, opt ); + // return ( QSize( sz.width()+3, sz.height() > 25 ? sz.height() : 25 ) ); + if ( ::qt_cast<const QComboBox *>(widget) && ((const QComboBox *)widget)->editable()) + return ( QSize( contentSize.width()+27, contentSize.height() + 4 > 22 ? contentSize.height() + 4 : 26 ) ); + else + return ( QSize( contentSize.width()+27, contentSize.height() + 2 > 24 ? contentSize.height() + 2 : 24 ) ); + } + case CT_PopupMenuItem: { + if ( ! widget || opt.isDefault() ) + break; + + const QPopupMenu *popup = ( const QPopupMenu * ) widget; + bool checkable = popup->isCheckable(); + QMenuItem *mi = opt.menuItem(); + int maxpmw = opt.maxIconWidth(); + int w = contentSize.width(); + int h = contentSize.height(); + + if ( mi->custom() ) { + w = mi->custom() ->sizeHint().width(); + h = mi->custom() ->sizeHint().height(); + if ( !mi->custom() ->fullSpan() ) + h += 2 * windowsItemVMargin + 2 * windowsItemFrame; + } else if ( mi->widget() ) {} + else if ( mi->isSeparator() ) { + w = 10; + h = windowsSepHeight; + } else { + if ( mi->pixmap() ) + h = QMAX( h, mi->pixmap() ->height() + 2 * windowsItemFrame ); + else if ( ! mi->text().isNull() ) + h = QMAX( h, popup->fontMetrics().height() + 2 * windowsItemVMargin + + 2 * windowsItemFrame ); + if ( mi->iconSet() != 0 ) + h = QMAX( h, mi->iconSet() ->pixmap( QIconSet::Small, + QIconSet::Normal ).height() + + 2 * windowsItemFrame ); + } + if ( !mi->text().isNull() && mi->text().find( '\t' ) >= 0 ) + w += windowsTabSpacing; + else if ( mi->popup() ) + w += 2 * windowsArrowHMargin; + if ( checkable && maxpmw < 20 ) + w += 20 - maxpmw; + if ( maxpmw ) + w += maxpmw + 6; + if ( checkable || maxpmw > 0 ) + w += windowsCheckMarkHMargin; + w += 20; + return ( QSize( w, h ) ); + } + default: + break; + } + return KStyle::sizeFromContents( contents, widget, contentSize, opt ); +} + + +QPixmap LiquidStyle::stylePixmap( StylePixmap stylepixmap, + const QWidget* widget, + const QStyleOption& opt ) const { + return KStyle::stylePixmap( stylepixmap, widget, opt ); +} + +#include "eventfilter.cpp" + +QRect LiquidStyle::querySubControlMetrics( ComplexControl control, const QWidget *widget, SubControl subcontrol, const QStyleOption &opt ) const +{ + if ( control == CC_ComboBox && subcontrol == SC_ComboBoxEditField ) + return QRect( 8, 3, widget->width() - 32, widget->height() - 7 ); + if (control == CC_TitleBar) + { + switch (subcontrol) + { + case SC_TitleBarSysMenu: + return QRect( widget->width() - 24, 1, 16, 16 ); + case SC_TitleBarMinButton: + return QRect( 26, 1, 16, 16 ); + case SC_TitleBarMaxButton: + return QRect( 47, 1, 16, 16 ); + case SC_TitleBarCloseButton: + return QRect( 5, 1, 16, 16 ); + case SC_TitleBarLabel: + return QRect( 68, 1, widget->width() - 107, 16 ); + case SC_TitleBarNormalButton: + return QRect( 26, 1, 16, 16 ); + case SC_TitleBarShadeButton: + return QRect( widget->width() - 29, 1, 24, 16 ); + case SC_TitleBarUnshadeButton: + return QRect( widget->width() - 29, 1, 24, 16 ); + default: + return ( KStyle::querySubControlMetrics( control, widget, subcontrol, opt ) ); + } + } + else + return ( KStyle::querySubControlMetrics( control, widget, subcontrol, opt ) ); +} + +QImage LiquidStyle::fetchImage( const char *name ){ + return uic_findImage( name ); +} + +QColor LiquidStyle::mapFadeColor(QColor &color, int index) const +{ + QRgb **rgb = fadeColorMap.find(color.rgb()); + if (rgb) + return QColor((*rgb)[index]); + // no color map found, create one and return the queried value + rgb = new QRgb*; + *rgb = new QRgb[10]; + int iRed = optionHandler->InactiveButtonColor().red(); + int iGreen = optionHandler->InactiveButtonColor().green(); + int iBlue = optionHandler->InactiveButtonColor().blue(); + int cRed = color.red(); + int cGreen = color.green(); + int cBlue = color.blue(); + for (int i = 10; i < 20; i++) + { + (*rgb)[i-10] = qRgb( iRed + (cRed-iRed)*(i)/20, iGreen + (cGreen-iGreen)*(i)/20, iBlue + (cBlue-iBlue)*(i)/20); + } + LiquidStyle *ptr = const_cast<LiquidStyle*>( this ); + ptr->fadeColorMap.insert(color.rgb(), rgb); + return QColor((*rgb)[index]); +} + +QPixmap* LiquidStyle::processEmbedded( const char *label, const QColor &c, bool blend, const QColor *bg ) const { + QImage img( uic_findImage( label ) ); + img.detach(); + if ( img.isNull() ) { // shouldn't happen, been tested + qWarning( "Invalid embedded label %s", label ); + return ( NULL ); + } + return ( adjustHSV( img, c, bg ) ); +} + +QPixmap* LiquidStyle::getPixmap( BitmapData item ) const +{ + if ( pixmaps[ item ] ) + return ( pixmaps[ item ] ); + QColor bgColor( optionHandler->InactiveButtonColor() ); + QColor btnColor( isOOO ? optionHandler->CustomButtonColor() : qApp->palette().active().button() ); + QColor btnHoverColor( isOOO ? optionHandler->CustomButtonColor().light(120) : btnColor.light( 120 ) ); + QColor sbGrooveColor( optionHandler->useCustomColors() ? + optionHandler->customColor( CustomSBGroove ) : bgColor ); + QColor sbSliderColor( optionHandler->useCustomColors() ? + optionHandler->customColor( CustomSBSlider ) : bgColor ); + QColor sbSliderHoverColor( optionHandler->useCustomColors() ? + optionHandler->customColor( CustomSBSliderHover ) : isOOO?optionHandler->CustomButtonColor():btnColor ); + QColor sbSliderPressedColor( optionHandler->useCustomColors() ? + optionHandler->customColor( CustomSBSliderPressed ) : btnColor.dark(110) ); + LiquidStyle *ptr = const_cast<LiquidStyle*>( this ); + switch ( item ) + { + case RadioOn: + ptr->pixmaps[ RadioOn ] = processEmbedded( (optionHandler->style() == Milk) ? "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ) : btnColor, true ); + break; + case RadioOff: + ptr->pixmaps[ RadioOff ] = processEmbedded( (optionHandler->style() == Milk) ? "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOff ) : bgColor, true ); + break; + case RadioOnHover: + ptr->pixmaps[ RadioOnHover ] = processEmbedded( (optionHandler->style() == Milk) ? "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).light( 110 ) : btnHoverColor, true ); + break; + case RadioOffHover: + ptr->pixmaps[ RadioOffHover ] = processEmbedded( (optionHandler->style() == Milk) ? "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ) : btnColor, true ); + case RadioOnPressed: + ptr->pixmaps[ RadioOnPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true ); + break; + case RadioOffPressed: + ptr->pixmaps[ RadioOffPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).dark( 120 ) : btnColor.dark( 120 ), true ); + break; + case Tab: + ptr->pixmaps[ Tab ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOff ) : optionHandler->InactiveButtonColor(), true ); + break; + case belowTab: + ptr->pixmaps[ belowTab ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOff ) : optionHandler->InactiveButtonColor(), true ); + *ptr->pixmaps[ belowTab ] = ptr->pixmaps[ belowTab ] ->xForm( iMatrix ); + break; + case TabDown: + ptr->pixmaps[ TabDown ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ) : btnColor, true ); + break; + case belowTabDown: + ptr->pixmaps[ belowTabDown ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ) : btnColor, true ); + *ptr->pixmaps[ belowTabDown ] = ptr->pixmaps[ belowTabDown ] ->xForm( iMatrix ); + break; + case TabFocus: + ptr->pixmaps[ TabFocus ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ).light( 120 ) : btnHoverColor, true ); + break; + case CB: + ptr->pixmaps[ CB ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOff ) : bgColor, true ); + break; + case CBDown: + ptr->pixmaps[ CBDown ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true ); + break; + case CBDownHover: + ptr->pixmaps[ CBDownHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).light( 110 ) : btnHoverColor, true ); + break; + case CBTri: + ptr->pixmaps[ CBTri ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true ); + *ptr->pixmaps[ CBTri ] = ptr->pixmaps[ CBTri ] ->xForm( mMatrix ); + break; + case CBTriHover: + ptr->pixmaps[ CBTriHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).light( 110 ) : btnHoverColor, true ); + *ptr->pixmaps[ CBTriHover ] = ptr->pixmaps[ CBTriHover ] ->xForm( mMatrix ); + break; + case CBHover: + ptr->pixmaps[ CBHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true ); + break; + case CBDownPressed: + ptr->pixmaps[ CBDownPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true ); + break; + case CBTriPressed: + ptr->pixmaps[ CBTriPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true ); + *ptr->pixmaps[ CBTriPressed ] = ptr->pixmaps[ CBTriPressed ] ->xForm( mMatrix ); + break; + case CBPressed: + ptr->pixmaps[ CBPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnColor.dark( 120 ), true ); + break; + case HSlider: + ptr->pixmaps[ HSlider ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true ); + break; + case VSlider: + ptr->pixmaps[ VSlider ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true ); + *ptr->pixmaps[ VSlider ] = ptr->pixmaps[ VSlider ] ->xForm( lMatrix ); + break; + case VSliderAbove: + ptr->pixmaps[ VSliderAbove ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true ); + *ptr->pixmaps[ VSliderAbove ] = ptr->pixmaps[ VSliderAbove ] ->xForm( rMatrix ); + break; + case HSliderInactive: + ptr->pixmaps[ HSliderInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true ); + break; + case VSliderInactive: + ptr->pixmaps[ VSliderInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true ); + *ptr->pixmaps[ VSliderInactive ] = ptr->pixmaps[ VSliderInactive ] ->xForm( lMatrix ); + break; + case VSliderAboveInactive: + ptr->pixmaps[ VSliderAboveInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true ); + *ptr->pixmaps[ VSliderAboveInactive ] = ptr->pixmaps[ VSliderAboveInactive ] ->xForm( rMatrix ); + break; + case VSBSliderTop: + ptr->pixmaps[ VSBSliderTop ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderColor, true, &sbGrooveColor ); + break; + case VSBSliderBtm: + ptr->pixmaps[ VSBSliderBtm ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderColor, true, &sbGrooveColor ); + break; + case VSBSliderMid: + ptr->pixmaps[ VSBSliderMid ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbIslider_mid", sbSliderColor, &sbGrooveColor ); + break; + case VSBSliderTopActive: + ptr->pixmaps[ VSBSliderTopActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderHoverColor, true, &sbGrooveColor ); + break; + case VSBSliderBtmActive: + ptr->pixmaps[ VSBSliderBtmActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderHoverColor, true, &sbGrooveColor ); + break; + case VSBSliderMidActive: + ptr->pixmaps[ VSBSliderMidActive ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderHoverColor, false, &sbGrooveColor ); + break; + case VSBSliderTopPressed: + ptr->pixmaps[ VSBSliderTopPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderPressedColor, true, &sbGrooveColor ); + *ptr->pixmaps[ VSBSliderTopPressed ] = ptr->pixmaps[ VSBSliderTopPressed ] ->xForm( mMatrix ); + break; + case VSBSliderBtmPressed: + ptr->pixmaps[ VSBSliderBtmPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderPressedColor, true, &sbGrooveColor ); + *ptr->pixmaps[ VSBSliderBtmPressed ] = ptr->pixmaps[ VSBSliderBtmPressed ] ->xForm( mMatrix ); + break; + case VSBSliderMidPressed: + ptr->pixmaps[ VSBSliderMidPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderPressedColor, false, &sbGrooveColor ); + if (optionHandler->style() == Milk) + *ptr->pixmaps[ VSBSliderMidPressed ] = ptr->pixmaps[ VSBSliderMidPressed ] ->xForm( iMatrix ); + break; + + case HSBSliderTop: + ptr->pixmaps[ HSBSliderTop ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderColor, true, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderTop ] = ptr->pixmaps[ HSBSliderTop ]->xForm( rMatrix ); + break; + case HSBSliderBtm: + ptr->pixmaps[ HSBSliderBtm ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderColor, true, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderBtm ] = ptr->pixmaps[ HSBSliderBtm ] ->xForm( rMatrix ); + break; + case HSBSliderMid: + ptr->pixmaps[ HSBSliderMid ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbIslider_mid", sbSliderColor, false, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderMid ] = ptr->pixmaps[ HSBSliderMid ]->xForm( rMatrix ); + break; + case HSBSliderTopActive: + ptr->pixmaps[ HSBSliderTopActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderHoverColor, true, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderTopActive ] = ptr->pixmaps[ HSBSliderTopActive ] ->xForm( rMatrix ); + break; + case HSBSliderBtmActive: + ptr->pixmaps[ HSBSliderBtmActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderHoverColor, true, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderBtmActive ] = ptr->pixmaps[ HSBSliderBtmActive ] ->xForm( rMatrix ); + break; + case HSBSliderMidActive: + ptr->pixmaps[ HSBSliderMidActive ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderHoverColor, false, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderMidActive ] = ptr->pixmaps[ HSBSliderMidActive ] ->xForm( rMatrix ); + break; + case HSBSliderTopPressed: + ptr->pixmaps[ HSBSliderTopPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderPressedColor, true, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderTopPressed ] = ptr->pixmaps[ HSBSliderTopPressed ] ->xForm( mMatrix ); + *ptr->pixmaps[ HSBSliderTopPressed ] = ptr->pixmaps[ HSBSliderTopPressed ] ->xForm( rMatrix ); + break; + case HSBSliderBtmPressed: + ptr->pixmaps[ HSBSliderBtmPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderPressedColor, true, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderBtmPressed ] = ptr->pixmaps[ HSBSliderBtmPressed ] ->xForm( mMatrix ); + *ptr->pixmaps[ HSBSliderBtmPressed ] = ptr->pixmaps[ HSBSliderBtmPressed ] ->xForm( rMatrix ); + break; + case HSBSliderMidPressed: + ptr->pixmaps[ HSBSliderMidPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderPressedColor, false, &sbGrooveColor ); + if (optionHandler->style() == Milk) + *ptr->pixmaps[ HSBSliderMidPressed ] = ptr->pixmaps[ HSBSliderMidPressed ] ->xForm( lMatrix ); + else + *ptr->pixmaps[ HSBSliderMidPressed ] = ptr->pixmaps[ HSBSliderMidPressed ] ->xForm( rMatrix ); + break; + case VSBSliderTopBg: + ptr->pixmaps[ VSBSliderTopBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_top-milk" : "sbgroove_top", sbGrooveColor, true, &sbGrooveColor ); + break; + case VSBSliderBtmBg: + ptr->pixmaps[ VSBSliderBtmBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_btm-milk" : "sbgroove_btm", sbGrooveColor, true, &sbGrooveColor ); + break; + case VSBSliderMidBg: + ptr->pixmaps[ VSBSliderMidBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_mid-milk" : "sbgroove_mid", sbGrooveColor, false, &sbGrooveColor ); + break; + case VSBSliderMidBgI: + ptr->pixmaps[ VSBSliderMidBgI ] = processEmbedded( (optionHandler->style() == Milk) ? "sb_subadd-milk" : "sb_subadd", sbGrooveColor, false, &sbGrooveColor ); + break; + case HSBSliderTopBg: + ptr->pixmaps[ HSBSliderTopBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_top-milk" : "sbgroove_top", sbGrooveColor, true, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderTopBg ] = ptr->pixmaps[ HSBSliderTopBg ] ->xForm( rMatrix ); + break; + case HSBSliderBtmBg: + ptr->pixmaps[ HSBSliderBtmBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_btm-milk" : "sbgroove_btm", sbGrooveColor, true, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderBtmBg ] = ptr->pixmaps[ HSBSliderBtmBg ] ->xForm( rMatrix ); + break; + case HSBSliderMidBg: + ptr->pixmaps[ HSBSliderMidBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_mid-milk" : "sbgroove_mid", sbGrooveColor, false, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderMidBg ] = ptr->pixmaps[ HSBSliderMidBg ] ->xForm( rMatrix ); + break; + case HSBSliderMidBgI: + ptr->pixmaps[ HSBSliderMidBgI ] = processEmbedded( (optionHandler->style() == Milk) ? "sb_subadd-milk" : "sb_subadd", sbGrooveColor, false, &sbGrooveColor ); + *ptr->pixmaps[ HSBSliderMidBgI ] = ptr->pixmaps[ HSBSliderMidBgI ] ->xForm( rMatrix ); + break; + + case Progress: + ptr->pixmaps[ Progress ] = processEmbedded( "progress", btnColor ); + break; + case progress2: + ptr->pixmaps[ progress2 ] = processEmbedded( "progress2", btnColor ); + break; + + case TitleBar: + { + if (optionHandler->style() == Jaguar) + { + ptr->pixmaps[ TitleBar ] = new QPixmap(32,22); + ptr->pixmaps[ TitleBar ]->fill( optionHandler->titleColor(0) ); + QPainter p; + p.begin( ptr->pixmaps[ TitleBar ] ); + p.setPen( QColor( + (optionHandler->titleColor(0).red()+optionHandler->titleColor(1).red())/2, + (optionHandler->titleColor(0).green()+optionHandler->titleColor(1).green())/2, + (optionHandler->titleColor(0).blue()+optionHandler->titleColor(1).blue())/2 )); + for ( int i = 1; i < 22; i += 4 ) + { + p.drawLine( 0, i, 31, i ); + p.drawLine( 0, i+2, 31, i+2 ); + } + p.setPen( optionHandler->titleColor(1)); + for ( int i = 2; i < 22; i += 4 ) + p.drawLine( 0, i, 31, i ); + p.end(); + } + else + ptr->pixmaps[ TitleBar ] = &KPixmapEffect::gradient (*((KPixmap*)(new QPixmap(32,22))), optionHandler->titleColor(0), optionHandler->titleColor(1), KPixmapEffect::VerticalGradient, 22); + break; + } + default: + break; + } + return ( pixmaps[ item ] ); +} + + +#include "baghira.moc" diff --git a/style/baghira.h b/style/baghira.h new file mode 100644 index 0000000..1336ac2 --- /dev/null +++ b/style/baghira.h @@ -0,0 +1,627 @@ +#ifndef __LIQUID_STYLE_H +#define __LIQUID_STYLE_H + +#include <qcstring.h> +#include <qdir.h> +#include <qintdict.h> +#include <qprogressbar.h> +#include <qtimer.h> +#include <qwmatrix.h> +#include <kpixmap.h> +#include <qwidget.h> +#include <kstyle.h> + +// #define BITMAP_ITEMS 75 // Don't worry, they're demand loaded ;-) +#define LIQUID_MENU_CHANGE 667 +#define MOSFET_BUTTON_CHANGE 661 + +class QColor; +class QHeader; +class QImage; +class QMenuBar; +class QPalette; +class QPoint; +class QPushButton; +class QRect; +class QScrollBar; +class QSize; +class QString; +class QTabBar; +class LiquidStyle; + +enum BitmapData{RadioOn = 0, RadioOff, RadioOnHover, RadioOffHover, RadioOnPressed, RadioOffPressed, + VSBSliderTop, VSBSliderMid, VSBSliderBtm, + VSBSliderTopActive, VSBSliderMidActive, VSBSliderBtmActive, + VSBSliderTopPressed, VSBSliderMidPressed, VSBSliderBtmPressed, + VSBSliderTopBg, VSBSliderMidBg, VSBSliderMidBgI, VSBSliderBtmBg, + HSBSliderTop, HSBSliderMid, HSBSliderBtm, + HSBSliderTopActive, HSBSliderMidActive, HSBSliderBtmActive, + HSBSliderTopPressed, HSBSliderMidPressed, HSBSliderBtmPressed, + HSBSliderTopBg, HSBSliderMidBg, HSBSliderMidBgI, HSBSliderBtmBg, + Tab, TabDown, TabFocus, belowTab, belowTabDown, + ButtonShadow, CB, CBDown, CBTri, CBHover, CBDownHover, CBTriHover, CBPressed, CBDownPressed, CBTriPressed, + HSlider, VSlider, VSliderAbove, HSliderInactive, VSliderInactive, VSliderAboveInactive, + Progress, rectbutton, combo, comboShadow, progress2, TitleBar, BITMAP_ITEMS}; + +enum CustomColor{CustomCBOn = 0, CustomCBOff, CustomRadioOn, CustomRadioOff, + CustomTabOn, CustomTabOff, CustomSBSlider, CustomSBSliderHover, CustomSBSliderPressed, CustomSBGroove}; + +enum PulseType{PushButton, ComboBox, AppletHandle, Splitter, ToolButton}; + +enum MenuBackground{Standard=0, Plain, Stipples, Gradient}; + +enum InactiveButtonColor{Original=0, Background, Active, Custom}; + +enum myExpanderStyle{Apple=0, MS}; + +enum progressStyle{mac=0, liquid, baghira}; + +enum DotlineStyle{Line=0, Dots}; + +enum Tile{TileTopLeft = 0, TileTop, TileTopRight, + TileLeft, TileMiddle, TileRight, TileBtmLeft, TileBtm, TileBtmRight}; + +enum myPosition{left = 0, center, right, full}; + +enum tabStyle {TrueTab = 0, Clever, Chooser}; + +enum Style {Jaguar = 0, Panther, Brushed, Tiger, Milk, NUMSTYLES }; + +class ButtonTile + { + public: + ButtonTile() + { + for ( int i = 0;i < 9;++i ) + pixmaps[ i ] = 0; + } + ~ButtonTile() + { + for ( int i = 0;i < 9;++i ) + if ( pixmaps[ i ] ) delete pixmaps[ i ]; + } + QPixmap* pixmap( Tile pos ) + { + return ( pixmaps[ ( int ) pos ] ); + } + void setPixmap( Tile pos, QPixmap *pix ) + { + pixmaps[ ( int ) pos ] = pix; + } + protected: + QPixmap *pixmaps[ 9 ]; + }; + + +class OptionHandler : public QObject +{ + Q_OBJECT +public: + OptionHandler( QObject *parent ); + void reloadSettings(); + inline static bool useShadowText() + { + return ( shadowText ); + } + const QColor& textColor(); + const QColor& bgColor(); + const QColor& buttonColor(); + static int custCols[8]; + + inline void reset() + { + menusProcessed = false; + } + + inline static bool glossyMenus() + { + return glossyMenus_; + } + + inline static bool drawMenuStripe() + { + return (drawMenuStripe_); + } + + inline static QColor menuStripeColor() + { + return menuStripeColor_; + } + + inline static QColor textColorHigh() + { + return fgColorHigh; + } + + inline static QColor menuColorHigh() + { + return colorHigh; + } + + inline static bool bevelHighlights() + { + return (bevelHighlights_); + } + inline static bool useBgStipple() + { + return ( bgStipple ); + } + inline static Style style() + { + return (style_); + } + inline static int stippleContrast() + { + return ( contrast ); + } + inline static bool useReverseBtnColor() + { + return ( reverseBtnColor ); + } + inline static bool useToolButtonFrame() + { + return ( tbFrame ); + } + + inline static bool useCustomColors() + { + return ( customWidgetColor ); + } + inline static const QColor& customColor( int idx ) + { + return ( customColors[ idx ] ); + } + + inline static bool DrawDotlines() + { + return ( drawDotlines ); + } + inline static bool squeezeSbSlider() + { + return ( squeezesbslider ); + } + inline static bool shadowSbSlider() + { + return (shadowsbslider); + } + inline static bool drawGroupBoxShadow() + { + return ( groupboxshadow ); + } + inline static int ShadowDarkness() + { + return ( shadowDarkness ); + } + inline static int InactiveButtonColorType() + { + return ( inactiveButtonColor ); + } + inline static int MenuBackground() + { + return (menuBackground); + } + inline static int MenuOpacity() + { + return (menuOpacity); + } + inline static bool UseCustomMenuColor() + { + return (useCustomMenuColor); + } + inline static int DotlineStyle() + { + return (dotlineStyle); + } + inline static bool MenuColorButton() + { + return (menuColorButton); + } + inline static int ExpanderStyle() + { + return (expanderStyle); + } + inline static bool UseCustomExpanderColor() + { + return (useCustomExpanderColor); + } + inline static QColor CustomExpanderColor() + { + return (expanderColor); + } + inline static QColor DotlineColor() + { + return (dotlineColor); + } + inline QColor InactiveButtonColor() + { + switch (inactiveButtonColor) + { + case 0 : return (QColor(232,232,232)); + case 1 : return (bgColor()); + case 2 : return (buttonColor()); + case 3 : return (customInactiveButtonColor); + } + } + inline static bool CenterTabs() + { + return centerTabs; + } + + inline static bool SmoothListViewHeaders() + { + return smoothListViewHeaders; + } + + inline static bool SmootherLVH() + { + return smootherLVH; + } + + inline static bool IcyButtons() + { + return icyButtons; + } + + inline static Style buttonStyle() + { + return _buttonStyle; + } + + inline static int ProgressBar() + { + return progressBar; + } + + inline static bool RemoveKickerBevel() + { + return removeKickerBevel; + } + + inline static Style toolbuttonStyle() + { + return _toolbuttonStyle; + } + + inline void setGroupShadowButton() + { + groupShadowButton = true; + } + inline void setNotGroupShadowButton() + { + groupShadowButton = false; + } + inline bool GroupShadowButton() + { + return groupShadowButton; + } + + inline void setScrollerActive() + { + scrollerActive = true; + } + + inline void setScrollerInactive() + { + scrollerActive = false; + } + + inline bool ScrollerActive() + { + return scrollerActive; + } + + inline static QColor Color() + { + return color; + } + + inline static QColor Color2() + { + return color2; + } + + inline static bool DrawProgressLabel() + { + return drawProgressLabel; + } + + inline static tabStyle TabStyle() + { + return tabStyle_; + } + + inline static QColor & BrushTint() + { + return brushTint; + } + + inline static bool TintBrush() + { + return tintBrush; + } + + inline static bool AnimateSlider() + { + return animateSlider; + } + inline static bool AnimateProgress() + { + return animateProgress; + } + inline static QColor CustomButtonColor() + { + return customButtonColor; + } + + inline static bool AnimateButton() + { + return animateButton; + } + + inline static QColor aDecoColor1() + { + return aDecoColor1_; + } + inline static QColor aDecoColor2() + { + return aDecoColor2_; + } + inline static QColor titleColor( int i ) + { + return titleColor_[i]; + } + inline static QColor titleButtonColor( int i ) + { + return titleButtonColor_[i]; + } + + QMenuBar *currentMenu; + QPixmap *indicatedMenuItemPix; + QRect *indicatedMenuItemRect; + QPixmap *lastIndicatedMenuItemPix; + QRect *lastIndicatedMenuItemRect; + bool mouseOverMenu; + WId lastIndicatedMenuItemID; + static unsigned long wmDesign; + + +public slots: + inline void warningSlot() + { + qWarning("widget destroyed"); + } + +protected: + static QColor titleColor_[2]; + static QColor titleButtonColor_[3]; + + // menu + static int menuBackground; + static int menuOpacity; + static bool menuColorButton; + static bool animateButton; + static bool shadowText; + static bool drawMenuStripe_; + static QColor menuStripeColor_; + static bool glossyMenus_; + //color + static QColor customButtonColor; + //widgets + static bool customWidgetColor; + static QColor customColors[ 10 ]; + //menu + static bool useCustomMenuColor; + static QColor color, color2, colorHigh, fgColor, fgColorHigh; + //incativeButton + static int inactiveButtonColor; + static QColor customInactiveButtonColor; + + //Design + //stipples + static bool bgStipple, bevelHighlights_; + static Style style_; + static int contrast; + //shadows + static bool groupboxshadow; + static int shadowDarkness; + //istviews; + static bool drawDotlines, useCustomExpanderColor; + static int expanderStyle; + static QColor expanderColor, dotlineColor; + static int dotlineStyle; + //slider + static bool squeezesbslider; + static bool shadowsbslider; + //toolbar + static bool reverseBtnColor, tbFrame; + //tweaks + static bool centerTabs; + static bool smoothListViewHeaders; + static bool smootherLVH; + static bool icyButtons; + static Style _buttonStyle; + bool menusProcessed; + bool scrollerActive; + int menuLevelCounter; + bool groupShadowButton; + static int progressBar; + static bool removeKickerBevel; + static Style _toolbuttonStyle; + static bool drawProgressLabel; + static tabStyle tabStyle_; + + QString colorStr, fgColorStr/*, panelColorStr*/; + static QColor brushTint; + static QColor aDecoColor1_; + static QColor aDecoColor2_; + static bool tintBrush; + static bool animateSlider; + static bool animateProgress; +}; + +class EventKiller : public QObject +{ + Q_OBJECT +public: + bool eventFilter( QObject *, QEvent *) + { + return TRUE; + } +}; + +class BMShower : public QObject +{ + Q_OBJECT +public: + BMShower(QObject *parent); + bool eventFilter( QObject *object, QEvent *event ); +}; + +class ButtonFadeInfo +{ +public: + ButtonFadeInfo() + { + timerId=0; index=0; fadeIn=TRUE; + } +public: + int timerId; + int index; + bool fadeIn; +}; + +class LiquidStyle : public KStyle +{ + Q_OBJECT +public: + friend class OptionHandler; + LiquidStyle(); + virtual ~LiquidStyle(); + bool isPlain() const; + + virtual void polish( QWidget *w ); +// virtual void polishPopupMenu( QPopupMenu *w ); + virtual void unPolish( QWidget *w ); + virtual void polish( QPalette &p ); + virtual void unPolish( QApplication *a ); + int styleHint(StyleHint sh, const QWidget * w, const QStyleOption & opt, QStyleHintReturn * shr) const; + void drawKStylePrimitive( KStylePrimitive kpe, QPainter* p, const QWidget* widget, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, const QStyleOption& = QStyleOption::Default ) const; + void drawPrimitive( PrimitiveElement pe, QPainter* p, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, const QStyleOption& = QStyleOption::Default ) const; + void drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, const QStyleOption& = QStyleOption::Default ) const; +// void drawControlMask( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& = QStyleOption::Default ) const; + void drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, SCFlags controls = SC_All, SCFlags active = SC_None, const QStyleOption& = QStyleOption::Default ) const; +// void drawComplexControlMask( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& = QStyleOption::Default ) const; + + int pixelMetric( PixelMetric m, const QWidget *widget = 0 ) const; + + QSize sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentSize, const QStyleOption& opt ) const; + QRect subRect( SubRect r, const QWidget *widget ) const; + QRect querySubControlMetrics( ComplexControl control, const QWidget *widget, SubControl subcontrol, const QStyleOption &opt = QStyleOption::Default ) const; + // Fix Qt3's wacky image positions + QPixmap stylePixmap( StylePixmap stylepixmap, const QWidget *widget = 0, const QStyleOption& = QStyleOption::Default ) const; + bool eventFilter( QObject *object, QEvent *event ); + +private slots: + void updateProgressPos(); + void updateSliderPos(); + void progressBarDestroyed(QObject*); + void fakeMouse(); + +protected: + void clearImage( QImage &img ) const; + ButtonTile* createButtonTile( const QColor &c, const QColor &bgColor, QImage *buttonImage, QImage *shadowImage, QImage *glowImage, QIntDict <ButtonTile>*buttonDict, QIntDict<ButtonTile>*shadowDict, QIntDict<ButtonTile>*glowDict, int w, int h, int xOff, int yOff, int centerW, int centerH, int shadowH, int glowWH, bool sunken) const; + ButtonTile* createRoundFrameTile(QImage &img, const QColor &color, const QColor *bg, const QColor &baseColor ) const; + QPixmap* createSliderEnd( const QColor &c, const QColor &bgColor, bool top/*, bool vertical*/ ) const; + ButtonTile* separateTiles( QPixmap *pix, int xO, int yO, int w, int h, int sh, bool sunken) const; + + QPixmap* getPixmap( BitmapData item ) const; + QPixmap* adjustHSV( QImage &img, const QColor &c, const QColor *bg = NULL ) const; + QImage* adjustHSVImage( QImage &img, const QColor &c, const QColor *bg = NULL ) const; + void adjustHSV( QPixmap &pix, const QColor &c ) const; + QImage* tintBrush( const QImage &img, const QColor &c ) const; + QPixmap* processEmbedded( const char *label, const QColor &c, bool blend = false, const QColor *bg = NULL ) const; + void drawRoundButton( QPainter *p, const QColorGroup &cg, const QColor &c, /*const QColor &bg,*/ int x, int y, int w, int h, bool pushedDown = false, bool hover = false, int bgX = -1, int bgY = -1) const; + void drawRectangularButton( QPainter *p, const QColorGroup &cg, const QColor &c, int x, int y, int w, int h, bool sunken = false, bool hover = false, bool isCombo = false, int position = full, bool isHtml = false) const; + void drawCombo( QPainter *painter, const QColorGroup &cg, const QColor &c, int x, int y, int w, int h, bool sunken, bool hover, bool isCombo, int position = full, bool isHTML = false ) const; + void drawEditFrame( QPainter *p, const QRect &r, const QColorGroup &cg, bool isHTML = false, bool focused = false, bool inverse = false/*, bool round = false*/ ) const; + void drawRoundFrame( QPainter *p, const QRect &r, const QColorGroup &cg, bool focused, QPoint offset ) const; + void drawHTMLCBBorder( const QPixmap &pix, const QColor &c ) const; + bool isHTMLWidget( const QWidget *w ) const; + + +private: + LiquidStyle( const LiquidStyle & ); + LiquidStyle& operator=( const LiquidStyle & ); + int getBrightness(unsigned int rgb) const; + QImage fetchImage( const char *name ); + QColor mapFadeColor(QColor &color, int index) const; + void fadeIn(QPushButton *button); + void fadeOut(QPushButton *button); + QColor brushedMetalColor(QColor &c) const; + QColor originalBgColor; + + + QBitmap *sbLeft, *sbRight, *sbUp, *sbDown, *checkmark; + QImage *btnBorderImg, *btnShadowImg, *slider_top, *slider_btm, *slider_top_shd, *slider_btm_shd, *rectbutton, *combo, *comboShadow, *buttonGlow, *roundFrame; + QPixmap *btnBlendPix, *menuPix, *groupShadow ; + QPixmap plainBrush, gradBrush; + QBrush pagerBrush, pagerHoverBrush; + + QPixmap *pixmaps[ BITMAP_ITEMS ]; + QPixmap sbBuffer; + QScrollBar *currentScrollBar; + QWMatrix lMatrix; + QWMatrix rMatrix; + QWMatrix iMatrix; + QWMatrix mMatrix; + QWMatrix m2Matrix; + + bool isKicker, isOOO, isHTMLButton, initialPaletteLoaded, inExitPolish; + + QHeader *currentHeader; + QTabBar *currentTabBar; + int headerHoverID; + int headerSortID; + QPoint btnOffset; + QPoint cursorPos_; + QWidget *currentTaskContainer; + KPixmap activeToolbarPix; + bool isTaskContainer, taskContainerHover; + + QPalette polishedPalette, tooltipPalette; + unsigned int qtrcModificationTime; + + int progAnimShift; + int prog2AnimShift; + int sliderAnimShift; + int hoveredTabIndex; + bool mouseButtonPressed_; + + OptionHandler *optionHandler; + + QIntDict<ButtonTile>btnDict; + QIntDict<ButtonFadeInfo>bfi; + QIntDict<QRgb*>fadeColorMap; + QIntDict<ButtonTile>btnShadowedDict; + QIntDict<ButtonTile>buttonGlowDict; + QIntDict<ButtonTile>comboDict; + QIntDict<ButtonTile>comboShadowedDict; + QIntDict<ButtonTile>tabDict; + QIntDict<ButtonTile>inverseTabDict; + QIntDict<ButtonTile>rectBtnDict; + QIntDict<ButtonTile>progress2Dict; + QMap<QWidget*, int> progAnimWidgets; + + QPixmap *tmpBtnPix; + ButtonTile *inactiveRoundFrame; + ButtonTile *activeRoundFrame; + + QWidget *highlightWidget; + QScrollBar *activeScroller; + EventKiller *eventKiller; + BMShower *bmShower; + static QPixmap popupBack; + QWidget *paintWidget; +}; + +#endif diff --git a/style/baghira.themerc b/style/baghira.themerc new file mode 100644 index 0000000..d6bfd1f --- /dev/null +++ b/style/baghira.themerc @@ -0,0 +1,6 @@ +[Misc] +Name=Baghira +Comment=The Big Black Cat +ConfigPage=kstyle_baghira_config +[KDE] +WidgetStyle=Baghira diff --git a/style/bitmaps.h b/style/bitmaps.h new file mode 100644 index 0000000..a4fafc4 --- /dev/null +++ b/style/bitmaps.h @@ -0,0 +1,21 @@ +#ifndef __BITMAPS_H +#define __BITMAPS_H + +static unsigned char sbarrow_down_bits[] = { +// 0x00, 0x00, 0x7f, 0x7f, 0x3e, 0x1c, 0x08}; + 0x7f, 0x3e, 0x3e, 0x1c, 0x1c, 0x08 }; +static unsigned char sbarrow_left_bits[] = { +// 0x18, 0x1c, 0x1e, 0x1f, 0x1e, 0x1c, 0x18}; + 0x20, 0x38, 0x3e, 0x3f, 0x3e, 0x38, 0x20 }; +static unsigned char sbarrow_right_bits[] = { +// 0x0c, 0x1c, 0x3c, 0x7c, 0x3c, 0x1c, 0x0c}; + 0x01, 0x07, 0x1f, 0x3f, 0x1f, 0x07, 0x01 }; +static unsigned char sbarrow_up_bits[] = { +// 0x08, 0x1c, 0x3e, 0x7f, 0x7f, 0x00, 0x00}; + 0x08, 0x1c, 0x1c, 0x3e, 0x3e, 0x7f }; +static unsigned char checkmark_bits[] = { + 0x40, 0x60, 0x71, 0x3b, 0x1f, 0x0e, 0x04 }; + +#endif + + diff --git a/style/configure.in.in b/style/configure.in.in new file mode 100644 index 0000000..b0f4a88 --- /dev/null +++ b/style/configure.in.in @@ -0,0 +1,5 @@ +compile_kompmgr=yes +KDE_CHECK_HEADERS(X11/extensions/Xdamage.h,,compile_kompmgr=no,[#include <X11/Xlib.h>]) +KDE_CHECK_HEADERS(X11/extensions/Xcomposite.h,,compile_kompmgr=no,[#include <X11/Xlib.h>]) +KDE_CHECK_HEADERS(X11/extensions/Xrender.h,,compile_kompmgr=no,[#include <X11/Xlib.h>]) +AM_CONDITIONAL(include_kompmgr, test "$compile_kompmgr" = "yes" ) diff --git a/style/eventfilter.cpp b/style/eventfilter.cpp new file mode 100644 index 0000000..ada0475 --- /dev/null +++ b/style/eventfilter.cpp @@ -0,0 +1,990 @@ +#include <qcursor.h> +#include <kpixmapeffect.h> +#include <X11/keysym.h> +#include <X11/extensions/XTest.h> +#include <fixx11h.h> + +bool LiquidStyle::eventFilter( QObject *obj, QEvent *ev ) +{ +// qWarning("%s, %s <- %s, %s: %d", obj->className(), obj->name(), obj->parent() ? obj->parent()->className() : "none", obj->parent()?obj->parent()->name():"none",ev->type()); + switch (ev->type()) + { + case QEvent::None: + case QEvent::Timer: + { + // first check if this is one of our fading pushbuttons - return elsewise + if (!(optionHandler->AnimateButton() && ::qt_cast<QPushButton*>(obj))) + return false; + ButtonFadeInfo *bfi_ = bfi[((QPushButton*)obj)->winId()]; + if (!bfi_ || ((QTimerEvent*)ev)->timerId() != bfi_->timerId) + return false; + // ok, this is one of our fading buttons asking for repaint + ((QPushButton*)obj)->repaint(false); + int index = bfi_->fadeIn?bfi_->index + 1:bfi_->index - 1; + // handle border cases + if (index < 0) // fade-out run has finished, either stop fading stuff, or start fade-in + { + bfi_->fadeIn=true; + if (((QPushButton*)obj)->isDefault()) + { + bfi_->index=0; + } + else + { + obj->killTimer(bfi_->timerId); + // qWarning("%u: stopped (%d)", ((QPushButton*)obj)->winId(), bfi_->timerId); + bfi_->timerId=0; + ((QPushButton*)obj)->repaint(false); // must be to clean out button + } + } + else if (index > 9) // fade-in run has finished, either stop fading stuff, or start fade-out + { + if (((QPushButton*)obj)->isDefault()) + { + bfi_->fadeIn=false; + bfi_->index=9; + } + else + { + obj->killTimer(bfi_->timerId); + // qWarning("%u: stopped (%d)", ((QPushButton*)obj)->winId(), bfi_->timerId); + bfi_->timerId=0; + } + } + else + bfi_->index = index; + } + case QEvent::MouseMove: + if (::qt_cast<QTabBar*>(obj)) + { + QTabBar *tb = (QTabBar*)obj; + QRect tmpRect; + bool done = false; + QMouseEvent *me = ( QMouseEvent*)ev; + int oldTab = hoveredTabIndex; + if (hoveredTabIndex == -1) + { + for (int i = 0; i < tb->count(); i++) + { + if (tb->tabAt(i)) + { + tmpRect = tb->tabAt(i)->rect(); + if ( tmpRect.x() < me->x() && me->x() < tmpRect.right()) + { + hoveredTabIndex = i; + break; + } + } + } + } + else + { + if ((oldTab > 0) && tb->tabAt(oldTab-1)) + { + tmpRect = tb->tabAt(oldTab-1)->rect(); + if ((tmpRect.x() < me->x()) && (me->x() < tmpRect.right())) + { + hoveredTabIndex = oldTab-1; + done = true; + } + } + if (!done && (oldTab < tb->count()-1) && tb->tabAt(oldTab+1)) + { + tmpRect = tb->tabAt(oldTab+1)->rect(); + if ((tmpRect.x() < me->x()) && (me->x() < tmpRect.right())) + { + hoveredTabIndex = oldTab+1; + } + } + } + if ( oldTab != hoveredTabIndex ) + { + // reset old tab + if ( oldTab != -1 ) + if (tb->tabAt(oldTab)) tb->repaint( tb->tabAt(oldTab)->rect(), false ); + if ( hoveredTabIndex != -1 ) + tb->repaint( tmpRect, false ); + } + return false; + } + else if ( ::qt_cast<QHeader*>(obj) ) + { + QHeader *hw = (QHeader*)obj; + QMouseEvent * me = ( QMouseEvent * ) ev; + int oldHeader = headerHoverID; + headerHoverID = hw->orientation() == Qt::Horizontal ? hw->sectionAt( me->x() + hw->offset() ) : hw->sectionAt( me->y() + hw->offset() ); + if ( oldHeader != headerHoverID ) + { + // reset old header + if ( oldHeader != -1 ) + hw->repaint(hw->sectionRect ( oldHeader ), false); +// hw->repaint( hw->sectionPos( oldHeader )-hw->offset(), 0, hw->sectionSize( oldHeader ), hw->height(), false ); + if ( headerHoverID != -1 ) + hw->repaint(hw->sectionRect ( headerHoverID ), false); +// hw->repaint( hw->sectionPos( headerHoverID )-hw->offset(), 0, hw->sectionSize( headerHoverID ), hw->height(), false ); + } + return false; + } + return false; + case QEvent::Paint: + if ( ::qt_cast<QToolButton*>(obj) ) + { + QToolButton * btn = ( QToolButton * ) obj; + if (!obj->inherits( "TaskContainer" )) + { + if (btn->backgroundOrigin() != QWidget::WindowOrigin) + btn->setBackgroundOrigin( QWidget::WindowOrigin ); + } + else + { + isTaskContainer = true; + if ( currentTaskContainer == btn ) + taskContainerHover = true; + else + taskContainerHover = false; + } + return false; + } + else if (::qt_cast<QMenuBar*>(obj)) + { + QWidget *w = (QWidget *)obj; + if(w->backgroundMode() != Qt::PaletteBackground) + { + w->setBackgroundMode(PaletteBackground); + w->setBackgroundOrigin(QWidget::WindowOrigin); + } + return false; + } + else if ( ::qt_cast<QHeader*>(obj) ) + { + QHeader *hw = (QHeader*)obj; + if (hw->parentWidget() && ::qt_cast<QListView*>(hw->parentWidget())) + headerSortID = ((QListView*)hw->parentWidget())->sortColumn(); + return false; + } + else if ( obj->inherits( "QDockWindow" ) ) + { + if (KStyle::eventFilter( obj, ev )) + return true; + QWidget * w = ( QWidget * ) obj; + if ( w->backgroundMode() != Qt::PaletteBackground ) + { + w->setBackgroundMode( Qt::PaletteBackground ); + w->setBackgroundOrigin( QWidget::WindowOrigin ); + } + return false; + } + else if ( obj->inherits( "QRadioButton" ) || obj->inherits( "QCheckBox" ) ) + { + QButton * btn = ( QButton * ) obj; + bool isStatusChild = btn->parent() && ( btn->parent() ->inherits( "QStatusBar" ) || btn->parent() ->inherits( "KonqFrameStatusBar" ) ); + bool isRadio = obj->inherits( "QRadioButton" ); + btn->erase(); + QPainter p; + p.begin( btn ); + QFontMetrics fm = btn->fontMetrics(); + QSize lsz = fm.size( ShowPrefix, btn->text() ); + QSize sz = isRadio ? + QSize( pixelMetric( PM_ExclusiveIndicatorWidth ), pixelMetric( PM_ExclusiveIndicatorHeight ) ) : + QSize( pixelMetric( PM_IndicatorWidth ), pixelMetric( PM_IndicatorHeight ) ); + int x = 0; + int y = isStatusChild ? 0 : ( btn->height() - lsz.height() + fm.height() - sz.height() ) / 2; + SFlags flags = Style_Default; + if ( btn->isEnabled() ) + flags |= Style_Enabled; + if ( btn->hasFocus() ) + flags |= Style_HasFocus; + if ( btn->isDown() ) + flags |= Style_Down; + if ( highlightWidget == btn ) + flags |= Style_MouseOver; + if ( btn->state() == QButton::On ) + flags |= Style_On; + else if ( btn->state() == QButton::Off ) + flags |= Style_Off; + if ( isRadio ) + drawControl( CE_RadioButton, &p, btn, QRect( x, y, sz.width(), sz.height() ), btn->colorGroup(), flags ); + else + drawControl( CE_CheckBox, &p, btn, QRect( x, y, sz.width(), sz.height() ), btn->colorGroup(), flags ); + x = sz.width() + 6; + y = 0; + if ( btn->hasFocus() ) + { + QColor tmp( btn->colorGroup().background().dark( 130 ) ); + drawItem( &p, QRect( sz.width() + 6 + 2, 1, btn->width() - ( sz.width() + 6 + 1 ), btn->height() ), AlignLeft | AlignVCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), btn->pixmap(), btn->text(), -1, &tmp ); + drawItem( &p, QRect( sz.width() + 6 + 3, 2, btn->width() - ( sz.width() + 6 + 1 ), btn->height() ), AlignLeft | AlignVCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), btn->pixmap(), btn->text(), -1, &tmp ); + } + drawItem( &p, QRect( sz.width() + 6 + 1, 0, btn->width() - ( sz.width() + 6 + 1 ), btn->height() ), AlignLeft | AlignVCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), btn->pixmap(), btn->text() ); + p.end(); + return true; + } + else if (obj->inherits("KColorGrid") && !(((QWidget*)obj)->width() && ((QWidget*)obj)->height())) + return true; + return false; + case QEvent::KeyPress: + case QEvent::KeyRelease: + return false; + case QEvent::Wheel: + if ( ::qt_cast<QScrollView*>(obj) ) + { + optionHandler->setScrollerActive(); + return false; + } + return false; + case QEvent::Enter: + if ( ::qt_cast<QToolButton*>(obj) ) + { + bool isTask = obj->inherits( "TaskContainer" ); + QToolButton * btn = ( QToolButton * ) obj; + if (isTask) + { + currentTaskContainer = btn; + btn->repaint( false ); + return false; + } + else if ( btn->isEnabled() ) + { + highlightWidget = btn; + btn->repaint( false ); + return false; + } + } + else if ( ::qt_cast<QPushButton*>(obj) || ::qt_cast<QComboBox*>(obj) || obj->inherits( "QSplitterHandle" ) || obj->inherits( "AppletHandleDrag" ) ) + { + QWidget * btn = ( QWidget * ) obj; + if ( btn->isEnabled() ) + { + highlightWidget = btn; + btn->repaint( false ); + if (optionHandler->AnimateButton() && ::qt_cast<QPushButton*>(obj)) + fadeIn((QPushButton*)obj); + } + return false; + } + else if (::qt_cast<KToolBar*>(obj)) + { + QObjectList *handlerList = obj->queryList( "QDockWindowHandle" ); + for (uint i= 0; i < handlerList->count(); i++) + ((QWidget*)(handlerList->at(i)))->repaint(false); + return false; + } + if ( ::qt_cast<QScrollBar*>(obj) ) + { + QScrollBar * sb = ( QScrollBar * ) obj; + if ( !sb->draggingSlider() ) + { + if ( sb->isEnabled() ) + { + activeScroller = sb; + highlightWidget = sb; + sb->repaint( false ); + } + } + return false; + } + else if ( ::qt_cast<QScrollView*>(obj) ) + { + QScrollView *sv = ( QScrollView * ) obj; + if (sv->vScrollBarMode() == QScrollView::AlwaysOff && sv->hScrollBarMode() == QScrollView::AlwaysOff) + return false; + optionHandler->setScrollerActive(); + if (!(highlightWidget == sv->verticalScrollBar())) + sv->verticalScrollBar()->repaint(false); + if (!(highlightWidget == sv->horizontalScrollBar())) + sv->horizontalScrollBar()->repaint(false); + return false; + } + else if ( ::qt_cast<QHeader*>(obj) ) + { + currentHeader = (QHeader*)obj; + headerHoverID = -1; + return false; + } + else if (::qt_cast<QTabBar*>(obj)) + { + currentTabBar = (QTabBar*)obj; + hoveredTabIndex = -1; + return false; + } + else if ( obj->inherits( "KateView" ) || obj->inherits( "TEWidget") || obj->inherits("CHexViewWidget")) + { + QObjectList *scrollerList = obj->queryList( "QScrollBar" ); + optionHandler->setScrollerActive(); + for (uint i= 0; i < scrollerList->count(); i++) + ((QWidget*)(scrollerList->at(i)))->repaint(false); + return false; + } + else if (obj->inherits("KDockWidgetAbstractHeaderDrag")) + { + ((QWidget *)obj)->repaint(); + return false; + } + else if (obj->inherits( "KAnimWidget" )) + { + return true; + } + else if ( obj->inherits( "QLineEdit" ) && obj->parent() && ::qt_cast<QComboBox*>(obj->parent())) + { + QWidget * btn = ( QWidget * ) obj->parent(); + if ( btn->isEnabled() ) + { + highlightWidget = btn; + btn->repaint( false ); + } + return false; + } + else if ( obj->inherits( "QRadioButton" ) || obj->inherits( "QCheckBox" ) ) + { + QButton * btn = ( QButton * ) obj; + if (btn->isEnabled()) + { + bool isStatusChild = btn->parent() && ( btn->parent() ->inherits( "QStatusBar" ) || btn->parent() ->inherits( "KonqFrameStatusBar" ) ); + bool isRadio = obj->inherits( "QRadioButton" ); + highlightWidget = btn; + QFontMetrics fm = btn->fontMetrics(); + QSize lsz = fm.size( ShowPrefix, btn->text() ); + QSize sz = isRadio ? + QSize( pixelMetric( PM_ExclusiveIndicatorWidth ), pixelMetric( PM_ExclusiveIndicatorHeight ) ) : + QSize( pixelMetric( PM_IndicatorWidth ), pixelMetric( PM_IndicatorHeight ) ); + int x = 0; + int y = isStatusChild ? 0 : ( btn->height() - lsz.height() + fm.height() - sz.height() ) / 2; + QPainter p; + p.begin( btn ); + SFlags flags = Style_Default; + if ( btn->isEnabled() ) + flags |= Style_Enabled; + if ( btn->hasFocus() ) + flags |= Style_HasFocus; + if ( btn->isDown() ) + flags |= Style_Down; + if ( highlightWidget == btn ) + flags |= Style_MouseOver; + if ( btn->state() == QButton::On ) + flags |= Style_On; + else if ( btn->state() == QButton::Off ) + flags |= Style_Off; + if ( isRadio ) + drawControl( CE_RadioButton, &p, btn, QRect( x, y, sz.width(), sz.height() ), btn->colorGroup(), flags ); + else + drawControl( CE_CheckBox, &p, btn, QRect( x, y, sz.width(), sz.height() ), btn->colorGroup(), flags ); + p.end(); + } + return false; + } + return false; + case QEvent::Leave: + if ( ::qt_cast<QToolButton*>(obj) ) + { + QToolButton * btn = ( QToolButton * ) obj; + if (obj->inherits( "TaskContainer" )) + { + currentTaskContainer = NULL; + btn->repaint( false ); + return false; + } + else if ( btn == highlightWidget ) + { + highlightWidget = NULL; + btn->repaint( false ); + return false; + } + } + else if ( ::qt_cast<QPushButton*>(obj) || ::qt_cast<QComboBox*>(obj) || obj->inherits( "QSplitterHandle" ) || obj->inherits( "AppletHandleDrag" ) ) + { + QWidget * btn = ( QWidget * ) obj; + if ( btn == highlightWidget ) + { + highlightWidget = NULL; + if (optionHandler->AnimateButton() && ::qt_cast<QPushButton*>(obj)) + fadeOut((QPushButton*)obj); + else + btn->repaint( false ); + } + return false; + } + else if (::qt_cast<KToolBar*>(obj)) + { + QObjectList *handlerList = obj->queryList( "QDockWindowHandle" ); + for (uint i= 0; i < handlerList->count(); i++) + ((QWidget*)(handlerList->at(i)))->repaint(false); + return false; + } + if ( ::qt_cast<QScrollBar*>(obj) ) + { + QScrollBar * sb = ( QScrollBar * ) obj; + if ( sb == highlightWidget && !sb->draggingSlider() ) + { + activeScroller = NULL; + highlightWidget = NULL; + sb->repaint( false ); + } + return false; + } + else if ( ::qt_cast<QScrollView*>(obj) ) + { + QScrollView *sv = (QScrollView*)obj; +// if (sv->clipRegion().boundingRect().contains(sv->mapFromGlobal(QCursor::pos()))) +// return false; // mouse is still in the scrollview + if (sv->vScrollBarMode() == QScrollView::AlwaysOff && sv->hScrollBarMode() == QScrollView::AlwaysOff) + return false; // no sliders available - don't mess up things + optionHandler->setScrollerInactive(); + if (!(highlightWidget == sv->verticalScrollBar())) + sv->verticalScrollBar()->repaint(false); + if (!(highlightWidget == sv->horizontalScrollBar())) + sv->horizontalScrollBar()->repaint(false); + return false; + } + else if ( ::qt_cast<QHeader*>(obj) ) + { + QHeader *hw = (QHeader*)obj; + currentHeader = NULL; + if ( headerHoverID != -1 ) + hw->repaint( hw->sectionPos( headerHoverID )-hw->offset(), 0, hw->sectionSize( headerHoverID ), hw->height(), false ); + headerHoverID = -1; + return false; + } + else if (::qt_cast<QTabBar*>(obj)) + { + QTabBar *tb = (QTabBar*)obj; + currentTabBar = NULL; + if ( hoveredTabIndex != -1 ) + { + QTab *tmpTab = tb->tabAt(hoveredTabIndex); + if (tmpTab) tb->repaint( tmpTab->rect(), false ); + } + hoveredTabIndex = -1; + return false; + } + else if ( obj->inherits( "KateView" ) || obj->inherits( "TEWidget") || obj->inherits("CHexViewWidget")) + { + QObjectList *scrollerList = obj->queryList( "QScrollBar" ); + optionHandler->setScrollerInactive(); + for (uint i= 0; i < scrollerList->count(); i++) + ((QWidget*)(scrollerList->at(i)))->repaint(false); + return false; + } + else if (obj->inherits("KDockWidgetAbstractHeaderDrag")) + { + ((QWidget *)obj)->repaint(); + return false; + } + else if (obj->inherits( "KAnimWidget" )){ + return true; + } + else if ( obj->inherits( "QLineEdit" ) && obj->parent() && ::qt_cast<QComboBox*>(obj->parent())) { + QWidget *btn = (QWidget*)obj->parent(); + if ( btn == highlightWidget ) + highlightWidget = NULL; + btn->repaint( false ); + return false; + } + else if ( obj->inherits( "QRadioButton" ) || obj->inherits( "QCheckBox" ) ) + { + QButton * btn = ( QButton * ) obj; + if (btn == highlightWidget) + { + bool isRadio = obj->inherits( "QRadioButton" ); + bool isStatusChild = btn->parent() && ( btn->parent() ->inherits( "QStatusBar" ) || btn->parent() ->inherits( "KonqFrameStatusBar" ) ); + highlightWidget = NULL; + QFontMetrics fm = btn->fontMetrics(); + QSize lsz = fm.size( ShowPrefix, btn->text() ); + QSize sz = isRadio ? + QSize( pixelMetric( PM_ExclusiveIndicatorWidth ), pixelMetric( PM_ExclusiveIndicatorHeight ) ) : + QSize( pixelMetric( PM_IndicatorWidth ), pixelMetric( PM_IndicatorHeight ) ); + int x = 0; + int y = isStatusChild ? 0 : ( btn->height() - lsz.height() + fm.height() - sz.height() ) / 2; + QPainter p; + p.begin( btn ); + SFlags flags = Style_Default; + if ( btn->isEnabled() ) + flags |= Style_Enabled; + if ( btn->hasFocus() ) + flags |= Style_HasFocus; + if ( btn->isDown() ) + flags |= Style_Down; + if ( highlightWidget == btn ) + flags |= Style_MouseOver; + if ( btn->state() == QButton::On ) + flags |= Style_On; + else if ( btn->state() == QButton::Off ) + flags |= Style_Off; + if ( isRadio ) + drawControl( CE_RadioButton, &p, btn, QRect( x, y, sz.width(), sz.height() ), btn->colorGroup(), flags ); + else + drawControl( CE_CheckBox, &p, btn, QRect( x, y, sz.width(), sz.height() ), btn->colorGroup(), flags ); + p.end(); + } + return false; + } + return false; + case QEvent::MouseButtonPress: +// qWarning("class: %s, name: %s",obj->className(), obj->name()); + if ( optionHandler->style() > Panther && ::qt_cast<QToolBar*>(obj)) + { + QMouseEvent *mev = (QMouseEvent *) ev; + if (mev->button() != Qt::LeftButton) + return false; + mouseButtonPressed_ = true; + cursorPos_ = mev->globalPos(); + QTimer::singleShot(50,this,SLOT(fakeMouse())); + return true; // fire this event + } + if ( ::qt_cast<QScrollBar*>(obj) && ((QMouseEvent*)ev)->button() != Qt::RightButton) + { + QScrollBar * sb = ( QScrollBar * ) obj; + activeScroller = NULL; + sb->repaint( false ); + return false; + } + else if (obj->inherits( "KAnimWidget" )) + { + ((QFrame *)obj)->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + return false; + } + return false; + case QEvent::MouseButtonRelease: + if ( mouseButtonPressed_ ) + { + mouseButtonPressed_= false; + } + if ( ::qt_cast<QScrollBar*>(obj) ) + { + QScrollBar * sb = ( QScrollBar * ) obj; + QMouseEvent * me = ( QMouseEvent * ) ev; + if ( sb == highlightWidget) + { + if ( sb->rect().contains( me->pos() ) ) + { + activeScroller = sb; + sb->repaint( false ); + } + else + { + // this assumes, scrollers are right/bottom to scrollview + if ( ((sb->orientation() == Vertical) && (me->pos().x() < 0)) || ((sb->orientation() == Horizontal) && (me->pos().y() < 0)) ) + { + optionHandler->setScrollerActive(); + sb->repaint( false ); + } + } + } + return false; + } + else if ( ::qt_cast<QHeader*>(obj) && obj->parent() && ::qt_cast<QListView*>(obj->parent())) + { + QMouseEvent * me = ( QMouseEvent * ) ev; + headerSortID = ((QHeader*)obj)->sectionAt( me->x() + ((QHeader*)obj)->offset()); + return false; + } + else if (obj->inherits( "KAnimWidget" )){ + ((QFrame *)obj)->setFrameShape(QFrame::NoFrame); + return false; + } + return false; + case QEvent::FocusIn: + if (optionHandler->AnimateButton() && ::qt_cast<QPushButton*>(obj)) + { + fadeIn((QPushButton*)obj); + return false; + } + if ( obj->inherits( "QLineEdit" ) ) + { + QObject *daddy = obj->parent(); + if ( daddy && daddy->inherits( "QSpinWidget" )) + ((QWidget*)daddy)->repaint(false); + else + ((QWidget*)obj)->repaint(false); + return false; + } + return false; + case QEvent::FocusOut: + if (optionHandler->AnimateButton() && ::qt_cast<QPushButton*>(obj)) + { + fadeOut((QPushButton*)obj); + return false; + } + if ( obj->inherits( "QLineEdit" ) ) + { + if ( obj->parent() && obj->parent()->inherits( "QSpinWidget" )) + ((QWidget*)obj->parent())->repaint(false); + else + ((QWidget*)obj)->repaint(false); + return false; + } + return false; + case QEvent::Move: + if ( !(::qt_cast<QToolBar*>(obj) || obj->inherits( "KActiveLabel" ))) + return false; + case QEvent::Show: + if (optionHandler->style() == Tiger && ::qt_cast<QToolBar*>(obj)) + { + QToolBar *tb = (QToolBar*)obj; + QPoint pt = tb->mapTo(tb->topLevelWidget(), QPoint(0,0)); + if (pt.y() == 0) + { + activeToolbarPix = QPixmap(32,tb->height()); + KPixmapEffect::gradient(activeToolbarPix, optionHandler->aDecoColor1(), optionHandler->aDecoColor2(), KPixmapEffect::VerticalGradient, 0); + QPainter painter(&activeToolbarPix); + painter.setPen( optionHandler->aDecoColor2().dark(130) ); + painter.drawLine ( 0, tb->height()-1, 31, tb->height()-1 ); + painter.end(); + tb->installEventFilter(eventKiller); + if (tb->isActiveWindow()) + { + tb->setPaletteBackgroundColor(optionHandler->aDecoColor2()); + tb->setPaletteBackgroundPixmap(activeToolbarPix); + } + else + { + QPalette pal( tb->palette() ); + pal.setColor( QColorGroup::Background, qApp->palette().color(QPalette::Active, QColorGroup::Background) ); + pal.setBrush ( QColorGroup::Background, qApp->palette().brush(QPalette::Active, QColorGroup::Background) ); + tb->setPalette( pal ); + } + tb->removeEventFilter(eventKiller); + } + else + { + QPalette pal( tb->palette() ); + pal.setBrush ( QColorGroup::Background, qApp->palette().brush(QPalette::Active, QColorGroup::Background) ); + tb->installEventFilter(eventKiller); + tb->setPalette( pal ); + tb->removeEventFilter(eventKiller); + } + } + if (optionHandler->AnimateButton() && ::qt_cast<QPushButton*>(obj)) + { + ButtonFadeInfo *bfi_ = bfi[((QPushButton*)obj)->winId()]; + if (bfi_) + return false; + bfi_ = new ButtonFadeInfo(); + bfi.insert(((QPushButton*)obj)->winId(),bfi_); + if (((QPushButton*)obj)->isDefault()) + fadeIn((QPushButton*)obj); + return false; + } + if (::qt_cast<QProgressBar*>(obj)) + { + progAnimWidgets[(QWidget*)obj] = 0; + return false; + } + if ( !qstrcmp(obj->name(), "kde toolbar widget") ) + { + QWidget* lb = static_cast<QWidget*>(obj); + if (lb->backgroundMode() == Qt::PaletteButton) + lb->setBackgroundMode(Qt::PaletteBackground); + lb->removeEventFilter(this); + return false; + } + else if ( !obj->inherits( "KActiveLabel" )) + return false; + case QEvent::Resize:{ + QResizeEvent* rev = (QResizeEvent*) ev; + if (::qt_cast<QPopupMenu*>(obj) && optionHandler->MenuBackground() == Gradient) + { + KPixmap tmpPix = QPixmap(rev->size().width(),32); + ((QWidget *)obj)->setPaletteBackgroundPixmap(KPixmapEffect::unbalancedGradient(tmpPix, optionHandler->Color(), optionHandler->Color2(), KPixmapEffect::HorizontalGradient, 100, 100)); + } + else if (optionHandler->style() == Tiger && ::qt_cast<QToolBar*>(obj) && rev->size().height() != rev->oldSize().height()) + { + QToolBar *tb = (QToolBar*)obj; + QPoint pt = tb->mapTo(tb->topLevelWidget(), QPoint(0,0)); + if (pt.y() == 0) + { + activeToolbarPix = QPixmap(32,rev->size().height()); + KPixmapEffect::gradient(activeToolbarPix, optionHandler->aDecoColor1(), optionHandler->aDecoColor2(), KPixmapEffect::VerticalGradient, 0); + QPainter painter(&activeToolbarPix); + painter.setPen( optionHandler->aDecoColor2().dark(130) ); + painter.drawLine ( 0, rev->size().height()-1, 31, rev->size().height()-1 ); + painter.end(); + tb->installEventFilter(eventKiller); + if (tb->isActiveWindow()) + { + tb->setPaletteBackgroundColor(optionHandler->aDecoColor2()); + tb->setPaletteBackgroundPixmap(activeToolbarPix); + } + else + { + QPalette pal( tb->palette() ); + pal.setColor( QColorGroup::Background, qApp->palette().color(QPalette::Active, QColorGroup::Background) ); + pal.setBrush ( QColorGroup::Background, qApp->palette().brush(QPalette::Active, QColorGroup::Background) ); + tb->setPalette( pal ); + } + tb->removeEventFilter(eventKiller); + } + else + { + QPalette pal( tb->palette() ); + pal.setBrush ( QColorGroup::Background, qApp->palette().brush(QPalette::Active, QColorGroup::Background) ); + tb->installEventFilter(eventKiller); + tb->setPalette( pal ); + tb->removeEventFilter(eventKiller); + } + } + /*hmhmhmm... this may break qgroupbox children?!?*/ + else if (::qt_cast<QGroupBox*>(obj)) + { + QGroupBox* gb = (QGroupBox*)(obj); + if(gb->title().isEmpty()) return false; + QResizeEvent * e = (QResizeEvent*)ev; + int fm = gb->fontMetrics().height()+(gb->isCheckable()?4:1); + gb->setFrameRect(QRect(gb->rect().x(), gb->rect().y()+fm, e->size().width(), e->size().height()-fm/*-gb->frameWidth()*/)); + if(gb->layout()) + gb->layout()->setGeometry(QRect(gb->rect().x(), gb->rect().y(), e->size().width(), e->size().height())); + return true; + } + else if ( obj->inherits( "KActiveLabel" )) + { + QWidget * w = ( QWidget * ) obj; + QPalette pal( w->palette() ); + QPixmap *tile = pal.brush( QPalette::Active, QColorGroup::Background ).pixmap(); + if ( tile ) + { + QSize sz( ev->type() == QEvent::Resize ? rev->size() : w->size() ); + QPixmap pix( sz.width(), sz.height() ); + QPainter p; + if (optionHandler->style() == Brushed) + { + p.begin( &pix ); + // calc brush offsets + QWidget *window = w->topLevelWidget(); + int leftWidth; + int rightWidth; + if (window) + { + QPoint zero = w->mapTo(window, QPoint(0,0)); + leftWidth = (window->width()-1024)/2 - zero.x(); + rightWidth = pix.width() - (1024 + leftWidth); + if (leftWidth > 0) + p.drawTiledPixmap(0, 0, leftWidth, sz.height(), plainBrush); + p.drawTiledPixmap(leftWidth>0?leftWidth:0, 0, + pix.width()-(leftWidth>0?leftWidth:0)-(rightWidth>0?rightWidth:0), sz.height(), + gradBrush,leftWidth>0?0:(zero.x()-(window->width()-1024)/2)); + if (rightWidth > 0) + p.drawTiledPixmap(pix.width()-rightWidth, 0, rightWidth, sz.height(), plainBrush); + } + else if (pix.width() > 1024) + { + leftWidth = (pix.width()-1024)/2; + rightWidth = pix.width() - leftWidth; + p.drawTiledPixmap(0, 0, leftWidth, sz.height(), plainBrush); + p.drawTiledPixmap(leftWidth, 0, 1024, sz.height(), gradBrush); + p.drawTiledPixmap(leftWidth + 1024, 0, rightWidth, sz.height(), plainBrush); + } + else + p.drawTiledPixmap(0, 0, pix.width(), sz.height(), gradBrush, (1024-pix.width())/2, 0); + p.end(); + QBrush brush( pal.active().background(), pix ); + pal.setBrush( QColorGroup::Base, brush ); + w->setPalette( pal ); + } + else + { + p.begin(w); + p.drawTiledPixmap(QRect(0,0,sz.width(),sz.height()), *tile, w->backgroundOffset()); + } + } + return false; + } + else if ((optionHandler->style() == Brushed) && obj->isWidgetType() && ((QWidget*)obj)->isTopLevel() && + !(::qt_cast<QPopupMenu*>(obj) || ::qt_cast<QMenuBar*>(obj) || ((QWidget*)obj)->isDesktop () || ::qt_cast<QListBox*>(obj) || + obj->inherits("QTipLabel") || obj->inherits("AlphaWidget") || obj->inherits("ScrollWidget") ) && (ev->type() == QEvent::Show || + rev->size().width() != rev->oldSize().width())) + { + QWidget* widget = (QWidget*)obj; + // create new brushpix + QPixmap tmpBrushPix(ev->type() == QEvent::Show?widget->width():rev->size().width(), plainBrush.height()); + QPainter lightMe(&tmpBrushPix); + // calc brush offsets + int tmpWidth; + if ((tmpWidth = tmpBrushPix.width()) > 1024) + { + int leftWidth = (tmpWidth-1024)/2; + int rightWidth = tmpWidth - leftWidth; + lightMe.drawTiledPixmap(0, 0, leftWidth, plainBrush.height(), plainBrush,256-leftWidth,0); + lightMe.drawPixmap(leftWidth, 0, gradBrush); + lightMe.drawTiledPixmap(leftWidth + 1024, 0, rightWidth, plainBrush.height(), plainBrush); + } + else + lightMe.drawPixmap(0, 0, gradBrush, (1024-tmpWidth)/2, 0, tmpWidth); + lightMe.end(); + //update palette + QPalette pal( qApp->palette()); + QBrush brush( pal.active().background(), tmpBrushPix ); + pal.setBrush ( QColorGroup::Background, brush ); + //reset apps palette + qApp->installEventFilter(eventKiller); // pssst... don't let anyone know... + qApp->setPalette(pal); + pal = QPalette(widget->palette()); + pal.setBrush ( QColorGroup::Background, brush ); + widget->installEventFilter(eventKiller); // pssst... don't let anyone know... + widget->setPalette(pal); + widget->removeEventFilter(eventKiller); // ...that we just replaced the palette + QObjectList *kids = widget->queryList("QWidget"); //TODO: implement a faster version, depending on ::qt_cast<QWidget*>() + for (uint i= 0; i < kids->count(); i++) + { + QWidget *kid = (QWidget*)kids->at(i); + if (kid && kid->paletteBackgroundPixmap() && !(kid->isTopLevel() || kid->inherits( "KonqIconViewWidget" ) || kid->inherits( "khtml") || kid->inherits( "KActiveLabel") || qstrcmp( kid->name(), "_B_ALI_HEADER" ) == 0 || (kid->parentWidget() && kid->parentWidget()->inherits("Thumbnail") || kid->parentWidget()->inherits("MarkListItem")) )) + { + //we can loose those kids anytime - especially if the user plays on konqueror... + if (::qt_cast<KToolBarButton*>(kid)) + kid->setErasePixmap(tmpBrushPix); + else + { + pal = QPalette(kid->palette()); + pal.setBrush ( QColorGroup::Background, brush ); + kid->installEventFilter(eventKiller); // pssst... don't let anyone know... + kid->setPalette(pal); + kid->removeEventFilter(eventKiller); // ...that we just replaced the palette + } + } + } + delete kids; + qApp->removeEventFilter(eventKiller); // ...that we just replaced the palette + return false; + } + return false; + } + case QEvent::Hide: + if (optionHandler->AnimateButton() && ::qt_cast<QPushButton*>(obj)) + { + ButtonFadeInfo *bfi_ = bfi[((QPushButton*)obj)->winId()]; + if (bfi_) + { + obj->killTimer(bfi_->timerId); + // qWarning("%u: stopped (%d)", ((QPushButton*)obj)->winId(), bfi_->timerId); + bfi_->index=0; + bfi_->timerId=0; + } + } + case QEvent::ApplicationPaletteChange: + if ( obj->inherits( "QTipLabel" ) ) + { + ( ( QWidget* ) obj ) ->setPalette( tooltipPalette ); + return true; + } + return false; + case QEvent::PaletteChange: + if (obj->inherits("QStatusBar")) + { + obj->installEventFilter(eventKiller); + ((QWidget*)obj)->setPalette(qApp->palette()); + obj->removeEventFilter(eventKiller); + return true; + } + if ( obj->inherits( "QTipLabel" ) ) + { + ( ( QWidget* ) obj ) ->setPalette( tooltipPalette ); + return true; + } + if (obj->inherits("KCalcButton")) + { + QWidget *w = (QWidget*)obj; + QPalette pal( w->palette() ); + pal.setBrush( QColorGroup::Background, qApp->palette().brush(QPalette::Active, QColorGroup::Background)); + w->installEventFilter(eventKiller); + w->setPalette( pal ); + w->removeEventFilter(eventKiller); + w->setBackgroundOrigin( QWidget::WindowOrigin ); + return true; + } + return false; + case QEvent::WindowActivate: + if (optionHandler->style() == Tiger && ::qt_cast<QToolBar*>(obj)) + { + QToolBar *tb = (QToolBar*)obj; + QPoint pt = tb->mapTo(tb->topLevelWidget(), QPoint(0,0)); + if (pt.y() == 0) + { + tb->installEventFilter(eventKiller); + tb->setPaletteBackgroundColor(optionHandler->aDecoColor2()); + tb->setPaletteBackgroundPixmap(activeToolbarPix); + tb->removeEventFilter(eventKiller); + } + } + return false; + case QEvent::WindowDeactivate: + if (optionHandler->style() == Tiger && ::qt_cast<QToolBar*>(obj)) + { + QToolBar *tb = (QToolBar*)obj; + QPoint pt = tb->mapTo(tb->topLevelWidget(), QPoint(0,0)); + if (pt.y() == 0) + { + QPalette pal( tb->palette() ); + pal.setColor( QColorGroup::Background, qApp->palette().color(QPalette::Active, QColorGroup::Background) ); + pal.setBrush ( QColorGroup::Background, qApp->palette().brush(QPalette::Active, QColorGroup::Background) ); + tb->installEventFilter(eventKiller); + tb->setPalette( pal ); + obj->removeEventFilter(eventKiller); + } + } + return false; + default: + return false; + } +} + +void LiquidStyle::fakeMouse() +{ + if (mouseButtonPressed_) // delayed mousepress for move event + { + QCursor::setPos ( cursorPos_ ); + XTestFakeButtonEvent(qt_xdisplay(),1, false, 0); + XTestFakeKeyEvent(qt_xdisplay(),XKeysymToKeycode(qt_xdisplay(), XK_Alt_L), true, 0); + XTestFakeButtonEvent(qt_xdisplay(),1, true, 0); + XTestFakeKeyEvent(qt_xdisplay(),XKeysymToKeycode(qt_xdisplay(), XK_Alt_L), false, 0); + XFlush(qt_xdisplay()); + } +} + +void LiquidStyle::fadeIn(QPushButton *button) +{ + ButtonFadeInfo *bfi_ = bfi[button->winId()]; + if (!bfi_) + { + bfi_ = new ButtonFadeInfo(); + bfi.insert(button->winId(),bfi_); + } + bfi_->fadeIn = true; + if (bfi_->timerId == 0) + { + bfi_->index = 0; + bfi_->timerId = button->startTimer(button->isDefault()?100:50); + // qWarning("%u: started (%d)", button->winId(), bfi_->timerId); + } +} + +void LiquidStyle::fadeOut(QPushButton *button) +{ + ButtonFadeInfo *bfi_ = bfi[button->winId()]; + if (!bfi_) + { + bfi_ = new ButtonFadeInfo(); + bfi.insert(button->winId(),bfi_); + } + bfi_->fadeIn = false; + if (bfi_->timerId == 0) + { + bfi_->index = 9; + bfi_->timerId = button->startTimer(50); + // qWarning("%u: started (%d)", button->winId(), bfi_->timerId); + } +} + +BMShower::BMShower(QObject *parent) : QObject(parent) +{ +} + +bool BMShower::eventFilter( QObject *obj, QEvent *ev ) +{ + if (ev->type() == QEvent::Show && (obj->isWidgetType() && ((QWidget*)obj)->isTopLevel() && + !(::qt_cast<QPopupMenu*>(obj) || ::qt_cast<QMenuBar*>(obj) || ((QWidget*)obj)->isDesktop () || ::qt_cast<QListBox*>(obj) || + obj->inherits("QTipLabel") || obj->inherits("AlphaWidget") || obj->inherits("ScrollWidget") ))) + { + QResizeEvent* rev = new QResizeEvent(((QWidget*)obj)->size(), QSize(0,0)); + parent()->eventFilter( obj, rev ); + obj->removeEventFilter(this); + delete rev; + } + return false; +} diff --git a/style/fracts.h b/style/fracts.h new file mode 100644 index 0000000..1774e93 --- /dev/null +++ b/style/fracts.h @@ -0,0 +1,74 @@ +#ifndef FRACTS_H +#define FRACTS_H + +/* +If you wish to replace the button or combo Images, you may end up with very querky results. +The reason is, that the style internally fracts those images into 9 tiles. + +To get valid results, you need to adjust the values below, so they fit your images. +the format is: +w, h, xOff, yOff, centerW, centerH, shadowH, glowWH + +- w, h are width and height of the whole button. +- xOff (yOff) is the distance of the central fraction from left (upper) button side. +- centerW (centerH) is the width (height) of the central button fraction. +- shadowH is the height of the buttons shadow +- glowWH is the size of the frame the glow draws around the button + +an image may be helpful (make sure your editor uses a monospace font) + +[- - - - - - - - - - - - - - - w - - - - - - - - - - - - -]--- +|----------------|--------------------------|-----------------| | +| | | | +| yOff | | | +| | | | +|----- xOff----->o--------- centerW --------|-----------------| | +| | | | +| | centerH | h +| | | | +|----------------|--------------------------|-----------------| | +| | | | +| | | | | +| | | | +| | | | | +|----------------|--------------------------|-----------------| | +. --- + +Also please notice, that the Button tiles are treated different from the rectangualr ones, namely, (S: static, T: tiled, TH: tiled horizontally, TV: tiled vertically) + +Round Button, Combo: +|----------------|--------------------------|-----------------| +| | | | +| S | TH | S | +| | | | +|----------------|--------------------------|-----------------| +| | | | +| TV | T | TV | +| | | | +|----------------|--------------------------|-----------------| +| | | | +| | | | +| S | TH | S | +| | | | +|----------------|--------------------------|-----------------| + +Rectangular Button: +|----------------|--------------------------|-----------------| +| | | | +| TV | TH | TV | +| | | | +|----------------|--------------------------|-----------------| +| | | | +| S | TH | S | +| | | | +|----------------|--------------------------|-----------------| +| | | | +| | | | +| TV | TH | TV | +| | | | +|----------------|--------------------------|-----------------| + +*/ + + +#endif diff --git a/style/generatePixmaps.sh b/style/generatePixmaps.sh new file mode 100755 index 0000000..388b002 --- /dev/null +++ b/style/generatePixmaps.sh @@ -0,0 +1,54 @@ +#!/bin/sh +top_srcdir="${1:-../..}" +imagebase="$top_srcdir/imagebase" +UIC=$(grep "UIC = " ../Makefile | cut -f3- -d" ") +echo -e "#ifndef SPIXMAPS_H\n#define SPIXMAPS_H\n" > pixmaps.h +$UIC -embed baghira \ +$imagebase/brushed-gradient \ +$imagebase/brushed-tile \ +$imagebase/button-base \ +$imagebase/button-milk \ +$imagebase/button-glow \ +$imagebase/button-jaguar \ +$imagebase/button-shadow \ +$imagebase/checkbox \ +$imagebase/checkboxdown \ +$imagebase/checkbox-milk \ +$imagebase/checkboxdown-milk \ +$imagebase/combo \ +$imagebase/combo-milk \ +$imagebase/combo-jaguar \ +$imagebase/combo-shadow \ +$imagebase/htmlradio \ +$imagebase/htmlradio_down \ +$imagebase/progress \ +$imagebase/progress2 \ +$imagebase/radio \ +$imagebase/radio_down \ +$imagebase/radio-milk \ +$imagebase/radio_down-milk \ +$imagebase/rectbutton \ +$imagebase/roundFrame \ +$imagebase/sbgroove_btm \ +$imagebase/sbgroove_mid \ +$imagebase/sbgroove_top \ +$imagebase/sbIslider_mid \ +$imagebase/sbslider_btm \ +$imagebase/sbslider_btm_shd \ +$imagebase/sbslider_mid \ +$imagebase/sbslider_top \ +$imagebase/sbslider_top_shd \ +$imagebase/sb_subadd \ +$imagebase/sliderarrow \ +$imagebase/sbgroove_btm-milk \ +$imagebase/sbgroove_mid-milk \ +$imagebase/sbgroove_top-milk \ +$imagebase/sbslider_btm-milk \ +$imagebase/sbslider_mid-milk \ +$imagebase/sbslider_top-milk \ +$imagebase/sb_subadd-milk \ +$imagebase/sliderarrow-milk \ +$imagebase/tab \ +$imagebase/tab-milk \ +$imagebase/tab-jaguar >> pixmaps.h +echo -e "#endif //SPIXMAPS_H\n" >> pixmaps.h diff --git a/style/optionHandler.cpp b/style/optionHandler.cpp new file mode 100644 index 0000000..d96b700 --- /dev/null +++ b/style/optionHandler.cpp @@ -0,0 +1,251 @@ +#include "baghira.h" +#include <qapplication.h> +#include <qbrush.h> +#include <qcolor.h> +#include <qevent.h> +#include <qimage.h> +#include <qobject.h> +#include <qpainter.h> +#include <qpalette.h> +#include <qpopupmenu.h> +#include <qrect.h> +#include <qsettings.h> +#include <qsize.h> +#include <qstring.h> +// #include <kconfig.h> +#include <kpixmapeffect.h> +#include <stdio.h> +#include <cmath> + +#define _SCALE_ 65536 +#define _NORMALIZE_ >>16 + +#define CLAMP(x,l,u) x < l ? l :\ +x > u ? u :\ +x + +OptionHandler::OptionHandler( QObject *parent ) : QObject( parent ) { + scrollerActive = false; + groupShadowButton = false; + reloadSettings(); + } + + +const QColor& OptionHandler::textColor() { + return ( useCustomMenuColor ? fgColor : qApp->palette().active().text() ); + } + +const QColor& OptionHandler::bgColor() { + return qApp->palette().active().background(); + } + +const QColor& OptionHandler::buttonColor() { + LiquidStyle * style = ( LiquidStyle* ) parent(); + /*if (style->isKicker) return style->origPanelBrush.color(); + else */if (style->isOOO) return CustomButtonColor(); + else return qApp->palette().active().button(); + } + +void OptionHandler::reloadSettings() { + // gather options... + QSettings config; + config.beginGroup("/baghira/Style"); + //we need that first to make sure we use some proper settings ;) + customButtonColor = QColor(config.readNumEntry("Design_ButtonColor",(int)qApp->palette().active().button().rgb())); + // design handling: + // first try file: + QString tmpString; + FILE *file = NULL; + wmDesign = 5; + for (int i = 0; i < 8; i++) + custCols[i] = -1; + if (qstrcmp( qApp->argv() [ 0 ], "ksplash" ) == 0) + { + style_ = Panther; + _toolbuttonStyle = Panther; + _buttonStyle = Panther; + tabStyle_ = Clever; + bgStipple = false; + inactiveButtonColor = Background; + } + else + { + // first try for a tmp file from bab starter + int tmpFile = 0; + tmpString = QDir::homeDirPath() + "/.baghira/.bab/" + qApp->argv() [ 0 ]; + file = fopen(tmpString.latin1(), "r"); + if( file == NULL ) + { + tmpFile = 1; + tmpString = QDir::homeDirPath() + "/.baghira/" + qApp->argv() [ 0 ]; + file = fopen(tmpString.latin1(), "r"); + if( file == NULL ) + { + tmpFile = 2; + tmpString = QDir::homeDirPath() + "/.baghira/.bab/.style"; + file = fopen(tmpString.latin1(), "r"); + } + } + if (file != NULL) + { + style_ = _buttonStyle = _toolbuttonStyle = Panther; int i3 = inactiveButtonColor = -1; tabStyle_ = (tabStyle)-1; + fscanf(file,"%u\n%u\n%u\n%u\n%u\n%u\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",&style_, &wmDesign, &_buttonStyle, &_toolbuttonStyle, &tabStyle_, &i3, &custCols[0], &custCols[1], &custCols[2], &custCols[3], &custCols[4], &custCols[5], &custCols[6], &custCols[7], &inactiveButtonColor); + fclose(file); + if (_toolbuttonStyle < 0 || _toolbuttonStyle >= NUMSTYLES) + _toolbuttonStyle = (Style)config.readNumEntry( "Special_ToolbuttonStyle", style_); + if (_buttonStyle < 0 || _buttonStyle >= NUMSTYLES) + _buttonStyle = (Style)config.readNumEntry( "Special_ButtonStyle", style_); + if (tabStyle_ < 0 || tabStyle_ > 2) + tabStyle_ = (tabStyle) config.readNumEntry( (style_ == Brushed)?"Design_TabStyleBrushed":"Design_TabStyleAqua", Clever); + if (inactiveButtonColor < 0 || inactiveButtonColor > 3) + inactiveButtonColor = config.readNumEntry( "Design_InactiveButtonStyle", Background); + if (style_ == Brushed) + bgStipple = TRUE; + else if (i3 == 0) + bgStipple = FALSE; + else + bgStipple = config.readBoolEntry( "Design_StippleBackground", true ); + // inactive Button + if (tmpFile == 0) + remove(tmpString.latin1()); // remove TEMPORARY file + else if (tmpFile == 2) + { + tmpString = QDir::homeDirPath() + "/.baghira/.bab/.deco"; + if ((file = fopen(tmpString.latin1(), "r")) != NULL) + { + fscanf(file,"%u\n%u\n",&i3, &wmDesign); + fclose(file); + } + } + } + else + { + style_ = (Style)config.readNumEntry( "Design_Default", Panther ); + _toolbuttonStyle = (Style)config.readNumEntry( "Special_ToolbuttonStyle", style_); + _buttonStyle = (Style)config.readNumEntry( "Special_ButtonStyle", style_); + tabStyle_ = (tabStyle) config.readNumEntry( (style_ == Brushed)?"Design_TabStyleBrushed":"Design_TabStyleAqua", Clever); + bgStipple = (style_ == Brushed) ? true : config.readBoolEntry( "Design_StippleBackground", true ); + inactiveButtonColor = config.readNumEntry( "Design_InactiveButtonStyle", Background); + } + } + contrast = 0; + if (wmDesign > 4) + wmDesign = style_; + if (style_ == Jaguar) + contrast = 4; + else if (style_ == Brushed) + { + tintBrush = config.readBoolEntry( "Colors_TintBrushedMetal", false ); + if (tintBrush) + brushTint.setRgb( config.readNumEntry( "Colors_BrushTint", ( int ) bgColor().rgb())); + } + // menu stuff + glossyMenus_ = config.readBoolEntry( "Menu_Glossy", true ); + menuBackground = config.readNumEntry( "Menu_Background", Standard); + menuOpacity = config.readNumEntry( "Menu_Opacity", 70); + int menuColorStyle = config.readNumEntry( "Menu_ColorStyle", 0); + menuColorButton = (menuColorStyle == 1); + useCustomMenuColor = (menuColorStyle == 2); + shadowText = config.readBoolEntry( "Menu_ShadowText", false); + if (useCustomMenuColor){ + color = QColor( config.readNumEntry( "Menu_Color1", 0 ) ); + color2 = QColor( config.readNumEntry( "Menu_Color2", 0 ) ); + colorHigh = QColor( config.readNumEntry( "Menu_ColorHighlight", 0 ) ); + fgColor = QColor( config.readNumEntry( "Menu_TextColor", 0 ) ); + fgColorHigh = QColor( config.readNumEntry( "Menu_TextColorHighlight", 0 ) ); + } + else if (menuColorButton){ + color = customButtonColor; + color2 = customButtonColor.dark(130); + } + else { + color = qApp->palette().active().background(); + color2 = qApp->palette().active().background().dark(130); + } + drawMenuStripe_ = config.readBoolEntry("Menu_DrawMenuStripe", false); + if (drawMenuStripe_) + menuStripeColor_ = QColor(config.readNumEntry("Menu_StripeColor"),(int)Qt::white.rgb()); + // color stuff + // widgets + customWidgetColor = config.readBoolEntry( "Colors_UseCustomColors", false); + if ( customWidgetColor ) { + customColors[ CustomRadioOn ].setRgb( config.readNumEntry( "Colors_RadioOn", ( int ) buttonColor().rgb() ) ); + customColors[ CustomRadioOff ].setRgb( config.readNumEntry( "Colors_RadioOff", ( int ) bgColor().rgb() ) ); + customColors[ CustomCBOn ].setRgb( config.readNumEntry( "Colors_CheckOn", ( int ) buttonColor().rgb() ) ); + customColors[ CustomCBOff ].setRgb( config.readNumEntry( "Colors_CheckOff", ( int ) bgColor().rgb() ) ); + customColors[ CustomTabOn ].setRgb( config.readNumEntry( "Colors_TabActive", ( int ) buttonColor().rgb() ) ); + customColors[ CustomTabOff ].setRgb( config.readNumEntry( "Colors_TabInactive", ( int ) bgColor().rgb() ) ); + customColors[ CustomSBSlider ].setRgb( config.readNumEntry( "Colors_Slider", ( int ) bgColor().rgb() ) ); + customColors[ CustomSBSliderHover ].setRgb( config.readNumEntry( "Colors_SliderHovered", ( int ) buttonColor().rgb() ) ); + customColors[ CustomSBSliderPressed ].setRgb( config.readNumEntry( "Colors_SliderPressed", ( int ) buttonColor().dark(110).rgb() ) ); + customColors[ CustomSBGroove ].setRgb( config.readNumEntry( "Colors_SliderGroove", ( int ) bgColor().rgb() ) ); + } + if (inactiveButtonColor == Custom) + customInactiveButtonColor = QColor( config.readNumEntry( "Design_InactiveButtonColor", (int) bgColor().rgb())); + contrast += config.readNumEntry( "Design_StippleContrast", 3); + bevelHighlights_ = config.readBoolEntry( "Design_BevelAsHighlight", true); + //shadows +groupboxshadow = (style_ == Brushed) ? false : config.readBoolEntry( "Design_ShadowGroupBoxes", true ); + shadowDarkness = config.readNumEntry( "Design_GroupBoxeShadowDarkness", 6); + //ListViews + expanderStyle = config.readNumEntry( "Special_ExpanderStyle", Apple); + useCustomExpanderColor = config.readBoolEntry( "Special_CustomExpanderColor", false); + if (useCustomExpanderColor) + expanderColor = QColor( config.readNumEntry( "Special_ExpanderColor", (int) qApp->palette().active().text().rgb())); + drawDotlines = config.readBoolEntry( "Special_DrawTreeLines", true); + if (drawDotlines){ + dotlineStyle = config.readNumEntry( "Special_TreelineStyle", Line); + dotlineColor = QColor( config.readNumEntry( "Special_TreelineColor", (int) qApp->palette().active().mid().rgb())); + } + //slider + squeezesbslider = config.readBoolEntry( "Special_SqueezeSlider", false ); + shadowsbslider = config.readBoolEntry( "Special_ShadowSlider", false ); + animateSlider = config.readBoolEntry( "Special_AnimateSlider", true ); + // toolbar + int utb = config.readNumEntry( "Special_UnhoveredToolButtons", 2 ); + tbFrame = (utb == 2) || ((style_ == Brushed) && (utb == 1)) || ((style_ != Brushed) && (utb == 0)); + + // tweaks + centerTabs = config.readBoolEntry( "Design_CenterTabs", true); + smoothListViewHeaders = (style_ == Milk) ? true : !config.readBoolEntry( "Special_UseFlatLVH", false); + smootherLVH = config.readBoolEntry( "Special_RoundTaskbuttons", false); + icyButtons = config.readNumEntry( "Design_ButtonStyle", 0) == 0; + progressBar = config.readNumEntry( "Special_ProgressStyle", baghira); + removeKickerBevel = config.readBoolEntry( "Special_RemoveKickerBevel", false); + animateButton = config.readBoolEntry( "Design_AnimateButtons", true); + animateProgress = config.readBoolEntry( "Design_AnimateProgress", true); + drawProgressLabel = config.readBoolEntry( "Special_ShowProgressValue", false); + config.endGroup(); + + config.beginGroup("/baghira/Deco"); + titleButtonColor_[0] = QColor((unsigned int)config.readNumEntry( "CloseButtonColor", QColor(200,85,70).rgb())); + titleButtonColor_[1] = QColor((unsigned int)config.readNumEntry( "MinButtonColor", QColor(230,155,40).rgb())); + titleButtonColor_[2] = QColor((unsigned int)config.readNumEntry( "MaxButtonColor", QColor(121,180,54).rgb())); + if (style_ == Jaguar) + { + titleColor_[0] = QColor((unsigned int)config.readNumEntry( "inactiveColor1_1", QColor(204,214,230).rgb())); + titleColor_[1] = QColor((unsigned int)config.readNumEntry( "inactiveColor2_1", QColor(194,196,211).rgb())); + } + else if (style_ != Brushed) + { + titleColor_[0] = QColor((unsigned int)config.readNumEntry( "activeColor1_2", QColor(238,238,238).rgb())); + titleColor_[1] = QColor((unsigned int)config.readNumEntry( "activeColor2_2", QColor(205,202,205).rgb())); + } + if (style_ == Tiger) + { + int r,g,b; + aDecoColor1_ = QColor((unsigned int)config.readNumEntry( "activeColor2_4", (unsigned int) QColor(205,202,205).rgb())); + aDecoColor2_ = QColor((unsigned int)config.readNumEntry( "activeColor1_4", (unsigned int) QColor(238,238,238).rgb())); + r = (int)CLAMP(aDecoColor1_.red() * pow((double)aDecoColor1_.red() / (double)aDecoColor2_.red(),2.0),0,255); + g = (int)CLAMP(aDecoColor1_.green() * pow((double)aDecoColor1_.green() / (double)aDecoColor2_.green(),2.0),0,255); + b = (int)CLAMP(aDecoColor1_.blue() * pow((double)aDecoColor1_.blue() / (double)aDecoColor2_.blue(),2.0),0,255); + aDecoColor2_.setRgb(r,g,b); + } + else + { + aDecoColor1_ = Qt::black; + aDecoColor2_ = Qt::black; + } + config.endGroup(); + // Option gathered + } diff --git a/style/polish.cpp b/style/polish.cpp new file mode 100644 index 0000000..f845d2b --- /dev/null +++ b/style/polish.cpp @@ -0,0 +1,878 @@ +//#include <qdir.h> +#include "baghira.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <qapplication.h> +#include <qbrush.h> +#include <qcolor.h> +#include <qcombobox.h> +#include <qcursor.h> +#include <qdialog.h> +#include <qframe.h> +#include <qfile.h> +#include <qheader.h> +#include <qgroupbox.h> +//#include <qiconview.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlistbox.h> +#include <klistview.h> +#include <kmenubar.h> +#include <qpalette.h> +#include <qpainter.h> +#include <qpopupmenu.h> +#include <qpushbutton.h> +#include <qscrollbar.h> +#include <qscrollview.h> +#include <qsizepolicy.h> +#include <qslider.h> +#include <qtabbar.h> +#include <qtoolbar.h> +#include <qtoolbutton.h> +#include <kdeversion.h> +#include <kpixmapeffect.h> +#include <kglobalsettings.h> +#include <kwin.h> +#include <X11/Xlib.h> +#include <X11/Xatom.h> + +#include <fixx11h.h> +#define OPAQUE 0xffffffff +#define OPACITY "_KDE_WM_WINDOW_OPACITY" +#define _FORCE_SCROLLBARS_ 0 + +#ifndef CLAMP +#define CLAMP(x,l,u) x < l ? l :\ +x > u ? u :\ +x +#endif + + +void LiquidStyle::polish( QPalette &pal ) +{ + if ( inExitPolish ) + return ; + // clear out all old colorized pixmaps + int i; + for ( i = 0; i < BITMAP_ITEMS; ++i ) + { + if ( pixmaps[ i ] ) + { + delete pixmaps[ i ]; + pixmaps[ i ] = NULL; + } + } + // clear out all dicts + btnDict.clear(); + btnShadowedDict.clear(); + // reset brushes + pagerHoverBrush = QBrush(); + pagerBrush = QBrush(); + + bool newPalette = false; + struct stat buffer; + if ( stat( QFile::encodeName( QDir::homeDirPath() + "/.qt/qtrc" ), &buffer ) == 0 ) + { + unsigned int lastModTime = ( unsigned int ) buffer.st_mtime; + if ( lastModTime > qtrcModificationTime ) + { + qtrcModificationTime = lastModTime; + newPalette = true; + } + } + else if ( !initialPaletteLoaded ) // Hack, should always have qtrc in KDE + newPalette = true; + initialPaletteLoaded = true; + + if ( !newPalette ) + { + pal = polishedPalette; + return ; + } + + originalBgColor = pal.color(QPalette::Active, QColorGroup::Background); + if (optionHandler->style() == Brushed) + pal.setColor(QColorGroup::Background, brushedMetalColor(optionHandler->BrushTint())); + if (isOOO) + pal.setColor( QColorGroup::Button, pal.active().background() ); + else if (optionHandler->custCols[0] != -1) + { + pal.setColor(QColorGroup::Background, QColor(optionHandler->custCols[0])); + pal.setColor(QColorGroup::Button, QColor(optionHandler->custCols[1])); + pal.setColor(QColorGroup::Base, QColor(optionHandler->custCols[2])); + pal.setColor(QPalette::Active, QColorGroup::Text, QColor(optionHandler->custCols[3])); + pal.setColor(QPalette::Active, QColorGroup::Foreground, QColor(optionHandler->custCols[3])); + pal.setColor(QColorGroup::Highlight, QColor(optionHandler->custCols[4])); + pal.setColor(QPalette::Active, QColorGroup::HighlightedText, QColor(optionHandler->custCols[5])); + pal.setColor(QPalette::Active, QColorGroup::ButtonText, QColor(optionHandler->custCols[6])); + pal.setColor(QColorGroup::Mid, QColor((qRed(optionHandler->custCols[2])+qRed(optionHandler->custCols[3]))/2,(qGreen(optionHandler->custCols[2])+qGreen(optionHandler->custCols[3]))/2,(qBlue(optionHandler->custCols[2])+qBlue(optionHandler->custCols[3]))/2)); + + pal.setColor(QPalette::Inactive, QColorGroup::Text, QColor(optionHandler->custCols[3])); + pal.setColor(QPalette::Inactive, QColorGroup::HighlightedText, QColor(optionHandler->custCols[5])); + pal.setColor(QPalette::Inactive, QColorGroup::ButtonText, QColor(optionHandler->custCols[6])); + } + else + pal.setColor( QColorGroup::Button, optionHandler->CustomButtonColor() ); +#if 0 + if ( isKicker ) + { + origPanelBrush = pal.brush( QPalette::Active, QColorGroup::Background ); + origPanelPalette = pal; + QColor c( pal.active().background() ); + + if ( optionHandler->usePanelCustomColor() && optionHandler->panelCustomColor().isValid() ) + c = optionHandler->panelCustomColor(); + + kickerColor = c; + + pal.setColor( QColorGroup::Mid, optionHandler->CustomButtonColor().dark( 110 ) ); + pal.setColor( QColorGroup::Dark, optionHandler->CustomButtonColor().dark( 130 ) ); + pal.setColor( QColorGroup::Midlight, optionHandler->CustomButtonColor().light( 110 ) ); + pal.setColor( QColorGroup::Light, optionHandler->CustomButtonColor().light( 115 ) ); + pal.setColor( QColorGroup::Button, optionHandler->CustomButtonColor()); + + if (optionHandler->style() == Brushed) + { + QBrush brush( c, gradBrush ); + pal.setBrush( QColorGroup::Background, brush ); + } + else if ( optionHandler->usePanelStipple() ) + { + QPixmap stipple( 64, 64 ); + stipple.fill( c.rgb() ); + QPainter p( &stipple ); + p.setPen( c.dark( 100 + (int)(optionHandler->stippleContrast()/4) ) ); + for ( int i = 1; i < 64; i += 4 ) + { + p.drawLine( 0, i, 63, i ); + p.drawLine( 0, i+2, 63, i+2 ); + } + p.setPen( c.dark( 100 + optionHandler->stippleContrast()) ); + for ( int i = 2; i < 63; i += 4 ) + p.drawLine( 0, i, 63, i ); + p.end(); + QBrush brush( c, stipple ); + pal.setBrush( QColorGroup::Background, brush ); + } + else + pal.setBrush( QColorGroup::Background, c ); + } +#endif + /*else*/ if (optionHandler->style() == Brushed) + { + QColor c( pal.active().background() ); + QBrush brush( c, gradBrush ); + pal.setBrush( QColorGroup::Background, brush ); + } + else if ( !isPlain() ) + { + QColor c( pal.active().background() ); + QPixmap stipple( 64, 64 ); + stipple.fill( c.rgb() ); + QPainter p; + p.begin( &stipple ); + p.setPen( c.dark( 100 + (int)(optionHandler->stippleContrast()/2) ) ); + for ( i = 1; i < 64; i += 4 ) + { + p.drawLine( 0, i, 63, i ); + p.drawLine( 0, i+2, 63, i+2 ); + } + p.setPen( c.dark( 100 + optionHandler->stippleContrast() ) ); + for ( i = 2; i < 63; i += 4 ) + p.drawLine( 0, i, 63, i ); + p.end(); + QBrush brush( c, stipple ); + pal.setBrush( QColorGroup::Background, brush ); + } + + if (optionHandler->bevelHighlights()) + { + QColor c(pal.active().highlight()); + QColor c2(c.light(140)); + QPixmap pix2 = QPixmap(48,48); + QPainter coolPainter(&pix2); + KPixmap pix = QPixmap(48,24); + KPixmapEffect::gradient(pix,c,c2,KPixmapEffect::VerticalGradient,0); + coolPainter.drawPixmap(0,0,pix); + KPixmapEffect::gradient(pix,c2,c,KPixmapEffect::VerticalGradient,0); + coolPainter.drawPixmap(0,24,pix); + QBrush brush(c, pix2); + pal.setBrush(QColorGroup::Highlight, brush); + } + polishedPalette = pal; + optionHandler->reset(); +} + +void LiquidStyle::unPolish( QApplication *app ) +{ + popupBack.resize(0,0); + QPalette pal( app->palette() ); + inExitPolish = true; + + if ( !isPlain() ) + { + // reset any stipples + if ( pal.brush( QPalette::Active, QColorGroup::Background ).pixmap() ) + pal.setBrush( QColorGroup::Background, pal.active().background() ); + if ( pal.brush( QPalette::Active, QColorGroup::Button ).pixmap() ) + pal.setBrush( QColorGroup::Button, pal.active().button() ); +// app->blockSignals( TRUE ); + app->setPalette( pal ); +// app->blockSignals( FALSE ); + } + + inExitPolish = false; +} + +Atom baghira_deco_design = XInternAtom(qt_xdisplay(), "BAGHIRA_DECO_DESIGN", False); + +void LiquidStyle::polish( QWidget *w ) +{ +// bool testWidget = w->inherits("Splash"); +// int testInt = 0; +// if (w->sizePolicy().horData() == QSizePolicy::Minimum || w->sizePolicy().horData() == QSizePolicy::MinimumExpanding) +// qWarning("%s, \"%s\"",w->className(), w->name()); +// w->installEventFilter(this); + + bool tmpBool = false; + bool isViewport = qstrcmp( w->name(), "qt_viewport" ) == 0 || + qstrcmp( w->name(), "qt_clipped_viewport" ) == 0; + bool isViewportChild = w->parent() && + ( ( qstrcmp( w->parent() ->name(), "qt_viewport" ) == 0 ) || + ( qstrcmp( w->parent() ->name(), "qt_clipped_viewport" ) == 0 ) ); + + if (w->isTopLevel()) + { + if ( ::qt_cast<QPopupMenu*>(w)) // popup menu designs + { + switch (optionHandler->MenuBackground()) + { + case Plain: + w->setBackgroundMode( QWidget::PaletteBackground ); + if (optionHandler->UseCustomMenuColor()) + w->setPaletteBackgroundColor(optionHandler->Color()); + else if (optionHandler->MenuColorButton()) + w->setPaletteBackgroundColor(optionHandler->buttonColor()); + else + w->setPaletteBackgroundColor(optionHandler->bgColor()); + break; + case Stipples: + { + QColor c; + if (optionHandler->UseCustomMenuColor()) + c = QColor( optionHandler->Color() ); + else if (optionHandler->MenuColorButton()) + c = QColor( optionHandler->buttonColor() ); + else + c = QColor( originalBgColor ); + if (popupBack.isNull()) + { + popupBack = QPixmap(64,64); + QPixmap *stipple = &popupBack; + stipple->fill( c.rgb() ); + QPainter p; + p.begin( stipple ); + if (optionHandler->UseCustomMenuColor()) + { + QColor c2 = QColor( optionHandler->Color2() ); + p.setPen(QColor((3*c.red()+c2.red())/4, + (3*c.green()+c2.green())/4, + (3*c.blue()+c2.blue())/4)); + for ( int i = 1; i < 64; i += 4 ) + { + p.drawLine( 0, i, 63, i ); + p.drawLine( 0, i+2, 63, i+2 ); + } + p.setPen(c2); + for ( int i = 2; i < 63; i += 4 ) + { + p.drawLine( 0, i, 63, i ); + } + } + else + { + p.setPen( c.dark( 100 + (int)(optionHandler->stippleContrast()/4) ) ); + for ( int i = 1; i < 64; i += 4 ) + { + p.drawLine( 0, i, 63, i ); + p.drawLine( 0, i+2, 63, i+2 ); + } + p.setPen( c.dark( 100 + optionHandler->stippleContrast() ) ); + for ( int i = 2; i < 63; i += 4 ) + { + p.drawLine( 0, i, 63, i ); + } + } + p.end(); + } + w->setBackgroundMode( QWidget::NoBackground ); + break; + } + case Gradient: + { + w->setBackgroundMode( QWidget::PaletteBackground ); + KPixmap tmpPix = QPixmap(w->width(), 32); + w->setPaletteBackgroundPixmap(KPixmapEffect::unbalancedGradient(tmpPix, optionHandler->Color(), optionHandler->Color2(),KPixmapEffect::HorizontalGradient, 100, 100, 16)); + w->installEventFilter( this ); + break; + } + default: + w->setBackgroundMode( QWidget::PaletteBackground ); + break; + } + //set popup menu opacity for them as they bypass the windowmanager + unsigned long opacity = optionHandler->MenuOpacity()/100.0*OPAQUE; + XChangeProperty(qt_xdisplay(), w->winId(), XInternAtom(qt_xdisplay(), OPACITY, False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); + goto kstpolish; + } + else + { + if (optionHandler->wmDesign < 5) // set deco design X Property + { + unsigned char *data = 0; + Atom actual; + int format, result; + unsigned long n, left; + result = XGetWindowProperty(qt_xdisplay(), w->winId(), baghira_deco_design, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, &data); + if (result != Success || data == None) // not found set design + { + int tmp = optionHandler->wmDesign != Tiger ? optionHandler->wmDesign : Panther; + XChangeProperty(qt_xdisplay(), w->winId(), baghira_deco_design, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &(tmp), 1L); + } + } + if ((optionHandler->style() == Brushed) && !( ::qt_cast<QPopupMenu*>(w) || ::qt_cast<QMenuBar*>(w) || w->isDesktop() || ::qt_cast<QListBox*>(w) || w->inherits("QTipLabel") || w->inherits("AlphaWidget") || w->inherits("ScrollWidget") || w->inherits("PlayerWidget"))) + // install resize event filter, allowing us to update the b/m gradient on horizontal resizes. some widgets must be excluded though + { + if (!isKicker) + w->installEventFilter( bmShower ); + w->installEventFilter( this ); + } + } + } // TopLevel Widgets + + if (w->inherits("KURLBar")/*ListBox*/) + { + w->setPaletteBackgroundColor(qApp->palette().color(QPalette::Active, QColorGroup::Base)); +// ((QListBox*)w)->viewport()->setPaletteBackgroundColor(qApp->palette().color(QPalette::Active, QColorGroup::Base)); + goto kstpolish; + } + + + if (w->inherits("KColorGrid")) + { + // kiconedit doesn't check for the paintevent rect size, but tries to create a (possibly) NULL Pixmap (after palette change event e.g.) + // so we catch it's paint event and destroy it if the size is NULL + // remove this after kiconedit corrected its code + w->installEventFilter( this ); + goto kstpolish; + } + + if (w->inherits("BGMonitor") || w->inherits("mapWidget") || w->isA("MyButton") || (w->parentWidget() && w->parentWidget()->inherits("Thumbnail"))) + // don't touch these widgets at all - they don't like it + { + goto kstpolish; + } + + + + if (qstrcmp( w->name(), "kde toolbar widget" ) == 0 ) + w->installEventFilter( this ); + + if (::qt_cast<QButton*>(w)) + { + w->setBackgroundOrigin(QWidget::WindowOrigin); + if (::qt_cast<QPushButton*>(w)) + { + if (w->inherits("KKeyButton")) + { + w->setBackgroundMode( QWidget::PaletteBackground); + QPalette pal( w->palette() ); + pal.setBrush( QColorGroup::Background, qApp->palette().active().background() ); + w->setPalette( pal ); + } + else if (w->inherits("KCalcButton")) + { + w->setBackgroundMode( QWidget::PaletteBackground); + QPalette pal( w->palette() ); + pal.setBrush( QColorGroup::Background, qApp->palette().brush(QPalette::Active, QColorGroup::Background)); + w->setPalette( pal ); + } + else +#if !KDE_IS_VERSION(3,4,3) + if (!(w->parent() && w->parent()->inherits("MiniBar"))) +#endif + w->setBackgroundMode( QWidget::NoBackground); + w->installEventFilter( this ); + goto kstpolish; + } + else if (w->inherits( "QRadioButton" ) || w->inherits( "QCheckBox" )) + { + w->setBackgroundOrigin(QWidget::WindowOrigin); + w->installEventFilter( this ); + goto kstpolish; + } + } + + if ( ::qt_cast<QToolBar*>(w)) + { + if (optionHandler->useToolButtonFrame() && w->inherits("KToolBar")) + ((QToolBar*)w)->boxLayout()->setSpacing( 0 ); + ((QToolBar*)w)->setMargin( 4 ); + w->setBackgroundMode(PaletteBackground); + w->setBackgroundOrigin(QWidget::WindowOrigin); + if (optionHandler->style() > Panther) + { + w->installEventFilter( this ); + if (optionHandler->wmDesign == Tiger) + { + XChangeProperty(qt_xdisplay(), w->topLevelWidget()->winId(), baghira_deco_design, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &(optionHandler->wmDesign), 1L); + } + } + + goto kstpolish ; + } + //if (testWidget) qWarning("testwidget stage %d",testInt++); + + if (tmpBool = ::qt_cast<QToolButton*>(w) || w->inherits( "QToolBarSeparator" ) || w->inherits( "KToolBarSeparator" ) ) + { + if (tmpBool && w->parentWidget() && ::qt_cast<QToolBar*>(w->parentWidget()) ) + { + w->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + } + w->setBackgroundMode( QWidget::PaletteBackground ); + w->setBackgroundOrigin(QWidget::WindowOrigin); + w->installEventFilter( this ); + goto kstpolish; + } + + if (::qt_cast<QComboBox*>(w)) + { + w->setBackgroundMode(NoBackground); + w->installEventFilter( this ); + w->setBackgroundOrigin(QWidget::WindowOrigin); + goto kstpolish; + } + + if (w->inherits("TaskBar")) + { + w->setBackgroundOrigin(QWidget::WidgetOrigin); + goto kstpolish; + } + + if (w->inherits("QSpinWidget") || w->inherits("KDockWidgetAbstractHeaderDrag")){ + w->installEventFilter( this ); + goto kstpolish; + } + + if ( !isPlain () && (w->inherits( "KonqIconViewWidget" ) || w->inherits( "khtml")/* || w->inherits( "QtVisionView")*/)) + { + // if you want custom backgrounds in konqueror, you have to reset pixmap, since Konq animation can't handle it + // original liquid did this on khtml, too (at speed loss) so we'll see, if we get errors from this... + QPalette pal( w->palette() ); + pal.setBrush( QColorGroup::Background, pal.active().background() ); + w->setPalette( pal ); + } + + if (::qt_cast<QSlider*>(w)) + { + //avoid flicker + w->setBackgroundMode( QWidget::NoBackground ); + goto kstpolish; + } + + if ((::qt_cast<QScrollView*>(w) || w->inherits("KateView") || w->inherits("TEWidget") || w->inherits("CHexViewWidget")) && !(w->isA("KOAgenda"))) + { + if (::qt_cast<KListView*>(w) && optionHandler->custCols[7] != -1 && ((KListView*)w)->alternateBackground() == KGlobalSettings::alternateBackgroundColor()) + { + ((KListView*)w)->setAlternateBackground(QColor(optionHandler->custCols[7])); + } +#if _FORCE_SCROLLBARS_ + if (::qt_cast<QScrollView*>(w) && !w->inherits( "KActiveLabel" )) + { + ((QScrollView*)w)->setVScrollBarMode(QScrollView::AlwaysOn); + } +#endif + if (::qt_cast<QListBox*>(w) && w->isTopLevel()) + //set opacity for them as they bypass the windowmanager + { + uint opacity = 0.8*OPAQUE; + XChangeProperty(qt_xdisplay(), w->winId(), XInternAtom(qt_xdisplay(), OPACITY, False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); + } +#if 0 + // doesn't work properly - best would be to have the items drawn via style() + int height = ((QListBox*)w)->itemHeight(); + if (height > 0) + { + QPalette pal = w->palette(); + QColor c(pal.active().highlight()); + QColor c2(c.light(140)); + KPixmap pix = QPixmap(48,height); + KPixmapEffect::gradient(pix,c2,c,KPixmapEffect::VerticalGradient,0); + QBrush brush(c, pix); + pal.setBrush(QColorGroup::Highlight, brush); + w->setPalette(pal); + } +#endif + // listen to enter events - highlightning the scrollbars + w->setMouseTracking( true ); + w->installEventFilter( this ); + goto kstpolish; + } + + if (w->inherits("QStatusBar")) + { + w->setBackgroundOrigin(QWidget::WindowOrigin); + if ( qstrcmp( w->name(), "KonquerorFrameStatusBar" ) == 0 ) + // konqueror resets the statusbars background to Qt::White as soon as you open a new tab - our eventfilter will block this + { + w->installEventFilter( this ); + } + goto kstpolish; + } + + if (w->inherits( "QLineEdit" ) || w->inherits("QSplitterHandle") || w->isA( "AppletHandleDrag" ) || w->inherits( "KMiniPagerButton" )) + { + w->setBackgroundOrigin(QWidget::WindowOrigin); + w->installEventFilter( this ); + goto kstpolish; + } + + if (w->inherits( "TaskContainer" )) + { + w->installEventFilter( this ); + goto kstpolish; + } + + if (w->inherits( "KickerTip" )) + // kickers new tooltip uses backgroundColor() instead of paletteBackgroundColor() - causing Qt::black + { + w->setPaletteBackgroundColor(qApp->palette().color(QPalette::Active, QColorGroup::Button)); + w->setBackgroundMode( QWidget::NoBackground ); + goto kstpolish; + } + + if ( !isPlain() ) + { + if ( !isViewport && w->parent() && qstrcmp( w->parent() ->name(), "proxyview" ) == 0 ) + { + w->setBackgroundOrigin( QWidget::WindowOrigin ); + goto kstpolish ; + } + + if ( w->inherits( "PanelButtonBase" ) ) + goto kstpolish ; + if ( !isKicker&& !isViewport && !isViewportChild && !w->testWFlags( WType_Popup ) && !w->inherits( "KDesktop" ) && !w->inherits( "PasswordDlg" )) + { + if ( w->backgroundMode() == QWidget::PaletteBackground || w->backgroundMode() == QWidget::PaletteButton ) + { + w->setBackgroundOrigin( QWidget::WindowOrigin ); + } + } + } + if ( ::qt_cast<QPushButton*>(w) || ::qt_cast<QComboBox*>(w)) goto kstpolish; + if ( ::qt_cast<QMenuBar*>(w)) + { +// if (optionHandler->SupportAppleBar() && w->isTopLevel()){ +// // QPalette pal(w->palette()); +// qWarning("resetting erase pixmap"); +// QColor c( w->palette().active().background() ); +// QPixmap stipple( 64, 64 ); +// stipple.fill( c.rgb() ); +// QPainter p; +// p.begin( &stipple ); +// p.setPen( c.dark( 100 + (int)(optionHandler->stippleContrast()/2) ) ); +// for (int i = 1; i < 64; i += 4 ) { +// p.drawLine( 0, i, 63, i ); +// p.drawLine( 0, i+2, 63, i+2 ); +// } +// p.setPen( c.dark( 100 + optionHandler->stippleContrast()) ); +// for ( int i = 2; i < 63; i += 4 ) { +// p.drawLine( 0, i, 63, i ); +// } +// p.end(); +// // QBrush brush( c, stipple ); +// // pal.setBrush( QColorGroup::Background, brush ); +// // w->setPalette( pal ); +// w->setErasePixmap(stipple); +// } + w->setBackgroundMode( QWidget::PaletteBackground ); + if (optionHandler->UseCustomMenuColor()) + { + QPalette pal( w->palette() ); + pal.setBrush( QColorGroup::Highlight, optionHandler->menuColorHigh() ); + pal.setBrush( QColorGroup::HighlightedText, optionHandler->textColorHigh() ); + w->setPalette( pal ); + } + w->setBackgroundOrigin(QWidget::WindowOrigin); + w->installEventFilter( this ); +#if 0 + if (!::qt_cast<KMenuBar*>(w)) + { + bool bold = w->font().bold(); + bool italic = w->font().italic(); + bool underline = w->font().underline(); + bool overline = w->font().overline(); + w->setFont(KGlobalSettings::menuFont()); + if (bold) + (const_cast<QFont*>(&w->font()))->setBold(true); + if (italic) + (const_cast<QFont*>(&w->font()))->setItalic(true); + if (underline) + (const_cast<QFont*>(&w->font()))->setUnderline(true); + if (overline) + (const_cast<QFont*>(&w->font()))->setOverline(true); + } +#endif + goto kstpolish ; + } + + if (::qt_cast<QFrame*>(w)) + { + w->setBackgroundOrigin(QWidget::WindowOrigin); + if ( ::qt_cast<QLabel*>(w)) + { + if (w->parentWidget() && w->parentWidget()->inherits("Kontact::Splash")) + goto kstpolish; + else if ( !isPlain() && !(w->inherits( "QTipLabel" ) || w->inherits( "KSystemTray" ))) + { + w->setBackgroundMode( QWidget::PaletteBackground ); + } + else if ( w->inherits( "QTipLabel" ) ) + { + w->setPalette( tooltipPalette ); + w->setBackgroundOrigin(QWidget::WidgetOrigin); + w->installEventFilter( this ); + } + } + if (qstrcmp( w->name(), "backdrop" ) == 0) //kscd + { + ((QFrame *)w)->setFrameShape(QFrame::LineEditPanel); + ((QFrame *)w)->setFrameShadow(QFrame::Sunken); + goto kstpolish; + } + if (w->inherits( "KWinInternal::TabBox" )) + { + uint opacity = 0.8*OPAQUE; + XChangeProperty(qt_xdisplay(), w->winId(), XInternAtom(qt_xdisplay(), OPACITY, False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); + goto kstpolish; + } + else if (w->inherits( "KAnimWidget" )) + { + ((QFrame *)w)->setFrameShape(QFrame::NoFrame); + w->installEventFilter( this ); // the widget resets it's frameshape on mouseevents - looks crap! + goto kstpolish ; + } + else if (((QFrame *)w)->frameShape() >= QFrame::Box && ((QFrame *)w)->frameShape() <= QFrame::WinPanel){ + ((QFrame *)w)->setFrameShape(QFrame::StyledPanel); + goto kstpolish ; + } + } + //if (testWidget) qWarning("testwidget stage %d",testInt++); + + + if ( w->parentWidget() && ( ( ::qt_cast<QListBox*>(w) && ::qt_cast<QPushButton*>(w->parentWidget())) || w->inherits( "KCompletionBox" ) ) ) { + QListBox* listbox = (QListBox*) w; + listbox->setBackgroundMode( NoBackground ); + w->installEventFilter( this ); + goto kstpolish; + } + //if (testWidget) qWarning("testwidget stage %d",testInt++); + + + if (::qt_cast<QHeader*>(w)){ +// if (::qt_cast<QListView*>(w->parentWidget())) +// headerSortID = ((QListView*)w->parentWidget())->sortColumn(); +// if (w->parentWidget()) qWarning(w->parentWidget()->className()); + w->setBackgroundMode( NoBackground ); + w->installEventFilter( this ); + goto kstpolish; + } + //if (testWidget) qWarning("testwidget stage %d",testInt++); + + + if (::qt_cast<QTabBar*>(w)){ +// qWarning("installing tab event"); + w->setMouseTracking( true ); + w->installEventFilter( this ); + w->setBackgroundOrigin(QWidget::WindowOrigin); + goto kstpolish; + } + + if (::qt_cast<QGroupBox*>(w) && ((QGroupBox*)w)->frameShape() == QFrame::GroupBoxPanel && !((QGroupBox*)w)->isFlat()) + { + if ( optionHandler->drawGroupBoxShadow() ) + { + w->setPaletteBackgroundPixmap ( *groupShadow ); + if (((QGroupBox*)w)->isCheckable()) + { + QWidget *cb = (QWidget*)w->child("qt_groupbox_checkbox",0,false); + cb->setPalette(w->parentWidget() ? w->parentWidget()->palette() : qApp->palette()); + QFont font( cb->font() ); + font.setBold( true ); + cb->setFont( font ); + } + } + w->setBackgroundOrigin(QWidget::WindowOrigin); + w->installEventFilter(this); + } + //if (testWidget) qWarning("testwidget stage %d",testInt++); + + + if (w->inherits("QProgressBar")) + { + w->setBackgroundMode( NoBackground ); + w->installEventFilter(this); + connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(progressBarDestroyed(QObject*))); + goto kstpolish; + } + + if ( w->inherits( "QDockWindow" ) ) { + w->setBackgroundMode( QWidget::PaletteBackground ); + w->setBackgroundOrigin(QWidget::WindowOrigin); + w->installEventFilter( this ); + goto kstpolish ; + } + + if ( ::qt_cast<QScrollBar*>(w)) { + QCursor tmpCursor(Qt::PointingHandCursor); + w->setCursor(tmpCursor); + w->installEventFilter( this ); + w->setBackgroundMode( QWidget::NoBackground ); + goto kstpolish ; + } + if ( w->inherits( "KdetvView")) { + w->setBackgroundMode( QWidget::NoBackground ); + } + //if (testWidget) qWarning("testwidget stage %d",testInt++); + kstpolish: KStyle::polish( w ); // nothing of all above? do default kde stuff +} + + + +void LiquidStyle::unPolish( QWidget *w ) { + + bool isViewport; + bool isViewportChild; + + // general - better than querying for each and ever widget if it got one... + w->removeEventFilter( this ); + + + if (w->inherits("KColorGrid")){ + goto kstunpolish; + } + + if ( w->inherits("QToolBar") || qstrcmp( w->name(), "kde toolbar widget" ) == 0 ) { + w->setBackgroundOrigin( QWidget::WidgetOrigin ); +// w->unsetPalette(); + goto kstunpolish; + } + if ( w->inherits( "QPopupMenu" ) ) { + w->unsetPalette(); + w->setBackgroundMode( QWidget::PaletteButton ); + w->removeEventFilter( this ); + XDeleteProperty (qt_xdisplay(), w->winId(), XInternAtom(qt_xdisplay(), OPACITY, False)); + goto kstunpolish; + } + if (::qt_cast<QListBox*>(w) && w->isTopLevel()){ + XDeleteProperty (qt_xdisplay(), w->winId(), XInternAtom(qt_xdisplay(), OPACITY, False)); + goto kstunpolish; + } + if ( !isPlain () && w->inherits( "KonqIconViewWidget" ) || + w->inherits( "KHTMLView" ) ) { + w->unsetPalette(); + goto kstunpolish; + } + if (w->inherits("KateView") || w->inherits("TEWidget") || w->inherits("CHexViewWidget")){ +// w->setMouseTracking( false ); + goto kstunpolish; + } + + if (w->isA( "QViewportWidget" ) || w->inherits( "QClipperWidget" ) ) + goto kstunpolish; + + if ( !isPlain() ) { + if ( w->inherits( "KActiveLabel" ) || w->inherits( "QTipLabel" ) ) { + w->unsetPalette(); + goto kstunpolish; + } + /* + else if(w->inherits("KdmClock")){ + ; // Check this! + return; + }*/ + } + else if ( w->inherits( "QMenuBar" ) ) { + w->setBackgroundMode( QWidget::PaletteButton ); + if ( !isPlain() ) + w->setBackgroundOrigin( QWidget::WidgetOrigin ); + goto kstunpolish; + }else if ( w->inherits( "QDockWindow" ) ) { + w->setBackgroundMode( QWidget::PaletteButton ); + if ( !isPlain() ) + w->setBackgroundOrigin( QWidget::WidgetOrigin ); + goto kstunpolish; + } else if ( w->inherits( "QComboBox" ) || w->inherits( "QPushButton" ) ) { + if (w->inherits( "QPushButton" )) + { + ButtonFadeInfo *bfi_ = bfi[w->winId()]; + if (bfi_){ + if (bfi_->timerId != 0) + w->killTimer(bfi_->timerId); + bfi.setAutoDelete(TRUE); + bfi.remove(w->winId()); + } + } + w->setBackgroundMode( QWidget::PaletteButton ); + } else if ( w->inherits( "QScrollBar" ) ) { +// if (!w->isEnabled()) w->setEnabled(true); + w->setBackgroundMode( QWidget::PaletteBackground ); + goto kstunpolish; + } else if ( w->inherits( "QHeader" ) ) { + w->setMouseTracking( false ); + } + + if ( w->inherits( "QToolButton" ) ) { +// w->unsetPalette(); + w->setBackgroundMode( QWidget::PaletteButton ); + if ( !isPlain() ) + w->setBackgroundOrigin( QWidget::WidgetOrigin ); + goto kstunpolish; + } + + isViewport = qstrcmp( w->name(), "qt_viewport" ) == 0 || + qstrcmp( w->name(), "qt_clipped_viewport" ) == 0; + isViewportChild = w->parent() && + ( ( qstrcmp( w->parent() ->name(), "qt_viewport" ) == 0 ) || + ( qstrcmp( w->parent() ->name(), "qt_clipped_viewport" ) == 0 ) ); + + if ( isViewportChild ) { + if ( w->inherits( "QRadioButton" ) || w->inherits( "QComboBox" ) || w->inherits( "QPushButton" ) ) { + if ( isHTMLWidget( w ) ) { + w->setBackgroundMode( QWidget::PaletteBackground ); + goto kstunpolish; + } + } + } + + if ( !isPlain() ) { + if ( !isViewport && w->parent() && qstrcmp( w->parent() ->name(), "proxyview" ) == 0 ) { + w->setBackgroundOrigin( QWidget::WidgetOrigin ); + goto kstunpolish; + } + if ( w->ownPalette() && !w->inherits( "QButton" ) && !w->inherits( "QComboBox" ) ) + goto kstunpolish; + if ( w->inherits( "PanelButtonBase" ) ) + goto kstunpolish; + + if ( !isViewport && !isViewportChild && !w->testWFlags( WType_Popup ) && + !w->inherits( "KDesktop" ) && !w->inherits( "PasswordDlg" ) ) { + + if ( w->backgroundOrigin() == QWidget::WindowOrigin ) + w->setBackgroundOrigin( QWidget::WidgetOrigin ); + goto kstunpolish; + } + } +kstunpolish: KStyle::unPolish( w ); + } diff --git a/style/utils.cpp b/style/utils.cpp new file mode 100644 index 0000000..dd24986 --- /dev/null +++ b/style/utils.cpp @@ -0,0 +1,1418 @@ +#include "baghira.h" + +#include <qbitmap.h> +#include <qimage.h> +#include <qcolor.h> +#include <qpalette.h> +#include <qrect.h> +#include <qpoint.h> +#include <qapplication.h> +#include <qpainter.h> +#include <qpen.h> +//#include <kwordwrap.h> + + +#include "config.h" + +#ifndef CLAMP +#define CLAMP(x,l,u) x < l ? l :\ + x > u ? u :\ + x +#endif + +#define ALPHA_COLOR(A,R,G,B) \ + destR = ((A * destR) + (255 - A) * R) / 255; \ + destG = ((A * destG) + (255 - A) * G) / 255; \ + destB = ((A * destB) + (255 - A) * B) / 255; \ + A = 255; + +#define ALPHA_COLOR2(A1,A2,R,G,B) \ + destR = ((A1 * destR) + (255 - A1) * R) / 255; \ + destG = ((A1 * destG) + (255 - A1) * G) / 255; \ + destB = ((A1 * destB) + (255 - A1) * B) / 255; \ + A1 = CLAMP(A1 + A2,0,255); + +#define DELTA_COLOR(D,R,G,B) \ + delta = (255 - qRed(D))/2; \ + destR = R - delta; \ + destG = G - delta; \ + destB = B - delta; + +#define SATURATION_COLOR(R,G,B) \ + grey = (299 * R + 587 * G + 114 * B) / 1000; \ + delta = 255 - grey; \ + grey = (grey *(10 - 5)) / 10; \ + iGrey = 255 - grey;\ + destR = (iGrey * (srcR - delta) + grey * R) / 255; \ + destG = (iGrey * (srcG - delta) + grey * G) / 255; \ + destB = (iGrey * (srcB - delta) + grey * B) / 255; + +#define SATURATION_COLOR2(S,R,G,B) \ + int max = 255+(int)(0.65*(100-S)); \ + destR = CLAMP((srcR + R - 128), 0, max); \ + destG = CLAMP((srcG + G - 128), 0, max); \ + destB = CLAMP((srcB + B - 128), 0, max); \ + destR = (S*destR + (100-S)*R)/100; \ + destG = (S*destG + (100-S)*G)/100; \ + destB = (S*destB + (100-S)*B)/100; + +#define TINT_WHITE(S,R,G,B) \ + int max = 255+(int)(0.65*(100-S)); \ + destR = CLAMP((128 + R), 0, max); \ + destG = CLAMP((128 + G), 0, max); \ + destB = CLAMP((128 + B), 0, max); \ + destR = (S*destR + (100-S)*R)/100; \ + destG = (S*destG + (100-S)*G)/100; \ + destB = (S*destB + (100-S)*B)/100; + + +#define SATURATION_COLOR3(S,R,G,B) \ + destR = (S*(srcR + R - 128)/100 + R)/2; \ + destG = (S*(srcG + G - 128)/100 + G)/2; \ + destB = (S*(srcB + B - 128)/100 + B)/2; + +#define GM_COLOR(R,G,B)\ + destR = CLAMP(destR + R - 128, 0, 255);\ + destG = CLAMP(destG + G - 128, 0, 255);\ + destB = CLAMP(destB + B - 128, 0, 255); + + +#define COLOR_SPACE(R,G,B) \ + if ( R < 0 ) R = 0; else if ( R > 255 ) R = 255; \ + if ( G < 0 ) G = 0; else if ( G > 255 ) G = 255; \ + if ( B < 0 ) B = 0; else if ( B > 255 ) B = 255; + +#ifndef PRINTDEVICE +#define PRINTDEVICE(_p_) qWarning("device is %s", (_p_->device()->devType() == QInternal::Widget) ?\ +"Widget": (_p_->device()->devType() == QInternal::Pixmap) ?\ +"Pixmap": (_p_->device()->devType() == QInternal::Printer) ?\ +"Printer": (_p_->device()->devType() == QInternal::Picture) ?\ +"Picture": (_p_->device()->devType() == QInternal::UndefinedDevice) ?\ +"UndefinedDevice": "fuckdevice!" ); +#endif + +int LiquidStyle::getBrightness(unsigned int rgb) const { + int red = qRed( rgb ); + int green = qGreen( rgb ); + int blue = qBlue( rgb ); + int V = red; + if (green > V) V = green; + if (blue > V) V = blue; + return V; +} + +QPixmap* LiquidStyle::adjustHSV( QImage &img, const QColor &c, const QColor *bg ) const +{ + QImage * tmp = adjustHSVImage( img, c, bg ); + + QPixmap *pix = new QPixmap; + pix->convertFromImage( *tmp ); + delete tmp; + return ( pix ); +} + + +ButtonTile* LiquidStyle::createRoundFrameTile(QImage &img, const QColor &color, const QColor *bg, const QColor &baseColor ) const +{ + QColor bgColor( bg ? *bg : qApp->palette().active().background() ); + + if ( img.depth() != 32 ) + img = img.convertDepth( 32 ); + QImage *dest = new QImage( img.width(), img.height(), 32, 0 ); + dest->setAlphaBuffer( true ); + unsigned int *data = ( unsigned int * ) img.bits(); + unsigned int *destData = ( unsigned int* ) dest->bits(); + int total = img.width() * img.height(); + int current; + int delta; + int red, green, blue, grey, iGrey; + int destR, destG, destB, alpha; + int x,y; + + int srcR = color.red(); + int srcG = color.green(); + int srcB = color.blue(); + + if (!optionHandler->IcyButtons()) + { + srcR += 20; + srcG += 20; + srcB += 20; + COLOR_SPACE(srcR, srcG, srcB); + } + + for ( current = 0 ; current < total ; ++current ) + { + alpha = qAlpha( data[ current ] ); + if (alpha) + { + if (optionHandler->IcyButtons()) + { + red = qRed( data[ current ] ); + green = qGreen( data[ current ] ); + blue = qBlue( data[ current ] ); + SATURATION_COLOR(red, green, blue); + } + else + { + // the coloring itself + DELTA_COLOR(data[ current ], srcR, srcG, srcB); + } + } +#if 1 + if ( alpha && alpha != 255 ) + { + // only on translucent pixels - alphablending + y = (int)(current/img.width()); + x = current - y*img.width(); + if (red < 180 || x < 2 || y < 2 || y > img.height() - 2 || x > img.width() - 3) + { + ALPHA_COLOR(alpha, bgColor.red(), bgColor.green(), bgColor.blue()); + } + else + { + ALPHA_COLOR(alpha, baseColor.red(), baseColor.green(), baseColor.blue()); + } + } +#endif + // force back to valid colorspace ! + COLOR_SPACE(destR, destG, destB); + destData[ current ] = qRgba( destR, destG, destB, alpha ); + } + QPixmap destPix; + destPix = *dest; + ButtonTile *ret = separateTiles( &destPix, 11, 10, 6, 1, 0, false); + delete dest; + return ret; +} + +QImage* LiquidStyle::adjustHSVImage( QImage &img, const QColor &c, const QColor *bg ) const +{ + QColor bgColor( bg ? *bg : qApp->palette().active().background() ); + + if ( img.depth() != 32 ) + img = img.convertDepth( 32 ); + QImage *dest = new QImage( img.width(), img.height(), 32, 0 ); + dest->setAlphaBuffer( true ); + unsigned int *data = ( unsigned int * ) img.bits(); + unsigned int *destData = ( unsigned int* ) dest->bits(); + int total = img.width() * img.height(); + int current; + int delta; + int red, green, blue; + int destR, destG, destB, alpha; + + int srcR = c.red(); + int srcG = c.green(); + int srcB = c.blue(); + + int hue, s, v; + c.getHsv( &hue, &s, &v ); + int sq = CLAMP((int)((45.0/128.0)*s+55),0,100); + + + if (!optionHandler->IcyButtons()) + { + srcR += 20; + srcG += 20; + srcB += 20; + COLOR_SPACE(srcR, srcG, srcB); + } + + // float srcPercent, destPercent; + for ( current = 0 ; current < total ; ++current ) + { + alpha = qAlpha( data[ current ] ); + if (optionHandler->IcyButtons()) + { + red = qRed( data[ current ] ); + green = qGreen( data[ current ] ); + blue = qBlue( data[ current ] ); + SATURATION_COLOR2(sq, red, green, blue); + } + else + { + // the coloring itself + DELTA_COLOR(data[ current ], srcR, srcG, srcB); + } + // force back to valid colorspace ! + COLOR_SPACE(destR, destG, destB); + destData[ current ] = qRgba( destR, destG, destB, alpha ); + } + return ( dest ); +} + +QImage* LiquidStyle::tintBrush( const QImage &img, const QColor &c ) const +{ +// if ( img.depth() != 32 ) +// img = img.convertDepth( 32 ); + QImage *dest = new QImage( img.width(), img.height(), 32, 0 ); + unsigned int *data = ( unsigned int * ) img.bits(); + unsigned int *destData = ( unsigned int* ) dest->bits(); + int total = img.width() * img.height(); + int current; + int delta; + int red, green, blue, grey, iGrey; + int destR, destG, destB, alpha; + + int srcR = c.red(); + int srcG = c.green(); + int srcB = c.blue(); + + // float srcPercent, destPercent; + for ( current = 0 ; current < total ; ++current ) + { + alpha = qAlpha( data[ current ] ); + blue = qBlue( data[ current ] ); + red = qRed( data[ current ] ); + green = qGreen( data[ current ] ); + SATURATION_COLOR(red, green, blue); + // force back to valid colorspace ! + COLOR_SPACE(destR, destG, destB); + destData[ current ] = qRgba( destR, destG, destB, alpha ); + } + return ( dest ); +} + +QColor LiquidStyle::brushedMetalColor(QColor &c) const +{ + if (optionHandler->TintBrush()) + { + int srcR = c.red(); + int srcG = c.green(); + int srcB = c.blue(); + int destR, destG, destB, grey, iGrey, delta; + SATURATION_COLOR(180, 180, 180); + COLOR_SPACE(destR, destG, destB); + return QColor(destR, destG, destB); + } + else + return QColor (180,180,180); +} + + + + +void LiquidStyle::clearImage( QImage &img ) const +{ + int x, y; + int w = img.width(); + int h = img.height(); + unsigned int pixel = qRgba( 0, 0, 0, 0 ); + unsigned int *data; + + for ( y = 0 ; y < h ; ++y ) + for ( data = (unsigned int *) img.scanLine( y ), x = 0 ; x < w ; data[ x++ ] = pixel ) ; + // img.fill( pixel ); +} + +void LiquidStyle::adjustHSV( QPixmap &pix, const QColor &c ) const +{ + QImage img = pix.convertToImage(); + QPixmap *result = adjustHSV( img, c); + pix = *result; + delete result; +} + + +/* buttons are fractioned to 9 parts. +w, h are width and height of the whole button. +xOff (yOff) is the distance of the central fraction from left (upper) button side. +centerW (centerH) is the width (height) of the central button fraction. +shadowH is the height of the buttons shadow*/ +ButtonTile* LiquidStyle::createButtonTile( const QColor &c, + const QColor &bgColor, + QImage *buttonImage, + QImage *shadowImage, + QImage *glowImage, + QIntDict<ButtonTile>*buttonDict, + QIntDict<ButtonTile>*shadowDict, + QIntDict<ButtonTile>*glowDict, + int w, int h, int xOff, int yOff, + int centerW, int centerH, + int shadowH, int glowWH, + bool sunken) const +{ + int x, y, delta; + int red, green, blue; + int destR, destG, destB, alpha; + bool rect = (buttonDict == &rectBtnDict); + + int hue, s, v; + c.getHsv( &hue, &s, &v ); + int sq = CLAMP((int)((45.0/128.0)*s+55),0,100); + + int srcR = c.red(); + int srcG = c.green(); + int srcB = c.blue(); + + if (!optionHandler->IcyButtons()) + { + srcR += 20; + srcG += 20; + srcB += 20; + + COLOR_SPACE(srcR, srcG, srcB); + } + + unsigned int *data, *destData; + ButtonTile *tile; + + int shadowOverhead; + shadowH > glowWH ? shadowOverhead = shadowH - glowWH : shadowOverhead = 0; + QImage img( w + 2*glowWH, h + 2*glowWH + shadowOverhead, 32, 0 ); + img.setAlphaBuffer( !isPlain() || optionHandler->drawGroupBoxShadow() ? true : false); + clearImage( img ); + + // For unpressed buttons things are a little more complex. First + // we color adjust the shadow with the background color then we + // adjust the button to the button color. Finally we overlay the + // button on the shadow, (in the same loop as color adjusting). + // Technically we probably could of gotten away + // with just adjusting both the shadow and the button to the button + // color since the shadow is quite dark, but this is more correct and + // would allow configurable shadow brightness. If the shadow was + // just the button color, if someone configured it to be a rather + // light brightness, and they had a dark background color it wouldn't + // look right if based off the button color. + // + // Luckily this is only done once when the button is created for any + // given color ;-) + + // first do the shadow + if ((!sunken || optionHandler->buttonStyle() == Milk) && shadowImage) + for ( y = 0 ; y < h + shadowH ; ++y ) + { + data = ( unsigned int * ) shadowImage->scanLine( y ); + destData = ( unsigned int * ) img.scanLine( y + glowWH ); // glowWH is the yOffset -> distance of visable button to top of complete button + if (optionHandler->buttonStyle() == Jaguar) // has brighter shadows... + { + for ( x = 0 ; x < w ; ++x ) + if ((alpha = qAlpha( data[ x ] ))) + { + destData[ x + glowWH ] = qRgba( qRed(data[ x ]), qGreen(data[ x ]), qBlue(data[ x ]), alpha >> 1 ); + } + } + else + { + for ( x = 0 ; x < w ; ++x ) + if ((alpha = qAlpha( data[ x ] ))) + { + destData[ x + glowWH ] = data[x]; + } + } + } + // ... or the glow + else if (glowImage) + for ( y = 0 ; y < h + 2*glowWH ; ++y ) + { + data = ( unsigned int * ) glowImage->scanLine( y ); + destData = ( unsigned int * ) img.scanLine( y ); + for ( x = 0 ; x < w + 2*glowWH ; ++x ) + if ((alpha = qAlpha( data[ x ] ))) + { + DELTA_COLOR(data[ x ], srcR, srcG, srcB); + COLOR_SPACE(destR, destG, destB); + destData[ x ] = qRgba( destR, destG, destB, alpha ); + } + } + + // then the button and overlay + for ( y = 0 ; y < h ; ++y ) + { + data = ( unsigned int * ) buttonImage->scanLine( y ); + destData = ( unsigned int * ) img.scanLine( y + glowWH ); + for ( x = 0 ; x < w ; ++x ) + if ((alpha = qAlpha( data[ x ] ))) + { + if (!rect || (y > 1 && y < h-2 && x > 0 && x < w-1) ) + { + if (optionHandler->IcyButtons()) + { + red = qRed( data[ x ] ); + green = qGreen( data[ x ] ); + blue = qBlue( data[ x ] ); + SATURATION_COLOR2(sq, red, green, blue); + } + else + { + DELTA_COLOR(data[ x ], srcR, srcG, srcB); + } + } + else + { + red = qRed( data[ x ] ); + green = qGreen( data[ x ] ); + blue = qBlue( data[ x ] ); + TINT_WHITE(55, red, green, blue); + } + if (alpha != 255) + { + if ( qAlpha( destData[ x + glowWH ] ) ) + { + ALPHA_COLOR2(alpha, qAlpha( destData[ x + glowWH ] ), qRed( destData[ x + glowWH ]), qGreen( destData[ x + glowWH ]), qBlue( destData[ x + glowWH ])); + } + } + COLOR_SPACE(destR, destG, destB); + destData[ x + glowWH ] = qRgba( destR, destG, destB, alpha ); + } + } + + QPixmap *pix = new QPixmap; + pix->convertFromImage( img ); + tile = separateTiles( pix, xOff+glowWH, yOff+glowWH, centerW, centerH, shadowH, sunken); + + if ( sunken && glowDict) + glowDict->insert(c.rgb(),tile); + else if (!sunken && shadowDict) + shadowDict->insert( c.rgb(), tile ); + else + buttonDict->insert( c.rgb(), tile ); + + delete pix; + return ( tile ); +} + +QPixmap* LiquidStyle::createSliderEnd( const QColor &c, const QColor &bgColor, bool top) const +{ + + int x, y, delta; + int red, green, blue; + int destR, destG, destB, alpha; + + int h, s, v; + c.getHsv( &h, &s, &v ); + int sq = CLAMP((int)((45.0/128.0)*s+55),0,100); + + int srcR = bgColor.red(); + int srcG = bgColor.green(); + int srcB = bgColor.blue(); + + unsigned int *data, *destData; + + QImage img( 13, 9, 32, 0 ); + img.setAlphaBuffer( true ); // we need this always, as the slider groove is nevernever plain! + clearImage( img ); + + // just stole that from above... + // first do the shadow + for ( y = 0 ; y < 9 ; ++y ) { + top ? data = ( unsigned int * ) slider_top_shd->scanLine( y ) : data = ( unsigned int * ) slider_btm_shd->scanLine( y ); + destData = ( unsigned int * ) img.scanLine( y ); + for ( x = 0; x < 13; ++x ) + if ((alpha = qAlpha( data[ x ] ))) { + DELTA_COLOR(data[ x ], bgColor.red(), bgColor.green(), bgColor.blue()); + COLOR_SPACE(destR, destG, destB); + destData[ x ] = qRgba( destR, destG, destB, alpha ); + } + } + // then the button and overlay + + srcR = c.red(); + srcG = c.green(); + srcB = c.blue(); + + if (!optionHandler->IcyButtons()){ + srcR +=20; + srcG += 20; + srcB += 20; + + COLOR_SPACE(srcR, srcG, srcB); + } + + for ( y = 0 ; y < 7 ; ++y ) { + top ? data = ( unsigned int * ) slider_top->scanLine( y ) : data = ( unsigned int * ) slider_btm->scanLine( y ); + destData = ( unsigned int * ) img.scanLine( top ? y + 2 : y ); + for ( x = 0 ; x < 13 ; ++x ) + if ((alpha = qAlpha( data[ x ] ))) { + if (optionHandler->IcyButtons()) { + red = qRed( data[ x ] ); + green = qGreen( data[ x] ); + blue = qBlue( data[ x] ); + SATURATION_COLOR2(sq, red, green, blue); + } + else { + DELTA_COLOR(data[ x ], srcR, srcG, srcB); + } + if (alpha != 255) { + if ( qAlpha( destData[ x ] ) ) { + ALPHA_COLOR2(alpha, qAlpha( destData[ x ]), qRed( destData[ x ]), qGreen( destData[ x ]), qBlue( destData[ x ])); + } + } + COLOR_SPACE(destR, destG, destB); + destData[ x ] = qRgba( destR, destG, destB, alpha ); + } + } + QPixmap *pix = new QPixmap; + pix->convertFromImage( img ); + return ( pix ); +} + + + +// 0 / xO / xO + w +// ------------------------------------- +// | xO | w | width()-xO-w | : yO / 0 +// ------------------------------------- +// | xO | w | width()-xO-w | : h / yO +// ------------------------------------- +// | xO | w | width()-xO-w | : height()-yO-h / yO+h +// ------------------------------------- +// Overload of mosfet's original function, takes 6 more parameters to use the funktion on variable bitmaps (mosfet's function does only work for very special bitmaps) +// by giving position and dimension of the central tile + the shadow height (panther doesn't seem to have a right shadow-offset) +ButtonTile* LiquidStyle::separateTiles( QPixmap *pix, + int xO, int yO, int w, int h, + int, bool sunken) const +{ + ButtonTile * tile = new ButtonTile(); + QPixmap *tmp; + + int w1 = xO; + int w2 = w; + int w3 = pix->width() - xO - w; + int h1 = yO; + int h2 = h; + int h3 = pix->height() - yO - h; + + int xO1 = 0; + int xO2 = xO; + int xO3 = xO + w; + int yO1 = 0; + int yO2 = yO; + int yO3 = yO + h; + + if ( !sunken ) { + // Top tiles + tmp = new QPixmap( w1, h1 ); + // bitBlt(...,x,y,width,height) + copyBlt( tmp, 0, 0, pix, xO1, yO1, w1, h1 ); + tile->setPixmap( TileTopLeft, tmp ); + tmp = new QPixmap( w2, h1 ); + copyBlt( tmp, 0, 0, pix, xO2, yO1, w2, h1 ); + tile->setPixmap( TileTop, tmp ); + tmp = new QPixmap( w3, h1 ); + copyBlt( tmp, 0, 0, pix, xO3, yO1, w3, h1 ); + tile->setPixmap( TileTopRight, tmp ); + + // Middle tiles + tmp = new QPixmap( w1, h2 ); + copyBlt( tmp, 0, 0, pix, xO1, yO2, w1, h2 ); + tile->setPixmap( TileLeft, tmp ); + tmp = new QPixmap( w2, h2 ); + copyBlt( tmp, 0, 0, pix, xO2, yO2, w2, h2 ); + tile->setPixmap( TileMiddle, tmp ); + tmp = new QPixmap( w3, h2 ); + copyBlt( tmp, 0, 0, pix, xO3, yO2, w3, h2 ); + tile->setPixmap( TileRight, tmp ); + + // Bottom tiles + tmp = new QPixmap( w1, h3 ); + copyBlt( tmp, 0, 0, pix, xO1, yO3, w1, h3 ); + tile->setPixmap( TileBtmLeft, tmp ); + tmp = new QPixmap( w2, h3 ); + copyBlt( tmp, 0, 0, pix, xO2, yO3, w2, h3 ); + tile->setPixmap( TileBtm, tmp ); + tmp = new QPixmap( w3, h3 ); + copyBlt( tmp, 0, 0, pix, xO3, yO3, w3, h3 ); + tile->setPixmap( TileBtmRight, tmp ); + + } + else { + // Top tiles + tmp = new QPixmap( w1, h3 ); + // bitBlt(...,x,y,width,height) + copyBlt( tmp, 0, 0, pix, xO1, yO1, w1, h3 ); + tile->setPixmap( TileTopLeft, tmp ); + tmp = new QPixmap( w2, h3 ); + copyBlt( tmp, 0, 0, pix, xO2, yO1, w2, h3 ); + tile->setPixmap( TileTop, tmp ); + tmp = new QPixmap( w3, h3 ); + copyBlt( tmp, 0, 0, pix, xO3, yO1, w3, h3 ); + tile->setPixmap( TileTopRight, tmp ); + + // Middle tiles + tmp = new QPixmap( w1, h2 ); + copyBlt( tmp, 0, 0, pix, xO1, yO2 + h3 - h1, w1, h2 ); + tile->setPixmap( TileLeft, tmp ); + tmp = new QPixmap( w2, h2 ); + copyBlt( tmp, 0, 0, pix, xO2, yO2 + h3 - h1, w2, h2 ); + tile->setPixmap( TileMiddle, tmp ); + tmp = new QPixmap( w3, h2 ); + copyBlt( tmp, 0, 0, pix, xO3, yO2 + h3 - h1, w3, h2 ); + tile->setPixmap( TileRight, tmp ); + + // Bottom tiles + tmp = new QPixmap( w1, h1 ); + copyBlt( tmp, 0, 0, pix, xO1, yO3 + h3 - h1, w1, h1 ); + tile->setPixmap( TileBtmLeft, tmp ); + tmp = new QPixmap( w2, h1 ); + copyBlt( tmp, 0, 0, pix, xO2, yO3 + h3 - h1, w2, h1 ); + tile->setPixmap( TileBtm, tmp ); + tmp = new QPixmap( w3, h1 ); + copyBlt( tmp, 0, 0, pix, xO3, yO3 + h3 - h1, w3, h1 ); + tile->setPixmap( TileBtmRight, tmp ); + } + return ( tile ); +} + +#define _LOFF_ tile->pixmap( TileLeft )->width() +#define _ROFF_ tile->pixmap( TileRight )->width() +#define _TOFF_ tile->pixmap( TileTop )->height() +#define _BOFF_ tile->pixmap( TileBtm )->height() +#define _MWIDTH_ tile->pixmap( TileMiddle )->width() +#define _MHEIGHT_ tile->pixmap( TileMiddle )->height() +#define _LRWIDTH_ (_LOFF_ + _ROFF_) +#define _TBHEIGHT_ (_TOFF_ + _BOFF_) + +void LiquidStyle::drawRoundButton( QPainter *painter, const QColorGroup &cg, const QColor &c, int x, int y, int w, int h, bool pushedDown, bool hover, int bgX, int bgY ) const +{ + + QColor myC =(isOOO && (hover || pushedDown))?optionHandler->CustomButtonColor():c; + LiquidStyle *ptr = const_cast<LiquidStyle*>( this ); + ButtonTile *tile = pushedDown ? btnDict.find( myC.rgb() ) : btnShadowedDict.find( myC.rgb() ); + + if ( !tile ) + { + tile = createButtonTile( myC, qApp->palette().color(QPalette::Active, QColorGroup::Background), ptr->btnBorderImg, ptr->btnShadowImg, ptr->buttonGlow, &(ptr->btnDict), &(ptr->btnShadowedDict), &(ptr->buttonGlowDict), 37, 21, 10, 11, 17, 1, 2, 2, pushedDown); + } + + if ( !tile ) + { + qWarning( "Button tile is NULL!" ); + return ; + } + + QPainter *p; + QPen oldPen = painter->pen(); + if (!isHTMLButton) + { + if ( !tmpBtnPix ) + ptr->tmpBtnPix = new QPixmap( w, h ); + else if ( w > tmpBtnPix->width() || h > tmpBtnPix->height() ) + { + // make temp pixmap size == largest button + ptr->tmpBtnPix->resize(w,h); + } + p = new QPainter(tmpBtnPix); + + if (!isPlain()) + { + QPixmap *stipple; + if (paintWidget && paintWidget->parentWidget()) + { + stipple = const_cast<QPixmap*>(paintWidget->parentWidget()->palette().brush(QPalette::Active, QColorGroup::Background).pixmap()); + if (!stipple || stipple->isNull()) + p->fillRect(0,0,w,h, paintWidget->parentWidget()->palette().brush(QPalette::Active, QColorGroup::Background) ); + else + p->drawTiledPixmap( 0, 0, w, h, *stipple, bgX, bgY ); + } + else + { + stipple = cg.brush( QColorGroup::Background ).pixmap(); + stipple ? p->drawTiledPixmap( 0, 0, w, h, *stipple, bgX, bgY ) : + p->fillRect(0,0,w,h, cg.brush( QColorGroup::Background )); + } + } + else + p->fillRect(0,0,w,h, cg.brush( QColorGroup::Background )); + } + else + { + p = painter; + } + +// QPainter p(tmpBtnPix); + + // tiled fills + if ( w > _LRWIDTH_ ) + { + p->drawTiledPixmap( _LOFF_, 0, w - _LRWIDTH_, _TOFF_, *tile->pixmap( TileTop ) ); + p->drawTiledPixmap( _LOFF_, h - _BOFF_, w - _LRWIDTH_, _BOFF_, *tile->pixmap( TileBtm ) ); + } + if ( h > _TBHEIGHT_ ) + { + p->drawTiledPixmap( 0, _TOFF_, _LOFF_, h - _TBHEIGHT_, *tile->pixmap( TileLeft ) ); + p->drawTiledPixmap( w - _ROFF_, _TOFF_, _ROFF_, h - _TBHEIGHT_, *tile->pixmap( TileRight ) ); + } + if ( w > _LRWIDTH_ && h > _TBHEIGHT_ ) + p->drawTiledPixmap( _LOFF_, _TOFF_, w - _LRWIDTH_, h - _TBHEIGHT_, *tile->pixmap( TileMiddle ) ); + // corners + p->drawPixmap( 0, 0, *tile->pixmap( TileTopLeft ) ); + p->drawPixmap( w - _ROFF_, 0, *tile->pixmap( TileTopRight ) ); + p->drawPixmap( 0, h - _BOFF_, *tile->pixmap( TileBtmLeft ) ); + p->drawPixmap( w - _ROFF_, h - _BOFF_, *tile->pixmap( TileBtmRight ) ); + + if (!isHTMLButton) + { + p->end(); + delete p; + painter->drawPixmap( x, y, *tmpBtnPix, 0, 0, w, h ); + } + else + p->setPen(oldPen); +} + + +void LiquidStyle::drawRectangularButton( QPainter *painter, + const QColorGroup &cg, const QColor &c, + int x, int y, int w, int h, + bool sunken, bool hover, bool isCombo, int position, bool isHTML) const +{ +#define _HEIGHT_ ptr->rectbutton->height() +#define _WIDTH_ ptr->rectbutton->width() + LiquidStyle *ptr = const_cast<LiquidStyle*>( this ); + + QColor tmpColor; + tmpColor = isCombo && !(hover || sunken) ? optionHandler->InactiveButtonColor() : c; + + int xOffset, width; + int cw = 0; + + ButtonTile *tile = rectBtnDict.find( tmpColor.rgb() ); + if ( !tile ) + tile = createButtonTile( tmpColor, cg.background(), ptr->rectbutton, ((QImage*)0L), ((QImage*)0L), &(ptr->rectBtnDict), (QIntDict<ButtonTile>*)0L, (QIntDict<ButtonTile>*)0L, 33, 25, 10, 5, 13, 15, 0, 0, sunken); + + if ( !tile ) + { + qWarning( "Button tile is NULL!" ); + return ; + } + + switch (position) + { + case left: + xOffset = _LOFF_; + width = w - _LOFF_; + cw = 24; + break; + case center: + xOffset = 0; + width = w; + cw = 24; + break; + case right: + xOffset = 0; + width = w - _ROFF_; + cw = 24-_ROFF_; + break; + case full: + xOffset = _LOFF_; + width = w - _LRWIDTH_; + cw = 24-_ROFF_; + break; + } + + QPainter *p; + QPen oldPen = painter->pen(); + if (!isHTML) + { + if ( !tmpBtnPix ) + ptr->tmpBtnPix = new QPixmap( w, h ); + else if ( w > tmpBtnPix->width() || h > tmpBtnPix->height() ) + { + // make temp pixmap size == largest button + ptr->tmpBtnPix->resize(w,h); + } + p = new QPainter(tmpBtnPix); + + if (position != center && paintWidget && paintWidget->parentWidget()) + { + if (this->paintWidget->parentWidget()->paletteBackgroundPixmap ()) + p->drawTiledPixmap(QRect(0, 0, w, h), *this->paintWidget->parentWidget()->paletteBackgroundPixmap(), ((QWidget *)this->paintWidget)->backgroundOffset()); + else + p->fillRect( 0, 0, w, h, this->paintWidget->parentWidget()->paletteBackgroundColor()); + } + else + p->fillRect( 0, 0, w, h, cg.background() ); + } + else + { + p = painter; + } + + int tileH = 0; + QPixmap tmpPix(_LOFF_, 1); + + if (position == left || position == full) + { + p->drawPixmap( 0, 0, *tile->pixmap( TileTopLeft ) ); + p->drawPixmap( 0, h - _BOFF_, *tile->pixmap( TileBtmLeft ) ); + } + + if (!isCombo || hover || sunken) + { + if ( w > _LRWIDTH_ ) + { + p->drawTiledPixmap( xOffset, 0, width, _TOFF_, *tile->pixmap( TileTop ) ); + p->drawTiledPixmap( xOffset, h - _BOFF_, width, _BOFF_, *tile->pixmap( TileBtm ) ); + } + + if ( h > _TBHEIGHT_ ) + { + tileH = (int)((h-_HEIGHT_)/2); + if (position == left || position == full) + { + if (h > _HEIGHT_) + { + p->drawPixmap(0, _TOFF_+tileH, *tile->pixmap( TileLeft )); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileLeft), 0, 0, _LOFF_, 1 ); + p->drawTiledPixmap(0, _TOFF_, _LOFF_, tileH, tmpPix); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileLeft), 0, _MHEIGHT_-1, _LOFF_, 1 ); + p->drawTiledPixmap(0, _TOFF_+tileH+_MHEIGHT_, _LOFF_, h-_HEIGHT_-tileH, tmpPix); + } + else //tileH is negative in this case + p->drawPixmap( 0, _TOFF_, *tile->pixmap( TileLeft ), 0, -tileH, _LOFF_, _MHEIGHT_+2*tileH+1); + } + if (position == right || position == full) + { + if (h > _HEIGHT_) + { + tmpPix.resize(_ROFF_, 1); + p->drawPixmap(w-_ROFF_, _TOFF_+tileH, *tile->pixmap( TileRight )); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileRight), 0, 0, _ROFF_, 1 ); + p->drawTiledPixmap(w-_ROFF_, _TOFF_, _ROFF_, tileH, tmpPix); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileRight), 0, _MHEIGHT_-1, _ROFF_, 1 ); + p->drawTiledPixmap(w-_ROFF_, _TOFF_+tileH+_MHEIGHT_, _ROFF_, h-_HEIGHT_-tileH, tmpPix); + } + else + p->drawPixmap( w-_ROFF_, _TOFF_, *tile->pixmap(TileRight), 0, -tileH, _ROFF_, _MHEIGHT_+2*tileH+1 /*tileH is negative in this case*/ ); + } + } + + + if ( w > _LRWIDTH_ && h > _TBHEIGHT_ ) + { + if (h > _HEIGHT_) + { + tmpPix.resize(_MWIDTH_, 1); + p->drawTiledPixmap(xOffset, _TOFF_+tileH, width, _MHEIGHT_, *tile->pixmap(TileMiddle)); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileMiddle), 0, 0, _MWIDTH_, 1 ); + p->drawTiledPixmap(xOffset, _TOFF_, width, tileH, tmpPix); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileMiddle), 0, _MHEIGHT_-1, _MWIDTH_, 1 ); + p->drawTiledPixmap(xOffset, _TOFF_+tileH+_MHEIGHT_, width, h-_HEIGHT_-tileH, tmpPix); + } + else //tileH is negative in this case + p->drawTiledPixmap( xOffset, _TOFF_, width, h-_TBHEIGHT_, *tile->pixmap(TileMiddle), 0, -tileH); + } + + + if (position == right || position == full) + { + p->drawPixmap( w - _ROFF_, 0, *tile->pixmap( TileTopRight ) ); + p->drawPixmap( w - _ROFF_, h - _BOFF_, *tile->pixmap( TileBtmRight ) ); + } + + } + else // split combo... + { + if ( w > _LRWIDTH_ ) + { + p->drawTiledPixmap( xOffset, 0, width-(24-_ROFF_), _TOFF_, *tile->pixmap( TileTop ) ); + p->drawTiledPixmap( xOffset, h - _BOFF_, width-(24-_ROFF_), _BOFF_, *tile->pixmap( TileBtm ) ); + } + if ( h > _TBHEIGHT_) + { + tileH = (int)((h-_HEIGHT_)/2); + if (position == left || position == full) + { + if (h > _HEIGHT_) + { + tmpPix.resize(_LOFF_, 1); + p->drawPixmap(0, _TOFF_+tileH, *tile->pixmap( TileLeft )); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileLeft), 0, 0, _LOFF_, 1 ); + p->drawTiledPixmap(0, _TOFF_, _LOFF_, tileH, tmpPix); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileLeft), 0, _MHEIGHT_-1, _LOFF_, 1 ); + p->drawTiledPixmap(0, _TOFF_+tileH+_MHEIGHT_, _LOFF_, h-_HEIGHT_-tileH, tmpPix); + } + else //tileH is negative in this case + p->drawPixmap( 0, _TOFF_, *tile->pixmap( TileLeft ), 0, -tileH, _LOFF_, _MHEIGHT_+2*tileH+1); + } + } + if ( w > _LRWIDTH_ && h > _TBHEIGHT_ ) + { + if (h > _HEIGHT_) + { + tmpPix.resize(_MWIDTH_, 1); + p->drawTiledPixmap(xOffset, _TOFF_+tileH, width-(24-_ROFF_), _MHEIGHT_, *tile->pixmap(TileMiddle)); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileMiddle), 0, 0, _MWIDTH_, 1 ); + p->drawTiledPixmap(xOffset, _TOFF_, width-(24-_ROFF_), tileH, tmpPix); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileMiddle), 0, _MHEIGHT_-1, _MWIDTH_, 1 ); + p->drawTiledPixmap(xOffset, _TOFF_+tileH+_MHEIGHT_, width-(24-_ROFF_), h-_HEIGHT_-tileH, tmpPix); + } + else //tileH is negative in this case + p->drawTiledPixmap( xOffset, _TOFF_, width-(24-_ROFF_), h-_TBHEIGHT_, *tile->pixmap(TileMiddle), 0, -tileH); + } + + // second part of combos if needed + tile = rectBtnDict.find( c.rgb() ); + if ( !tile ) + tile = createButtonTile( c, cg.background(), ptr->rectbutton, ((QImage*)0L), ((QImage*)0L), &(ptr->rectBtnDict), (QIntDict<ButtonTile>*)0L, (QIntDict<ButtonTile>*)0L, 33, 25, 10, 5, 13, 15, 0, 0, sunken); + if ( !tile ) + { + qWarning( "Button tile is NULL!" ); + return ; + } + + if ( w > _LRWIDTH_ ) + { + p->drawTiledPixmap( w-24, 0, cw, _TOFF_, *tile->pixmap( TileTop ) ); + p->drawTiledPixmap( w-24, h - _BOFF_, cw, _BOFF_, *tile->pixmap( TileBtm ) ); + } + + tileH = (int)((h-_HEIGHT_)/2); + if (position == right || position == full) + { + if (h > _HEIGHT_) + { + tileH = (int)((h-_HEIGHT_)/2); + tmpPix.resize(_ROFF_, 1); + p->drawPixmap(w-_ROFF_, _TOFF_+tileH, *tile->pixmap( TileRight )); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileRight), 0, 0, _ROFF_, 1 ); + p->drawTiledPixmap(w-_ROFF_, _TOFF_, _ROFF_, tileH, tmpPix); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileRight), 0, _MHEIGHT_-1, _ROFF_, 1 ); + p->drawTiledPixmap(w-_ROFF_, _TOFF_+tileH+_MHEIGHT_, _ROFF_, h-_HEIGHT_-tileH, tmpPix); + } + else if ( h > _TBHEIGHT_)//tileH is negative in this case + { + tileH = (int)((h-_HEIGHT_)/2); + p->drawPixmap( w-_ROFF_, _TOFF_, *tile->pixmap( TileRight ), 0, -tileH, _ROFF_, _MHEIGHT_+2*tileH+1); + } + p->drawPixmap( w - _ROFF_, 0, *tile->pixmap( TileTopRight ) ); + p->drawPixmap( w - _ROFF_, h - _BOFF_, *tile->pixmap( TileBtmRight ) ); + } + + if ( w > _LRWIDTH_ && h > _TBHEIGHT_ ) + { + if (h > _HEIGHT_) + { + tmpPix.resize(_MWIDTH_, 1); + p->drawTiledPixmap(w-24, _TOFF_+tileH, cw, _MHEIGHT_, *tile->pixmap(TileMiddle)); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileMiddle), 0, 0, _MWIDTH_, 1 ); + p->drawTiledPixmap(w-24, _TOFF_, cw, tileH, tmpPix); + copyBlt( &tmpPix, 0, 0, tile->pixmap(TileMiddle), 0, _MHEIGHT_-1, _MWIDTH_, 1 ); + p->drawTiledPixmap(w-24, _TOFF_+tileH+_MHEIGHT_, cw, h-_HEIGHT_-tileH, tmpPix); + } + else //tileH is negative in this case + p->drawTiledPixmap( w-24, _TOFF_, cw, h-_TBHEIGHT_, *tile->pixmap(TileMiddle), 0, -tileH); + } + } + if (position == center) + { + p->setPen(c.dark(130)); + if (sunken || hover) p->drawLine(0,1,0,h-2); + p->drawLine(w-1,2,w-1,h-2); + } + else if (position == left) + { + p->setPen(c.dark(130)); + p->drawLine(w-1,2,w-1,h-2); + } + else if (position == right && (sunken || hover)) + { + p->setPen(c.dark(130)); + p->drawLine(0,2,0,h-2); + } + if (isCombo) + { + p->setPen(c); + p->drawLine(w-24,2,w-24,h-2); + + int ax = w - 15; + int ay = h/3 - 1; + + p->setPen(cg.text()); + p->setBrush( cg.text() ); + p->drawPixmap(ax, ay-1, *sbUp, 1, 0, 5, 4); + p->drawPixmap(ax, ay+6, *sbDown, 1, 2, 5, 4); + } + if (!isHTML) + { + p->end(); + delete p; + painter->drawPixmap( x, y, *tmpBtnPix, 0, 0, w, h ); + } + else + p->setPen(oldPen); +#undef _HEIGHT_ +#undef _WIDTH_ +} + + +void LiquidStyle::drawCombo( QPainter *painter, + const QColorGroup &cg, + const QColor &c, + int x, int y, int w, int h, + bool sunken, bool hover, bool isCombo, + int position, bool isHTML ) const +{ + + LiquidStyle *ptr = const_cast<LiquidStyle*>( this ); + + QColor myC =(isOOO && isCombo)?optionHandler->CustomButtonColor():c; + QColor tmpColor = isCombo && !(hover || sunken) ? optionHandler->InactiveButtonColor() : myC; + + ButtonTile *tile = sunken ? comboDict.find( tmpColor.rgb() ) : comboShadowedDict.find( tmpColor.rgb() ); + if ( !tile ) + { + if (optionHandler->buttonStyle() == Milk && sunken) + tile = createButtonTile( tmpColor, cg.background(), ptr->btnBorderImg, ptr->comboShadow, ((QImage*)0L), &(ptr->comboDict), &(ptr->comboShadowedDict), (QIntDict<ButtonTile>*)0L, 44, 21, 7, 9, 30, 1, 2, 0, true); + else + tile = createButtonTile( tmpColor, cg.background(), ptr->combo, ptr->comboShadow, ((QImage*)0L), &(ptr->comboDict), &(ptr->comboShadowedDict), (QIntDict<ButtonTile>*)0L, 44, 21, 7, 9, 30, 1, 2, 0, sunken); + } + + if ( !tile ) + { + qWarning( "Button tile is NULL!" ); + return ; + } + + int xOffset, width, cw; + + switch (position) + { + case full: + xOffset = _LOFF_; + width = w - _LRWIDTH_; + cw = 24 - _ROFF_; + break; + case left: + xOffset = _LOFF_; + width = w - _LOFF_; + cw = 24; + break; + case center: + xOffset = 0; + width = w; + cw = 24; + break; + case right: + xOffset = 0; + width = w - _ROFF_; + cw = 24 - _ROFF_; + break; + } + + QPainter *p; + QPen oldPen = painter->pen(); + if (!isHTML) + { + if ( !tmpBtnPix ) + ptr->tmpBtnPix = new QPixmap( w, h ); + else if ( w > tmpBtnPix->width() || h > tmpBtnPix->height() ) + { + // make temp pixmap size == largest button + ptr->tmpBtnPix->resize(w,h); + } + p = new QPainter(tmpBtnPix); + +#if 0 + QPixmap *stipple = cg.brush( QColorGroup::Background ).pixmap(); + if ( !stipple ) // button may have custom colorgroup + stipple = qApp->palette().active().brush( QColorGroup::Background ).pixmap(); + if ( stipple ) + p->drawTiledPixmap( 0, 0, w, h, *stipple); + else + p->fillRect( 0, 0, w, h, cg.background() ); +#endif + if (position != center && paintWidget && paintWidget->parentWidget()) + { + if (this->paintWidget->parentWidget()->paletteBackgroundPixmap ()) + p->drawTiledPixmap(QRect(0, 0, w, h), *this->paintWidget->parentWidget()->paletteBackgroundPixmap(), ((QWidget *)this->paintWidget)->backgroundOffset()); + else + p->fillRect( 0, 0, w, h, this->paintWidget->parentWidget()->paletteBackgroundColor()); + } + else + p->fillRect( 0, 0, w, h, cg.background() ); + } + else + { + p = painter; + } + + if (position == left || position == full) + { + p->drawPixmap( 0, 0, *tile->pixmap( TileTopLeft ) ); + p->drawPixmap( 0, h - _BOFF_, *tile->pixmap( TileBtmLeft ) ); + } + + if (!isCombo || hover || sunken) + { + if ( w > _LRWIDTH_ ) + { + p->drawTiledPixmap( xOffset, 0, width, _TOFF_, *tile->pixmap( TileTop ) ); + p->drawTiledPixmap( xOffset, h - _BOFF_, width, _BOFF_, *tile->pixmap( TileBtm ) ); + } + if ( h > _TBHEIGHT_ ) + { + if (position == left || position == full) + p->drawTiledPixmap( 0, _TOFF_, _LOFF_, h - _TBHEIGHT_, *tile->pixmap( TileLeft ) ); + if (position == right || position == full) + p->drawTiledPixmap( w - _ROFF_, _TOFF_, _ROFF_, h - _TBHEIGHT_, *tile->pixmap( TileRight ) ); + } + if ( w > _LRWIDTH_ && h > _TBHEIGHT_ ) + p->drawTiledPixmap( xOffset, _TOFF_, width, h - _TBHEIGHT_, *tile->pixmap( TileMiddle ) ); + if (position == right || position == full) + { + p->drawPixmap( w - _ROFF_, 0, *tile->pixmap( TileTopRight ) ); + p->drawPixmap( w - _ROFF_, h - _BOFF_, *tile->pixmap( TileBtmRight ) ); + } + } + else // split combo... + { + if ( w > _LRWIDTH_ ) + { + p->drawTiledPixmap( xOffset, 0, width-(24 - _ROFF_), _TOFF_, *tile->pixmap( TileTop ) ); + p->drawTiledPixmap( xOffset, h - _BOFF_, width-(24 - _ROFF_), _BOFF_, *tile->pixmap( TileBtm ) ); + } + if ( h > _TBHEIGHT_ && (position == left || position == full)) + p->drawTiledPixmap( 0, _TOFF_, _LOFF_, h - _TBHEIGHT_, *tile->pixmap( TileLeft ) ); + if ( w > _LRWIDTH_ && h > _TBHEIGHT_ ) + p->drawTiledPixmap( xOffset, _TOFF_, width-(24 - _ROFF_), h - _TBHEIGHT_, *tile->pixmap( TileMiddle ) ); + + // second part of combos if needed + tile = comboShadowedDict.find( myC.rgb() ); + if ( !tile ) + { + tile = createButtonTile( myC, cg.background(), ptr->combo, ptr->comboShadow, ((QImage*)0L), &(ptr->comboDict), &(ptr->comboShadowedDict), (QIntDict<ButtonTile>*)0L, 44, 21, 7, 9, 30, 1, 2, 0, sunken); + } + if ( !tile ) + { + qWarning( "Button tile is NULL!" ); + return ; + } + if ( w > _LRWIDTH_ ) + { + p->drawTiledPixmap( w-24, 0, cw, _TOFF_, *tile->pixmap( TileTop ) ); + p->drawTiledPixmap( w-24, h - _BOFF_, cw, _BOFF_, *tile->pixmap( TileBtm ) ); + } + if ( h > _TBHEIGHT_ ) + p->drawTiledPixmap( w - _ROFF_, _TOFF_, _ROFF_, h - _TBHEIGHT_, *tile->pixmap( TileRight ) ); + if ( w > _LRWIDTH_ && h > _TBHEIGHT_ ) + p->drawTiledPixmap( w-24, _TOFF_, cw, h - _TBHEIGHT_, *tile->pixmap( TileMiddle ) ); + if (position == right || position == full) + { + p->drawPixmap( w - _ROFF_, 0, *tile->pixmap( TileTopRight ) ); + p->drawPixmap( w - _ROFF_, h - _BOFF_, *tile->pixmap( TileBtmRight ) ); + } + } + + switch (position) + { + case left: + p->setPen(optionHandler->InactiveButtonColor().dark(130)); + p->drawLine(w-1,3,w-1,h-6); + break; + case center: + p->setPen(optionHandler->InactiveButtonColor().dark(130)); + if (sunken || hover) p->drawLine(0,3,0,h-6); + p->drawLine(w-1,3,w-1,h-6); + break; + case right: + if (sunken || hover) + { + p->setPen(optionHandler->InactiveButtonColor().dark(130)); + p->drawLine(0,3,0,h-6); + } + break; + default: + break; + } + + if (isCombo) + { + p->setPen(c); + p->drawLine(w-24,1,w-24,h-4); + + int ax = w - 15; + int ay = h/3 - 1; + + p->setPen(cg.text()); + p->setBrush( cg.text() ); + p->drawPixmap(ax, ay-1, *sbUp, 1, 0, 5, 4); + p->drawPixmap(ax, ay+6, *sbDown, 1, 2, 5, 4); + } + + if (!isHTML) + { + p->end(); + delete p; + painter->drawPixmap( x, y, *tmpBtnPix, 0, 0, w, h ); + } + else + p->setPen(oldPen); +} + +void LiquidStyle::drawRoundFrame( QPainter *p, const QRect &r, + const QColorGroup &cg, bool focused, QPoint offset ) const +{ + ButtonTile *tile = focused ? activeRoundFrame : inactiveRoundFrame; + if (!tile) tile = createRoundFrameTile(*roundFrame, focused ? cg.button() : optionHandler->InactiveButtonColor(), &cg.background(), cg.base() ); + + // first: fill background (tiled) + // outer + QPixmap *stipple = cg.brush( QColorGroup::Background ).pixmap(); + if (stipple) + { + p->drawTiledPixmap( r.x(),r.y(), 7, 8, *stipple, offset.x(), offset.y()); + p->drawTiledPixmap( r.right() - 7, r.y(), 8, 8, *stipple, offset.x()+r.width()-6, offset.y()); + p->drawTiledPixmap( r.x(), r.bottom()-7, 8, 8, *stipple, offset.x(), offset.y() + r.height()-6); + p->drawTiledPixmap( r.right() - 7, r.bottom()-7, 8, 8, *stipple, offset.x() + r.width() - 6, offset.y() + r.height()-6); + } + else + { + p->fillRect(r.x(),r.y(), 7, 8, cg.background()); + p->fillRect(r.right() - 7, r.y(), 8, 8, cg.background()); + p->fillRect(r.x(), r.bottom()-7, 8, 8, cg.background()); + p->fillRect(r.right() - 7, r.bottom()-7, 8, 8, cg.background()); + } + // inner + p->fillRect(r.x()+3,r.y()+4,r.width()-6,r.height()-7,cg.base()); + + // now draw frame + p->drawPixmap(0,0, *tile->pixmap( TileTopLeft )); + p->drawPixmap(r.right()-10,0, *tile->pixmap( TileTopRight )); + p->drawPixmap(0,r.bottom()-10, *tile->pixmap( TileBtmLeft )); + p->drawPixmap(r.right()-10,r.bottom()-10, *tile->pixmap( TileBtmRight )); + if (r.width() > 22) + { + p->drawTiledPixmap(11,0,r.width()-22,10, *tile->pixmap( TileTop )); + p->drawTiledPixmap(11,r.bottom()-10,r.width()-22,11, *tile->pixmap( TileBtm )); + } + if (r.height() > 21) + { + p->drawTiledPixmap(0,10,11,r.height()-21, *tile->pixmap( TileLeft )); + p->drawTiledPixmap(r.right()-10,10,11,r.height()-21, *tile->pixmap( TileRight )); + } + if (focused) + { + p->setPen(cg.button()); + p->drawLine(r.x()+8,r.bottom()-1,r.right()-8,r.bottom()-1); + } +} + +void LiquidStyle::drawEditFrame( QPainter *p, const QRect &r, + const QColorGroup &cg, bool isHTML, bool focused, bool inverse ) const +{ + QColor fill( cg.background().dark( 105 ) ); + QColor tmp(0,0,0); + QColor light1( 0, 0, 0 ); + QColor light2( 0, 0, 0 ); + + QColor dark1( 0, 0, 0 ); + QColor dark2( 0, 0, 0 ); + QColor dark3( 0, 0, 0 ); + + if ( !focused ) + { + if (optionHandler->style() == Brushed) + { + light1 = cg.background().light( 140 ); + light2 = cg.background().light( 120 ); + } + else + { + light1 = cg.background().dark( 115 ); + light2 = cg.background().dark( 120 ); + } + + dark1 = cg.background().dark( 140 ); + dark2 = cg.background().dark( 160 ); + dark3 = cg.background().dark( 200 ); + } + else + { + int h,s,v; + cg.button().getHsv( &h, &s, &v ); + tmp.setHsv(h, (int)(s/1.5) ,v); + light1 = tmp; + light2 = tmp.light( 120 ); + + dark1 = tmp.dark( 110 ); + dark2 = tmp.dark( 120 ); + dark3 = tmp.dark( 140 ); + } + + int x = r.x(); + int y = inverse ? r.bottom() - 1: r.y(); + int right = r.right(); + int bottom = inverse ? r.y() + 1 : r.bottom(); + + if ( !isHTML ) + { + p->setPen( fill ); + p->drawPoint( x, y ); + p->drawPoint( x, bottom ); + p->drawPoint( right, y ); + p->drawPoint( right, bottom ); + + // outer rect + // top + p->setPen( light1 ); + p->drawPoint( x + 1, y ); + p->drawPoint( right - 1, y ); + p->drawPoint( x, y + 1 ); + p->drawPoint( right, y + 1 ); + // bottom + p->drawPoint( x, bottom - 1 ); + p->drawPoint( right, bottom - 1 ); + p->drawPoint( x + 1, bottom ); + p->drawPoint( right - 1, bottom ); + // top + focused ? p->setPen( light2 ) : p->setPen( dark1 ); + p->drawLine( x + 2, y, right - 2, y ); + // bottom, left and right + if (!focused) p->setPen( light2 ); + p->drawLine( x, y + 2, x, bottom - 2 ); + p->drawLine( right, y + 2, right, bottom - 2 ); + if (!focused) p->setPen( light1 ); + p->drawLine( x + 2, bottom, right - 2, bottom ); + } + else + { + p->setPen( light2 ); + p->drawLine( x, y, right, y ); + p->drawLine( x, y, x, bottom ); + p->setPen( dark1 ); + p->drawLine( x, bottom, right, bottom ); + p->drawLine( right, y, right, bottom ); + } + // inner rect + p->setPen( dark1 ); + p->drawPoint( x + 1, y + 1 ); + p->drawPoint( x + 1, bottom - 1 ); + p->drawPoint( right - 1, y + 1 ); + p->drawPoint( right - 1, bottom - 1 ); + p->drawLine( x + 2, bottom - 1, right - 2, bottom - 1 ); + p->setPen( dark3 ); + p->drawLine( x + 2, y + 1, right - 2, y + 1 ); + p->setPen( dark2 ); + p->drawLine( x + 1, y + 2, x + 1, bottom - 2 ); + p->drawLine( right - 1, y + 2, right - 1, bottom - 2 ); +} + +bool LiquidStyle::isHTMLWidget( const QWidget *widget ) const +{ + const QObject * w = widget->parent(); + if ( w ) + { + if ( !w->inherits( "QClipperWidget" ) ) + return ( false ); + w = w->parent(); + if ( w ) + { + w = w->parent(); + if ( w && w->inherits( "KHTMLView" ) ) + return ( true ); + } + } + return ( false ); +} + +void LiquidStyle::drawHTMLCBBorder( const QPixmap &pix, const QColor &c ) const +{ + QPainter p; + p.begin( &pix ); + p.setPen( c.dark( 200 ) ); + p.drawRect( 0, 0, 16, 16 ); + p.end(); +} |