/* * Copyright (C) 2007 Gustavo Pichorim Boiko * Copyright (C) 2006 Laurent Montel * * renderGradient() code adapted from the Plastik stype * Copyright (C) 2003 Sandro Giessl * * based on KDE3 HighColor Style (version 1.0) * Copyright (C) 2001-2002 Karol Szwed * (C) 2001-2002 Fredrik Höglund * * Drawing routines adapted from the KDE2 HCStyle, * Copyright (C) 2000 Daniel M. Duley * (C) 2000 Dirk Mueller * (C) 2001 Martijn Klingens * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License version 2 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef __MANDRIVASTYLE_H #define __MANDRIVASTYLE_H #include #include #include #include #include #include class QPopupMenu; class MandrivaStyle : public KStyle { Q_OBJECT public: MandrivaStyle(); virtual ~MandrivaStyle(); void polish( QWidget* widget ); void unPolish( QWidget* widget ); void polish( QApplication *app ); void renderMenuBlendPixmap( KPixmap& pix, const QColorGroup &cg, const QPopupMenu* popup ) 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; // Fix Qt3's wacky image positions QPixmap stylePixmap( StylePixmap stylepixmap, const QWidget *widget = 0, const QStyleOption& = QStyleOption::Default ) const; QRect querySubControlMetrics( ComplexControl control, const QWidget* widget, SubControl subcontrol, const QStyleOption& opt = QStyleOption::Default ) const; protected: enum Hover { HoverNone = 0, // scrollbar HoverScrollBarSlider, HoverScrollBarAddLine, HoverScrollBarSubLine, HoverScrollBarAddPage, HoverScrollBarSubPage, HoverScrollBarFirst, HoverScrollBarLast, // combobox HoverComboBoxArrow, HoverComboBoxEdit }; bool eventFilter( QObject *object, QEvent *event ); void renderGradient(QPainter* p, const QRect& r, const QColor& ca, const QColor& cb , bool horizontal) const; QWidget *hoverWidget; enum Hover hoverControl; struct MandrivaColorData { ~MandrivaColorData(); QRgb spotColor; // gradient color //rename to grey QColor shades[7]; // five blue color QColor blueMdkColor[5]; // button gradients QColor buttonColor[7]; QColor radioColor; bool isGroup (const QColorGroup &cg) { return cg.button() == buttonColor[0] && cg.highlight().rgb() == spotColor; } }; private: enum TabPosition {Single = 0,First,Last, Middle}; // Disable copy constructor and = operator MandrivaStyle( const MandrivaStyle & ); MandrivaStyle& operator=( const MandrivaStyle & ); void drawButton( const MandrivaColorData *cdata, const QRect & r, QPainter *p, const QColorGroup &cg, SFlags flags) const; void drawHandlePoint ( const MandrivaColorData *cdata, QPainter *p, int x, int y) const; void drawHandle( const MandrivaColorData *cdata, QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags, const QStyleOption& opt, bool drawBorderAndGradient, bool drawGradient = false ) const; void drawGroupBox(const MandrivaColorData *cdata, const QColorGroup & cg, QPainter *p, const QRect & r, bool active, bool sunken )const; void drawLineSeparator(const MandrivaColorData *cdata, const QColorGroup & cg, QPainter *p, const QRect & r, bool horiziontal, bool active, bool sunken, bool skipOffset = true) const; void drawFrame( const MandrivaColorData *cdata, const QColorGroup & cg, QPainter *p, const QRect & r, bool active) const; void drawComboboxArrow( QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags, SCFlags active)const; void drawMandrivaArrow( QPointArray a, QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags, const QStyleOption& opt ) const; MandrivaColorData *realizeData (const QColorGroup &cg) const; const MandrivaColorData *lookupData (const QColorGroup &cg) const; bool isFormWidget(const QWidget* widget) const; bool excludeColor(const QColor &col, bool active) const; void getShade (const QColorGroup &cg, int shadenr, QColor &res) const; void updateHoverControl(const QPoint &pos); QIntCache m_dataCache; static const double shading[8]; mutable bool formMode; bool kickerMode; // For KPE_ListViewBranch mutable QBitmap *verticalLine; mutable QBitmap *horizontalLine; // pixmap cache. enum CacheEntryType { cSurface, cGradientTile, cAlphaDot }; struct CacheEntry { CacheEntryType type; int width; int height; QRgb c1Rgb; QRgb c2Rgb; bool horizontal; QPixmap* pixmap; CacheEntry(CacheEntryType t, int w, int h, QRgb c1, QRgb c2 = 0, bool hor = false, QPixmap* p = 0 ): type(t), width(w), height(h), c1Rgb(c1), c2Rgb(c2), horizontal(hor), pixmap(p) {} ~CacheEntry() { delete pixmap; } int key() { // create an int key from the properties which is used to refer to entries in the QIntCache. // the result may not be 100% correct as we don't have so much space in one integer -- use // == operator after find to make sure we got the right one. :) return horizontal ^ (type<<1) ^ (width<<5) ^ (height<<10) ^ (c1Rgb<<19) ^ (c2Rgb<<22); } bool operator == (const CacheEntry& other) { bool match = (type == other.type) && (width == other.width) && (height == other.height) && (c1Rgb == other.c1Rgb) && (c1Rgb == other.c1Rgb) && (horizontal == other.horizontal); return match; } }; QIntCache *pixmapCache; }; #endif // vim: ts=4 et sw=4