00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef __PLASTIK_H
00040 #define __PLASTIK_H
00041
00042
00043
00044 #include "kde_subset/kstyle.h"
00045
00046 #include <qbitmap.h>
00047
00048 #define u_arrow -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2
00049 #define d_arrow -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1
00050 #define l_arrow 0,-3, 0,3,-1,-2,-1,2,-2,-1,-2,1,-3,0
00051 #define r_arrow -2,-3,-2,3,-1,-2, -1,2,0,-1,0,1,1,0
00052
00053 #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
00054
00055 class QSettings;
00056 class PlastikStyle : public KStyle
00057 {
00058 Q_OBJECT
00059
00060 public:
00061 PlastikStyle();
00062 virtual ~PlastikStyle();
00063
00064 bool inheritsKHTML( const QWidget* widget ) const;
00065 void polish(QApplication* app );
00066 void polish(QWidget* widget );
00067 void unPolish(QWidget* widget );
00068
00069 void drawKStylePrimitive(KStylePrimitive kpe,
00070 QPainter* p,
00071 const QWidget* widget,
00072 const QRect &r,
00073 const QColorGroup &cg,
00074 SFlags flags = Style_Default,
00075 const QStyleOption& = QStyleOption::Default ) const;
00076
00077 void drawPrimitive(PrimitiveElement pe,
00078 QPainter *p,
00079 const QRect &r,
00080 const QColorGroup &cg,
00081 SFlags flags = Style_Default,
00082 const QStyleOption &opt = QStyleOption::Default ) const;
00083
00084 void drawControl(ControlElement element,
00085 QPainter *p,
00086 const QWidget *widget,
00087 const QRect &r,
00088 const QColorGroup &cg,
00089 SFlags flags = Style_Default,
00090 const QStyleOption& = QStyleOption::Default ) const;
00091
00092 void drawControlMask( ControlElement, QPainter *, const QWidget *, const QRect &, const QStyleOption &) const;
00093
00094 void drawComplexControl(ComplexControl control,
00095 QPainter *p,
00096 const QWidget *widget,
00097 const QRect &r,
00098 const QColorGroup &cg,
00099 SFlags flags = Style_Default,
00100 SCFlags controls = SC_All,
00101 SCFlags active = SC_None,
00102 const QStyleOption& = QStyleOption::Default ) const;
00103
00104 int pixelMetric(PixelMetric m,
00105 const QWidget *widget = 0 ) const;
00106
00107 QRect subRect(SubRect r,
00108 const QWidget *widget ) const;
00109
00110 QRect querySubControlMetrics(ComplexControl control,
00111 const QWidget *widget,
00112 SubControl subcontrol,
00113 const QStyleOption &opt = QStyleOption::Default ) const;
00114
00115 void drawComplexControlMask(QStyle::ComplexControl c,
00116 QPainter *p,
00117 const QWidget *w,
00118 const QRect &r,
00119 const QStyleOption &o=QStyleOption::Default) const;
00120
00121 QSize sizeFromContents(QStyle::ContentsType t,
00122 const QWidget *w,
00123 const QSize &s,
00124 const QStyleOption &o) const;
00125
00126 protected:
00127 enum TabPosition
00128 {
00129 First = 0,
00130 Middle,
00131 Last,
00132 Single
00133 };
00134
00135 enum ColorType
00136 {
00137 ButtonContour,
00138 ButtonSurface,
00139 PanelContour,
00140 PanelLight,
00141 PanelLight2,
00142 PanelDark,
00143 PanelDark2
00144 };
00145
00146
00147
00148 enum SurfaceFlags {
00149 Draw_Left = 0x00000001,
00150 Draw_Right = 0x00000002,
00151 Draw_Top = 0x00000004,
00152 Draw_Bottom = 0x00000008,
00153 Highlight_Left = 0x00000010,
00154 Highlight_Right = 0x00000020,
00155 Highlight_Top = 0x00000040,
00156 Highlight_Bottom = 0x00000080,
00157 Is_Sunken = 0x00000100,
00158 Is_Horizontal = 0x00000200,
00159 Is_Highlight = 0x00000400,
00160 Is_Default = 0x00000800,
00161 Is_Disabled = 0x00001000,
00162 Round_UpperLeft = 0x00002000,
00163 Round_UpperRight = 0x00004000,
00164 Round_BottomLeft = 0x00008000,
00165 Round_BottomRight = 0x00010000
00166 };
00167
00168 void renderContour(QPainter *p,
00169 const QRect &r,
00170 const QColor &backgroundColor,
00171 const QColor &contourColor,
00172 const uint flags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|
00173 Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight) const;
00174
00175 void renderMask(QPainter *p,
00176 const QRect &r,
00177 const QColor &color,
00178 const uint flags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|
00179 Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight) const;
00180
00181 void renderSurface(QPainter *p,
00182 const QRect &r,
00183 const QColor &backgroundColor,
00184 const QColor &buttonColor,
00185 const QColor &highlightColor,
00186 int intensity = 5,
00187 const uint flags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|
00188 Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight|
00189 Is_Horizontal) const;
00190
00191 void renderButton(QPainter *p,
00192 const QRect &r,
00193 const QColorGroup &g,
00194 bool sunken = false,
00195 bool mouseOver = false,
00196 bool horizontal = true,
00197 bool enabled = true) const;
00198
00199 void renderHeader(QPainter *p,
00200 const QRect &r,
00201 const QColorGroup &g,
00202 bool sunken = false,
00203 bool mouseOver = false,
00204 bool horizontal = true,
00205 bool enabled = true) const;
00206
00207 void renderPanel(QPainter *p,
00208 const QRect &r,
00209 const QColorGroup &g,
00210 const bool pseudo3d = true,
00211 const bool sunken = true,
00212 const bool thick = false) const;
00213
00214 void renderSliderHandle(QPainter *p,
00215 const QRect &r,
00216 const QColorGroup &g,
00217 const bool mouseOver,
00218 const bool horizontal = true,
00219 const bool enabled = true) const;
00220
00221 void renderDot(QPainter *p,
00222 const QPoint &point,
00223 const QColor &baseColor,
00224 const bool thick = false,
00225 const bool sunken = false) const;
00226
00227
00228 void renderTab(QPainter *p,
00229 const QRect &r,
00230 const QColorGroup &g,
00231 bool mouseOver = false,
00232 const bool selected = false,
00233 const bool bottom = false,
00234 const TabPosition pos = Middle,
00235 const bool triangular = false) const;
00236
00237
00238 bool eventFilter(QObject *, QEvent *);
00239
00240
00241
00242
00243
00244 QWidget* hoverWidget;
00245 protected slots:
00246 QColor getColor(const QColorGroup &cg, const ColorType t, const bool enabled=true)const;
00247
00248
00249
00250 private:
00251
00252 PlastikStyle( const PlastikStyle & );
00253 PlastikStyle& operator=( const PlastikStyle & );
00254 QSettings *settings;
00255
00256 bool kickerMode, kornMode, reverseLayout;
00257
00258 int _contrast;
00259 bool _scrollBarLines;
00260
00261 QValueList<QWidget*> m_widgets;
00262 };
00263
00264 #endif // __PLASTIK_H