summaryrefslogtreecommitdiffstats
path: root/src/kernel/qstyle.h
blob: c27d7c9c2f8a6e5a90071f7af722464442dd3b02 (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
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
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
/****************************************************************************
**
** Definition of QStyle class
**
** Created : 980616
**
** Copyright (C) 1992-2008 Trolltech ASA.  All rights reserved.
**
** This file is part of the kernel module of the Qt GUI Toolkit.
**
** This file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the files LICENSE.GPL2
** and LICENSE.GPL3 included in the packaging of this file.
** Alternatively you may (at your option) use any later version
** of the GNU General Public License if such license has been
** publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free Qt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at [email protected].
**
** This file may be used under the terms of the Q Public License as
** defined by Trolltech ASA and appearing in the file LICENSE.QPL
** included in the packaging of this file.  Licensees holding valid Qt
** Commercial licenses may use this file in accordance with the Qt
** Commercial License Agreement provided with the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/
#ifndef QSTYLE_H
#define QSTYLE_H

#ifndef QT_H
#include "qobject.h"
#include "qpixmap.h"
#include "qcolor.h"
#include "qiconset.h"
#include "qtabbar.h"
#include "qtoolbutton.h"
#endif // QT_H


#ifndef QT_NO_STYLE

class QPopupMenu;
class QStylePrivate;
class QMenuItem;
class QTab;
class QListViewItem;
class QCheckListItem;

class Q_EXPORT QStyleOption {
public:
    enum StyleOptionDefault { Default };

    QStyleOption(StyleOptionDefault=Default);
    QStyleOption(int in1);
    QStyleOption(int in1, int in2);
    QStyleOption(int in1, int in2, int in3, int in4);
    QStyleOption(QMenuItem* m);
    QStyleOption(QMenuItem* m, int in1);
    QStyleOption(QMenuItem* m, int in1, int in2);
    QStyleOption(const QColor& c);
    QStyleOption(QTab* t);
    QStyleOption(QListViewItem* i);
    QStyleOption(QCheckListItem* i);
    QStyleOption(Qt::ArrowType a);
    QStyleOption(const QRect& r);
    QStyleOption(QWidget *w);

    bool isDefault() const { return def; }

    int day() const { return i1; }

    int lineWidth() const { return i1; }
    int midLineWidth() const { return i2; }
    int frameShape() const { return i3; }
    int frameShadow() const { return i4; }

    int headerSection() const { return i1; }
    QMenuItem* menuItem() const { return mi; }
    int maxIconWidth() const { return i1; }
    int tabWidth() const { return i2; }

    const QColor& color() const { return *cl; }

    QTab* tab() const { return tb; }

    QCheckListItem* checkListItem() const { return cli; }
    QListViewItem* listViewItem() const { return li; }

    Qt::ArrowType arrowType() const { return (Qt::ArrowType)i1; }
    QRect rect() const { return QRect( i1, i2, i3, i4 ); }
    QWidget* widget() const { return (QWidget*)p1; }

    QStyleOption(QTab* t, QTab* h) : def(FALSE), tb(t), cli(NULL), tbh(h) {}
    QTab* hoverTab() const { return tbh; }

private:
    // NOTE: none of these components have constructors.
    bool def;
    bool b1,b2,b3; // reserved
    QMenuItem* mi;
    QTab* tb;
    QListViewItem* li;
    const QColor* cl;
    int i1, i2, i3, i4;
    int i5, i6; // reserved
    QCheckListItem* cli;
    void *p1, *p2, *p3, *p4; // reserved
    QTab* tbh;
    // (padded to 64 bytes on some architectures)
};

class QStyleHintReturn; // not defined yet

typedef QMap<Q_UINT32, QSize> DialogButtonSizeMap;
typedef QMap<Q_INT32, Q_INT32> TabIdentifierIndexMap;

class QStyleControlElementGenericWidgetData;

class QStyleControlElementPopupMenuData {
	public:
		//
};

class QStyleControlElementCheckListItemData {
	public:
		bool dataValid;
		bool enabled;
		bool hasParent;
		int height;
};

class QStyleControlElementListViewData {
	public:
		bool rootDecorated;
		int itemMargin;
};

class QStyleControlElementSpinWidgetData {
	public:
		Q_UINT32 buttonSymbols;
		QRect upRect;
		QRect downRect;
		bool upEnabled;
		bool downEnabled;
};

class QStyleControlElementTitleBarData {
	public:
		bool hasWindow;
		bool usesActiveColor;
		int windowState;
		QString visibleText;
};

class QStyleControlElementDockWidgetData {
	public:
		bool hasDockArea;
		bool closeEnabled;
		Qt::Orientation areaOrientation;
};

class QStyleControlElementToolBarWidgetData {
	public:
		Qt::Orientation orientation;
};

class QStyleControlElementGenericWidgetData {
	public:
		QStringList widgetObjectTypes;
		bool allDataPopulated;
		Qt::WFlags wflags;
		Qt::WindowState windowState;
		QPixmap bgPixmap;
		QBrush bgBrush;
		QColor bgColor;
		QPoint bgOffset;
		Qt::BackgroundMode backgroundMode;
		QColor fgColor;
		QColorGroup colorGroup;
		QRect geometry;
		QRect rect;
		QPoint pos;
		QPixmap icon;
		QPalette palette;
		QFont font;
		QColor paletteBgColor;
		QString name;
		QString caption;
};

class QStyleControlElementTabBarData {
	public:
		int tabCount;
		int currentTabIndex;
		QTabBar::Shape shape;
		TabIdentifierIndexMap identIndexMap;
#ifdef Q_QDOC
#else
		QStyleControlElementGenericWidgetData cornerWidgets[4];
#endif

		enum CornerWidgetLocation {
			CWL_TopLeft			= 0,
			CWL_TopRight			= 1,
			CWL_BottomLeft			= 2,
			CWL_BottomRight			= 3
		};
};

class Q_EXPORT QStyleControlElementData {
	public:
		QStyleControlElementData();
		~QStyleControlElementData();

	public:
		bool isNull;
		QStringList widgetObjectTypes;
		bool allDataPopulated;
		Qt::WFlags wflags;
		Qt::WindowState windowState;
		QPixmap bgPixmap;
		QBrush bgBrush;
		QColor bgColor;
		QPoint bgOffset;
		Qt::BackgroundMode backgroundMode;
		QPixmap fgPixmap;
		QColor fgColor;
		QColorGroup colorGroup;
		QRect geometry;
		QRect rect;
		QPoint pos;
		QPixmap icon;
		QIconSet iconSet;
		QString text;
		Qt::Orientation orientation;
		QColor activeItemPaletteBgColor;
		QPalette palette;
		int totalSteps;
		int currentStep;
		Q_UINT32 tickMarkSetting;
		int tickInterval;
		int minSteps;
		int maxSteps;
		int startStep;
		int pageStep;
		int lineStep;
		int dlgVisibleButtons;
		DialogButtonSizeMap dlgVisibleSizeHints;
		QString progressText;
		QString textLabel;
		QFont font;
		int percentageVisible;
		QStyleControlElementDockWidgetData dwData;
		QToolButton::TextPosition toolButtonTextPosition;
		int popupDelay;
		QStyleControlElementTitleBarData titleBarData;
		QStyleControlElementSpinWidgetData spinWidgetData;
		QStyleControlElementGenericWidgetData parentWidgetData;
		QStyleControlElementGenericWidgetData viewportData;
		QStyleControlElementListViewData listViewData;
		QStyleControlElementTabBarData tabBarData;
		QStyleControlElementCheckListItemData checkListItemData;
		Q_UINT32 comboBoxLineEditFlags;
		Q_UINT32 frameStyle;
		QRect sliderRect;
		QPainter* activePainter;
		QStyleControlElementToolBarWidgetData toolBarData;
		Q_UINT32 comboBoxListBoxFlags;
		QColor paletteBgColor;
		Q_UINT32 parentWidgetFlags;
		QString name;
		QString caption;
		QStyleControlElementGenericWidgetData topLevelWidgetData;
		Q_UINT32 topLevelWidgetFlags;
		QPixmap paletteBgPixmap;

#ifdef ENABLE_QSTYLECONTROLELEMENTDATA_SLOW_COPY
	public:
		QStyleControlElementData(const QStyleControlElementData&);
#else // ENABLE_QSTYLECONTROLELEMENTDATA_SLOW_COPY
	private:
		// Disable copy constructor
		QStyleControlElementData(const QStyleControlElementData&);
#endif // ENABLE_QSTYLECONTROLELEMENTDATA_SLOW_COPY

};

class Q_EXPORT QStyleWidgetActionRequestData {
	public:
		QStyleWidgetActionRequestData();
		QStyleWidgetActionRequestData(int metric1, int metric2=0);
		QStyleWidgetActionRequestData(QPalette palette, bool informWidgets = FALSE, const char* className = 0);
		QStyleWidgetActionRequestData(QFont font, bool informWidgets = FALSE, const char* className = 0);
		QStyleWidgetActionRequestData(QRect rect);
		QStyleWidgetActionRequestData(QPaintEvent* paintEvent);
		~QStyleWidgetActionRequestData();
	public:
		bool bool1;
		bool bool2;
		int metric1;
		int metric2;
		QPalette palette;
		QFont font;
		QRect rect;
		const char * cstr;
		QString string;
		QPaintEvent * paintEvent;
};

typedef QStyleWidgetActionRequestData QStyleApplicationActionRequestData;

class Q_EXPORT QStyle: public QObject
{
    Q_OBJECT

public:
    QStyle();
    virtual ~QStyle();

    enum ControlElementFlags {
	CEF_None			= 0x00000000,
	CEF_IsDefault			= 0x00000001,
	CEF_AutoDefault			= 0x00000002,
	CEF_IsActive			= 0x00000004,
	CEF_IsDown			= 0x00000008,
	CEF_IsOn			= 0x00000010,
	CEF_IsEnabled			= 0x00000020,
	CEF_BiState			= 0x00000040,
	CEF_HasFocus			= 0x00000080,
	CEF_IsMenuWidget		= 0x00000100,
	CEF_IsContainerEmpty		= 0x00000200,
	CEF_CenterIndicator		= 0x00000400,
	CEF_IndicatorFollowsStyle	= 0x00000800,
	CEF_UsesTextLabel		= 0x00001000,
	CEF_UsesBigPixmap		= 0x00002000,
	CEF_UseGenericParameters	= 0x00004000,
	CEF_HasParentWidget		= 0x00008000,
	CEF_HasPopupMenu		= 0x00010000,
	CEF_IsCheckable			= 0x00020000,
	CEF_HasFocusProxy		= 0x00040000,
	CEF_IsEditable			= 0x00080000,
	CEF_IsFlat			= 0x00100000,
	CEF_IsActiveWindow		= 0x00200000,
	CEF_IsTopLevel			= 0x00400000,
	CEF_IsVisible			= 0x00800000,
	CEF_IsShown			= 0x01000000,
	CEF_HasMouse			= 0x02000000
    };

    // New QStyle API - most of these should probably be pure virtual

    // Old API
    // DEPRECATED
    virtual void polish( QWidget * );

    // New API
    virtual void polish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * );

    // Old API
    // DEPRECATED
    virtual void unPolish( QWidget * );

    // New API
    virtual void unPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * );

    // Old API
    // DEPRECATED
    virtual void polish( QApplication * );

    // New API
    virtual void applicationPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * );

    // Old API
    // DEPRECATED
    virtual void unPolish( QApplication * );

    // New API
    virtual void applicationUnPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * );

    virtual void polish( QPalette & );

    // Old API
    // DEPRECATED
    virtual void polishPopupMenu( QPopupMenu* );

    // New API
    virtual void polishPopupMenu( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ) = 0;

    virtual QRect itemRect( QPainter *p, const QRect &r,
			    int flags, bool enabled,
			    const QPixmap *pixmap,
			    const QString &text, int len = -1 ) const;

    virtual void drawItem( QPainter *p, const QRect &r,
			   int flags, const QColorGroup &g, bool enabled,
			   const QPixmap *pixmap, const QString &text,
			   int len = -1, const QColor *penColor = 0 ) const;

    enum PrimitiveElement {
	PE_ButtonCommand,
	PE_ButtonDefault,
	PE_ButtonBevel,
	PE_ButtonTool,
	PE_ButtonDropDown,

	PE_FocusRect,

	PE_ArrowUp,
	PE_ArrowDown,
	PE_ArrowRight,
	PE_ArrowLeft,

	PE_SpinWidgetUp,
	PE_SpinWidgetDown,
	PE_SpinWidgetPlus,
	PE_SpinWidgetMinus,

	PE_Indicator,
	PE_IndicatorMask,
	PE_ExclusiveIndicator,
	PE_ExclusiveIndicatorMask,

	PE_DockWindowHandle,
	PE_DockWindowSeparator,
	PE_DockWindowResizeHandle,

	PE_Splitter,

	PE_Panel,
	PE_PanelPopup,
	PE_PanelMenuBar,
	PE_PanelDockWindow,

	PE_TabBarBase,

	PE_HeaderSection,
	PE_HeaderArrow,
	PE_StatusBarSection,

	PE_GroupBoxFrame,

	PE_Separator,

	PE_SizeGrip,

	PE_CheckMark,

	PE_ScrollBarAddLine,
	PE_ScrollBarSubLine,
	PE_ScrollBarAddPage,
	PE_ScrollBarSubPage,
	PE_ScrollBarSlider,
	PE_ScrollBarFirst,
	PE_ScrollBarLast,

	PE_ProgressBarChunk,

	PE_PanelLineEdit,
	PE_PanelTabWidget,

	PE_WindowFrame,

	PE_CheckListController,
	PE_CheckListIndicator,
	PE_CheckListExclusiveIndicator,

	PE_PanelGroupBox,
	PE_RubberBand,

	PE_HeaderSectionMenu,

	PE_PanelScrollBar,
	PE_MenuItemIndicatorFrame,
	PE_MenuItemIndicatorIconFrame,
	PE_MenuItemIndicatorCheck,

	PE_ScrollBarTrough,

	// do not add any values below/greater this
	PE_CustomBase =			0xf000000
    };

    enum StyleFlags {
	Style_Default = 		0x00000000,
	Style_Enabled = 		0x00000001,
	Style_Raised =			0x00000002,
	Style_Sunken =	 		0x00000004,
	Style_Off =			0x00000008,
	Style_NoChange =		0x00000010,
	Style_On =			0x00000020,
	Style_Down =			0x00000040,
	Style_Horizontal =		0x00000080,
	Style_HasFocus =		0x00000100,
	Style_Top =			0x00000200,
	Style_Bottom =			0x00000400,
	Style_FocusAtBorder =		0x00000800,
	Style_AutoRaise =		0x00001000,
	Style_MouseOver =		0x00002000,
	Style_Up =			0x00004000,
	Style_Selected =	 	0x00008000,
	Style_Active =			0x00010000,
	Style_ButtonDefault =		0x00020000
    };
    typedef uint SFlags;

    // Old API
    // DEPRECATED
    virtual void drawPrimitive( PrimitiveElement pe,
				QPainter *p,
				const QRect &r,
				const QColorGroup &cg,
				SFlags flags = Style_Default,
				const QStyleOption& = QStyleOption::Default ) const;

    // New API
    virtual void drawPrimitive( PrimitiveElement pe,
				QPainter *p,
				const QStyleControlElementData &ceData,
				ControlElementFlags elementFlags,
				const QRect &r,
				const QColorGroup &cg,
				SFlags flags = Style_Default,
				const QStyleOption& = QStyleOption::Default ) const = 0;


    enum ControlElement {
	CE_PushButton,
	CE_PushButtonLabel,

	CE_CheckBox,
	CE_CheckBoxLabel,

	CE_RadioButton,
	CE_RadioButtonLabel,

	CE_TabBarTab,
	CE_TabBarLabel,

	CE_ProgressBarGroove,
	CE_ProgressBarContents,
	CE_ProgressBarLabel,

	CE_PopupMenuItem,
	CE_MenuBarItem,

	CE_ToolButtonLabel,
	CE_MenuBarEmptyArea,
	CE_PopupMenuScroller,
	CE_DockWindowEmptyArea,
	CE_PopupMenuVerticalExtra,
	CE_PopupMenuHorizontalExtra,

	CE_ToolBoxTab,
	CE_HeaderLabel,

	// do not add any values below/greater than this
	CE_CustomBase =		0xf0000000
    };

    // Old API
    // DEPRECATED
    virtual void drawControl( ControlElement element,
			      QPainter *p,
			      const QWidget *widget,
			      const QRect &r,
			      const QColorGroup &cg,
			      SFlags how = Style_Default,
			      const QStyleOption& = QStyleOption::Default ) const;

    // New API
    virtual void drawControl( ControlElement element,
			      QPainter *p,
			      const QStyleControlElementData &ceData,
			      ControlElementFlags elementFlags,
			      const QRect &r,
			      const QColorGroup &cg,
			      SFlags how = Style_Default,
			      const QStyleOption& = QStyleOption::Default,
			      const QWidget *widget = 0 /* compat, will likely go away */ ) const = 0;

    // Old API
    // DEPRECATED
    virtual void drawControlMask( ControlElement element,
				  QPainter *p,
				  const QWidget *widget,
				  const QRect &r,
				  const QStyleOption& = QStyleOption::Default ) const;

    // New API
    virtual void drawControlMask( ControlElement element,
				  QPainter *p,
				  const QStyleControlElementData &ceData,
				  ControlElementFlags elementFlags,
				  const QRect &r,
				  const QStyleOption& = QStyleOption::Default,
				  const QWidget *widget = 0 /* compat, will likely go away */ ) const = 0;

    enum SubRect {
	SR_PushButtonContents,
	SR_PushButtonFocusRect,

	SR_CheckBoxIndicator,
	SR_CheckBoxContents,
	SR_CheckBoxFocusRect,

	SR_RadioButtonIndicator,
	SR_RadioButtonContents,
	SR_RadioButtonFocusRect,

	SR_ComboBoxFocusRect,

	SR_SliderFocusRect,

	SR_DockWindowHandleRect,

	SR_ProgressBarGroove,
	SR_ProgressBarContents,
	SR_ProgressBarLabel,

	SR_ToolButtonContents,

	SR_DialogButtonAccept,
	SR_DialogButtonReject,
	SR_DialogButtonApply,
	SR_DialogButtonHelp,
	SR_DialogButtonAll,
	SR_DialogButtonAbort,
	SR_DialogButtonIgnore,
	SR_DialogButtonRetry,
	SR_DialogButtonCustom,

	SR_ToolBoxTabContents,

	// do not add any values below/greater than this
	SR_CustomBase =		0xf0000000
    };

    // Old API
    // DEPRECATED
    virtual QRect subRect( SubRect r, const QWidget *widget ) const;

    // New API
    virtual QRect subRect( SubRect r, const QStyleControlElementData &ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const = 0;


    enum ComplexControl{
	CC_SpinWidget,
	CC_ComboBox,
	CC_ScrollBar,
	CC_Slider,
	CC_ToolButton,
	CC_TitleBar,
	CC_ListView,

	// do not add any values below/greater than this
	CC_CustomBase =		0xf0000000
    };

    enum SubControl {
	SC_None =			0x00000000,

	SC_ScrollBarAddLine =		0x00000001,
	SC_ScrollBarSubLine =		0x00000002,
	SC_ScrollBarAddPage =		0x00000004,
	SC_ScrollBarSubPage =		0x00000008,
	SC_ScrollBarFirst =		0x00000010,
	SC_ScrollBarLast =		0x00000020,
	SC_ScrollBarSlider =		0x00000040,
	SC_ScrollBarGroove =		0x00000080,

	SC_SpinWidgetUp =		0x00000001,
	SC_SpinWidgetDown =		0x00000002,
	SC_SpinWidgetFrame =		0x00000004,
	SC_SpinWidgetEditField =	0x00000008,
	SC_SpinWidgetButtonField =	0x00000010,

	SC_ComboBoxFrame =		0x00000001,
	SC_ComboBoxEditField =		0x00000002,
	SC_ComboBoxArrow =		0x00000004,
	SC_ComboBoxListBoxPopup =	0x00000008,

	SC_SliderGroove =		0x00000001,
	SC_SliderHandle = 		0x00000002,
	SC_SliderTickmarks = 		0x00000004,

	SC_ToolButton =			0x00000001,
	SC_ToolButtonMenu =		0x00000002,

	SC_TitleBarLabel =		0x00000001,
	SC_TitleBarSysMenu =		0x00000002,
	SC_TitleBarMinButton =		0x00000004,
	SC_TitleBarMaxButton =		0x00000008,
	SC_TitleBarCloseButton =	0x00000010,
	SC_TitleBarNormalButton =	0x00000020,
	SC_TitleBarShadeButton =	0x00000040,
	SC_TitleBarUnshadeButton =	0x00000080,

	SC_ListView =			0x00000001,
	SC_ListViewBranch =		0x00000002,
	SC_ListViewExpand =		0x00000004,

	SC_All =			0xffffffff
    };
    typedef uint SCFlags;


    // Old API
    // DEPRECATED
    virtual void drawComplexControl( ComplexControl control,
				     QPainter *p,
				     const QWidget *widget,
				     const QRect &r,
				     const QColorGroup &cg,
				     SFlags how = Style_Default,
#ifdef Q_QDOC
				     SCFlags sub = SC_All,
#else
				     SCFlags sub = (uint)SC_All,
#endif
				     SCFlags subActive = SC_None,
				     const QStyleOption& = QStyleOption::Default ) const;

    virtual void drawComplexControl( ComplexControl control,
				     QPainter *p,
				     const QStyleControlElementData &ceData,
				     ControlElementFlags elementFlags,
				     const QRect &r,
				     const QColorGroup &cg,
				     SFlags how = Style_Default,
#ifdef Q_QDOC
				     SCFlags sub = SC_All,
#else
				     SCFlags sub = (uint)SC_All,
#endif
				     SCFlags subActive = SC_None,
				     const QStyleOption& = QStyleOption::Default,
				     const QWidget *widget = 0 ) const = 0;

    // Old API
    // DEPRECATED
    virtual void drawComplexControlMask( ComplexControl control,
					 QPainter *p,
					 const QWidget *widget,
					 const QRect &r,
					 const QStyleOption& = QStyleOption::Default ) const;

    // New API
    virtual void drawComplexControlMask( ComplexControl control,
					 QPainter *p,
					 const QStyleControlElementData &ceData,
					 const ControlElementFlags elementFlags,
					 const QRect &r,
					 const QStyleOption& = QStyleOption::Default,
					 const QWidget *widget = 0 ) const = 0;

    // Old API
    // DEPRECATED
    virtual QRect querySubControlMetrics( ComplexControl control,
					  const QWidget *widget,
					  SubControl sc,
					  const QStyleOption& = QStyleOption::Default ) const;

    // New API
    virtual QRect querySubControlMetrics( ComplexControl control,
					  const QStyleControlElementData &ceData,
					  ControlElementFlags elementFlags,
					  SubControl sc,
					  const QStyleOption& = QStyleOption::Default,
					  const QWidget *widget = 0 ) const = 0;

    // Old API
    // DEPRECATED
    virtual SubControl querySubControl( ComplexControl control,
					const QWidget *widget,
					const QPoint &pos,
					const QStyleOption& = QStyleOption::Default ) const;

    // New API
    virtual SubControl querySubControl( ComplexControl control,
					const QStyleControlElementData &ceData,
					ControlElementFlags elementFlags,
					const QPoint &pos,
					const QStyleOption& = QStyleOption::Default,
					const QWidget *widget = 0 ) const = 0;


    enum PixelMetric {
	PM_ButtonMargin,
	PM_ButtonDefaultIndicator,
	PM_MenuButtonIndicator,
	PM_ButtonShiftHorizontal,
	PM_ButtonShiftVertical,

	PM_DefaultFrameWidth,
	PM_SpinBoxFrameWidth,

	PM_MaximumDragDistance,

	PM_ScrollBarExtent,
	PM_ScrollBarSliderMin,

	PM_SliderThickness,	       	// total slider thickness
	PM_SliderControlThickness,    	// thickness of the business part
	PM_SliderLength,		// total length of slider
	PM_SliderTickmarkOffset,	//
	PM_SliderSpaceAvailable,	// available space for slider to move

	PM_DockWindowSeparatorExtent,
	PM_DockWindowHandleExtent,
	PM_DockWindowFrameWidth,

	PM_MenuBarFrameWidth,

	PM_TabBarTabOverlap,
	PM_TabBarTabHSpace,
	PM_TabBarTabVSpace,
	PM_TabBarBaseHeight,
	PM_TabBarBaseOverlap,

	PM_ProgressBarChunkWidth,

	PM_SplitterWidth,
	PM_TitleBarHeight,

	PM_IndicatorWidth,
	PM_IndicatorHeight,
	PM_ExclusiveIndicatorWidth,
	PM_ExclusiveIndicatorHeight,
	PM_PopupMenuScrollerHeight,
	PM_CheckListButtonSize,
	PM_CheckListControllerSize,
	PM_PopupMenuFrameHorizontalExtra,
	PM_PopupMenuFrameVerticalExtra,

	PM_DialogButtonsSeparator,
	PM_DialogButtonsButtonWidth,
	PM_DialogButtonsButtonHeight,

	PM_MDIFrameWidth,
	PM_MDIMinimizedWidth,
	PM_HeaderMargin,
	PM_HeaderMarkSize,
	PM_HeaderGripMargin,
	PM_TabBarTabShiftHorizontal,
	PM_TabBarTabShiftVertical,
	PM_TabBarScrollButtonWidth,

	PM_MenuBarItemSpacing,
	PM_ToolBarItemSpacing,

	PM_MenuIndicatorFrameHBorder,
	PM_MenuIndicatorFrameVBorder,
	PM_MenuIconIndicatorFrameHBorder,
	PM_MenuIconIndicatorFrameVBorder,

	PM_ArrowSize,

	// do not add any values below/greater than this
	PM_CustomBase =		0xf0000000
    };

    // Old API
    // DEPRECATED
    virtual int pixelMetric( PixelMetric metric,
			     const QWidget *widget = 0 ) const;

    // New API
    virtual int pixelMetric( PixelMetric metric,
			     const QStyleControlElementData &ceData,
			     ControlElementFlags elementFlags,
			     const QWidget *widget = 0 ) const = 0;


    enum ContentsType {
	CT_PushButton,
	CT_CheckBox,
	CT_RadioButton,
	CT_ToolButton,
	CT_ComboBox,
	CT_Splitter,
	CT_DockWindow,
	CT_ProgressBar,
	CT_PopupMenuItem,
	CT_TabBarTab,
	CT_Slider,
	CT_Header,
	CT_LineEdit,
	CT_MenuBar,
	CT_SpinBox,
	CT_SizeGrip,
	CT_TabWidget,
	CT_DialogButtons,

	// do not add any values below/greater than this
	CT_CustomBase =		0xf0000000
    };

    // Old API
    // DEPRECATED
    virtual QSize sizeFromContents( ContentsType contents,
				    const QWidget *widget,
				    const QSize &contentsSize,
				    const QStyleOption& = QStyleOption::Default ) const;

    virtual QSize sizeFromContents( ContentsType contents,
				    const QStyleControlElementData &ceData,
				    ControlElementFlags elementFlags,
				    const QSize &contentsSize,
				    const QStyleOption& = QStyleOption::Default,
				    const QWidget *widget = 0 ) const = 0;

    enum StyleHint  {
	// ...
	// the general hints
	// ...
       	// disabled text should be etched, ala Windows
	SH_EtchDisabledText,

	// the GUI style enum, argh!
	SH_GUIStyle,

	// ...
	// widget specific hints
	// ...
	SH_ScrollBar_BackgroundMode,
	SH_ScrollBar_MiddleClickAbsolutePosition,
	SH_ScrollBar_ScrollWhenPointerLeavesControl,

	// QEvent::Type - which mouse event to select a tab
	SH_TabBar_SelectMouseType,

	SH_TabBar_Alignment,

	SH_Header_ArrowAlignment,

	// bool - sliders snap to values while moving, ala Windows
	SH_Slider_SnapToValue,

	// bool - key presses handled in a sloppy manner - ie. left on a vertical
	// slider subtracts a line
	SH_Slider_SloppyKeyEvents,

	// bool - center button on progress dialogs, ala Motif, else right aligned
	// perhaps this should be a Qt::Alignment value
	SH_ProgressDialog_CenterCancelButton,

	// Qt::AlignmentFlags - text label alignment in progress dialogs
	// Center on windows, Auto|VCenter otherwize
	SH_ProgressDialog_TextLabelAlignment,

	// bool - right align buttons on print dialog, ala Windows
	SH_PrintDialog_RightAlignButtons,

	// bool - 1 or 2 pixel space between the menubar and the dockarea, ala Windows
	// this *REALLY* needs a better name
	SH_MainWindow_SpaceBelowMenuBar,

	// bool - select the text in the line edit about the listbox when selecting
	// an item from the listbox, or when the line edit receives focus, ala Windows
	SH_FontDialog_SelectAssociatedText,

	// bool - allows disabled menu items to be active
	SH_PopupMenu_AllowActiveAndDisabled,

	// bool - pressing space activates item, ala Motif
	SH_PopupMenu_SpaceActivatesItem,

	// int - number of milliseconds to wait before opening a submenu
	// 256 on windows, 96 on motif
	SH_PopupMenu_SubMenuPopupDelay,

	// bool - should scrollviews draw their frame only around contents (ala Motif),
	// or around contents, scrollbars and corner widgets (ala Windows) ?
	SH_ScrollView_FrameOnlyAroundContents,

	// bool - menubars items are navigatable by pressing alt, followed by using
	// the arrow keys to select the desired item
	SH_MenuBar_AltKeyNavigation,

	// bool - mouse tracking in combobox dropdown lists
	SH_ComboBox_ListMouseTracking,

	// bool - mouse tracking in popupmenus
	SH_PopupMenu_MouseTracking,

	// bool - mouse tracking in menubars
	SH_MenuBar_MouseTracking,

	// bool - gray out selected items when loosing focus
	SH_ItemView_ChangeHighlightOnFocus,

	// bool - supports shared activation among modeless widgets
	SH_Widget_ShareActivation,

	// bool - workspace should just maximize the client area
	SH_Workspace_FillSpaceOnMaximize,

	// bool - supports popup menu comboboxes
	SH_ComboBox_Popup,

	// bool - titlebar has no border
	SH_TitleBar_NoBorder,

	// bool - stop scrollbar at mouse
	SH_ScrollBar_StopMouseOverSlider,

	//bool - blink cursort with selected text
	SH_BlinkCursorWhenTextSelected,

	//bool - richtext selections extend the full width of the docuemnt
	SH_RichText_FullWidthSelection,

	//bool - popupmenu supports scrolling instead of multicolumn mode
	SH_PopupMenu_Scrollable,

	// Qt::AlignmentFlags - text label vertical alignment in groupboxes
	// Center on windows, Auto|VCenter otherwize
	SH_GroupBox_TextLabelVerticalAlignment,

	// Qt::QRgb - text label color in groupboxes
	SH_GroupBox_TextLabelColor,

	// bool - popupmenu supports sloppy submenus
	SH_PopupMenu_SloppySubMenus,

	// Qt::QRgb - table grid color
	SH_Table_GridLineColor,

	// QChar - Unicode character for password char
	SH_LineEdit_PasswordCharacter,

	// QDialogButtons::Button - default button
	SH_DialogButtons_DefaultButton,

	// QToolBox - Boldness of the selected page title
	SH_ToolBox_SelectedPageTitleBold,

	//bool - if a tabbar prefers not to have scroller arrows
	SH_TabBar_PreferNoArrows,

	//bool - if left button should cause an absolute position
	SH_ScrollBar_LeftClickAbsolutePosition,

	// QEvent::Type - which mouse event to select a list view expansion
	SH_ListViewExpand_SelectMouseType,

	//bool - if underline for accelerators
	SH_UnderlineAccelerator,

	// bool - QToolButton - if tool buttons should use a 3D frame
	// when the mouse is over the button
	SH_ToolButton_Uses3D,

	// bool - hide underlined accelerators uless Alt key is currently down
	SH_HideUnderlineAcceleratorWhenAltUp,

	// int - width of menu check column
	SH_MenuIndicatorColumnWidth,

	// bool - whether or not the lower two button drawing areas should be combined into one
	SH_ScrollBar_CombineAddLineRegionDrawingAreas,

	// bool - whether or not the upper two button drawing areas should be combined into one
	SH_ScrollBar_CombineSubLineRegionDrawingAreas,

	// Qt::QRgb - color of the popup menu arrow (active, menuitem enabled)
	SH_PopupMenu_SubMenuArrowColorActiveEnabled,

	// Qt::QRgb - color of the popup menu arrow (active, menuitem disabled)
	SH_PopupMenu_SubMenuArrowColorActiveDisabled,

	// Qt::QRgb - color of the popup menu arrow (inactive, menuitem enabled)
	SH_PopupMenu_SubMenuArrowColorInactiveEnabled,

	// Qt::QRgb - color of the popup menu arrow (active, menuitem disabled)
	SH_PopupMenu_SubMenuArrowColorInactiveDisabled,

	// do not add any values below/greater than this
	SH_CustomBase =		0xf0000000
    };

    // Old API
    // DEPRECATED
    virtual int styleHint( StyleHint stylehint,
			   const QWidget *widget = 0,
			   const QStyleOption& = QStyleOption::Default,
			   QStyleHintReturn* returnData = 0
			   ) const;

    // New API
    virtual int styleHint( StyleHint stylehint,
			   const QStyleControlElementData &ceData,
			   ControlElementFlags elementFlags,
			   const QStyleOption& = QStyleOption::Default,
			   QStyleHintReturn* returnData = 0,
			   const QWidget *widget = 0
			   ) const = 0;


    enum StylePixmap {
	SP_TitleBarMinButton,
	SP_TitleBarMaxButton,
	SP_TitleBarCloseButton,
	SP_TitleBarNormalButton,
	SP_TitleBarShadeButton,
	SP_TitleBarUnshadeButton,
	SP_DockWindowCloseButton,
	SP_MessageBoxInformation,
	SP_MessageBoxWarning,
	SP_MessageBoxCritical,
	SP_MessageBoxQuestion,

	// do not add any values below/greater than this
	SP_CustomBase =		0xf0000000
    };

    // Old API
    // DEPRECATED
    virtual QPixmap stylePixmap( StylePixmap stylepixmap,
				 const QWidget *widget = 0,
				 const QStyleOption& = QStyleOption::Default ) const;

    virtual QPixmap stylePixmap( StylePixmap stylepixmap,
				 const QStyleControlElementData &ceData,
				 ControlElementFlags elementFlags,
				 const QStyleOption& = QStyleOption::Default,
				 const QWidget *widget = 0 ) const = 0;


    // Old API
    // DEPRECATED
    static QRect visualRect( const QRect &logical, const QWidget *w );

    // New API
    static QRect visualRect( const QRect &logical, const QStyleControlElementData &ceData, const ControlElementFlags elementFlags );

    static QRect visualRect( const QRect &logical, const QRect &bounding );


    // Object event handling API
    typedef QMap<void*, QStyle*> ObjectEventSourceToHandlerMap;
    typedef QMap<void*, QStyleControlElementData> ObjectEventSourceDataToHandlerMap;
    typedef QMap<void*, ControlElementFlags> ObjectEventSourceFlagsToHandlerMap;
    typedef bool (*EventHandlerInstallationHook)(const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, QStyle* handler);
    typedef bool (*EventHandlerRemovalHook)(const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, QStyle* handler);
    void installObjectEventHandler( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, QStyle* handler );
    void removeObjectEventHandler( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, QStyle* handler );
    void setEventHandlerInstallationHook( EventHandlerInstallationHook );
    void setEventHandlerRemovalHook( EventHandlerRemovalHook hook );
    virtual bool objectEventHandler( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, QEvent *e );

    enum WidgetActionRequest {
	WAR_Repaint,
	WAR_RepaintRect,
	WAR_EnableMouseTracking,
	WAR_DisableMouseTracking,
	WAR_SetAutoMask,
	WAR_UnSetAutoMask,
	WAR_SetCheckable,
	WAR_UnSetCheckable,
	WAR_FrameSetStyle,
	WAR_FrameSetLineWidth,
	WAR_SetLayoutMargin,
	WAR_SetPalette,
	WAR_SetBackgroundMode,
	WAR_SetBackgroundOrigin,
	WAR_SetFont,
	WAR_RepaintAllAccelerators,
	WAR_SetDefault,
	WAR_UnSetDefault,
	WAR_SendPaintEvent
    };

    typedef bool (*WidgetActionRequestHook)(const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData);
    void setWidgetActionRequestHook( WidgetActionRequestHook );
    virtual bool widgetActionRequest( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData = QStyleWidgetActionRequestData() );

    enum ApplicationActionRequest {
	AAR_SetPalette,
	AAR_SetFont
    };

    typedef bool (*ApplicationActionRequestHook)(const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, QStyleApplicationActionRequestData requestData);
    void setApplicationActionRequestHook( ApplicationActionRequestHook );
    virtual bool applicationActionRequest( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, QStyleApplicationActionRequestData requestData = QStyleApplicationActionRequestData() );

    // Old 2.x QStyle API

#ifndef QT_NO_COMPAT
    int defaultFrameWidth() const;
    void tabbarMetrics( const QWidget* t, int& hf, int& vf, int& ov ) const;
    QSize scrollBarExtent() const;
#endif

public:
    virtual bool eventFilter( QObject *, QEvent * );
    bool acceleratorsShown() const;

protected:
    void acceleratorKeypressEventMonitor( QObject *, QEvent * );

private:
    QStylePrivate * d;

#if defined(Q_DISABLE_COPY)
    QStyle( const QStyle & );
    QStyle& operator=( const QStyle & );
#endif

    EventHandlerInstallationHook m_eventHandlerInstallationHook;
    EventHandlerRemovalHook m_eventHandlerRemovalHook;
    WidgetActionRequestHook m_widgetActionRequestHook;
    ApplicationActionRequestHook m_applicationActionRequestHook;
    ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap;
    ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap;
    ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap;
    bool conditionalAcceleratorsEnabled;
};

inline QStyle::ControlElementFlags operator|(const QStyle::ControlElementFlags a, const QStyle::ControlElementFlags b) { return static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); }
// inline QStyle::ControlElementFlags operator|=(QStyle::ControlElementFlags &a, const QStyle::ControlElementFlags b) { a = static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); return a; }

Q_EXPORT const QStyleControlElementData &populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields=true);
Q_EXPORT const QStyleControlElementData &populateControlElementDataFromApplication(const QApplication* app, const QStyleOption& opt, bool populateReliantFields=true);
Q_EXPORT QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, const QStyleOption& opt, bool populateReliantFields=true);
Q_EXPORT QStringList getObjectTypeListForObject(const QObject* object);
Q_EXPORT const QStyleControlElementData &populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields, bool populateMinimumNumberOfFields);

#endif // QT_NO_STYLE
#endif // QSTYLE_H