File: mstyle.h

package info (click to toggle)
musescore 2.0.3%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 202,532 kB
  • ctags: 58,769
  • sloc: cpp: 257,595; xml: 172,226; ansic: 139,931; python: 6,565; sh: 6,383; perl: 423; makefile: 290; awk: 142; pascal: 67; sed: 3
file content (740 lines) | stat: -rw-r--r-- 37,461 bytes parent folder | download | duplicates (2)
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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
//=============================================================================
//  MuseScore
//  Linux Music Score Editor
//  $Id:$
//
//  Copyright (C) 2010 Werner Schweer and others
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2.
//
//  This program 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 General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================

#ifndef __MSTYLE_H__
#define __MSTYLE_H__

#include "tileset.h"
#include "stylehelper.h"

class StyleHelper;
class FrameShadowFactory;
class WidgetExplorer;
class Animations;
class Transitions;

//---------------------------------------------------------
//   MgStyle
//---------------------------------------------------------

class MgStyle : public QCommonStyle {
            Q_OBJECT

            //! arrow orientation
            enum ArrowOrientation {
                  ArrowNone, ArrowUp, ArrowDown, ArrowLeft, ArrowRight
                  };

            //! get polygon corresponding to generic arrow
            enum ArrowSize {
                  ArrowNormal, ArrowSmall, ArrowTiny
                  };

            //! internal option flags to pass arguments around
            enum StyleOption {
                  Sunken = 0x1,
                  Focus = 0x2,
                  Hover = 0x4,
                  Disabled = 0x8,
                  NoFill = 0x10,
                  SubtleShadow = 0x20
                  };

            Q_DECLARE_FLAGS(StyleOptions, StyleOption)

            //! used to store slab characteristics
            class SlabRect {
                  public:
                        //! constructor
                        SlabRect(void): _tiles( TileSet::Ring ) {}

                        //! constructor
                        SlabRect( const QRect& r, const int& tiles ): _r( r ), _tiles( TileSet::Tiles( tiles ) ) {}

                        QRect _r;
                        TileSet::Tiles _tiles;
                  };

            //! list of slabs
            typedef QList<SlabRect> SlabRectList;

            /*!
            tabBar data class needed for
            the rendering of tabbars when
            one tab is being drawn
            */
            class TabBarData: public QObject {
                        QWeakPointer<const MgStyle> _style;   //! pointer to parent style object
                        QWeakPointer<const QWidget> _tabBar; //! pointer to target tabBar
                        bool _dirty;                         //! if true, will paint on next TabBarTabShapeControlCall

                  public:
                        TabBarData(MgStyle* parent):
                              QObject(parent),
                              _style(parent),
                              _dirty(false)
                              {}

                        virtual ~TabBarData() {}

                        //! assign target tabBar
                        void lock(const QWidget* widget) {
                              _tabBar = widget;
                              }

                        //! true if tabbar is locked
                        bool locks( const QWidget* widget ) const {
                              return _tabBar && _tabBar.data() == widget;
                              }

                        void setDirty(const bool& value = true) {
                              _dirty = value;
                              }
                        void release()                          {
                              _tabBar.clear();
                              }
                        virtual void drawTabBarBaseControl(const QStyleOptionTab*, QPainter*, const QWidget*);
                  };

            bool emptyControl(const QStyleOption*, QPainter*, const QWidget*) const {
                  return true;
                  }
            bool drawMenuBarItem(const QStyleOption*, QPainter*, const QWidget*) const;

            //! metrics
            /*! these are copied from the old KStyle WidgetProperties */
            enum InternalMetrics {
                  GlowWidth = 1,

                  // checkbox. Do not change, unless
                  // changing the actual cached pixmap size
                  CheckBox_Size = 21,
                  CheckBox_BoxTextSpace = 4,

