Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / runtime / kstyles / oxygen / oxygen.h
blob67e6a8fdbda797aced125b315bada26d19ec4199
1 /* Oxygen widget style for KDE 4
2 Copyright (C) 2003-2005 Sandro Giessl <sandro@giessl.com>
4 based on the KDE style "dotNET":
5 Copyright (C) 2001-2002, Chris Lee <clee@kde.org>
6 Carsten Pfeiffer <pfeiffer@kde.org>
7 Karol Szwed <gallium@kde.org>
8 Drawing routines completely reimplemented from KDE3 HighColor, which was
9 originally based on some stuff from the KDE2 HighColor.
11 based on drawing routines of the style "Keramik":
12 Copyright (c) 2002 Malte Starostik <malte@kde.org>
13 (c) 2002,2003 Maksim Orlovich <mo002j@mail.rochester.edu>
14 based on the KDE3 HighColor Style
15 Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org>
16 (C) 2001-2002 Fredrik Höglund <fredrik@kde.org>
17 Drawing routines adapted from the KDE2 HCStyle,
18 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
19 (C) 2000 Dirk Mueller <mueller@kde.org>
20 (C) 2001 Martijn Klingens <klingens@kde.org>
21 Progressbar code based on KStyle,
22 Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org>
24 This library is free software; you can redistribute it and/or
25 modify it under the terms of the GNU Library General Public
26 License version 2 as published by the Free Software Foundation.
28 This library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Library General Public License for more details.
33 You should have received a copy of the GNU Library General Public License
34 along with this library; see the file COPYING.LIB. If not, write to
35 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 Boston, MA 02110-1301, USA.
39 #ifndef __OXYGEN_H
40 #define __OXYGEN_H
42 #include <KStyle>
43 #include <KColorScheme>
44 #include <KSharedConfig>
46 #include <QtGui/QBitmap>
47 #include <QtGui/QStyleOption>
48 #include <QTabBar>
50 #include "helper.h"
51 #include "tileset.h"
53 #define u_arrow -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2
54 #define d_arrow -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1
55 #define l_arrow 0,-3, 0,3,-1,-2,-1,2,-2,-1,-2,1,-3,0
56 #define r_arrow -2,-3,-2,3,-1,-2, -1,2,0,-1,0,1,1,0
58 #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
60 class QTimer;
62 class OWidget : public QWidget
64 friend class OxygenStyle;
65 public:
66 OWidget(QWidget *parent) : QWidget(parent) {}
70 class OxygenStyle : public KStyle
72 Q_OBJECT
74 public:
75 OxygenStyle();
76 virtual ~OxygenStyle();
78 virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *widget) const;
79 virtual void drawComplexControl(ComplexControl control,const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
81 virtual void drawKStylePrimitive(WidgetType widgetType, int primitive,
82 const QStyleOption* opt,
83 const QRect &r, const QPalette &pal, State flags,
84 QPainter* p,
85 const QWidget* widget = 0,
86 Option* kOpt = 0) const;
88 virtual QRect subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const;
90 virtual void polish(QWidget* widget);
91 virtual void unpolish(QWidget* widget);
93 virtual int styleHint(StyleHint hint, const QStyleOption * option = 0,
94 const QWidget * widget = 0, QStyleHintReturn * returnData = 0) const;
95 virtual int pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *widget) const;
96 virtual QRect subControlRect(ComplexControl control, const QStyleOptionComplex* option,
97 SubControl subControl, const QWidget* widget) const;
98 virtual QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget) const;
99 public:
100 enum StyleOption
102 Sunken = 0x1,
103 Focus = 0x2,
104 Hover = 0x4,
105 Disabled = 0x8,
106 NoFill = 0x10
108 Q_DECLARE_FLAGS(StyleOptions, StyleOption)
110 protected:
111 enum TabPosition
113 First = 0,
114 Middle,
115 Last,
116 Single // only one tab!
119 enum ColorType
121 ButtonContour,
122 DragButtonContour,
123 DragButtonSurface,
124 PanelContour,
125 PanelLight,
126 PanelLight2,
127 PanelDark,
128 PanelDark2,
129 MouseOverHighlight,
130 FocusHighlight,
131 CheckMark
134 void renderSlab(QPainter*, const QRect&, const QColor&, StyleOptions = 0,
135 TileSet::Tiles tiles = TileSet::Ring) const;
137 void renderHole(QPainter *p, const QColor&, const QRect &r,
138 bool focus=false, bool hover=false,
139 TileSet::Tiles posFlags = TileSet::Ring) const;
141 void renderCheckBox(QPainter *p, const QRect &r, const QPalette &pal,
142 bool enabled, bool hasFocus, bool mouseOver,
143 int checkPrimitive, bool sunken=false) const;
144 void renderRadioButton(QPainter *p, const QRect &r, const QPalette &pal,
145 bool enabled, bool mouseOver, int radioPrimitive,
146 bool drawButton=true) const;
148 void renderDot(QPainter *p, const QPointF &point, const QColor &baseColor) const;
150 void renderTab(QPainter *p,
151 const QRect &r,
152 const QPalette &pal,
153 bool mouseOver,
154 const bool selected,
155 const QStyleOptionTabV2 *tabOpt,
156 const bool reverseLayout) const;
158 void renderWindowBackground(QPainter *p, const QRect &clipRect, const QWidget *widget) const;
160 bool eventFilter(QObject *, QEvent *);
162 protected Q_SLOTS:
163 virtual QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
164 //Animation slots.
165 void updateProgressPos();
166 void progressBarDestroyed(QObject* bar);
167 //For KGlobalSettings notifications
168 void globalSettingsChange(int type, int arg);
170 private:
171 mutable bool flatMode;
173 bool _animateProgressBar;
174 bool _drawToolBarItemSeparator;
175 bool _drawTriangularExpander;
176 bool _checkCheck;
177 enum {
178 MM_DARK = 0,
179 MM_SUBTLE = 1,
180 MM_STRONG = 2
181 } _menuHighlightMode;
183 // global colors
184 OxygenStyleHelper &_helper;
185 KSharedConfigPtr _config;
186 KStatefulBrush _viewFocusBrush;
187 KStatefulBrush _viewHoverBrush;
189 //Animation support.
190 QMap<QWidget*, int> progAnimWidgets;
191 // For progress bar animation
192 QTimer *animationTimer;
194 TileSet *m_holeTileSet;
197 Q_DECLARE_OPERATORS_FOR_FLAGS(OxygenStyle::StyleOptions)
199 #endif // __OXYGEN_H
201 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;