summaryrefslogtreecommitdiff
path: root/noncore/styles/liquid/liquid.h
blob: 0582c9aec21da70b3bd3ca8b70667baa5efd9604 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#ifndef LIQUID_STYLE_H
#define LIQUID_STYLE_H


#include <qwindowsstyle.h>
#include <qpainter.h>
#include <qdrawutil.h>
#include <qpalette.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qscrollbar.h>
#include <qbitmap.h>
#include <qintdict.h>
#include <qstrlist.h>
#include <qobject.h>
#include <limits.h>


/*-
 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
 */

class QPixmap;

#define BITMAP_ITEMS 41
#define LIQUID_MENU_CHANGE 667
#define MOSFET_BUTTON_CHANGE 661

enum BitmapData{RadioOn=0, RadioOff, RadioOnHover, RadioOffHover, VSBSliderTop,
VSBSliderMid, VSBSliderBtm, VSBSliderTopHover, VSBSliderMidHover,
VSBSliderBtmHover, VSBSliderTopBg, VSBSliderMidBg, VSBSliderBtmBg,
HSBSliderTop, HSBSliderMid, HSBSliderBtm, HSBSliderTopHover, HSBSliderMidHover,
HSBSliderBtmHover, HSBSliderTopBg, HSBSliderMidBg,
HSBSliderBtmBg, Tab, TabDown, TabFocus, CB, CBDown, CBHover, CBDownHover,
HSlider, VSlider, HTMLBtnBorder, HTMLBtnBorderDown, HTMLCB, HTMLCBDown,
HTMLCBHover, HTMLCBDownHover, HTMLRadio, HTMLRadioDown, HTMLRadioHover,
HTMLRadioDownHover};


class QHeader;

enum TransType{None=0, StippledBg, StippledBtn, TransStippleBg,
    TransStippleBtn, Custom};

class TransMenuHandler : public QObject
{
    Q_OBJECT
public:
    TransMenuHandler(QObject *parent);
    ~TransMenuHandler(){;}
    void reloadSettings();
    int transType(){return(type);}
    QPixmap *pixmap(WId id){return(pixDict.find(id));}
    const QColor& textColor(){return(fgColor);}
    const QColor& bgColor(){return(color);}
    bool useShadowText(){return(shadowText);}
protected:
    bool eventFilter(QObject *obj, QEvent *ev);
    void stripePixmap(QPixmap &pix, const QColor &color);

    QColor color, fgColor;
    int opacity;
    int type;
    bool shadowText;
    QIntDict<QPixmap>pixDict;
};

