• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KStyles

oxygen.h

Go to the documentation of this file.
00001 /* Oxygen widget style for KDE 4
00002    Copyright (C) 2003-2005 Sandro Giessl <sandro@giessl.com>
00003 
00004    based on the KDE style "dotNET":
00005    Copyright (C) 2001-2002, Chris Lee <clee@kde.org>
00006                             Carsten Pfeiffer <pfeiffer@kde.org>
00007                             Karol Szwed <gallium@kde.org>
00008    Drawing routines completely reimplemented from KDE3 HighColor, which was
00009    originally based on some stuff from the KDE2 HighColor.
00010 
00011    based on drawing routines of the style "Keramik":
00012    Copyright (c) 2002 Malte Starostik <malte@kde.org>
00013              (c) 2002,2003 Maksim Orlovich <mo002j@mail.rochester.edu>
00014    based on the KDE3 HighColor Style
00015    Copyright (C) 2001-2002 Karol Szwed      <gallium@kde.org>
00016              (C) 2001-2002 Fredrik Höglund  <fredrik@kde.org>
00017    Drawing routines adapted from the KDE2 HCStyle,
00018    Copyright (C) 2000 Daniel M. Duley       <mosfet@kde.org>
00019              (C) 2000 Dirk Mueller          <mueller@kde.org>
00020              (C) 2001 Martijn Klingens      <klingens@kde.org>
00021    Progressbar code based on KStyle,
00022    Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org>
00023 
00024    This library is free software; you can redistribute it and/or
00025    modify it under the terms of the GNU Library General Public
00026    License version 2 as published by the Free Software Foundation.
00027 
00028    This library is distributed in the hope that it will be useful,
00029    but WITHOUT ANY WARRANTY; without even the implied warranty of
00030    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00031    Library General Public License for more details.
00032 
00033    You should have received a copy of the GNU Library General Public License
00034    along with this library; see the file COPYING.LIB.  If not, write to
00035    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00036    Boston, MA 02110-1301, USA.
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 // only one tab!
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     //Animation slots.
00172     void updateProgressPos();
00173     void progressBarDestroyed(QObject* bar);
00174     //For KGlobalSettings notifications
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     // global colors
00194     OxygenStyleHelper &_helper;
00195     KSharedConfigPtr _config;
00196     KStatefulBrush _viewFocusBrush;
00197     KStatefulBrush _viewHoverBrush;
00198 
00199     //Animation support.
00200     QMap<QWidget*, int> progAnimWidgets;
00201     // For progress bar animation
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 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;

KStyles

Skip menu "KStyles"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal