Eneboo - Documentación para desarrolladores
src/plugins/styles/qtcurve/qtcurve.h
Ir a la documentación de este archivo.
00001 #ifndef __QTCURVE_H__
00002 #define __QTCURVE_H__
00003 
00004 /*
00005   QtCurve (C) Craig Drummond, 2003 - 2010 craig.p.drummond@gmail.com
00006 
00007   ----
00008 
00009   Based upon B???Curve style (Copyright (c) 2002 R?d H?t, Inc)
00010       Bernhard Rosenkrazer <bero@r?dh?t.com>
00011       Preston Brown <pbrown@r?dh?t.com>
00012       Than Ngo <than@r?dh?t.com>
00013 
00014   This program is free software; you can redistribute it and/or
00015   modify it under the terms of the GNU General Public
00016   License version 2 as published by the Free Software Foundation.
00017 
00018   This program is distributed in the hope that it will be useful,
00019   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021   General Public License for more details.
00022 
00023   You should have received a copy of the GNU General Public License
00024   along with this program; see the file COPYING.  If not, write to
00025   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00026   Boston, MA 02110-1301, USA.
00027 
00028   ----
00029 
00030   B???Curve is based on the KDE Light style, 2nd revision:
00031   Copyright (c) 2000-2001 Trolltech AS (info@trolltech.com). The light style
00032   license is as follows:
00033 
00034   Permission is hereby granted, free of charge, to any person obtaining a
00035   copy of this software and associated documentation files (the "Software"),
00036   to deal in the Software without restriction, including without limitation
00037   the rights to use, copy, modify, merge, publish, distribute, sublicense,
00038   and/or sell copies of the Software, and to permit persons to whom the
00039   Software is furnished to do so, subject to the following conditions:
00040 
00041   The above copyright notice and this permission notice shall be included in
00042   all copies or substantial portions of the Software.
00043 
00044   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00045   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00046   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00047   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00048   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00049   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00050   DEALINGS IN THE SOFTWARE.
00051 */
00052 
00053 #include "config.h"
00054 #ifdef QTC_QT_ONLY
00055 #include "qtc_kstyle.h"
00056 #else
00057 #include <kdeversion.h>
00058 #include <kstyle.h>
00059 #endif
00060 #include <qcolor.h>
00061 #include <qpoint.h>
00062 #include <qpalette.h>
00063 #include <qpixmap.h>
00064 #include <qcache.h>
00065 #include <qvaluelist.h>
00066 #include "common.h"
00067 
00068 class QTimer;
00069 class QSlider;
00070 
00071 #ifdef QTC_QT_ONLY
00072 #define BASE_STYLE QtCKStyle
00073 #else
00074 #define BASE_STYLE KStyle
00075 #endif
00076 
00077 class ShortcutHandler;
00078 
00079 class QtCurveStyle : public BASE_STYLE
00080 {
00081     Q_OBJECT
00082 
00083     public:
00084 
00085     enum EApp
00086     {
00087         APP_KICKER,
00088         APP_KORN,
00089         APP_OPENOFFICE,
00090         APP_MACTOR,
00091         APP_KPRESENTER,
00092         APP_KONQUEROR,
00093         APP_SKIP_TASKBAR,
00094         APP_KPRINTER,
00095         APP_KDIALOG,
00096         APP_KDIALOGD,
00097         APP_TORA,
00098         APP_KONTACT,
00099         APP_OPERA,
00100         APP_SYSTEMSETTINGS,
00101         APP_KATE,
00102         APP_OTHER
00103     };
00104 
00105     enum EHover
00106     {
00107         HOVER_NONE,
00108         HOVER_CHECK,
00109         HOVER_RADIO,
00110         HOVER_SB_ADD,
00111         HOVER_SB_SUB,
00112         HOVER_SB_SUB2,
00113         HOVER_SB_SLIDER,
00114         HOVER_HEADER,
00115         HOVER_KICKER,
00116         HOVER_SW_UP,
00117         HOVER_SW_DOWN,
00118         HOVER_SW_ENTRY,
00119         HOVER_CB_ARROW,
00120         HOVER_CB_ENTRY
00121     };
00122 
00123     enum EntryColor
00124     {
00125         ENTRY_FOCUS,
00126         ENTRY_MOUSE_OVER,
00127         ENTRY_NONE
00128     };
00129 
00130 #ifdef QTC_STYLE_SUPPORT
00131     QtCurveStyle(const QString &name=QString());
00132 #else
00133     QtCurveStyle();
00134 #endif
00135 
00136     virtual ~QtCurveStyle();
00137 
00138     void polish(QApplication *app);
00139     void unPolish(QApplication *app);
00140     void polish(QPalette &pal);
00141     QColorGroup setColorGroup(const QColorGroup &old, const QColorGroup &act, bool dis=false);
00142     void polish(QWidget *widget);
00143     void unPolish(QWidget *widget);
00144     void drawLightBevel(QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags,
00145                         int round, const QColor &fill, const QColor *custom=NULL,
00146                         bool doBorder=true, bool doCorners=true, EWidget w=WIDGET_OTHER, const QWidget *widget=0L) const
00147     { drawLightBevel(cg.background(), p, r, cg, flags, round, fill, custom, doBorder, doCorners, w, widget); }
00148     void drawLightBevel(const QColor &bgnd, QPainter *p, const QRect &r, const QColorGroup &cg,
00149                         SFlags flags, int round, const QColor &fill, const QColor *custom=NULL,
00150                         bool doBorder=true, bool doCorners=true, EWidget w=WIDGET_OTHER, const QWidget *widget=0L) const;
00151     void drawGlow(QPainter *p, const QRect &r, const QColorGroup &cg, EWidget w, const QColor *cols=0) const;
00152     void drawEtch(QPainter *p, const QRect &r, const QColorGroup &cg, bool raised=false, bool square=false, EWidget w=WIDGET_OTHER) const;
00153     void drawBorder(const QColor &bgnd, QPainter *p, const QRect &r, const QColorGroup &cg,
00154                     SFlags flags, int round, const QColor *custom=NULL, EWidget w=WIDGET_OTHER,
00155                     bool doCorners=true, EBorder borderProfile=BORDER_FLAT, bool blendBorderColors=true, int borderVal=STD_BORDER) const;
00156     void drawMdiIcon(QPainter *painter, const QColor &color, const QColor &shadow, const QRect &r, bool sunken, int margin,
00157                      SubControl button) const;
00158     void drawWindowIcon(QPainter *painter, const QColor &color, const QRect &r, bool sunken, int margin, SubControl button) const;
00159     void drawEntryField(QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags,
00160                         EntryColor coloration, int round, EWidget=WIDGET_ENTRY) const;
00161     void drawArrow(QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags,
00162                    QStyle::PrimitiveElement pe,  bool small=false, bool checkActive=false) const;
00163     void drawPrimitive(PrimitiveElement, QPainter *, const QRect &, const QColorGroup &,
00164                        SFlags = Style_Default, const QStyleOption & = QStyleOption::Default) const;
00165     void drawKStylePrimitive(KStylePrimitive kpe, QPainter* p, const QWidget* widget, const QRect &r,
00166                              const QColorGroup &cg, SFlags flags, const QStyleOption &opt ) const;
00167     void drawControl(ControlElement, QPainter *, const QWidget *, const QRect &, const QColorGroup &,
00168                      SFlags = Style_Default, const QStyleOption & = QStyleOption::Default) const;
00169     void drawControlMask(ControlElement, QPainter *, const QWidget *, const QRect &,
00170                          const QStyleOption & = QStyleOption::Default) const;
00171     void drawComplexControlMask(ComplexControl control, QPainter *p, const QWidget *widget,
00172                                 const QRect &r, const QStyleOption &data) const;
00173     QRect subRect(SubRect, const QWidget *) const;
00174     void drawComplexControl(ComplexControl, QPainter *, const QWidget *, const QRect &,
00175                             const QColorGroup &, SFlags = Style_Default, SCFlags = SC_All,
00176                             SCFlags = SC_None, const QStyleOption & = QStyleOption::Default) const;
00177     QRect querySubControlMetrics(ComplexControl, const QWidget *, SubControl,
00178                                  const QStyleOption & = QStyleOption::Default) const;
00179     int pixelMetric(PixelMetric, const QWidget *widget= 0) const;
00180     int kPixelMetric(KStylePixelMetric kpm, const QWidget *widget) const;
00181     QSize sizeFromContents(ContentsType, const QWidget *, const QSize &,
00182                            const QStyleOption & = QStyleOption::Default) const;
00183     int styleHint(StyleHint, const QWidget *widget= 0, const QStyleOption & = QStyleOption::Default,
00184                   QStyleHintReturn *returnData= 0) const;
00185     void drawItem(QPainter *p, const QRect &r, int flags, const QColorGroup &cg, bool enabled,
00186                   const QPixmap *pixmap, const QString &text, int len=-1, const QColor *penColor=0) const;
00187 
00188     protected:
00189 
00190     bool appIsNotEmbedded(QDialog *dlg);
00191     bool eventFilter(QObject *object, QEvent *event);
00192     void drawMenuItem(QPainter *p, const QRect &r, int flags, const QColorGroup &cg,
00193                       bool mbi, int round, const QColor &bgnd, const QColor *cols) const;
00194     void drawProgress(QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags, int round,
00195                       const QWidget *widget) const;
00196     void drawBevelGradient(const QColor &base, const QColor &bgnd, QPainter *p, QRect const &r,
00197                            bool horiz, bool sel, EAppearance bevApp, EWidget w=WIDGET_OTHER) const;
00198     void drawBevelGradientReal(const QColor &base, const QColor &bgnd, QPainter *p, QRect const &r,
00199                                bool horiz, bool sel, EAppearance bevApp, EWidget w=WIDGET_OTHER) const;
00200     void drawGradient(const QColor &top, const QColor &bot, QPainter *p, const QRect &r, bool horiz=true) const;
00201     void drawSbSliderHandle(QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags, bool slider=false) const;
00202     void drawSliderHandle(QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags, QSlider *slider, bool tb=false) const;
00203     void drawSliderGroove(QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags,
00204                           const QWidget *widget) const;
00205     void drawMenuOrToolBarBackground(QPainter *p, const QRect &r, const QColorGroup &cg, bool menu=true, bool horiz=true) const;
00206     void drawHandleMarkers(QPainter *p, const QRect &r, SFlags flags, bool tb, ELine handles) const;
00207     void drawHighlight(QPainter *p, const QRect &r, const QColorGroup &cg, bool horiz, bool inc) const;
00208 
00209     private:
00210 
00211     static QColor shadowColor(const QColor col)
00212     {
00213         return qGray(col.rgb()) < 100 ? QColor(255, 255, 255) : QColor(0, 0, 0);
00214     }
00215 
00216     void           shadeColors(const QColor &base, QColor *vals) const;
00217     const QColor * buttonColors(const QColorGroup &cg) const;
00218     const QColor * popupMenuCols(const QColorGroup &cg) const;
00219     const QColor & popupMenuCol(const QColorGroup &cg, int shade=ORIGINAL_SHADE) const;
00220     const QColor * checkRadioColors(const QColorGroup &cg, SFlags flags) const;
00221     const QColor * sliderColors(/*const QColorGroup &cg, */SFlags flags) const;
00222     const QColor * backgroundColors(const QColor &c) const;
00223     const QColor * backgroundColors(const QColorGroup &cg) const
00224                                 { return backgroundColors(cg.background()); }
00225     const QColor * borderColors(SFlags flags, const QColor *use) const;
00226     const QColor * getSidebarButtons() const;
00227     void           setMenuColors(const QColorGroup &cg);
00228     void           setMenuTextColors(QWidget *widget, bool isMenuBar) const;
00229     const QColor * menuColors(const QColorGroup &cg, bool active) const;
00230     void           setDecorationColors(bool init=false);
00231     const QColor * getMdiColors(const QColorGroup &cg, bool active) const;
00232 #ifdef SET_MDI_WINDOW_BUTTON_POSITIONS
00233     void           readMdiPositions() const;
00234 #endif
00235     bool           redrawHoverWidget(const QPoint &pos);
00236     const QColor & getFill(SFlags flags, const QColor *use, bool cr=false, bool darker=false) const;
00237     const QColor & getListViewFill(SFlags flags, const QColor *use) const;
00238     const QColor & getTabFill(bool current,  bool highlight, const QColor *use) const;
00239     const QColor & menuStripeCol(const QColorGroup &cg) const;
00240     const QColor & checkRadioCol(SFlags flags, const QColorGroup &cg) const;
00241     QColor         shade(const QColor &a, float k) const;
00242     void           shade(const color &ca, color *cb, double k) const;
00243     void           drawDot(QPainter *p, const QRect &r, const QColor *cols) const;
00244     QPixmap *      getPixelPixmap(const QColor col) const;
00245     QPixmap *      getPixmap(const QColor col, EPixmap pix, double shade=1.0) const;
00246     QPixmap *      createStripePixmap(const QColor &col, bool forWindow) const;
00247     void           setSbType();
00248     bool           isFormWidget(const QWidget *w) const { return itsKhtmlWidgets.contains(w); }
00249     void           resetHover();
00250     bool           isWindowDragWidget(QObject *o, const QPoint &pos=QPoint());
00251 
00252     private slots:
00253 
00254     void updateProgressPos();
00255     void progressBarDestroyed(QObject *bar);
00256     void sliderThumbMoved(int val);
00257     void khtmlWidgetDestroyed(QObject *o);
00258     void hoverWidgetDestroyed(QObject *o);
00259 
00260     private:
00261 
00262     mutable Options            opts;
00263     QColor                     itsHighlightCols[TOTAL_SHADES+1],
00264                                itsBackgroundCols[TOTAL_SHADES+1],
00265                                itsMenubarCols[TOTAL_SHADES+1],
00266                                itsFocusCols[TOTAL_SHADES+1],
00267                                *itsPopupMenuCols,
00268                                *itsSliderCols,
00269                                *itsDefBtnCols,
00270                                *itsMouseOverCols,
00271                                *itsComboBtnCols,
00272                                *itsCheckRadioSelCols,
00273                                *itsSortedLvColors,
00274                                *itsProgressCols,
00275                                itsButtonCols[TOTAL_SHADES+1],
00276                                itsCheckRadioCol;
00277     mutable QColor             *itsSidebarButtonsCols;
00278     mutable QColor             *itsActiveMdiColors;
00279     mutable QColor             *itsMdiColors;
00280     mutable QColor             itsActiveMdiTextColor;
00281     mutable QColor             itsMdiTextColor;
00282     mutable QColor             itsColoredButtonCols[TOTAL_SHADES+1];
00283     mutable QColor             itsColoredBackgroundCols[TOTAL_SHADES+1];
00284     EApp                       itsThemedApp;
00285     mutable QCache<QPixmap>    itsPixmapCache;
00286 #if defined QTC_QT_ONLY || !defined KDE_VERSION || KDE_VERSION >= 0x30200
00287     bool                       itsIsTransKicker;
00288 #endif
00289     EHover                     itsHover;
00290     QPoint                     itsOldPos;
00291     mutable bool               itsFormMode;
00292     QWidget                    *itsHoverWidget;
00293     int                        itsHoverSect;
00294     QTab                       *itsHoverTab;
00295     QPalette                   *itsMactorPal;
00296     QMap<QWidget*, int>        itsProgAnimWidgets;
00297     QMap<const QWidget*, bool> itsKhtmlWidgets;
00298     QTimer                     *itsAnimationTimer;
00299     mutable bool               itsActive,
00300                                itsIsSpecialHover;
00301     mutable QValueList<int>    itsMdiButtons[2]; // 0=left, 1=right
00302     QWidget                    *itsDragWidget;
00303     bool                       itsDragWidgetHadMouseTracking;
00304     ShortcutHandler            *itsShortcutHandler;
00305 };
00306 
00307 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'