File indexing completed on 2024-04-21 05:46:57

0001 /*****************************************************************************
0002  *   Copyright 2003 - 2010 Craig Drummond <craig.p.drummond@gmail.com>       *
0003  *   Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com>                     *
0004  *                                                                           *
0005  *   This program is free software; you can redistribute it and/or modify    *
0006  *   it under the terms of the GNU Lesser General Public License as          *
0007  *   published by the Free Software Foundation; either version 2.1 of the    *
0008  *   License, or (at your option) version 3, or any later version accepted   *
0009  *   by the membership of KDE e.V. (or its successor approved by the         *
0010  *   membership of KDE e.V.), which shall act as a proxy defined in          *
0011  *   Section 6 of version 3 of the license.                                  *
0012  *                                                                           *
0013  *   This program is distributed in the hope that it will be useful,         *
0014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0016  *   Lesser General Public License for more details.                         *
0017  *                                                                           *
0018  *   You should have received a copy of the GNU Lesser General Public        *
0019  *   License along with this library. If not,                                *
0020  *   see <http://www.gnu.org/licenses/>.                                     *
0021  *****************************************************************************/
0022 
0023 #ifndef __QTC_DRAWING_H__
0024 #define __QTC_DRAWING_H__
0025 
0026 #include <common/common.h>
0027 #include <qtcurve-cairo/draw.h>
0028 
0029 #define CAIRO_GRAD_END 1.0
0030 
0031 namespace QtCurve {
0032 
0033 void drawBgnd(cairo_t *cr, const GdkColor *col, GtkWidget *widget,
0034               const QtcRect *area, int x, int y, int width, int height);
0035 void drawAreaModColor(cairo_t *cr, const QtcRect *area, const GdkColor *orig,
0036                       double mod, int x, int y, int width, int height);
0037 QTC_ALWAYS_INLINE static inline void
0038 drawAreaMod(cairo_t *cr, GtkStyle *style, GtkStateType state,
0039             const QtcRect *area, double mod, int x, int y,
0040             int width, int height)
0041 {
0042     drawAreaModColor(cr, area, &style->bg[state], mod, x, y, width, height);
0043 }
0044 
0045 void drawBevelGradient(cairo_t *cr, const QtcRect *area, int x, int y,
0046                        int width, int height, const GdkColor *base, bool horiz,
0047                        bool sel, EAppearance bevApp, EWidget w, double alpha=1);
0048 
0049 typedef enum {
0050     DF_DRAW_INSIDE = 0x001,
0051     DF_BLEND = 0x002,
0052     DF_SUNKEN = 0x004,
0053     DF_DO_BORDER = 0x008,
0054     DF_VERT = 0x010,
0055     DF_HIDE_EFFECT = 0x020,
0056     DF_HAS_FOCUS = 0x040
0057 } EDrawFlags;
0058 
0059 void drawBorder(cairo_t *cr, GtkStyle *style, GtkStateType state,
0060                 const QtcRect *area, int x, int y, int width, int height,
0061                 const GdkColor *c_colors, ECornerBits round,
0062                 EBorder borderProfile, EWidget widget, int flags,
0063                 int borderVal=QTC_STD_BORDER);
0064 void drawGlow(cairo_t *cr, const QtcRect *area, int x, int y, int w, int h,
0065               ECornerBits round, EWidget widget,
0066               const GdkColor *colors=nullptr);
0067 void drawEtch(cairo_t *cr, const QtcRect *area, GtkWidget *widget, int x, int y,
0068               int w, int h, bool raised, ECornerBits round, EWidget wid);
0069 void qtcClipPath(cairo_t *cr, int x, int y, int w, int h, EWidget widget,
0070                  ERadius rad, ECornerBits round);
0071 void drawLightBevel(cairo_t *cr, GtkStyle *style, GtkStateType state,
0072                     const QtcRect *area, int x, int y, int width, int height,
0073                     const GdkColor *base, const GdkColor *colors,
0074                     ECornerBits round, EWidget widget, EBorder borderProfile,
0075                     int flags, GtkWidget *wid);
0076 void drawFadedLine(cairo_t *cr, int x, int y, int width, int height,
0077                    const GdkColor *col, const QtcRect *area,
0078                    const QtcRect *gap, bool fadeStart, bool fadeEnd,
0079                    bool horiz, double alpha=1);
0080 void drawHighlight(cairo_t *cr, int x, int y, int width, int height,
0081                    const QtcRect *area, bool horiz, bool inc);
0082 void setLineCol(cairo_t *cr, cairo_pattern_t *pt, const GdkColor *col);
0083 void drawLines(cairo_t *cr, double rx, double ry, int rwidth, int rheight,
0084                bool horiz, int nLines, int offset, const GdkColor *cols,
0085                const QtcRect *area, int dark, ELine type);
0086 void drawEntryCorners(cairo_t *cr, const QtcRect *area, int round, int x, int y,
0087                       int width, int height, const GdkColor *col, double a);
0088 void drawBgndRing(cairo_t *cr, int x, int y, int size,
0089                   int size2, bool isWindow);
0090 void drawBgndRings(cairo_t *cr, int x, int y, int width, int height,
0091                    bool isWindow);
0092 void drawBgndImage(cairo_t *cr, int x, int y, int w, int h, bool isWindow);
0093 void drawStripedBgnd(cairo_t *cr, int x, int y, int w, int h,
0094                      const GdkColor *col, double alpha);
0095 bool drawWindowBgnd(cairo_t *cr, GtkStyle *style, const QtcRect *area,
0096                     GdkWindow *window, GtkWidget *widget, int x, int y,
0097                     int width, int height);
0098 void drawEntryField(cairo_t *cr, GtkStyle *style, GtkStateType state,
0099                     GdkWindow *window, GtkWidget *widget, const QtcRect *area,
0100                     int x, int y, int width, int height, ECornerBits round,
0101                     EWidget w);
0102 void drawProgress(cairo_t *cr, GtkStyle *style, GtkStateType state,
0103                   GtkWidget *widget, const QtcRect *area, int x, int y,
0104                   int width, int height, bool rev, bool isEntryProg);
0105 void drawProgressGroove(cairo_t *cr, GtkStyle *style, GtkStateType state,
0106                         GdkWindow *window, GtkWidget *widget,
0107                         const QtcRect *area, int x, int y, int width,
0108                         int height, bool isList, bool horiz);
0109 void drawSliderGroove(cairo_t *cr, GtkStyle *style, GtkStateType state,
0110                       GtkWidget *widget, const char *detail,
0111                       const QtcRect *area, int x, int y, int width, int height,
0112                       bool horiz);
0113 void drawTriangularSlider(cairo_t *cr, GtkStyle *style, GtkStateType state,
0114                           const char *detail, int x, int y,
0115                           int width, int height);
0116 void drawScrollbarGroove(cairo_t *cr, GtkStyle *style, GtkStateType state,
0117                          GtkWidget *widget, const QtcRect *area, int x, int y,
0118                          int width, int height, bool horiz);
0119 void drawSelectionGradient(cairo_t *cr, const QtcRect *area, int x, int y,
0120                            int width, int height, ECornerBits round,
0121                            bool isLvSelection, double alpha,
0122                            const GdkColor *col, bool horiz);
0123 void drawSelection(cairo_t *cr, GtkStyle *style, GtkStateType state,
0124                    const QtcRect *area, GtkWidget *widget, int x, int y,
0125                    int width, int height, ECornerBits round, bool isLvSelection,
0126                    double alphaMod, int factor);
0127 void createRoundedMask(GtkWidget *widget, int x, int y, int width, int height,
0128                        double radius, bool isToolTip);
0129 void clearRoundedMask(GtkWidget *widget, bool isToolTip);
0130 void drawTreeViewLines(cairo_t *cr, const GdkColor *col, int x, int y, int h,
0131                        int depth, int levelIndent, int expanderSize,
0132                        GtkTreeView *treeView, GtkTreePath *path);
0133 void fillTab(cairo_t *cr, GtkStyle *style, GtkWidget *widget,
0134              const QtcRect *area, GtkStateType state, const GdkColor *col,
0135              int x, int y, int width, int height, bool horiz,
0136              EWidget tab, bool grad);
0137 void drawToolTip(cairo_t *cr, GtkWidget *widget, const QtcRect *area,
0138                  int x, int y, int width, int height);
0139 void drawSplitter(cairo_t *cr, GtkStateType state, GtkStyle *style,
0140                   const QtcRect *area, int x, int y, int width, int height);
0141 void drawSidebarButton(cairo_t *cr, GtkStateType state, GtkStyle *style,
0142                        const QtcRect *area, int x, int y,
0143                        int width, int height);
0144 void drawMenuItem(cairo_t *cr, GtkStateType state, GtkStyle *style,
0145                   GtkWidget *widget, const QtcRect *area, int x, int y,
0146                   int width, int height);
0147 void drawMenu(cairo_t *cr, GtkWidget *widget, const QtcRect *area,
0148               int x, int y, int width, int height);
0149 void drawBoxGap(cairo_t *cr, GtkStyle *style, GtkShadowType shadow,
0150                 GtkStateType state, GtkWidget *widget, const QtcRect *area,
0151                 int x, int y, int width, int height, GtkPositionType gap_side,
0152                 int gapX, int gapWidth, EBorder borderProfile, bool isTab);
0153 void drawBoxGapFixes(cairo_t *cr, GtkWidget *widget, int x, int y,
0154                      int width, int height, GtkPositionType gapSide,
0155                      int gapX, int gapWidth);
0156 void drawShadowGap(cairo_t *cr, GtkStyle *style, GtkShadowType shadow,
0157                    GtkStateType state, GtkWidget *widget, const QtcRect *area,
0158                    int x, int y, int width, int height,
0159                    GtkPositionType gapSide, int gapX, int gapWidth);
0160 void drawCheckBox(cairo_t *cr, GtkStateType state, GtkShadowType shadow,
0161                   GtkStyle *style, GtkWidget *widget, const char *detail,
0162                   const QtcRect *area, int x, int y, int width, int height);
0163 void drawTab(cairo_t *cr, GtkStateType state, GtkStyle *style,
0164              GtkWidget *widget, QtcRect *area, int x, int y,
0165              int width, int height, GtkPositionType gapSide);
0166 void drawRadioButton(cairo_t *cr, GtkStateType state, GtkShadowType shadow,
0167                      GtkStyle *style, GtkWidget *widget, const char *detail,
0168                      const QtcRect *area, int x, int y, int width, int height);
0169 void drawToolbarBorders(cairo_t *cr, GtkStateType state, int x, int y,
0170                         int width, int height, bool isActiveWindowMenubar,
0171                         const char *detail);
0172 void drawListViewHeader(cairo_t *cr, GtkStateType state,
0173                         const GdkColor *btnColors, int bgnd,
0174                         const QtcRect *area, int x, int y,
0175                         int width, int height);
0176 void drawDefBtnIndicator(cairo_t *cr, GtkStateType state,
0177                          const GdkColor *btnColors, int bgnd, bool sunken,
0178                          const QtcRect *area, int x, int y,
0179                          int width, int height);
0180 GdkPixbuf *renderIcon(GtkStyle *style, const GtkIconSource *source,
0181                       GtkStateType state, GtkIconSize size, GtkWidget *widget);
0182 
0183 }
0184 
0185 #endif