Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

plastik.h

Go to the documentation of this file.
00001 /* Plastik widget style for KDE 3
00002    Copyright (C) 2003 Sandro Giessl <ceebx@users.sourceforge.net>
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., 59 Temple Place - Suite 330,
00036    Boston, MA 02111-1307, USA.
00037  */
00038 
00039 #ifndef __PLASTIK_H
00040 #define __PLASTIK_H
00041 
00042 //AAA-start
00043 //#include <kstyle.h>
00044 #include "kde_subset/kstyle.h"
00045 //AAA-end
00046 #include <qbitmap.h>
00047 
00048 #define u_arrow -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2
00049 #define d_arrow -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1
00050 #define l_arrow 0,-3, 0,3,-1,-2,-1,2,-2,-1,-2,1,-3,0
00051 #define r_arrow -2,-3,-2,3,-1,-2, -1,2,0,-1,0,1,1,0
00052 
00053 #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
00054 
00055 class QSettings;
00056 class PlastikStyle : public KStyle
00057 {
00058     Q_OBJECT
00059 
00060 public:
00061     PlastikStyle();
00062     virtual ~PlastikStyle();
00063 
00064     bool inheritsKHTML( const QWidget* widget ) const;
00065     void polish(QApplication* app );
00066     void polish(QWidget* widget );
00067     void unPolish(QWidget* widget );
00068 
00069     void drawKStylePrimitive(KStylePrimitive kpe,
00070                              QPainter* p,
00071                              const QWidget* widget,
00072                              const QRect &r,
00073                              const QColorGroup &cg,
00074                              SFlags flags = Style_Default,
00075                              const QStyleOption& = QStyleOption::Default ) const;
00076 
00077     void drawPrimitive(PrimitiveElement pe,
00078                        QPainter *p,
00079                        const QRect &r,
00080                        const QColorGroup &cg,
00081                        SFlags flags = Style_Default,
00082                        const QStyleOption &opt = QStyleOption::Default ) const;
00083 
00084     void drawControl(ControlElement element,
00085                      QPainter *p,
00086                      const QWidget *widget,
00087                      const QRect &r,
00088                      const QColorGroup &cg,
00089                      SFlags flags = Style_Default,
00090                      const QStyleOption& = QStyleOption::Default ) const;
00091 
00092     void drawControlMask( ControlElement, QPainter *, const QWidget *, const QRect &, const QStyleOption &) const;
00093 
00094     void drawComplexControl(ComplexControl control,
00095                             QPainter *p,
00096                             const QWidget *widget,
00097                             const QRect &r,
00098                             const QColorGroup &cg,
00099                             SFlags flags = Style_Default,
00100                             SCFlags controls = SC_All,
00101                             SCFlags active = SC_None,
00102                             const QStyleOption& = QStyleOption::Default ) const;
00103 
00104     int pixelMetric(PixelMetric m,
00105                     const QWidget *widget = 0 ) const;
00106 
00107     QRect subRect(SubRect r,
00108                   const QWidget *widget ) const;
00109 
00110     QRect querySubControlMetrics(ComplexControl control,
00111                                  const QWidget *widget,
00112                                  SubControl subcontrol,
00113                                  const QStyleOption &opt = QStyleOption::Default ) const;
00114 
00115     void drawComplexControlMask(QStyle::ComplexControl c,
00116                                 QPainter *p,
00117                                 const QWidget *w,
00118                                 const QRect &r,
00119                                 const QStyleOption &o=QStyleOption::Default) const;
00120 
00121     QSize sizeFromContents(QStyle::ContentsType t,
00122                            const QWidget *w,
00123                            const QSize &s,
00124                            const QStyleOption &o) const;
00125 
00126 protected:
00127     enum TabPosition
00128     {
00129         First = 0,
00130         Middle,
00131         Last,
00132         Single // only one tab!
00133     };
00134 
00135     enum ColorType
00136     {
00137         ButtonContour,
00138         ButtonSurface,
00139         PanelContour,
00140         PanelLight,
00141         PanelLight2,
00142         PanelDark,
00143         PanelDark2
00144     };
00145 
00146     // the only way i see to provide all these options
00147     // to renderContour/renderSurface...
00148     enum SurfaceFlags {
00149         Draw_Left =          0x00000001,
00150         Draw_Right =         0x00000002,
00151         Draw_Top =           0x00000004,
00152         Draw_Bottom =        0x00000008,
00153         Highlight_Left =     0x00000010, // surface
00154         Highlight_Right =    0x00000020, // surface
00155         Highlight_Top =      0x00000040, // surface
00156         Highlight_Bottom =   0x00000080, // surface
00157         Is_Sunken =          0x00000100, // surface
00158         Is_Horizontal =      0x00000200, // surface
00159         Is_Highlight =       0x00000400, // surface
00160         Is_Default =         0x00000800, // surface
00161         Is_Disabled =        0x00001000,
00162         Round_UpperLeft =    0x00002000,
00163         Round_UpperRight =   0x00004000,
00164         Round_BottomLeft =   0x00008000,
00165         Round_BottomRight =  0x00010000
00166     };
00167 
00168     void renderContour(QPainter *p,
00169                        const QRect &r,
00170                        const QColor &backgroundColor,
00171                        const QColor &contourColor,
00172                        const uint flags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|
00173                                Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight) const;
00174 
00175     void renderMask(QPainter *p,
00176                     const QRect &r,
00177                     const QColor &color,
00178                     const uint flags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|
00179                             Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight) const;
00180 
00181     void renderSurface(QPainter *p,
00182                         const QRect &r,
00183                         const QColor &backgroundColor,
00184                         const QColor &buttonColor,
00185                         const QColor &highlightColor,
00186                         int intensity = 5,
00187                         const uint flags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|
00188                                 Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight|
00189                                 Is_Horizontal) const;
00190 
00191     void renderButton(QPainter *p,
00192                       const QRect &r,
00193                       const QColorGroup &g,
00194                       bool sunken = false,
00195                       bool mouseOver = false,
00196                       bool horizontal = true,
00197                       bool enabled = true) const;
00198 
00199     void renderHeader(QPainter *p,
00200                       const QRect &r,
00201                       const QColorGroup &g,
00202                       bool sunken = false,
00203                       bool mouseOver = false,
00204                       bool horizontal = true,
00205                       bool enabled = true) const;
00206 
00207     void renderPanel(QPainter *p,
00208                      const QRect &r,
00209                      const QColorGroup &g,
00210                      const bool pseudo3d = true,
00211                      const bool sunken = true,
00212                      const bool thick = false) const;
00213 
00214     void renderSliderHandle(QPainter *p,
00215                             const QRect &r,
00216                             const QColorGroup &g,
00217                             const bool mouseOver,
00218                             const bool horizontal = true,
00219                             const bool enabled = true) const;
00220 
00221     void renderDot(QPainter *p,
00222                    const QPoint &point,
00223                    const QColor &baseColor,
00224                    const bool thick = false,
00225                    const bool sunken = false) const;
00226 
00227 
00228     void renderTab(QPainter *p,
00229                    const QRect &r,
00230                    const QColorGroup &g,
00231                    bool mouseOver = false,
00232                    const bool selected = false,
00233                    const bool bottom = false,
00234                    const TabPosition pos = Middle,
00235                    const bool triangular = false) const;
00236 
00237 
00238     bool eventFilter(QObject *, QEvent *);
00239 
00240 //     void updatePalette( QComboBox * );
00241 //     void updatePalette( QToolBar * );
00242 //     void updatePalette( QMenuBar * );
00243 
00244     QWidget* hoverWidget;
00245 protected slots:
00246     QColor getColor(const QColorGroup &cg, const ColorType t, const bool enabled=true)const;
00247 //     void slotDestroyed();
00248 //     void paletteChanged();
00249 
00250 private:
00251 // Disable copy constructor and = operator
00252     PlastikStyle( const PlastikStyle & );
00253     PlastikStyle& operator=( const PlastikStyle & );
00254     QSettings *settings;
00255 
00256     bool kickerMode, kornMode, reverseLayout;
00257 
00258     int _contrast;
00259     bool _scrollBarLines;
00260 
00261     QValueList<QWidget*> m_widgets;
00262 };
00263 
00264 #endif // __PLASTIK_H

Generated on Fri Feb 27 12:01:39 2004 for Glitch by doxygen 1.3.2