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