                  // combobox
                  ComboBox_FrameWidth = 3,
                  ComboBox_ButtonWidth = 19,
                  ComboBox_ButtonMargin = 2,
                  ComboBox_ButtonMargin_Left = 0,
                  ComboBox_ButtonMargin_Right = 4,
                  ComboBox_ButtonMargin_Top = 2,
                  ComboBox_ButtonMargin_Bottom = 1,

                  ComboBox_ContentsMargin = 0,
                  ComboBox_ContentsMargin_Left = 2,
                  ComboBox_ContentsMargin_Right = 0,
                  ComboBox_ContentsMargin_Top = 0,
                  ComboBox_ContentsMargin_Bottom = 0,

                  // dockwidgets
                  DockWidget_FrameWidth = 0,
                  DockWidget_SeparatorExtend = 3,
                  DockWidget_TitleMargin = 3,

                  // generic frames
                  Frame_FrameWidth = 3,

                  // group boxes
                  GroupBox_FrameWidth = 3,

                  // header
                  Header_TextToIconSpace = 3,
                  Header_ContentsMargin = 3,

                  // line edit
                  LineEdit_FrameWidth = 3,

                  // menu item
                  MenuItem_AccelSpace = 16,
                  MenuItem_ArrowWidth = 11,
                  MenuItem_ArrowSpace = 3,
                  MenuItem_CheckWidth = 16,
                  MenuItem_CheckSpace = 3,
                  MenuItem_IconWidth = 12,
                  MenuItem_IconSpace = 3,
                  MenuItem_Margin = 2,
                  MenuItem_MinHeight = 20,

                  // menu bar item
                  MenuBarItem_Margin = 3,
                  MenuBarItem_Margin_Left = 5,
                  MenuBarItem_Margin_Right = 5,

                  // pushbuttons
                  PushButton_ContentsMargin        = 5,
                  PushButton_ContentsMargin_Left   = 8,
                  PushButton_ContentsMargin_Top    = -1,
                  PushButton_ContentsMargin_Right  = 8,
                  PushButton_ContentsMargin_Bottom = 0,
                  PushButton_MenuIndicatorSize     = 8,
                  PushButton_TextToIconSpace       = 6,

                  // progress bar
                  ProgressBar_BusyIndicatorSize = 10,
                  ProgressBar_GrooveMargin = 2,

                  // scrollbar
                  ScrollBar_MinimumSliderHeight = 21,

                  // spin boxes
                  SpinBox_FrameWidth = 3,
                  SpinBox_ButtonWidth = 19,
                  SpinBox_ButtonMargin = 0,
                  SpinBox_ButtonMargin_Left = 2,
                  SpinBox_ButtonMargin_Right = 6,
                  SpinBox_ButtonMargin_Top = 4,
                  SpinBox_ButtonMargin_Bottom = 2,

                  // splitter
                  Splitter_Width = 3,

                  // tabs
                  TabBar_BaseOverlap = 7,
                  TabBar_BaseHeight = 2,
                  TabBar_ScrollButtonWidth = 18,
                  TabBar_TabContentsMargin = 4,
                  TabBar_TabContentsMargin_Left = 5,
                  TabBar_TabContentsMargin_Right = 5,
                  TabBar_TabContentsMargin_Top = 2,
                  TabBar_TabContentsMargin_Bottom = 4,
                  TabBar_TabOverlap = 0,

                  TabWidget_ContentsMargin = 4,

                  // toolbuttons
                  ToolButton_ContentsMargin = 4,
                  ToolButton_InlineMenuIndicatorSize = 8,
                  ToolButton_InlineMenuIndicatorXOff = -11,
                  ToolButton_InlineMenuIndicatorYOff = -10,
                  ToolButton_MenuIndicatorSize = 11,

                  Tree_MaxExpanderSize = 9
                  };

            //! scrollbar buttons
            enum ScrollBarButtonType {
                  NoButton,
                  SingleButton,
                  DoubleButton
                  };

