summaryrefslogtreecommitdiffstats
path: root/src/widget/ia_ora.h
blob: 2c9c1749c12ea6609b7625be5159df50763ac382 (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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*
 * Copyright (C) 2007 Gustavo Pichorim Boiko <boiko@mandriva.com>
 * Copyright (C) 2006 Laurent Montel<lmontel@mandriva.com>
 *
 * renderGradient() code adapted from the Plastik stype
 * Copyright (C) 2003 Sandro Giessl <ceebx@users.sourceforge.net>
 *
 * based on KDE3 HighColor Style (version 1.0)
 * Copyright (C) 2001-2002 Karol Szwed      <gallium@kde.org>
 *           (C) 2001-2002 Fredrik Höglund  <fredrik@kde.org>
 *
 * Drawing routines adapted from the KDE2 HCStyle,
 * Copyright (C) 2000 Daniel M. Duley       <mosfet@kde.org>
 *           (C) 2000 Dirk Mueller          <mueller@kde.org>
 *           (C) 2001 Martijn Klingens      <klingens@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License version 2 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */


#ifndef __MANDRIVASTYLE_H
#define __MANDRIVASTYLE_H

#include <tqbitmap.h>
#include <tqintdict.h>
#include <kdrawutil.h>
#include <kpixmap.h>
#include <kstyle.h>
#include <tqintcache.h>

class TQPopupMenu;


class MandrivaStyle : public KStyle
{
    Q_OBJECT

public:
    MandrivaStyle();
    virtual ~MandrivaStyle();

    void polish( TQWidget* widget );
    void unPolish( TQWidget* widget );
    void polish( TQApplication *app );
    void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup &cg,
                                const TQPopupMenu* popup ) const;

    void drawKStylePrimitive( KStylePrimitive kpe,
                              TQPainter* p,
                              const TQWidget* widget,
                              const TQRect &r,
                              const TQColorGroup &cg,
                              SFlags flags = Style_Default,
                              const TQStyleOption& = TQStyleOption::Default ) const;

    void drawPrimitive( PrimitiveElement pe,
                        TQPainter* p,
                        const TQRect &r,
                        const TQColorGroup &cg,
                        SFlags flags = Style_Default,
                        const TQStyleOption& = TQStyleOption::Default ) const;

    void drawControl( ControlElement element,
                      TQPainter *p,
                      const TQWidget *widget,
                      const TQRect &r,
                      const TQColorGroup &cg,
                      SFlags flags = Style_Default,
                      const TQStyleOption& = TQStyleOption::Default ) const;

    void drawControlMask( ControlElement element,
                          TQPainter *p,
                          const TQWidget *widget,
                          const TQRect &r,
                          const TQStyleOption& = TQStyleOption::Default ) const;

    void drawComplexControl( ComplexControl control,
                             TQPainter *p,
                             const TQWidget *widget,
                             const TQRect &r,
                             const TQColorGroup &cg,
                             SFlags flags = Style_Default,
                             SCFlags controls = SC_All,
                             SCFlags active = SC_None,
                             const TQStyleOption& = TQStyleOption::Default ) const;

    void drawComplexControlMask( ComplexControl control,
                                 TQPainter *p,
                                 const TQWidget *widget,
                                 const TQRect &r,
                                 const TQStyleOption& = TQStyleOption::Default ) const;

    int pixelMetric( PixelMetric m,
                     const TQWidget *widget = 0 ) const;

    TQSize sizeFromContents( ContentsType contents,
                            const TQWidget *widget,
                            const TQSize &contentSize,
                            const TQStyleOption& opt ) const;

    TQRect subRect( SubRect r,
                   const TQWidget *widget ) const;

    // Fix TQt3's wacky image positions
    TQPixmap stylePixmap( StylePixmap stylepixmap,
                         const TQWidget *widget = 0,
                         const TQStyleOption& = TQStyleOption::Default ) const;

    TQRect querySubControlMetrics( ComplexControl control,
                                  const TQWidget* widget,
                                  SubControl subcontrol,
                                  const TQStyleOption& opt = TQStyleOption::Default ) const;

protected:
    enum Hover
    {
        HoverNone = 0,
        // scrollbar
        HoverScrollBarSlider,
        HoverScrollBarAddLine,
        HoverScrollBarSubLine,
        HoverScrollBarAddPage,
        HoverScrollBarSubPage,
        HoverScrollBarFirst,
        HoverScrollBarLast,
        // combobox
        HoverComboBoxArrow,
        HoverComboBoxEdit
    };


    bool eventFilter( TQObject *object, TQEvent *event );

    void renderGradient(TQPainter* p,
                        const TQRect& r,
                        const TQColor& ca,
                        const TQColor& cb ,
                        bool horizontal) const;

    TQWidget    *hoverWidget;
    enum Hover hoverControl;

    struct MandrivaColorData 
    {
        ~MandrivaColorData();
        TQRgb spotColor;

        // gradient color
        //rename to grey
        TQColor shades[7];
        
        // five blue color
        TQColor blueMdkColor[5];

        // button gradients 
        TQColor buttonColor[7];
        
        
        TQColor radioColor;

        bool isGroup (const TQColorGroup &cg) 
        {
            return cg.button() == buttonColor[0] && cg.highlight().rgb() == spotColor;
        }
    };

private:
    enum TabPosition {Single = 0,First,Last, Middle};

    // Disable copy constructor and = operator
    MandrivaStyle( const MandrivaStyle & );
    MandrivaStyle& operator=( const MandrivaStyle & );

    void drawButton( const MandrivaColorData *cdata, 
                     const TQRect & r, TQPainter *p,
                     const TQColorGroup &cg, 
                     SFlags flags) const;

    void drawHandlePoint ( const MandrivaColorData *cdata,
                           TQPainter *p, 
                           int x, 
                           int y) const;

    void drawHandle( const MandrivaColorData *cdata, 
                     TQPainter *p,
                     const TQRect &r,
                     const TQColorGroup &cg,
                     SFlags flags, 
                     const TQStyleOption& opt, 
                     bool drawBorderAndGradient, 
                     bool drawGradient = false ) const;

    void drawGroupBox(const MandrivaColorData *cdata, 
                      const TQColorGroup & cg, 
                      TQPainter *p, 
                      const TQRect & r, 
                      bool active, 
                      bool sunken )const;

    void drawLineSeparator(const MandrivaColorData *cdata, 
                           const TQColorGroup & cg, 
                           TQPainter *p, 
                           const TQRect & r, 
                           bool horiziontal,
                           bool active, 
                           bool sunken,
                           bool skipOffset = true) const;

    void drawFrame( const MandrivaColorData *cdata, 
                    const TQColorGroup & cg, 
                    TQPainter *p, 
                    const TQRect & r, 
                    bool active) const;

    void drawComboboxArrow( TQPainter *p,
                            const TQWidget *widget,
                            const TQRect &r,
                            const TQColorGroup &cg,
                            SFlags flags,
                            SCFlags active)const;

    void drawMandrivaArrow( TQPointArray a, TQPainter *p,
                            const TQRect &r,
                            const TQColorGroup &cg,
                            SFlags flags,
                            const TQStyleOption& opt ) const;


    MandrivaColorData *realizeData (const TQColorGroup &cg) const;
    const MandrivaColorData *lookupData (const TQColorGroup &cg) const;
    bool isFormWidget(const TQWidget* widget) const;
    bool excludeColor(const TQColor &col, bool active) const;
    void getShade (const TQColorGroup &cg, int shadenr, TQColor &res) const;
    void updateHoverControl(const TQPoint &pos);
    TQIntCache<MandrivaColorData> m_dataCache;
    static const double shading[8];
    mutable bool formMode;
    bool kickerMode;
    // For KPE_ListViewBranch
    mutable TQBitmap *verticalLine;
    mutable TQBitmap *horizontalLine;

    // pixmap cache.
    enum CacheEntryType 
    {
        cSurface,
        cGradientTile,
        cAlphaDot
    };
    struct CacheEntry
    {
        CacheEntryType type;
        int width;
        int height;
        TQRgb c1Rgb;
        TQRgb c2Rgb;
        bool horizontal;

        TQPixmap* pixmap;

        CacheEntry(CacheEntryType t, int w, int h, TQRgb c1, TQRgb c2 = 0,
                   bool hor = false, TQPixmap* p = 0 ):
            type(t), width(w), height(h), c1Rgb(c1), c2Rgb(c2), horizontal(hor), pixmap(p)
        {}

        ~CacheEntry()
        {
            delete pixmap;
        }

        int key()
        {
            // create an int key from the properties which is used to refer to entries in the TQIntCache.
            // the result may not be 100% correct as we don't have so much space in one integer -- use
            // == operator after find to make sure we got the right one. :)
            return horizontal ^ (type<<1) ^ (width<<5) ^ (height<<10) ^ (c1Rgb<<19) ^ (c2Rgb<<22);
        }

        bool operator == (const CacheEntry& other)
        {
            bool match = (type == other.type) &&
                        (width   == other.width) &&
                        (height == other.height) &&
                        (c1Rgb == other.c1Rgb) &&
                        (c1Rgb == other.c1Rgb) &&
                        (horizontal == other.horizontal);
            return match;
        }
    };
    TQIntCache<CacheEntry> *pixmapCache;

};

#endif

// vim: ts=4 et sw=4