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