summaryrefslogtreecommitdiffstats
path: root/style/baghira.h
blob: 1336ac2fa0d64942b19a7487c1359a9f407ee4c2 (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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
#ifndef __LIQUID_STYLE_H
#define __LIQUID_STYLE_H

#include <qcstring.h>
#include <qdir.h>
#include <qintdict.h>
#include <qprogressbar.h>
#include <qtimer.h>
#include <qwmatrix.h> 
#include <kpixmap.h>
#include <qwidget.h>
#include <kstyle.h>

// #define BITMAP_ITEMS 75 // Don't worry, they're demand loaded ;-)
#define LIQUID_MENU_CHANGE 667
#define MOSFET_BUTTON_CHANGE 661

class QColor;
class QHeader;
class QImage;
class QMenuBar;
class QPalette;
class QPoint;
class QPushButton;
class QRect;
class QScrollBar;
class QSize;
class QString;
class QTabBar;
class LiquidStyle;

enum BitmapData{RadioOn = 0, RadioOff, RadioOnHover, RadioOffHover, RadioOnPressed, RadioOffPressed,
		VSBSliderTop, VSBSliderMid, VSBSliderBtm,
		VSBSliderTopActive, VSBSliderMidActive, VSBSliderBtmActive,
		VSBSliderTopPressed, VSBSliderMidPressed, VSBSliderBtmPressed,
		VSBSliderTopBg, VSBSliderMidBg, VSBSliderMidBgI, VSBSliderBtmBg,
                HSBSliderTop, HSBSliderMid, HSBSliderBtm,
		HSBSliderTopActive, HSBSliderMidActive, HSBSliderBtmActive,
		HSBSliderTopPressed, HSBSliderMidPressed, HSBSliderBtmPressed,
		HSBSliderTopBg, HSBSliderMidBg, HSBSliderMidBgI, HSBSliderBtmBg,
		Tab, TabDown, TabFocus, belowTab, belowTabDown,
		ButtonShadow, CB, CBDown, CBTri, CBHover, CBDownHover, CBTriHover, CBPressed, CBDownPressed, CBTriPressed,
		HSlider, VSlider, VSliderAbove, HSliderInactive, VSliderInactive, VSliderAboveInactive,
		Progress, rectbutton, combo, comboShadow, progress2, TitleBar, BITMAP_ITEMS};

enum CustomColor{CustomCBOn = 0, CustomCBOff, CustomRadioOn, CustomRadioOff,
                 CustomTabOn, CustomTabOff, CustomSBSlider, CustomSBSliderHover, CustomSBSliderPressed, CustomSBGroove};

enum PulseType{PushButton, ComboBox, AppletHandle, Splitter, ToolButton};

enum MenuBackground{Standard=0, Plain, Stipples, Gradient};

enum InactiveButtonColor{Original=0, Background, Active, Custom};

enum myExpanderStyle{Apple=0, MS};

enum progressStyle{mac=0, liquid, baghira};

enum DotlineStyle{Line=0, Dots};

enum Tile{TileTopLeft = 0, TileTop, TileTopRight,
          TileLeft, TileMiddle, TileRight, TileBtmLeft, TileBtm, TileBtmRight};

enum myPosition{left = 0, center, right, full};

enum tabStyle {TrueTab = 0, Clever, Chooser};

enum Style {Jaguar = 0, Panther, Brushed, Tiger, Milk, NUMSTYLES };

class ButtonTile
    {
    public:
    ButtonTile()
        {
        for ( int i = 0;i < 9;++i )
            pixmaps[ i ] = 0;
        }
    ~ButtonTile()
        {
        for ( int i = 0;i < 9;++i )
            if ( pixmaps[ i ] ) delete pixmaps[ i ];
        }
    QPixmap* pixmap( Tile pos )
        {
        return ( pixmaps[ ( int ) pos ] );
        }
    void setPixmap( Tile pos, QPixmap *pix )
        {
        pixmaps[ ( int ) pos ] = pix;
        }
    protected:
            QPixmap *pixmaps[ 9 ];
    };


class OptionHandler : public QObject
{
   Q_OBJECT
public:
   OptionHandler( QObject *parent );
   void reloadSettings();
   inline static bool useShadowText()
   {
      return ( shadowText );
   }
   const QColor& textColor();
   const QColor& bgColor();
   const QColor& buttonColor();
   static int custCols[8];
		
   inline void reset()
   {
      menusProcessed = false;
   }

   inline static bool glossyMenus()
   {
      return glossyMenus_;
   }

   inline static bool drawMenuStripe()
   {
      return (drawMenuStripe_);
   }

   inline static QColor menuStripeColor()
   {
      return menuStripeColor_;
   }

   inline static QColor textColorHigh()
   {
      return fgColorHigh;
   }

   inline static QColor menuColorHigh()
   {
      return colorHigh;
   }

   inline static bool bevelHighlights()
   {
      return (bevelHighlights_);
   }
   inline static bool useBgStipple()
   {
      return ( bgStipple );
   }
   inline static Style style()
   {
      return (style_);
   }
   inline static int stippleContrast()
   {
      return ( contrast );
   }
   inline static bool useReverseBtnColor() 
   {
      return ( reverseBtnColor );
   }
   inline static bool useToolButtonFrame()
   {
      return ( tbFrame );
   }

   inline static bool useCustomColors()
   {
      return ( customWidgetColor );
   }
   inline static const QColor& customColor( int idx )
   {
      return ( customColors[ idx ] );
   }

   inline static bool DrawDotlines()
   {
      return ( drawDotlines );
   }
   inline static bool squeezeSbSlider()
   {
      return ( squeezesbslider );
   }
   inline static bool shadowSbSlider()
   {
      return (shadowsbslider);
   }
   inline static bool drawGroupBoxShadow()
   {
      return ( groupboxshadow );
   }
   inline static int ShadowDarkness()
   {
      return ( shadowDarkness );
   }
   inline static int InactiveButtonColorType()
   {
      return ( inactiveButtonColor );
   }
   inline static int MenuBackground()
   {
      return (menuBackground);
   }
   inline static int MenuOpacity()
   {
      return (menuOpacity);
   }
   inline static bool UseCustomMenuColor()
   {
      return (useCustomMenuColor);
   }
   inline static int DotlineStyle()
   {
      return (dotlineStyle);
   }
   inline static bool MenuColorButton()
   {
      return (menuColorButton);
   }
   inline static int ExpanderStyle()
   {
      return (expanderStyle);
   }
   inline static bool UseCustomExpanderColor()
   {
      return (useCustomExpanderColor);
   }
   inline static QColor CustomExpanderColor()
   {
      return (expanderColor);
   }
   inline static QColor DotlineColor()
   {
      return (dotlineColor);
   }
   inline QColor InactiveButtonColor()
   {
      switch (inactiveButtonColor)
      {
      case 0 : return (QColor(232,232,232));
      case 1 : return (bgColor());
      case 2 : return (buttonColor());
      case 3 : return (customInactiveButtonColor);
      }
   }
   inline static bool CenterTabs()
   {
      return centerTabs;
   }

   inline static bool SmoothListViewHeaders()
   {
      return smoothListViewHeaders;
   }

   inline static bool SmootherLVH()
   {
      return smootherLVH;
   }
		
   inline static bool IcyButtons()
   {
      return icyButtons;
   }

   inline static Style buttonStyle()
   {
      return _buttonStyle;
   }

   inline static int ProgressBar()
   {
      return progressBar;
   }

   inline static bool RemoveKickerBevel()
   {
      return removeKickerBevel;
   }

   inline static Style toolbuttonStyle()
   {
      return _toolbuttonStyle;
   }

   inline void setGroupShadowButton()
   {
      groupShadowButton = true;
   }
   inline void setNotGroupShadowButton()
   {
      groupShadowButton = false;
   }
   inline bool GroupShadowButton()
   {
      return groupShadowButton;
   }

   inline void setScrollerActive()
   {
      scrollerActive = true;
   }

   inline void setScrollerInactive()
   {
      scrollerActive = false;
   }

   inline bool ScrollerActive()
   {
      return scrollerActive;
   }

   inline static QColor Color()
   {
      return color;
   }

   inline static QColor Color2()
   {
      return color2;
   }
		
   inline static bool DrawProgressLabel()
   {
      return drawProgressLabel;
   }
		
   inline static tabStyle TabStyle()
   {
      return tabStyle_;
   }
		
   inline static QColor & BrushTint()
   {
      return brushTint;
   }
		
   inline static bool TintBrush()
   {
      return tintBrush;
   }
		
   inline static bool AnimateSlider()
   {
      return animateSlider;
   }
   inline static bool AnimateProgress()
   {
      return animateProgress;
   }
   inline static QColor CustomButtonColor()
   {
      return customButtonColor;
   }
   
   inline static bool AnimateButton()
   {
      return animateButton;
   }
   
   inline static QColor aDecoColor1()
   {
      return aDecoColor1_;
   }
   inline static QColor aDecoColor2()
   {
      return aDecoColor2_;
   }
   inline static QColor titleColor( int i )
   {
      return titleColor_[i];
   }
   inline static QColor titleButtonColor( int i )
   {
      return titleButtonColor_[i];
   }
		
   QMenuBar *currentMenu;
   QPixmap *indicatedMenuItemPix;
   QRect *indicatedMenuItemRect;
   QPixmap *lastIndicatedMenuItemPix;
   QRect *lastIndicatedMenuItemRect;
   bool mouseOverMenu;
   WId lastIndicatedMenuItemID;
   static unsigned long wmDesign;

		
public slots:
   inline void warningSlot()
   {
      qWarning("widget destroyed");
   }
		
protected:
   static QColor titleColor_[2];
   static QColor titleButtonColor_[3];

   // menu
   static int menuBackground;
   static int menuOpacity;
   static bool menuColorButton;
   static bool animateButton;
   static bool shadowText;
   static bool drawMenuStripe_;
   static QColor menuStripeColor_;
   static bool glossyMenus_;
   //color
   static QColor customButtonColor;
   //widgets
   static bool customWidgetColor;
   static QColor customColors[ 10 ];
   //menu
   static bool useCustomMenuColor;
   static QColor color, color2, colorHigh, fgColor, fgColorHigh;
   //incativeButton
   static int inactiveButtonColor;
   static QColor customInactiveButtonColor;

   //Design
   //stipples
   static bool bgStipple, bevelHighlights_;
   static Style style_;
   static int contrast;
   //shadows
   static bool groupboxshadow;
   static int shadowDarkness;
   //istviews;
   static bool drawDotlines, useCustomExpanderColor;
   static int expanderStyle;
   static QColor expanderColor, dotlineColor;
   static int dotlineStyle;
   //slider
   static bool squeezesbslider;
   static bool shadowsbslider;
   //toolbar
   static bool reverseBtnColor, tbFrame;
   //tweaks
   static bool centerTabs;
   static bool smoothListViewHeaders;
   static bool smootherLVH;
   static bool icyButtons;
   static Style _buttonStyle;
   bool menusProcessed;
   bool scrollerActive;
   int menuLevelCounter;
   bool groupShadowButton;
   static int progressBar;
   static bool removeKickerBevel;
   static Style _toolbuttonStyle;
   static bool drawProgressLabel;
   static tabStyle tabStyle_;
   
   QString colorStr, fgColorStr/*, panelColorStr*/;
   static QColor brushTint;
   static QColor aDecoColor1_;
   static QColor aDecoColor2_;
   static bool tintBrush;
   static bool animateSlider;
   static bool animateProgress;
};
	
class EventKiller : public QObject 
{
   Q_OBJECT
public:
   bool eventFilter( QObject *, QEvent *)
   {
      return TRUE;
   }
};
    
class BMShower : public QObject 
{
   Q_OBJECT
public:
   BMShower(QObject *parent);
   bool eventFilter( QObject *object, QEvent *event );
};
    
class ButtonFadeInfo 
{
public:
   ButtonFadeInfo()
   {
   timerId=0; index=0; fadeIn=TRUE;
   }
public:
   int timerId;
   int index;
   bool fadeIn;
};

class LiquidStyle : public KStyle
{
   Q_OBJECT
public:
   friend class OptionHandler;
   LiquidStyle();
   virtual ~LiquidStyle();
   bool isPlain() const;
   
   virtual void polish( QWidget *w );
//                 virtual void polishPopupMenu( QPopupMenu *w );
   virtual void unPolish( QWidget *w );
   virtual void polish( QPalette &p );
   virtual void unPolish( QApplication *a );
   int styleHint(StyleHint sh, const QWidget * w, const QStyleOption & opt, QStyleHintReturn * shr) const;
   void drawKStylePrimitive( KStylePrimitive kpe, QPainter* p, const QWidget* widget, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, const QStyleOption& = QStyleOption::Default ) const;
   void drawPrimitive( PrimitiveElement pe, QPainter* p, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, const QStyleOption& = QStyleOption::Default ) const;
   void drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, const QStyleOption& = QStyleOption::Default ) const;
//		void drawControlMask( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& = QStyleOption::Default ) const;
   void drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, SCFlags controls = SC_All, SCFlags active = SC_None, const QStyleOption& = QStyleOption::Default ) const;
