KStyles
helper.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __OXYGEN_HELPER_H
00023 #define __OXYGEN_HELPER_H
00024
00025 #include <ksharedconfig.h>
00026 #include <kcomponentdata.h>
00027
00028 #include <QtGui/QColor>
00029 #include <QtGui/QPixmap>
00030 #include <QtGui/QLinearGradient>
00031 #include <QtCore/QCache>
00032
00033 #define _glowBias 0.9 // not likely to be configurable
00034
00035
00036 class OxygenHelper
00037 {
00038 public:
00039 explicit OxygenHelper(const QByteArray &componentName);
00040 virtual ~OxygenHelper() {}
00041
00042 KSharedConfigPtr config() const;
00043 void reloadConfig();
00044
00045 void renderWindowBackground(QPainter *p, const QRect &clipRect, const QWidget *widget, const QPalette & pal, int y_shift=-23 );
00046 virtual void invalidateCaches();
00047
00048 static bool lowThreshold(const QColor &color);
00049
00050 static QColor alphaColor(QColor color, double alpha);
00051
00052 QColor calcLightColor(const QColor &color) const;
00053 QColor calcDarkColor(const QColor &color) const;
00054 QColor calcShadowColor(const QColor &color) const;
00055
00056 QColor backgroundColor(const QColor &color, int height, int y);
00057
00058 QColor backgroundRadialColor(const QColor &color) const;
00059 QColor backgroundTopColor(const QColor &color) const;
00060 QColor backgroundBottomColor(const QColor &color) const;
00061
00062 QPixmap verticalGradient(const QColor &color, int height);
00063 QPixmap radialGradient(const QColor &color, int width);
00064
00065 QLinearGradient decoGradient(const QRect &r, const QColor &color);
00066
00067 QPixmap windecoButton(const QColor &color, bool pressed, int size = 21);
00068 QPixmap windecoButtonGlow(const QColor &color, int size = 21);
00069
00070 void drawFloatFrame(QPainter *p, const QRect r, const QColor &color, bool drawUglyShadow=true, bool isActive=false, const QColor &frameColor=QColor()) const;
00071
00072 void drawSeparator(QPainter *p, const QRect &r, const QColor &color, Qt::Orientation orientation) const;
00073
00074 protected:
00075 void drawShadow(QPainter&, const QColor&, int size) const;
00076 static QPixmap glow(const QColor&, int size, int rsize);
00077
00078 static const double _shadowGain;
00079
00080 KComponentData _componentData;
00081 KSharedConfigPtr _config;
00082 qreal _contrast;
00083 qreal _bgcontrast;
00084
00085 QCache<quint64, QPixmap> m_backgroundCache;
00086 QCache<quint64, QPixmap> m_windecoButtonCache;
00087 QCache<quint64, QPixmap> m_windecoButtonGlowCache;
00088 };
00089
00090 #endif // __OXYGEN_HELPER_H