            //! returns height for scrollbar buttons depending of button types
            int scrollBarButtonHeight( const ScrollBarButtonType& type ) const {
                  switch ( type ) {
                        case NoButton:
                              return _noButtonHeight;
                        case SingleButton:
                              return _singleButtonHeight;
                        case DoubleButton:
                              return _doubleButtonHeight;
                        default:
                              return 0;
                        }
                  }
            //! adjusted slabRect
            inline void adjustSlabRect( SlabRect& slab, const QRect&, bool documentMode, bool vertical ) const;

            //! qdial slab
            void renderDialSlab( QPainter* p, const QRect& r, const QColor& c, const QStyleOption* option, StyleOptions opts = 0 ) const {
                  renderDialSlab( p, r, c, option, opts, -1,  AnimationNone );
                  }

            //! qdial slab
            void renderDialSlab( QPainter*, const QRect&, const QColor&, const QStyleOption*, StyleOptions, qreal, AnimationMode ) const;

            //! generic button slab
            void renderButtonSlab( QPainter* p, QRect r, const QColor& c, StyleOptions opts = 0, TileSet::Tiles tiles = TileSet::Ring) const {
                  renderButtonSlab( p, r, c, opts, -1,  AnimationNone, tiles );
                  }

            //! generic button slab
            void renderButtonSlab( QPainter*, QRect, const QColor&, StyleOptions, qreal, AnimationMode, TileSet::Tiles ) const;

            //! generic slab
            void renderSlab( QPainter* painter, const SlabRect& slab, const QColor& color, StyleOptions options = 0 ) const {
                  renderSlab( painter, slab._r, color, options, slab._tiles );
                  }

            //! generic slab
            void renderSlab( QPainter* painter, QRect rect, const QColor& color, StyleOptions options = 0, TileSet::Tiles tiles = TileSet::Ring) const {
                  renderSlab( painter, rect, color, options, -1, AnimationNone, tiles );
                  }

            //! generic slab
            void renderSlab( QPainter* painter, const SlabRect& slab, const QColor& color, StyleOptions options, qreal opacity, AnimationMode mode ) const {
                  renderSlab( painter, slab._r, color, options, opacity, mode, slab._tiles );
                  }

            //! generic slab
            void renderSlab( QPainter*, QRect, const QColor&, StyleOptions, qreal, AnimationMode, TileSet::Tiles ) const;

            // render tab background
            void renderTabBackground( QPainter*, const QRect&, const QPalette&, const QTabBar::Shape, const QWidget* ) const;

            //! tab background
            /*! this paints window background behind tab when tab is being dragged */
            void fillTabBackground( QPainter*, const QRect&, const QColor&, const QTabBar::Shape, const QWidget* ) const;

            //! tab filling
            void fillTab( QPainter*, const QRect&, const QColor&, const QTabBar::Shape, bool active ) const;

            // scrollbar button types (for addLine and subLine )
            ScrollBarButtonType _addLineButtons;
            ScrollBarButtonType _subLineButtons;

            // metrics for scrollbar buttons
            int _noButtonHeight;
            int _singleButtonHeight;
            int _doubleButtonHeight;

            // mnemonic state
            Qt::TextFlag _mnemonic;

            StyleHelper _helper;
            Animations* _animations;
            Transitions* _transitions;
//      WindowManager* _windowManager;
            FrameShadowFactory* _frameShadowFactory;

            //! widget explorer
//      WidgetExplorer* _widgetExplorer;

            //! tabBar data
            TabBarData* _tabBarData;

            //! pointer to primitive specialized function
            typedef bool (MgStyle::*StylePrimitive)( const QStyleOption*, QPainter*, const QWidget* ) const;
            StylePrimitive _frameFocusPrimitive;

            //! pointer to control specialized function
            typedef bool (MgStyle::*StyleControl)( const QStyleOption*, QPainter*, const QWidget* ) const;
            StyleControl _tabBarTabShapeControl;

            //! pointer to control specialized function
            typedef bool (MgStyle::*StyleComplexControl)( const QStyleOptionComplex*, QPainter*, const QWidget* ) const;