//		void drawComplexControlMask( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& = QStyleOption::Default ) const;

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

   QSize sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentSize, const QStyleOption& opt ) const;
   QRect subRect( SubRect r, const QWidget *widget ) const;
   QRect querySubControlMetrics( ComplexControl control, const QWidget *widget, SubControl subcontrol, const QStyleOption &opt = QStyleOption::Default ) const;
   // Fix Qt3's wacky image positions
   QPixmap stylePixmap( StylePixmap stylepixmap, const QWidget *widget = 0, const QStyleOption& = QStyleOption::Default ) const;
   bool eventFilter( QObject *object, QEvent *event );
		
private slots:
   void updateProgressPos();
   void updateSliderPos();
   void progressBarDestroyed(QObject*);
   void fakeMouse();
	
protected:
   void clearImage( QImage &img ) const;
   ButtonTile* createButtonTile( const QColor &c, const QColor &bgColor, QImage *buttonImage, QImage *shadowImage, QImage *glowImage, QIntDict <ButtonTile>*buttonDict, QIntDict<ButtonTile>*shadowDict, QIntDict<ButtonTile>*glowDict, int w, int h, int xOff, int yOff, int centerW, int centerH, int shadowH, int glowWH, bool sunken) const;
   ButtonTile* createRoundFrameTile(QImage &img, const QColor &color, const QColor *bg, const QColor &baseColor ) const;
   QPixmap* createSliderEnd( const QColor &c, const QColor &bgColor, bool top/*, bool vertical*/ ) const;
   ButtonTile* separateTiles( QPixmap *pix, int xO, int yO, int w, int h, int sh, bool sunken) const;
   
   QPixmap* getPixmap( BitmapData item ) const;
   QPixmap* adjustHSV( QImage &img, const QColor &c, const QColor *bg = NULL ) const;
   QImage* adjustHSVImage( QImage &img, const QColor &c, const QColor *bg = NULL ) const;
   void adjustHSV( QPixmap &pix, const QColor &c ) const;
   QImage* tintBrush( const QImage &img, const QColor &c ) const;
   QPixmap* processEmbedded( const char *label, const QColor &c, bool blend = false, const QColor *bg = NULL ) const;
   void drawRoundButton( QPainter *p, const QColorGroup &cg, const QColor &c, /*const QColor &bg,*/ int x, int y, int w, int h, bool pushedDown = false, bool hover = false, int bgX = -1, int bgY = -1) const;
   void drawRectangularButton( QPainter *p, const QColorGroup &cg, const QColor &c, int x, int y, int w, int h, bool sunken = false, bool hover = false, bool isCombo = false, int position = full, bool isHtml = false) const;
   void drawCombo( QPainter *painter, const QColorGroup &cg, const QColor &c, int x, int y, int w, int h, bool sunken, bool hover, bool isCombo, int position = full, bool isHTML = false ) const;
   void drawEditFrame( QPainter *p, const QRect &r, const QColorGroup &cg, bool isHTML = false, bool focused = false, bool inverse = false/*, bool round = false*/ ) const;
   void drawRoundFrame( QPainter *p, const QRect &r, const QColorGroup &cg, bool focused, QPoint offset ) const;
   void drawHTMLCBBorder( const QPixmap &pix, const QColor &c ) const;
   bool isHTMLWidget( const QWidget *w ) const;


