Back to index

kdeartwork  4.3.2
phasestyle.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00003 // phasestyle.h
00004 // -------------------
00005 // Qt widget style
00006 // -------------------
00007 // Copyright (c) 2004-2008 David Johnson <david@usermode.org>
00008 //
00009 // Permission is hereby granted, free of charge, to any person obtaining a copy
00010 // of this software and associated documentation files (the "Software"), to
00011 // deal in the Software without restriction, including without limitation the
00012 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00013 // sell copies of the Software, and to permit persons to whom the Software is
00014 // furnished to do so, subject to the following conditions:
00015 //
00016 // The above copyright notice and this permission notice shall be included in
00017 // all copies or substantial portions of the Software.
00018 //
00019 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00025 // IN THE SOFTWARE.
00027 
00028 #ifndef PHASESTYLE_H
00029 #define PHASESTYLE_H
00030 
00031 #include <QWindowsStyle>
00032 
00033 class QStyleOptionTab;
00034 class QProgressBar;
00035 
00036 class PhaseStyle : public QWindowsStyle
00037 {
00038     Q_OBJECT
00039 public:
00040     PhaseStyle();
00041     virtual ~PhaseStyle();
00042 
00043     void polish(QApplication* app);
00044     void polish(QWidget *widget);
00045     void polish(QPalette &pal);
00046     void unpolish(QApplication *app);
00047     void unpolish(QWidget *widget);
00048 
00049     QPalette standardPalette() const;
00050 
00051     void drawPrimitive(PrimitiveElement element,
00052             const QStyleOption *option,
00053             QPainter *painter,
00054             const QWidget *widget = 0) const;
00055 
00056     void drawControl(ControlElement element,
00057             const QStyleOption *option,
00058             QPainter *painter,
00059             const QWidget *widget = 0) const;
00060 
00061     void drawComplexControl(ComplexControl control,
00062             const QStyleOptionComplex *option,
00063             QPainter *painter,
00064             const QWidget *widget = 0) const;
00065 
00066     QPixmap standardPixmap(StandardPixmap pixmap,
00067             const QStyleOption *option,
00068             const QWidget *widget) const;
00069 
00070     int pixelMetric(PixelMetric metric,
00071             const QStyleOption *option = 0,
00072             const QWidget *widget = 0) const;
00073 
00074     QRect subElementRect(SubElement element,
00075             const QStyleOption *option,
00076             const QWidget *widget) const;
00077 
00078     QRect subControlRect(ComplexControl control,
00079             const QStyleOptionComplex *option,
00080             SubControl subcontrol,
00081             const QWidget *widget = 0) const;
00082 
00083     SubControl hitTestComplexControl(ComplexControl control,
00084             const QStyleOptionComplex *option,
00085             const QPoint &position,
00086             const QWidget *widget = 0) const;
00087 
00088     int styleHint(StyleHint hint,
00089             const QStyleOption *option = 0,
00090             const QWidget *widget = 0,
00091             QStyleHintReturn *data = 0) const;
00092 
00093     QSize sizeFromContents(ContentsType contentstype,
00094             const QStyleOption *option,
00095             const QSize &contentssize,
00096             const QWidget *widget) const;
00097 
00098 private:
00099     enum GradientType {
00100         Horizontal,
00101         Vertical,
00102         HorizontalReverse,
00103         VerticalReverse,
00104         GradientCount
00105     };
00106 
00107     enum BitmapType {
00108         UArrow,
00109         DArrow,
00110         LArrow,
00111         RArrow,
00112         PlusSign,
00113         MinusSign,
00114         CheckMark,
00115         TitleClose,
00116         TitleMin,
00117         TitleMax,
00118         TitleNormal,
00119         TitleHelp
00120     };
00121 
00122     PhaseStyle(const PhaseStyle &);
00123     PhaseStyle& operator=(const PhaseStyle &);
00124 
00125     void drawPhaseGradient(QPainter *painter,
00126             const QRect &rect,
00127             QColor color,
00128             bool horizontal,
00129             const QSize &gsize = QSize(),
00130             bool reverse=false) const;
00131 
00132     void drawPhaseBevel(QPainter *painter,
00133             QRect rect,
00134             const QPalette &pal,
00135            const QBrush &fill,
00136             bool sunken=false,
00137             bool horizontal=true,
00138             bool reverse=false) const;
00139 
00140     void drawPhaseButton(QPainter *painter,
00141             QRect rect,
00142             const QPalette &pal,
00143            const QBrush &fill,
00144             bool sunken=false) const;
00145 
00146     void drawPhasePanel(QPainter *painter,
00147             const QRect &rect,
00148             const QPalette &pal,
00149             const QBrush &fill,
00150             bool sunken = false) const;
00151 
00152     void drawPhaseDoodads(QPainter *painter,
00153             const QRect &rect,
00154             const QPalette &pal,
00155             bool horizontal) const;
00156 
00157     void drawPhaseTab(QPainter *painter,
00158             const QPalette &pal,
00159             const QStyleOptionTab *option) const;
00160 
00161     void timerEvent(QTimerEvent *event);
00162     bool eventFilter(QObject *object, QEvent *event);
00163 
00164 private:
00165     int contrast_;
00166     bool gradients_;
00167     bool highlights_;
00168 
00169     QList<QBitmap> bitmaps_;
00170     QList<QProgressBar*> bars_; // animated progressbars
00171     int timerid_;
00172 };
00173 
00174 #endif // PHASESTYLE_H