            int _hintCounter;
            int _controlCounter;
            int _subElementCounter;
            QHash<QString, int> _styleElements;

            QStyle::ControlElement CE_CapacityBar;

            void renderSplitter(const QStyleOption*, QPainter*, const QWidget*, bool) const;

            QSize expandSize(const QSize& size, int main, int left = 0, int top = 0, int right = 0, int bottom = 0) const;
            QSize checkBoxSizeFromContents(const QStyleOption*, const QSize&, const QWidget*) const;
            QSize comboBoxSizeFromContents(const QStyleOption*, const QSize&, const QWidget*) const;
            QSize headerSectionSizeFromContents(const QStyleOption*, const QSize&, const QWidget*) const;
            QSize menuItemSizeFromContents(const QStyleOption*, const QSize&, const QWidget*) const;
            QSize pushButtonSizeFromContents(const QStyleOption*, const QSize&, const QWidget*) const;
            QSize tabBarTabSizeFromContents(const QStyleOption*, const QSize& size, const QWidget*) const;
            QSize toolButtonSizeFromContents(const QStyleOption*, const QSize&, const QWidget*) const;
            //! returns true for vertical tabs
            bool isVerticalTab(const QStyleOptionTab* option) const {
                  return isVerticalTab(option->shape);
                  }
            bool isVerticalTab(const QTabBar::Shape& shape) const;
            void polishScrollArea(QAbstractScrollArea* scrollArea) const;

