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
00040
00041
00042 #ifndef __OXYGEN_H
00043 #define __OXYGEN_H
00044
00045 #include <KStyle>
00046 #include <KColorScheme>
00047 #include <KSharedConfig>
00048
00049 #include <QtGui/QBitmap>
00050 #include <QtGui/QStyleOption>
00051 #include <QTabBar>
00052
00053 #include "helper.h"
00054 #include "tileset.h"
00055
00056 #define u_arrow -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2
00057 #define d_arrow -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1
00058 #define l_arrow 0,-3, 0,3,-1,-2,-1,2,-2,-1,-2,1,-3,0
00059 #define r_arrow -2,-3,-2,3,-1,-2, -1,2,0,-1,0,1,1,0
00060
00061 #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
00062
00063 class QTimer;
00064
00065 class OWidget : public QWidget
00066 {
00067 friend class OxygenStyle;
00068 public:
00069 OWidget(QWidget *parent) : QWidget(parent) {}
00070 };
00071
00072
00073 class OxygenStyle : public KStyle
00074 {
00075 Q_OBJECT
00076
00077 public:
00078 OxygenStyle();
00079 virtual ~OxygenStyle();
00080
00081 virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *widget) const;
00082 virtual void drawComplexControl(ComplexControl control,const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
00083
00084 virtual void drawKStylePrimitive(WidgetType widgetType, int primitive,
00085 const QStyleOption* opt,
00086 const QRect &r, const QPalette &pal, State flags,
00087 QPainter* p,
00088 const QWidget* widget = 0,
00089 Option* kOpt = 0) const;
00090
00091 virtual QRect subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const;
00092
00093 virtual void polish(QWidget* widget);
00094 virtual void unpolish(QWidget* widget);
00095 using KStyle::polish;
00096 using KStyle::unpolish;
00097
00098
00099 virtual int styleHint(StyleHint hint, const QStyleOption * option = 0,
00100 const QWidget * widget = 0, QStyleHintReturn * returnData = 0) const;
00101 virtual int pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *widget) const;
00102 virtual QRect subControlRect(ComplexControl control, const QStyleOptionComplex* option,
00103 SubControl subControl, const QWidget* widget) const;
00104 virtual QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget) const;
00105 public:
00106 enum StyleOption
00107 {
00108 Sunken = 0x1,
00109 Focus = 0x2,
00110 Hover = 0x4,
00111 Disabled = 0x8,
00112 NoFill = 0x10
00113 };
00114 Q_DECLARE_FLAGS(StyleOptions, StyleOption)
00115
00116 protected:
00117 enum TabPosition
00118 {
00119 First = 0,
00120 Middle,
00121 Last,
00122 Single
00123 };
00124
00125 enum ColorType
00126 {
00127 ButtonContour,
00128 DragButtonContour,
00129 DragButtonSurface,
00130 PanelContour,
00131 PanelLight,
00132 PanelLight2,
00133 PanelDark,
00134 PanelDark2,
00135 MouseOverHighlight,
00136 FocusHighlight,
00137 CheckMark
00138 };
00139
00140 void renderSlab(QPainter*, QRect, const QColor&, StyleOptions = 0,
00141 TileSet::Tiles tiles = TileSet::Ring) const;
00142
00143 void renderHole(QPainter *p, const QColor&, const QRect &r,
00144 bool focus=false, bool hover=false,
00145 TileSet::Tiles posFlags = TileSet::Ring) const;
00146
00147 void renderCheckBox(QPainter *p, const QRect &r, const QPalette &pal,
00148 bool enabled, bool hasFocus, bool mouseOver,
00149 int checkPrimitive, bool sunken=false) const;
00150 void renderRadioButton(QPainter *p, const QRect &r, const QPalette &pal,
00151 bool enabled, bool hasFocus, bool mouseOver,
00152 int radioPrimitive, bool drawButton=true) const;
00153
00154 void renderDot(QPainter *p, const QPointF &point, const QColor &baseColor) const;
00155
00156 void renderTab(QPainter *p,
00157 const QRect &r,
00158 const QPalette &pal,
00159 bool mouseOver,
00160 const bool selected,
00161 const QStyleOptionTabV2 *tabOpt,
00162 const bool reverseLayout) const;
00163
00164 void renderWindowIcon(QPainter *p, const QRectF &r, int &type) const;
00165
00166 void renderScrollBarHole(QPainter *p, const QRect &r, const QColor &color,
00167 Qt::Orientation orientation, TileSet::Tiles = TileSet::Full) const;
00168
00169 void renderScrollBarHandle(QPainter *p, const QRect &r, const QPalette &pal,
00170 Qt::Orientation orientation, bool hover) const;
00171
00172 bool eventFilter(QObject *, QEvent *);
00173
00174 protected Q_SLOTS:
00175 virtual QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
00176
00177 void updateProgressPos();
00178 void progressBarDestroyed(QObject* bar);
00179
00180 void globalSettingsChange(int type, int arg);
00181
00182 private:
00183 QPoint handleRTL(const QStyleOption* opt, const QPoint& pos) const;
00184 QRect handleRTL(const QStyleOption* opt, const QRect& subRect) const;
00185
00186 bool _animateProgressBar;
00187 bool _drawToolBarItemSeparator;
00188 bool _drawTriangularExpander;
00189 bool _checkCheck;
00190 enum {
00191 MM_DARK = 0,
00192 MM_SUBTLE = 1,
00193 MM_STRONG = 2
00194 } _menuHighlightMode;
00195
00196
00197 OxygenStyleHelper &_helper;
00198 KSharedConfigPtr _config;
00199 KStatefulBrush _viewFocusBrush;
00200 KStatefulBrush _viewHoverBrush;
00201
00202
00203 QMap<QWidget*, int> progAnimWidgets;
00204
00205 QTimer *animationTimer;
00206
00207 TileSet *m_holeTileSet;
00208 };
00209
00210 Q_DECLARE_OPERATORS_FOR_FLAGS(OxygenStyle::StyleOptions)
00211
00212 #endif // __OXYGEN_H
00213
00214