private:
   LiquidStyle( const LiquidStyle & );
   LiquidStyle& operator=( const LiquidStyle & );
   int getBrightness(unsigned int rgb) const;
   QImage fetchImage( const char *name );
   QColor mapFadeColor(QColor &color, int index) const;
   void fadeIn(QPushButton *button);
   void fadeOut(QPushButton *button);
   QColor brushedMetalColor(QColor &c) const;
   QColor originalBgColor;
   
   
   QBitmap *sbLeft, *sbRight, *sbUp, *sbDown, *checkmark;
   QImage *btnBorderImg, *btnShadowImg, *slider_top, *slider_btm, *slider_top_shd, *slider_btm_shd, *rectbutton, *combo, *comboShadow, *buttonGlow, *roundFrame;
   QPixmap *btnBlendPix, *menuPix, *groupShadow ;
   QPixmap plainBrush, gradBrush;
   QBrush pagerBrush, pagerHoverBrush;

   QPixmap *pixmaps[ BITMAP_ITEMS ];
   QPixmap sbBuffer;
   QScrollBar *currentScrollBar;
   QWMatrix lMatrix;
   QWMatrix rMatrix;
   QWMatrix iMatrix;
   QWMatrix mMatrix;
   QWMatrix m2Matrix;

   bool isKicker, isOOO, isHTMLButton, initialPaletteLoaded, inExitPolish;

   QHeader *currentHeader;
   QTabBar *currentTabBar;
   int headerHoverID;
   int headerSortID;
   QPoint btnOffset;
   QPoint cursorPos_;
   QWidget *currentTaskContainer;
   KPixmap activeToolbarPix;
   bool isTaskContainer, taskContainerHover;

   QPalette polishedPalette, tooltipPalette;
   unsigned int qtrcModificationTime;
   
   int progAnimShift;
   int prog2AnimShift;
   int sliderAnimShift;
   int hoveredTabIndex;
   bool mouseButtonPressed_;

   OptionHandler *optionHandler;

   QIntDict<ButtonTile>btnDict;
   QIntDict<ButtonFadeInfo>bfi;
   QIntDict<QRgb*>fadeColorMap;
   QIntDict<ButtonTile>btnShadowedDict;
   QIntDict<ButtonTile>buttonGlowDict;
   QIntDict<ButtonTile>comboDict;
   QIntDict<ButtonTile>comboShadowedDict;
   QIntDict<ButtonTile>tabDict;
   QIntDict<ButtonTile>inverseTabDict;
   QIntDict<ButtonTile>rectBtnDict;
   QIntDict<ButtonTile>progress2Dict;
   QMap<QWidget*, int> progAnimWidgets;

   QPixmap *tmpBtnPix;
   ButtonTile *inactiveRoundFrame;
   ButtonTile *activeRoundFrame;

   QWidget *highlightWidget;
   QScrollBar *activeScroller;
   EventKiller *eventKiller;
   BMShower *bmShower;
   static QPixmap popupBack;
   QWidget *paintWidget;
};
	
#endif