            bool drawPanelTipLabelPrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget) const;
            bool drawFramePrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawFrameFocusRectPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawFrameGroupBoxPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawFrameMenuPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawFrameTabBarBasePrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawFrameTabWidgetPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawFrameWindowPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawIndicatorArrowUpPrimitive(const QStyleOption* option, QPainter* painter, const QWidget* widget) const {
                  return drawIndicatorArrowPrimitive( ArrowUp, option, painter, widget );
                  }
            bool drawIndicatorArrowDownPrimitive(const QStyleOption* option, QPainter* painter, const QWidget* widget) const {
                  return drawIndicatorArrowPrimitive( ArrowDown, option, painter, widget );
                  }
            bool drawIndicatorArrowLeftPrimitive(const QStyleOption* option, QPainter* painter, const QWidget* widget) const {
                  return drawIndicatorArrowPrimitive( ArrowLeft, option, painter, widget );
                  }
            bool drawIndicatorArrowRightPrimitive(const QStyleOption* option, QPainter* painter, const QWidget* widget) const {
                  return drawIndicatorArrowPrimitive( ArrowRight, option, painter, widget );
                  }
            bool drawIndicatorArrowPrimitive( ArrowOrientation, const QStyleOption*, QPainter*, const QWidget* ) const;

            //! dock widget separators
            /*! it uses the same painting as QSplitter, but due to Qt, the horizontal/vertical convention is inverted */
            bool drawIndicatorDockWidgetResizeHandlePrimitive(const QStyleOption* option,
                        QPainter* painter, const QWidget* widget) const {
                  renderSplitter(option, painter, widget, !(option->state & State_Horizontal));
                  return true;
                  }

            bool drawIndicatorHeaderArrowPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawPanelButtonCommandPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawPanelMenuPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawPanelButtonToolPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawPanelScrollAreaCornerPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawPanelItemViewItemPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawPanelLineEditPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawIndicatorBranchPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawIndicatorButtonDropDownPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawIndicatorCheckBoxPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawIndicatorRadioButtonPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawIndicatorTabTearPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawIndicatorToolBarHandlePrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawIndicatorToolBarSeparatorPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawWidgetPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const;

            //! checkbox state (used for checkboxes _and_ radio buttons)
            enum CheckBoxState {
                  CheckOn,
                  CheckOff,
                  CheckTriState
                  };
            void renderRadioButton(QPainter*, const QRect&, const QPalette&, StyleOptions,
                                   CheckBoxState, qreal opacity = -1, AnimationMode mode = AnimationNone) const;
            QColor slabShadowColor( QColor, StyleOptions, qreal, AnimationMode ) const;

            //! checkbox
            void renderCheckBox( QPainter*, const QRect&, const QPalette&, StyleOptions, CheckBoxState, qreal opacity = -1, AnimationMode mode = AnimationNone ) const;
            void renderScrollBarHole( QPainter*, const QRect&, const QColor&, const Qt::Orientation&, const TileSet::Tiles& = TileSet::Full ) const;
            //! scrollbar handle (non animated)
            void renderScrollBarHandle(
                  QPainter* painter, const QRect& r, const QPalette& palette,
                  const Qt::Orientation& orientation, const bool& hover) const {
                  renderScrollBarHandle( painter, r, palette, orientation, hover, -1 );
                  }

            void renderScrollBarHandle( QPainter*, const QRect&, const QPalette&, const Qt::Orientation&, const bool&, const qreal& ) const;
            void renderScrollBarArrow( QPainter*, const QRect&, const QColor&, const QColor&, ArrowOrientation ) const;
            QColor scrollBarArrowColor( const QStyleOption*, const SubControl&, const QWidget* ) const;
            void renderSliderTickmarks( QPainter*, const QStyleOptionSlider*, const QWidget* ) const;
            QPolygonF genericArrow(ArrowOrientation, ArrowSize = ArrowNormal) const;
            QRect centerRect(const QRect& in, const QSize& s ) const {
                  return centerRect( in, s.width(), s.height() );
                  }
            QRect centerRect(const QRect& in, int w, int h) const {
                  return QRect(in.x() + (in.width() - w) / 2, in.y() + (in.height() - h) / 2, w, h);
                  }
            //! adjust rect based on provided margins
            QRect insideMargin( const QRect& r, int main, int left = 0, int top = 0, int right = 0, int bottom = 0 ) const {
                  return r.adjusted( main + left, main + top, -main - right, -main - bottom );
                  }
            //! generic element
            int newStyleElement( const QString& element, const char* check, int& counter) {
                  if ( !element.contains(check) )
                        return 0;
                  int id = _styleElements.value(element, 0);
                  if ( !id ) {
                        ++counter;
                        id = counter;
                        _styleElements.insert(element, id);
                        }
                  return id;
                  }

            //! style hint
            QStyle::StyleHint newStyleHint( const QString& element ) {
                  return (StyleHint) newStyleElement( element, "SH_", _hintCounter );
                  }

            //! control element
            QStyle::ControlElement newControlElement( const QString& element ) {
                  return (ControlElement)newStyleElement( element, "CE_", _controlCounter );
                  }

            //! subElement
            QStyle::SubElement newSubElement(const QString& element ) {
                  return (SubElement)newStyleElement( element, "SE_", _subElementCounter );
                  }
            bool drawComboBoxComplexControl(const QStyleOptionComplex*, QPainter*, const QWidget*) const;
            bool drawDialComplexControl(const QStyleOptionComplex*, QPainter*, const QWidget*) const;
            bool drawGroupBoxComplexControl(const QStyleOptionComplex*, QPainter*, const QWidget*) const;
            bool drawSliderComplexControl(const QStyleOptionComplex*, QPainter*, const QWidget*) const;
            bool drawSpinBoxComplexControl(const QStyleOptionComplex*, QPainter*, const QWidget*) const;
            bool drawTitleBarComplexControl(const QStyleOptionComplex*, QPainter*, const QWidget*) const;
            bool drawToolButtonComplexControl(const QStyleOptionComplex*, QPainter*, const QWidget*) const;

            bool eventFilterComboBoxContainer( QWidget*, QEvent* );
            bool eventFilterDockWidget( QDockWidget*, QEvent* );
            bool eventFilterMdiSubWindow( QMdiSubWindow*, QEvent* );
            bool eventFilterScrollBar( QWidget*, QEvent* );
            bool eventFilterTabBar( QWidget*, QEvent* );
            bool eventFilterToolBar( QToolBar*, QEvent* );
            bool eventFilterToolBox( QToolBox*, QEvent* );

            bool drawCapacityBarControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawComboBoxLabelControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawDockWidgetTitleControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawHeaderEmptyAreaControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawHeaderLabelControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawHeaderSectionControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawMenuBarItemControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawMenuItemControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawProgressBarControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawProgressBarContentsControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawProgressBarGrooveControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawProgressBarLabelControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawPushButtonLabelControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawRubberBandControl( const QStyleOption*, QPainter*, const QWidget* ) const;

            //! scrollbar
            bool drawScrollBarSliderControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawScrollBarAddLineControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawScrollBarSubLineControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawScrollBarAddPageControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawScrollBarSubPageControl( const QStyleOption*, QPainter*, const QWidget* ) const;

            bool drawShapedFrameControl( const QStyleOption*, QPainter*, const QWidget* ) const;

            // splitters
            bool drawSplitterControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const {
                  renderSplitter( option, painter, widget, option->state & State_Horizontal );
                  return true;
                  }

            bool drawTabBarTabLabelControl( const QStyleOption*, QPainter*, const QWidget* ) const;

            //! tabbar tabs.
            /*! there are two methods (_Single and _Plain) implemented, to deal with tabbar appearance selected from options */
            bool drawTabBarTabShapeControl_Single( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawTabBarTabShapeControl_Plain( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawToolBarControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawToolBoxTabLabelControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawToolBoxTabShapeControl( const QStyleOption*, QPainter*, const QWidget* ) const;
            bool drawToolButtonLabelControl( const QStyleOption*, QPainter*, const QWidget* ) const;

            QRect handleRTL(const QStyleOption* opt, const QRect& subRect) const {
                  return visualRect(opt->direction, opt->rect, subRect);
                  }

            //! right to left alignment handling
            QPoint handleRTL(const QStyleOption* opt, const QPoint& pos) const {
                  return visualPos(opt->direction, opt->rect, pos);
                  }

            //! tiles from tab orientation
            inline TileSet::Tiles tilesByShape( const QTabBar::Shape& shape) const;

            //! toolbar mask
            /*! this masks out toolbar expander buttons, when visible, from painting */
            QRegion tabBarClipRegion( const QTabBar* ) const;
            inline QStyle::SubControl scrollBarHitTest(const QRect& rect, const QPoint& point, const QStyleOption* option) const;
            inline bool preceeds( const QPoint& point, const QRect& bound, const QStyleOption* option ) const;
            TabBarData& tabBarData() const {
                  return *_tabBarData;
                  }

            QRect groupBoxSubControlRect( const QStyleOptionComplex*, SubControl, const QWidget* ) const;
            QRect comboBoxSubControlRect( const QStyleOptionComplex*, SubControl, const QWidget* ) const;
            QRect scrollBarSubControlRect( const QStyleOptionComplex*, SubControl, const QWidget* ) const;
            QRect sliderSubControlRect( const QStyleOptionComplex*, SubControl, const QWidget* ) const;
            QRect spinBoxSubControlRect( const QStyleOptionComplex*, SubControl, const QWidget* ) const;

            //! this properly handles single/double or no scrollBar buttons
            QRect scrollBarInternalSubControlRect( const QStyleOptionComplex*, SubControl ) const;

            //! menu item background
            void renderMenuItemBackground( const QStyleOption*, QPainter*, const QWidget* ) const;

            void renderMenuItemRect( const QStyleOption* opt, const QRect& rect, const QPalette& pal,
                                     QPainter* p, qreal opacity = -1 ) const {
                  renderMenuItemRect( opt, rect, pal.color(QPalette::Window), p, opacity );
                  }

            void renderMenuItemRect( const QStyleOption*, const QRect&, const QColor&, const QPalette&, QPainter* p, qreal opacity = -1 ) const;

            //! header background
            void renderHeaderBackground( const QRect&, const QPalette&, QPainter*, const QWidget*, bool horizontal, bool reverse ) const;
            void renderHeaderLines( const QRect&, const QPalette&, QPainter*, TileSet::Tiles ) const;

            //! mdi subwindow titlebar button
            void renderTitleBarButton( QPainter*, const QStyleOptionTitleBar*, const QWidget*, const SubControl& ) const;
            void renderTitleBarIcon( QPainter*, const QRectF&, const SubControl& ) const;
            void renderSpinBoxArrow( QPainter*, const QStyleOptionSpinBox*, const QWidget*, const SubControl& ) const;
            //! default implementation. Does not change anything
            QRect defaultSubElementRect( const QStyleOption* option, const QWidget* ) const {
                  return option->rect;
                  }

            //! pushbutton contents
            QRect pushButtonContentsRect( const QStyleOption* option, const QWidget* ) const {
                  return insideMargin( option->rect,
                                       PushButton_ContentsMargin,
                                       PushButton_ContentsMargin_Left,
                                       PushButton_ContentsMargin_Top,
                                       PushButton_ContentsMargin_Right,
                                       PushButton_ContentsMargin_Bottom );
                  }

            //! toolbox tab
            QRect toolBoxTabContentsRect( const QStyleOption* option, const QWidget* ) const {
                  return insideMargin( option->rect, 0, 5, 0, 5, 0 );
                  }

            QRect checkBoxContentsRect( const QStyleOption* option, const QWidget* ) const {
                  return handleRTL( option, option->rect.adjusted( CheckBox_Size + CheckBox_BoxTextSpace, 0, 0, 0 ) );
                  }

            QRect progressBarContentsRect( const QStyleOption* option, const QWidget* ) const {
                  return insideMargin( option->rect, ProgressBar_GrooveMargin );
                  }

            //! tabBar buttons
            QRect tabBarTabLeftButtonRect( const QStyleOption* option, const QWidget* widget ) const {
                  return tabBarTabButtonRect( SE_TabBarTabLeftButton, option, widget );
                  }

            QRect tabBarTabRightButtonRect( const QStyleOption* option, const QWidget* widget ) const {
                  return tabBarTabButtonRect( SE_TabBarTabRightButton, option, widget );
                  }

            QRect tabBarTabButtonRect( SubElement, const QStyleOption*, const QWidget* ) const;

            // tabbar tab text
            QRect tabBarTabTextRect( const QStyleOption* option, const QWidget* widget ) const {
                  return QCommonStyle::subElementRect( SE_TabBarTabText, option, widget ).adjusted( 6, 0, -6, 0 );
                  }

            // tab widgets
            QRect tabWidgetTabContentsRect( const QStyleOption*, const QWidget* ) const;
            QRect tabWidgetTabPaneRect( const QStyleOption*, const QWidget* ) const;

            QRect tabWidgetLeftCornerRect( const QStyleOption* option, const QWidget* widget ) const;
            QRect tabWidgetRightCornerRect( const QStyleOption* option, const QWidget* widget ) const;
            bool emptyPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const {
                  return true;
                  }
            QIcon getCachedIcon(QString key) const;

      protected slots:
            virtual QIcon standardIcon(StandardPixmap standardIcon,
                        const QStyleOption* option, const QWidget* widget) const;

      public slots:
            void configurationChanged();

      public:
            MgStyle();
            virtual int pixelMetric(PixelMetric, const QStyleOption* = 0, const QWidget* = 0) const;
            virtual int styleHint(StyleHint, const QStyleOption* = 0, const QWidget* = 0, QStyleHintReturn* = 0) const;
            virtual QRect subElementRect(SubElement, const QStyleOption*, const QWidget*) const;
            virtual QRect subControlRect(ComplexControl, const QStyleOptionComplex*, SubControl, const QWidget*) const;
            QSize sizeFromContents(ContentsType, const QStyleOption*, const QSize&, const QWidget*) const;
            SubControl hitTestComplexControl(ComplexControl, const QStyleOptionComplex*, const QPoint&, const QWidget*) const;

            virtual void polish(QWidget* widget);
            void unpolish(QWidget* widget);
            void drawPrimitive(PrimitiveElement, const QStyleOption*, QPainter*, const QWidget*) const;
            void drawControl(ControlElement, const QStyleOption*, QPainter*, const QWidget*) const;
            void drawComplexControl(ComplexControl, const QStyleOptionComplex*, QPainter*, const QWidget*) const;
            virtual void drawItemText(QPainter*, const QRect&, int alignment, const QPalette&, bool enabled,
                                      const QString&, QPalette::ColorRole = QPalette::NoRole) const;

            virtual bool eventFilter(QObject*, QEvent*);

            Animations& animations() const                 {
                  return *_animations;
                  }
            Transitions& transitions() const               {
                  return *_transitions;
                  }
//      WindowManager& windowManager() const           { return *_windowManager; }
            FrameShadowFactory& frameShadowFactory() const {
                  return *_frameShadowFactory;
                  }
//      virtual QPalette standardPalette() const;
      };

//---------------------------------------------------------
//   preceeds
//---------------------------------------------------------

bool MgStyle::preceeds( const QPoint& point, const QRect& bound, const QStyleOption* option ) const {
      if (option->state & QStyle::State_Horizontal) {
            if (option->direction == Qt::LeftToRight)
                  return point.x() < bound.right();
            else
                  return point.x() > bound.x();
            }
      else
            return point.y() < bound.y();
      }

//---------------------------------------------------------
//   scrollBarHitTest
//---------------------------------------------------------

QStyle::SubControl MgStyle::scrollBarHitTest(const QRect& rect, const QPoint& point, const QStyleOption* option) const {
      if (option->state & QStyle::State_Horizontal) {
            if (option->direction == Qt::LeftToRight )
                  return point.x() < rect.center().x() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
            else
                  return point.x() > rect.center().x() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
            }
      else
            return point.y() < rect.center().y() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
      }

//---------------------------------------------------------
//   tilesByShape
//---------------------------------------------------------

TileSet::Tiles MgStyle::tilesByShape( const QTabBar::Shape& shape ) const {
      switch (shape) {
            case QTabBar::RoundedNorth:
            case QTabBar::TriangularNorth:
                  return TileSet::Top | TileSet::Left | TileSet::Right;

            case QTabBar::RoundedSouth:
            case QTabBar::TriangularSouth:
                  return TileSet::Bottom | TileSet::Left | TileSet::Right;

            case QTabBar::RoundedEast:
            case QTabBar::TriangularEast:
                  return TileSet::Right | TileSet::Top | TileSet::Bottom;

            case QTabBar::RoundedWest:
            case QTabBar::TriangularWest:
                  return TileSet::Left | TileSet::Top | TileSet::Bottom;

            default:
                  return TileSet::Ring;
            }
      }

//---------------------------------------------------------
//   adjustSlabRect
//---------------------------------------------------------

void MgStyle::adjustSlabRect(SlabRect& slab, const QRect& tabWidgetRect, bool documentMode, bool vertical) const {
      // no tabWidget found, do nothing
      if ( documentMode || !tabWidgetRect.isValid() )
            return;
      else if ( vertical ) {
            slab._r.setTop( qMax( slab._r.top(), tabWidgetRect.top() ) );
            slab._r.setBottom( qMin( slab._r.bottom(), tabWidgetRect.bottom() ) );
            }
      else {
            slab._r.setLeft( qMax( slab._r.left(), tabWidgetRect.left() ) );
            slab._r.setRight( qMin( slab._r.right(), tabWidgetRect.right() ) );
            }
      return;
      }
#endif