class LiquidStyle : public QWindowsStyle
{
    friend class TransMenuHandler;
public:
    LiquidStyle();
    ~LiquidStyle();
    virtual void polish(QWidget *w);
    virtual void unPolish(QWidget *w);
    virtual void polish(QApplication *a);
    virtual void unPolish(QApplication *a);
    virtual void polish(QPalette &p);
    void drawButton(QPainter *p, int x, int y, int w, int h,
                    const QColorGroup &g, bool sunken = FALSE,
                    const QBrush *fill = 0 );
    void drawButtonMask(QPainter *p, int x, int y, int w, int h);
    void drawComboButtonMask(QPainter *p, int x, int y, int w, int h);
    QRect buttonRect(int x, int y, int w, int h);
    void drawBevelButton(QPainter *p, int x, int y, int w, int h,
                         const QColorGroup &g, bool sunken = FALSE,
                         const QBrush *fill = 0 );
    void drawPushButton(QPushButton *btn, QPainter *p);
    virtual void drawPushButtonLabel (QPushButton *btn, QPainter *p);
    void drawScrollBarControls(QPainter*,  const QScrollBar*, int sliderStart,
                               uint controls, uint activeControl );
    QStyle::ScrollControl scrollBarPointOver(const QScrollBar *sb,
                                             int sliderStart, const QPoint &p);
    void scrollBarMetrics(const QScrollBar *sb, int &sliderMin, int &sliderMax,
                          int &sliderLength, int &buttonDim);
    QSize indicatorSize() const;
    void drawIndicator(QPainter* p, int x, int y, int w, int h,
                       const QColorGroup &g, int state, bool down = FALSE,
                       bool enabled = TRUE );
    void drawIndicatorMask(QPainter *p, int x, int y, int w, int h, int);
    QSize exclusiveIndicatorSize() const;
    void drawExclusiveIndicator(QPainter* p,  int x, int y, int w, int h,
                                const QColorGroup &g, bool on,
                                bool down = FALSE, bool enabled =  TRUE );
    void drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w,
                                    int h, bool);
    void drawComboButton(QPainter *p, int x, int y, int w, int h,
                         const QColorGroup &g, bool sunken = FALSE,
                         bool editable = FALSE, bool enabled = TRUE,
                         const QBrush *fill = 0 );
    QRect comboButtonRect(int x, int y, int w, int h);
    QRect comboButtonFocusRect(int x, int y, int w, int h);
    int sliderLength() const;
    void drawArrow(QPainter *p, Qt::ArrowType type, bool down,
                   int x, int y, int w, int h, const QColorGroup &g,
                   bool enabled=true, const QBrush *fill = 0);
    void drawSlider(QPainter *p, int x, int y, int w, int h,
                    const QColorGroup &g, Orientation orient,
                    bool tickAbove, bool tickBelow);
    void drawSliderMask(QPainter *p, int x, int y, int w, int h,
                        Orientation orient, bool, bool);
	void drawMenuBarItem(QPainter *p, int x, int y, int w, int h,
                            QMenuItem *mi, QColorGroup &g, bool enabled, bool active );

    void drawPopupMenuItem(QPainter *p, bool checkable, int maxpmw,
                           int tab, QMenuItem *mi, const QPalette &pal,
                           bool act, bool enabled, int x, int y, int w,
                           int h);
    int popupMenuItemHeight(bool c, QMenuItem *mi, const QFontMetrics &fm);
    void drawFocusRect(QPainter *p, const QRect &r, const QColorGroup &g,
                       const QColor *pen, bool atBorder);
    int defaultFrameWidth() const {return(2);}
    void polishPopupMenu(QPopupMenu *mnu);
    void drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab,
                 bool selected);
    void drawTabMask( QPainter*, const QTabBar*, QTab*, bool selected );
    void tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame,
                       int &overlap);

    void drawSplitter(QPainter *p, int x, int y, int w, int h,
                      const QColorGroup &g, Orientation orient);
    int splitterWidth() const {return(6);}
    void drawPanel(QPainter *p, int x, int y, int w, int h,
                   const QColorGroup &g, bool sunken, int lineWidth,
                   const QBrush *fill);
    void drawToolButton(QPainter *p, int x, int y, int w,
                        int h, const QColorGroup &g,
                        bool sunken, const QBrush *fill);
    // for repainting toolbuttons when the toolbar is resized
    bool eventFilter(QObject *obj, QEvent *ev);
    void drawSliderGroove(QPainter * p, int x, int y, int w,  int h,
                          const QColorGroup &g, QCOORD c, Orientation);
    void drawSliderGrooveMask(QPainter * p, int x, int y, int w, int h,
                              QCOORD c, Orientation);
    int buttonDefaultIndicatorWidth() const {return(2);}
    void drawPopupPanel(QPainter *p, int x, int y, int w, int h,
                        const QColorGroup &g, int lineWidth,
                        const QBrush * fill);
protected:
    void adjustHSV(QPixmap &pix, int h, int s, int v);
    void intensity(QPixmap &pix, float percent);

    void drawRoundButton(QPainter *p, const QColor &c, const QColor &bg, int x,
                         int y, int w, int h, bool  supportPushDown = false,
                         bool pushedDown = false, bool autoDefault = false,
                         bool isMasked = false);
    void drawClearBevel(QPainter *p, int x, int y, int w, int h,
                        const QColor &c, const QColor &bg);
    void drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
                   bool horiz);
    void drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g,
                      bool down=false, bool fast = true);
    void drawRoundRect(QPainter *p, int x, int y, int w, int h);
    QPixmap* getPixmap(BitmapData item);
    QPixmap* processEmbedded(const char *label, int h, int s, int v, bool blend=false);
private:
	bool oldqte;
	bool flatTBButtons;
    QWidget *highlightWidget;
    QBitmap btnMaskBmp, htmlBtnMaskBmp;
    QPixmap *btnBorderPix, *btnBlendPix, *bevelFillPix, *smallBevelFillPix, *menuPix;
    QBrush bgBrush, menuBrush;
    bool menuAni, menuFade;

    QIntDict<QPixmap>btnDict;
    QIntDict<QPixmap>btnBorderDict;
    QIntDict<QPixmap>bevelFillDict;
    QIntDict<QPixmap>smallBevelFillDict;

    QPixmap *vsbSliderFillPix;
    TransMenuHandler *menuHandler;
    QPixmap *pixmaps[BITMAP_ITEMS];
    QPixmap sbBuffer;
    int oldSliderThickness;
    int lowLightVal;
    QHeader *currentHeader;
    int headerHoverID;
    QWMatrix rMatrix;
    int bH, bS, bV;
    int bHoverH, bHoverS, bHoverV;
    int btnH, btnS, btnV;
    int btnHoverH, btnHoverS, btnHoverV;
};

#endif