summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/src/kernel/tqwidget.h
blob: c0274646c26d8849b05abbb35feacaf915158809 (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
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
/****************************************************************************
**
** Definition of TQWidget class
**
** Created : 931029
**
** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
**
** This file is part of the kernel module of the TQt 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 TQt 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 sales@trolltech.com.
**
** This file may be used under the terms of the Q Public License as
** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
** included in the packaging of this file.  Licensees holding valid TQt
** Commercial licenses may use this file in accordance with the TQt
** 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 TQWIDGET_H
#define TQWIDGET_H

#include "tqtglobaldefines.h"

#ifndef TQT_H
#include "tqwindowdefs.h"
#include "tqobject.h"
#include "tqpaintdevice.h"
#include "tqpalette.h"
#include "tqfont.h"
#include "tqfontmetrics.h"
#include "tqfontinfo.h"
#include "tqsizepolicy.h"
#include "tqbitmap.h"
#endif // TQT_H

#ifdef USE_QT4
#ifndef TQFONTENGINE_P_H

#include <Qt/qwidget.h>
#include <private/qt4_qwidget_p.h>

#endif // TQFONTENGINE_P_H
#endif // USE_QT4

class TQLayout;

#ifdef USE_QT4

// FIXME
// Neither TQTLWExtra nor TQWExtra are fully Qt4 compatible!

class TQFocusData;

// typedef struct QTLWExtra TQTLWExtra;

struct TQTLWExtra : public QTLWExtra, virtual public TQt
{
	TQFocusData *focusData;				// focus data (for TLW)
	ulong fleft, fright, ftop, fbottom;
	uint uspos : 1;					// User defined position
	uint ussize : 1;				// User defined size

#if defined(TQ_WS_X11)
	WId parentWinId;				// tqparent window Id (valid after reparenting)
#endif
};

// typedef struct QWExtra TQWExtra;

struct TQWExtra : public QWExtra, virtual public TQt
{
	TQRect micro_focus_hint;			// micro focus hint
	TQPixmap *bg_pix;				// background pixmap
	char bg_mode;					// background mode
	char bg_mode_visual;				// visual background mode
	uint bg_origin : 2;
	TQSizePolicy size_policy;
	TQTLWExtra *topextra;				// only useful for TLWs		// WARNING: This is overriding the Qt4 builtin topextra with unknown consequences.....
};

#else // USE_QT4

struct TQWExtra;
struct TQTLWExtra;

#endif // USE_QT4

class TQFocusData;
class TQCursor;
class TQWSRegionManager;
class TQStyle;

#ifdef USE_QT4

#include <Qt/qx11info_x11.h>
#include <private/qt4_qwidget_p.h>

typedef unsigned long long WFlags;
typedef QFlags<Qt::WindowState> WState;

// #define WType_Desktop		Qt::Desktop
// 
// #define Key_Escape		Qt::Key_Escape
// #define ShiftButton		Qt::ShiftModifier
// #define ControlButton		Qt::ControlModifier
// 
// #define WStyle_Customize	0
// #define WType_Popup		Qt::Popup
// #define WX11BypassWM		Qt::X11BypassWindowManagerHint

// #define TQWIDGETSIZE_MAX 32767
#define TQWIDGETSIZE_MAX QWIDGETSIZE_MAX

#define TQT_TQWIDGET_INDEPENDENT_REQUIRED_INITIALIZATION						\
	setAttribute(Qt::WA_PaintOutsidePaintEvent, TRUE);						\
	setAutoFillBackground(true);

#define TQT_TQWIDGET_REQUIRED_INITIALIZATION								\
	extra = 0;											\
	tqt_internal_ignore_next_windowstatechange_event = FALSE;					\
	tqt_internal_show_called_event = FALSE;								\
	if (testWFlags(WType_Popup) && testWFlags(WType_Dialog))					\
        	clearWFlags((WType_Dialog & (~WType_TopLevel)));					\
	TQT_TQWIDGET_INDEPENDENT_REQUIRED_INITIALIZATION						\
	setDefaultWidgetFlags();									\
	processUpperWidgetFlags();

#define TQT_TQWIDGET_FIX_BROKEN_POPUP_MOUSE_FOCUS												\
	bool new_receiver_found = FALSE;													\
	QWidget *popup = qApp->activePopupWidget();												\
	QWidget *newreceiver = this;														\
	QPoint gpos = mapToGlobal(e->pos());													\
	QPoint npos = newreceiver->mapFromGlobal(gpos);												\
	if (popup) {																\
		while (!TQT_TQRECT_OBJECT(newreceiver->rect()).tqcontains(npos)) {								\
			new_receiver_found = TRUE;												\
			newreceiver = tqwidget_parent_popup_menu(newreceiver);									\
			if (newreceiver) {													\
				npos = newreceiver->mapFromGlobal(gpos);									\
			}															\
			else {															\
				break;														\
			}															\
		}																\
		if ((newreceiver) && (new_receiver_found)) {											\
			if (TQT_TQRECT_OBJECT(newreceiver->rect()).tqcontains(npos)) {							\
				if (tqwidget_is_popup_menu(newreceiver)) {									\
					npos = newreceiver->mapFromGlobal(gpos);								\
					QMouseEvent fixedevent(e->type(), npos, e->globalPos(), e->button(), e->buttons(), e->modifiers());	\
					QApplication::sendEvent(newreceiver, &fixedevent);							\
					e->accept();												\
				}														\
			}															\
		}																\
	}																	\
	if (!((newreceiver) && (new_receiver_found)))

extern bool tqwidget_is_popup_menu(QWidget*);
extern QWidget* tqwidget_parent_popup_menu(QWidget*);

// class TQ_EXPORT TQWidget : public TQObject, public QWidget
class TQ_EXPORT TQWidget : public QWidget, virtual public TQt
{
	Q_OBJECT
	TQ_OBJECT
public:
	TQObject *tqparent() const;
	TQObjectList childrenListObject();
	const TQObjectList childrenListObject() const;

public:
// 	enum FocusPolicy {
// 		NoFocus = 0,
// 		TabFocus = 0x1,
// 		ClickFocus = 0x2,
// 		StrongFocus = TabFocus | ClickFocus | 0x8,
// 		WheelFocus = StrongFocus | 0x4
// 	};

	enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin };

// TQWidget methods
public:
	TQWidget( QWidget* tqparent=0, const char* name=0, WFlags f=0 );

	void setWState( uint state );
	void clearWState( uint flags );
	WState getWState() const;
	WState testWState( WState s ) const;
	WState testWState( TQt::WidgetState s ) const;

	void setWFlags( WFlags flags );
	void clearWFlags( WFlags flags );
	WFlags getWFlags() const;
	WFlags testWFlags( WFlags f ) const;

	uint windowState() const;
	void setWindowState(uint windowState);

	void setActiveWindow( void );
	Display * x11Display( void );
	int x11Depth() const;
	int x11Screen( void );
	TQWidget * parentWidget( bool sameWindow = FALSE ) const;
	static TQCString normalizeSignalSlot( const char *signalSlot );
	TQMetaObject *tqmetaObject() const;
	static TQWidget * tqfind( WId w );
	bool isShown() const;
	TQWidget *tqchildAt( int x, int y, bool includeThis = FALSE ) const;
	TQWidget *tqchildAt( const TQPoint &p, bool includeThis = FALSE ) const;
	TQWidget *tqtopLevelWidget() const;
	bool isA(const char *classname) const;
	bool inherits( const char * ) const;
// 	virtual bool close( bool alsoDelete ) { TQ_UNUSED(alsoDelete); return QWidget::close(); }
// 	TQWExtra *extraData() { return TQT_TQWEXTRA(qt_widget_private(this)->extraData()); }
	TQWExtra *extraData();
// 	TQTLWExtra *topData() { return qt_widget_private(this)->topData(); }
	TQTLWExtra *topData();
	void setName(const char *aName);
	TQWidget *parentWidget( bool sameWindow = FALSE );
	bool isDialog() const;
	TQObject *child( const char *objName, const char *inheritsClass = 0, bool recursiveSearch = TRUE );
	const TQRect tqgeometry() const;
	TQLayout *tqlayout() const;
	virtual TQSize tqsizeHint() const;
	virtual TQSize tqminimumSizeHint() const;
	virtual QSize sizeHint() const;
	virtual QSize minimumSizeHint() const;
	TQSize tqminimumSize() const;
	TQSize tqmaximumSize() const;
	TQColorGroup tqcolorGroup() const;
	TQStyle &tqstyle() const;
	void reparent(QWidget *parent, WFlags f, const QPoint &p, bool showIt=false);
	void reparent(QWidget *parent, const QPoint &p, bool showIt=false);
	void iconify();
	void constPolish() const;
	bool hasMouse() const;
#ifndef QT_NO_CURSOR
	bool ownCursor() const;
#endif
	bool ownFont() const;
	void setBackgroundPixmap(const QPixmap &pm);
	virtual void tqsetBackgroundPixmap(const QPixmap &pm);
	const TQPixmap *backgroundPixmap() const;
	void tqsetSizePolicy(QSizePolicy qsp);
	void tqsetSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
	void tqsetSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw);
	void setInputMethodEnabled(bool b);
	bool isInputMethodEnabled() const;
	bool isPopup() const;
	TQString caption() const;
	void setCaption(const QString &c);
	TQRect tqchildrenRect() const;
	TQRegion tqchildrenRegion() const;
	void unsetFont();
	bool ownPalette() const;
	void unsetPalette();
	const TQPalette &tqpalette() const;
	bool isUpdatesEnabled() const;
	void tqrepaint(int x, int y, int w, int h);
	void tqrepaint(const QRect &r);
	void tqrepaint(const QRegion &r);
	void tqrepaint(bool eraseme);
	void tqrepaint(int x, int y, int w, int h, bool);
	void tqrepaint(const QRect &r, bool);
	void tqrepaint(const QRegion &rgn, bool);
	TQSizePolicy tqsizePolicy() const;
	TQPoint backgroundOffset() const;
	bool tqsignalsBlocked() const;
	TQObjectList *queryList( const char *inheritsClass = 0, const char *objName = 0, bool regexpMatch = TRUE, bool recursiveSearch = TRUE ) const;
	TQWidget *tqfocusWidget() const;
	 void setBackgroundOrigin(BackgroundOrigin);
	BackgroundOrigin backgroundOrigin() const;
	void setIconText(const QString &it);
	void insertChild( TQObject *object );
	void removeChild( TQObject *object );

	bool close();
	bool close(bool alsoDelete);

	void setFocus(Qt::FocusReason reason);
	void setFocus(TQFocusEvent::Reason reason);

	TQt::BackgroundMode backgroundMode() const;
	/*virtual*/ void setBackgroundMode( TQt::BackgroundMode tqbm );
	void setBackgroundMode(TQt::BackgroundMode, TQt::BackgroundMode);
	const QColor &paletteForegroundColor() const;
	void setPaletteForegroundColor(const QColor &c);
	const QColor &paletteBackgroundColor() const;
	/*virtual*/ void setPaletteBackgroundColor(const QColor &c);
	const TQPixmap *paletteBackgroundPixmap() const;
	/*virtual*/ void setPaletteBackgroundPixmap(const QPixmap &pm);
	const TQColor &backgroundColor() const;
	/*virtual*/ void setBackgroundColor(const QColor &c);
	const TQColor &eraseColor() const;
	/*virtual*/ void setEraseColor(const QColor &c);
	const TQPixmap *erasePixmap() const;
	/*virtual*/ void setErasePixmap(const QPixmap &pm);
	const TQColor &foregroundColor() const;

	virtual void setAutoMask(bool);
	bool autoMask() const;
	virtual void updateMask();

	void erase();
	void erase(int x, int y, int w, int h);
	void erase(const QRect &r);
	void erase(const QRegion &r);

	void drawText( int x, int y, const TQString &);
	void drawText( const TQPoint &, const TQString &);

	const TQBrush& backgroundBrush() const;
	void setIcon(const QPixmap &i);
	const TQPixmap *icon() const;
	const TQPixmap iconPixmap() const;

	const char *tqname() const;
	const char *name() const;
	const char *name(const char *defaultName) const;

	bool isVisibleToTLW() const; // obsolete
	static TQWidget* tqt_ensure_valid_widget_painting(TQWidget* w);

	void setMask( const QBitmap );
	void setMask( const QRegion );

#ifndef TQT_NO_STYLE
	void setStyle( TQStyle * );
	TQStyle* setStyle( const TQString& );
#endif

#ifndef TQT_NO_PALETTE
	void tqsetPalette( const TQPalette &p, bool );
#endif

// 	static TQWidgetMapper *wmapper( void ) { return QWidgetPrivate::mapper; }

// TQWExtra	*extraData();
// TQTLWExtra	*topData();
// TQFocusData	*focusData();

	bool isDesktop() const;

	void createTLSysExtra( void );
	void destroyInputContext( void );

	void createExtra();
	void deleteExtra();

	bool isFocusEnabled() const;

// 	TQRect tqeffectiveRectFor(const QRect &rect);
	TQRect tqclipRect() const;
	TQRect visibleRect() const;
	TQRegion clipRegion() const;

	virtual bool customWhatsThis() const;

	virtual void setKeyCompression(bool);
	TQRect microFocusHint() const;
	virtual void setMicroFocusHint(int x, int y, int w, int h, bool text=TRUE, TQFont *f = 0);

// 	// Interoperability
// 	TQWidget* operator= (QWidget* a)
// 	{
// 		return static_cast<TQWidget*>(a);
// 	}

	operator TQObject*() const { return TQT_TQOBJECT(const_cast<TQWidget*>(this)); }	// This implicit pointer converter doesn't work for some reason

public:
	// TQt handler
	virtual bool eventFilter( TQObject *, TQEvent * );

	// Qt4 handler interface
	virtual bool eventFilter( QObject *q, QEvent *e );
	bool event( QEvent *e );

protected:
	inline bool checkConnectArgs(const char *signal, const TQT_BASE_OBJECT_NAME *name, const char *member) { return TQT_TQOBJECT(this)->checkConnectArgs(signal, name, member); }

// TQt event handlers
protected:
	TQFocusData *focusData();
//	virtual bool event( QEvent *e );					// NOTE: All event handlers that can be subclassed must be declared here, and
										// declared virtual, so that run time dynamic call resolution will occur
	virtual bool event( TQEvent *e );
	virtual void mousePressEvent( TQMouseEvent * );	
	virtual void mouseReleaseEvent( TQMouseEvent * );
	virtual void mouseDoubleClickEvent( TQMouseEvent * );
	virtual void mouseMoveEvent( TQMouseEvent * );
#ifndef TQT_NO_WHEELEVENT
	virtual void wheelEvent( TQWheelEvent * );
#endif
	virtual void keyPressEvent( TQKeyEvent * );
	virtual void keyReleaseEvent( TQKeyEvent * );
	virtual void focusInEvent( TQFocusEvent * );
	virtual void focusOutEvent( TQFocusEvent * );
	virtual void enterEvent( TQEvent * );
	virtual void leaveEvent( TQEvent * );
	virtual void paintEvent( TQPaintEvent * );
	virtual void moveEvent( TQMoveEvent * );
	virtual void resizeEvent( TQResizeEvent * );
	virtual void closeEvent( TQCloseEvent * );
	virtual void contextMenuEvent( TQContextMenuEvent * );
	virtual void imStartEvent( TQIMEvent * );
	virtual void imComposeEvent( TQIMEvent * );
	virtual void imEndEvent( TQIMEvent * );
	virtual void tabletEvent( TQTabletEvent * );

#ifndef TQT_NO_DRAGANDDROP
	virtual void dragEnterEvent( TQDragEnterEvent * );
	virtual void dragMoveEvent( TQDragMoveEvent * );
	virtual void dragLeaveEvent( TQDragLeaveEvent * );
	virtual void dropEvent( TQDropEvent * );
#endif

	virtual void showEvent( TQShowEvent * );
	virtual void hideEvent( TQHideEvent * );

#if defined(TQ_WS_MAC)
	virtual bool macEvent( MSG * );
#endif
#if defined(TQ_WS_WIN)
	virtual bool winEvent( MSG * );
#endif
#if defined(TQ_WS_X11)
	virtual bool x11Event( XEvent * );
#endif
#if defined(TQ_WS_TQWS)
	virtual bool qwsEvent( TQWSEvent * );
#endif

// Qt4 event handler interface
protected:
	virtual void mousePressEvent(QMouseEvent *e);
	virtual void mouseReleaseEvent(QMouseEvent *e);
	virtual void mouseDoubleClickEvent(QMouseEvent *e);
	virtual void mouseMoveEvent(QMouseEvent *e);
#ifndef QT_NO_WHEELEVENT
	virtual void wheelEvent(QWheelEvent *e);
#endif
	virtual void keyPressEvent(QKeyEvent *e);
	virtual void keyReleaseEvent(QKeyEvent *e);
	virtual void focusInEvent(QFocusEvent *e);
	virtual void focusOutEvent(QFocusEvent *e);
	virtual void enterEvent(QEvent *e);
	virtual void leaveEvent(QEvent *e);
	virtual void paintEvent(QPaintEvent *e);
	virtual void moveEvent(QMoveEvent *e);
	virtual void resizeEvent(QResizeEvent *e);
	virtual void closeEvent(QCloseEvent *e);
#ifndef QT_NO_CONTEXTMENU
	virtual void contextMenuEvent(QContextMenuEvent *e);
#endif
#ifndef QT_NO_TABLETEVENT
	virtual void tabletEvent(QTabletEvent *e);
#endif
#ifndef QT_NO_ACTION
// 	inline virtual void actionEvent(QActionEvent *e) { actionEvent(static_cast<TQActionEvent*>(e)); }
#endif

// #ifndef QT_NO_DRAGANDDROP
// 	inline virtual void dragEnterEvent(QDragEnterEvent *e) { dragEnterEvent(static_cast<TQDragEnterEvent*>(e)); }
// 	inline virtual void dragMoveEvent(QDragMoveEvent *e) { dragMoveEvent(static_cast<TQDragMoveEvent*>(e)); }
// 	inline virtual void dragLeaveEvent(QDragLeaveEvent *e) { dragLeaveEvent(static_cast<TQDragLeaveEvent*>(e)); }
// 	inline virtual void dropEvent(QDropEvent *e) { dropEvent(static_cast<TQDropEvent*>(e)); }
// #endif

	virtual void showEvent(QShowEvent *e);
	virtual void hideEvent(QHideEvent *e);

// #if defined(Q_WS_MAC)
// 	inline virtual bool macEvent(EventHandlerCallRef e, EventRef r);
// #endif
// #if defined(Q_WS_WIN)
// 	inline virtual bool winEvent(MSG *message, long *result);
// #endif
// #if defined(Q_WS_X11)
// 	inline virtual bool x11Event(XEvent *e)
// #endif
// #if defined(Q_WS_QWS)
// 	inline virtual bool qwsEvent(QWSEvent *e);
// #endif

// TQt event handlers
protected:
	virtual void timerEvent( TQTimerEvent * );
	virtual void childEvent( TQChildEvent * );
	virtual void customEvent( TQCustomEvent * );

// Qt4 event handler interface
protected:
	virtual void timerEvent(QTimerEvent *e);
	virtual void childEvent(QChildEvent *e);
	virtual void customEvent(QEvent *e);

private:
	mutable TQStyle* tqt_internal_stylePointer;
	void erase_helper(int x, int y, int w, int h);
	TQWExtra *extra;
	TQFocusData *focusData( bool create );
	void createTLExtra();
	bool tqt_internal_show_called_event;
	mutable bool tqt_internal_ignore_next_windowstatechange_event;
	mutable TQString static_object_name;

	void showWindow();
	void hideWindow();

	WFlags TQtUpperWidgetFlags;
	void processUpperWidgetFlags();
	void setDefaultWidgetFlags();

	friend class TQObject;

public Q_SLOTS:
	virtual void tqsetUpdatesEnabled( bool enable );
	void tqrepaint();
	virtual void setFocus();
	virtual void show();
	virtual void adjustSize();
// 	inline virtual void adjustSize() {
// 		QApplication::sendPostedEvents( 0, TQEvent::ChildInserted );
// 		QWidget::adjustSize();
// 	}
	virtual void polish();
// 	inline virtual void setGeometry( int x, int y, int w, int h ) { return QWidget::setGeometry(x, y, w, h); }
// 	inline virtual void setGeometry( const TQRect &r ) { return QWidget::setGeometry(r); }

// protected:
	TQConnectionList *tqreceivers( const char* signal ) const;
	TQConnectionList *tqreceivers( int signal ) const;
//
	void activate_signal( int signal );
// 	void activate_signal( int signal, int second ) { TQT_TQOBJECT(this)->activate_signal(signal, second); }
// 	void activate_signal( int signal, double second ) { TQT_TQOBJECT(this)->activate_signal(signal, second); }
// 	void activate_signal( int signal, TQString second ) { TQT_TQOBJECT(this)->activate_signal(signal, second); }
// 	void activate_signal_bool( int signal, bool second ) { TQT_TQOBJECT(this)->activate_signal(signal, second); }
	void activate_signal( TQConnectionList *clist, TQUObject *o );

	void tqt_handle_qt_destroyed(QObject* obj);

Q_SIGNALS:
	void destroyed( TQObject* obj );
};

inline void TQWidget::drawText( const TQPoint &p, const TQString &s )
{ drawText( p.x(), p.y(), s ); }

#else // USE_QT4

class TQ_EXPORT TQWidget : public TQObject, public TQPaintDevice
{
    TQ_OBJECT
    TQ_ENUMS( BackgroundMode FocusPolicy BackgroundOrigin )
    Q_PROPERTY( bool isTopLevel READ isTopLevel )
    Q_PROPERTY( bool isDialog READ isDialog )
    Q_PROPERTY( bool isModal READ isModal )
    Q_PROPERTY( bool isPopup READ isPopup )
    Q_PROPERTY( bool isDesktop READ isDesktop )
    Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
    Q_PROPERTY( TQRect tqgeometry READ tqgeometry WRITE setGeometry )
    Q_PROPERTY( TQRect frameGeometry READ frameGeometry )
    Q_PROPERTY( int x READ x )
    Q_PROPERTY( int y READ y )
    Q_PROPERTY( TQPoint pos READ pos WRITE move DESIGNABLE false STORED false )
    Q_PROPERTY( TQSize frameSize READ frameSize )
    Q_PROPERTY( TQSize size READ size WRITE resize DESIGNABLE false STORED false )
    Q_PROPERTY( int width READ width )
    Q_PROPERTY( int height READ height )
    Q_PROPERTY( TQRect rect READ rect )
    Q_PROPERTY( TQRect tqchildrenRect READ tqchildrenRect )
    Q_PROPERTY( TQRegion tqchildrenRegion READ tqchildrenRegion )
    Q_PROPERTY( TQSizePolicy sizePolicy READ sizePolicy WRITE tqsetSizePolicy )
    Q_PROPERTY( TQSize tqminimumSize READ tqminimumSize WRITE setMinimumSize )
    Q_PROPERTY( TQSize tqmaximumSize READ tqmaximumSize WRITE setMaximumSize )
    Q_PROPERTY( int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false )
    Q_PROPERTY( int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false )
    Q_PROPERTY( int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false )
    Q_PROPERTY( int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false )
    Q_PROPERTY( TQSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement )
    Q_PROPERTY( TQSize baseSize READ baseSize WRITE setBaseSize )
    Q_PROPERTY( BackgroundMode backgroundMode READ backgroundMode WRITE setBackgroundMode DESIGNABLE false )
    Q_PROPERTY( TQColor paletteForegroundColor READ paletteForegroundColor WRITE setPaletteForegroundColor RESET unsetPalette )
    Q_PROPERTY( TQColor paletteBackgroundColor READ paletteBackgroundColor WRITE setPaletteBackgroundColor RESET unsetPalette )
    Q_PROPERTY( TQPixmap paletteBackgroundPixmap READ paletteBackgroundPixmap WRITE setPaletteBackgroundPixmap RESET unsetPalette )
    Q_PROPERTY( TQBrush backgroundBrush READ backgroundBrush )
    Q_PROPERTY( TQColorGroup tqcolorGroup READ tqcolorGroup )
    Q_PROPERTY( TQPalette palette READ palette WRITE setPalette RESET unsetPalette  STORED ownPalette )
    Q_PROPERTY( BackgroundOrigin backgroundOrigin READ backgroundOrigin WRITE setBackgroundOrigin )
    Q_PROPERTY( bool ownPalette READ ownPalette )
    Q_PROPERTY( TQFont font READ font WRITE setFont RESET unsetFont STORED ownFont )
    Q_PROPERTY( bool ownFont READ ownFont )
#ifndef TQT_NO_CURSOR
    Q_PROPERTY( TQCursor cursor READ cursor WRITE setCursor RESET unsetCursor STORED ownCursor )
    Q_PROPERTY( bool ownCursor READ ownCursor )
#endif
#ifndef TQT_NO_WIDGET_TOPEXTRA
    Q_PROPERTY( TQString caption READ caption WRITE setCaption )
    Q_PROPERTY( TQPixmap icon READ icon WRITE setIcon )
    Q_PROPERTY( TQString iconText READ iconText WRITE setIconText )
#endif
    Q_PROPERTY( bool mouseTracking READ hasMouseTracking WRITE setMouseTracking )
    Q_PROPERTY( bool underMouse READ hasMouse )
    Q_PROPERTY( bool isActiveWindow READ isActiveWindow )
    Q_PROPERTY( bool focusEnabled READ isFocusEnabled )
    Q_PROPERTY( FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy )
    Q_PROPERTY( bool focus READ hasFocus )
    Q_PROPERTY( bool updatesEnabled READ isUpdatesEnabled WRITE setUpdatesEnabled DESIGNABLE false )
    Q_PROPERTY( bool visible READ isVisible )
    Q_PROPERTY( TQRect visibleRect READ visibleRect ) // obsolete
    Q_PROPERTY( bool hidden READ isHidden WRITE setHidden DESIGNABLE false SCRIPTABLE false )
    Q_PROPERTY( bool shown READ isShown WRITE setShown DESIGNABLE false SCRIPTABLE false )
    Q_PROPERTY( bool minimized READ isMinimized )
    Q_PROPERTY( bool maximized READ isMaximized )
    Q_PROPERTY( bool fullScreen READ isFullScreen )
    Q_PROPERTY( TQSize tqsizeHint READ tqsizeHint )
    Q_PROPERTY( TQSize tqminimumSizeHint READ tqminimumSizeHint )
    Q_PROPERTY( TQRect microFocusHint READ microFocusHint )
    Q_PROPERTY( bool acceptDrops READ acceptDrops WRITE setAcceptDrops )
    Q_PROPERTY( bool autoMask READ autoMask WRITE setAutoMask DESIGNABLE false SCRIPTABLE false )
    Q_PROPERTY( bool customWhatsThis READ customWhatsThis )
    Q_PROPERTY( bool inputMethodEnabled READ isInputMethodEnabled WRITE setInputMethodEnabled DESIGNABLE false SCRIPTABLE false )
    Q_PROPERTY( double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE false )

public:
    TQ_EXPLICIT TQWidget( TQWidget* tqparent=0, const char* name=0, WFlags f=0 );
    ~TQWidget();

    WId		 winId() const;
    void	 setName( const char *name );
#ifndef TQT_NO_STYLE
    // GUI style setting

    TQStyle     &style() const;
    void        setStyle( TQStyle * );
    TQStyle*	setStyle( const TQString& );
#endif
    // Widget types and states

    bool	 isTopLevel()	const;
    bool	 isDialog()	const;
    bool	 isPopup()	const;
    bool	 isDesktop()	const;
    bool	 isModal()	const;

    bool	 isEnabled()	const;
    bool	 isEnabledTo(TQWidget*) const;
    bool	 isEnabledToTLW() const;

public Q_SLOTS:
    virtual void setEnabled( bool );
    void setDisabled( bool );

    // Widget coordinates

public:
    TQRect	 frameGeometry() const;
    const TQRect &tqgeometry()	const;
    int		 x()		const;
    int		 y()		const;
    TQPoint	 pos()		const;
    TQSize	 frameSize()    const;
    TQSize	 size()		const;
    int		 width()	const;
    int		 height()	const;
    TQRect	 rect()		const;
    TQRect	 tqchildrenRect() const;
    TQRegion	 tqchildrenRegion() const;

    TQSize	 tqminimumSize()	 const;
    TQSize	 tqmaximumSize()	 const;
    int		 minimumWidth()	 const;
    int		 minimumHeight() const;
    int		 maximumWidth()	 const;
    int		 maximumHeight() const;
    void	 setMinimumSize( const TQSize & );
    virtual void setMinimumSize( int minw, int minh );
    void	 setMaximumSize( const TQSize & );
    virtual void setMaximumSize( int maxw, int maxh );
    void	 setMinimumWidth( int minw );
    void	 setMinimumHeight( int minh );
    void	 setMaximumWidth( int maxw );
    void	 setMaximumHeight( int maxh );

    TQSize	 sizeIncrement() const;
    void	 setSizeIncrement( const TQSize & );
    virtual void setSizeIncrement( int w, int h );
    TQSize	 baseSize() const;
    void	 setBaseSize( const TQSize & );
    void	 setBaseSize( int basew, int baseh );

    void	setFixedSize( const TQSize & );
    void	setFixedSize( int w, int h );
    void	setFixedWidth( int w );
    void	setFixedHeight( int h );

    // Widget coordinate mapping

    TQPoint	 mapToGlobal( const TQPoint & )	 const;
    TQPoint	 mapFromGlobal( const TQPoint & ) const;
    TQPoint	 mapToParent( const TQPoint & )	 const;
    TQPoint	 mapFromParent( const TQPoint & ) const;
    TQPoint	 mapTo( TQWidget *, const TQPoint & ) const;
    TQPoint	 mapFrom( TQWidget *, const TQPoint & ) const;

    TQWidget	*tqtopLevelWidget()   const;

    // Widget attribute functions

    BackgroundMode	backgroundMode() const;
    virtual void	setBackgroundMode( BackgroundMode );
    void 		setBackgroundMode( BackgroundMode, BackgroundMode );

    const TQColor &	foregroundColor() const;

    const TQColor &	eraseColor() const;
    virtual void	setEraseColor( const TQColor & );

    const TQPixmap *	erasePixmap() const;
    virtual void	setErasePixmap( const TQPixmap & );

#ifndef TQT_NO_PALETTE
    const TQColorGroup & tqcolorGroup() const;
    const TQPalette &	palette()    const;
    bool		ownPalette() const;
    virtual void	setPalette( const TQPalette & );
    void		unsetPalette();
#endif

    const TQColor &	paletteForegroundColor() const;
    void		setPaletteForegroundColor( const TQColor & );

    const TQColor &	paletteBackgroundColor() const;
    virtual void	setPaletteBackgroundColor( const TQColor & );

    const TQPixmap *	paletteBackgroundPixmap() const;
    virtual void 	setPaletteBackgroundPixmap( const TQPixmap & );

    const TQBrush&	backgroundBrush() const;

    TQFont		font() const;
    bool		ownFont() const;
    virtual void	setFont( const TQFont & );
    void		unsetFont();
    TQFontMetrics	fontMetrics() const;
    TQFontInfo	 	fontInfo() const;

#ifndef TQT_NO_CURSOR
    const TQCursor      &cursor() const;
    bool		ownCursor() const;
    virtual void	setCursor( const TQCursor & );
    virtual void	unsetCursor();
#endif
#ifndef TQT_NO_WIDGET_TOPEXTRA
    TQString		caption() const;
    const TQPixmap      *icon() const;
    TQString		iconText() const;
#endif
    bool		hasMouseTracking() const;
    bool		hasMouse() const;

    virtual void	setMask( const TQBitmap & );
    virtual void	setMask( const TQRegion & );
    void		clearMask();

    const TQColor &	backgroundColor() const; // obsolete, use eraseColor()
    virtual void	setBackgroundColor( const TQColor & ); // obsolete, use setEraseColor()
    const TQPixmap *	backgroundPixmap() const; // obsolete, use erasePixmap()
    virtual void	setBackgroundPixmap( const TQPixmap & ); // obsolete, use setErasePixmap()

public Q_SLOTS:
#ifndef TQT_NO_WIDGET_TOPEXTRA
    virtual void	setCaption( const TQString &);
    virtual void	setIcon( const TQPixmap & );
    virtual void	setIconText( const TQString &);
#endif
    virtual void	setMouseTracking( bool enable );

    // Keyboard input focus functions

    virtual void	setFocus();
    void		clearFocus();

public:
    enum FocusPolicy {
	NoFocus = 0,
	TabFocus = 0x1,
	ClickFocus = 0x2,
	StrongFocus = TabFocus | ClickFocus | 0x8,
	WheelFocus = StrongFocus | 0x4
    };

    bool		isActiveWindow() const;
    virtual void	setActiveWindow();
    bool		isFocusEnabled() const;

    FocusPolicy		focusPolicy() const;
    virtual void	setFocusPolicy( FocusPolicy );
    bool		hasFocus() const;
    static void		setTabOrder( TQWidget *, TQWidget * );
    virtual void	setFocusProxy( TQWidget * );
    TQWidget *		focusProxy() const;

    void setInputMethodEnabled( bool b );
    bool isInputMethodEnabled() const;
    // Grab functions

    void		grabMouse();
#ifndef TQT_NO_CURSOR
    void		grabMouse( const TQCursor & );
#endif
    void		releaseMouse();
    void		grabKeyboard();
    void		releaseKeyboard();
    static TQWidget *	mouseGrabber();
    static TQWidget *	keyboardGrabber();

    // Update/refresh functions

    bool	 	isUpdatesEnabled() const;

#if 0 //def TQ_WS_TQWS
    void		repaintUnclipped( const TQRegion &, bool erase = TRUE );
#endif
public Q_SLOTS:
    virtual void	setUpdatesEnabled( bool enable );
    void		update();
    void		update( int x, int y, int w, int h );
    void		update( const TQRect& );
    void		tqrepaint();
    void		tqrepaint( bool erase );
    void		tqrepaint( int x, int y, int w, int h, bool erase=TRUE );
    void		tqrepaint( const TQRect &, bool erase = TRUE );
    void		tqrepaint( const TQRegion &, bool erase = TRUE );

    // Widget management functions

    virtual void	show();
    virtual void	hide();
    void		setShown( bool show );
    void		setHidden( bool hide );
#ifndef TQT_NO_COMPAT
    void		iconify() { showMinimized(); }
#endif
    virtual void	showMinimized();
    virtual void	showMaximized();
    void		showFullScreen();
    virtual void	showNormal();
    virtual void	polish();
    void 		constPolish() const;
    bool		close();

    void		raise();
    void		lower();
    void		stackUnder( TQWidget* );
    virtual void	move( int x, int y );
    void		move( const TQPoint & );
    virtual void	resize( int w, int h );
    void		resize( const TQSize & );
    virtual void	setGeometry( int x, int y, int w, int h );
    virtual void	setGeometry( const TQRect & ); // ### make non virtual in TQt 4?

public:
    virtual bool	close( bool alsoDelete );
    bool		isVisible()	const;
    bool		isVisibleTo(TQWidget*) const;
    bool		isVisibleToTLW() const; // obsolete
    TQRect		visibleRect() const; // obsolete
    bool 		isHidden() const;
    bool 		isShown() const;
    bool		isMinimized() const;
    bool		isMaximized() const;
    bool		isFullScreen() const;

    uint windowState() const;
    void setWindowState(uint windowState);

    virtual TQSize	tqsizeHint() const;
    virtual TQSize	tqminimumSizeHint() const;
    virtual TQSizePolicy	sizePolicy() const;
    virtual void	tqsetSizePolicy( TQSizePolicy );
    void 		tqsetSizePolicy( TQSizePolicy::SizeType hor, TQSizePolicy::SizeType ver, bool hfw = FALSE );
    virtual int heightForWidth(int) const;

    TQRegion	clipRegion() const;

// ### move together with other Q_SLOTS in TQt 4.0
public Q_SLOTS:
    virtual void  	adjustSize();

public:
#ifndef TQT_NO_LAYOUT
    TQLayout *		tqlayout() const { return lay_out; }
#endif
    void		updateGeometry();
    virtual void 	reparent( TQWidget *tqparent, WFlags, const TQPoint &,
				  bool showIt=FALSE );
    void		reparent( TQWidget *tqparent, const TQPoint &,
				  bool showIt=FALSE );
#ifndef TQT_NO_COMPAT
    void		recreate( TQWidget *tqparent, WFlags f, const TQPoint & p,
				  bool showIt=FALSE ) { reparent(tqparent,f,p,showIt); }
#endif

    void		erase();
    void		erase( int x, int y, int w, int h );
    void		erase( const TQRect & );
    void		erase( const TQRegion & );
    void		scroll( int dx, int dy );
    void		scroll( int dx, int dy, const TQRect& );

    void		drawText( int x, int y, const TQString &);
    void		drawText( const TQPoint &, const TQString &);

    // Misc. functions

    TQWidget *		tqfocusWidget() const;
    TQRect               microFocusHint() const;

    // drag and drop

    bool		acceptDrops() const;
    virtual void	setAcceptDrops( bool on );

    // transparency and pseudo transparency

    virtual void	setAutoMask(bool);
    bool		autoMask() const;

    enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin };

    virtual void setBackgroundOrigin( BackgroundOrigin );
    BackgroundOrigin backgroundOrigin() const;
    TQPoint backgroundOffset() const;

    // whats this help
    virtual bool customWhatsThis() const;

    TQWidget *		parentWidget( bool sameWindow = FALSE ) const;
    WState		testWState( WState s ) const;
    WFlags		testWFlags( WFlags f ) const;
    static TQWidget *	tqfind( WId );
    static TQWidgetMapper *wmapper();

    TQWidget  *tqchildAt( int x, int y, bool includeThis = FALSE ) const;
    TQWidget  *tqchildAt( const TQPoint &, bool includeThis = FALSE ) const;

#if defined(TQ_WS_TQWS)
    virtual TQGfx * graphicsContext(bool clip_tqchildren=TRUE) const;
#endif
#if defined(TQ_WS_MAC)
    TQRegion clippedRegion(bool do_tqchildren=TRUE);
    uint clippedSerial(bool do_tqchildren=TRUE);
#ifndef TQMAC_NO_TQUARTZ
    CGContextRef macCGContext(bool clipped=TRUE) const;
#endif
#endif

    void setWindowOpacity(double level);
    double windowOpacity() const;

protected:
    // Event handlers
    virtual bool event( TQEvent * );
    virtual void mousePressEvent( TQMouseEvent * );
    virtual void mouseReleaseEvent( TQMouseEvent * );
    virtual void mouseDoubleClickEvent( TQMouseEvent * );
    virtual void mouseMoveEvent( TQMouseEvent * );
#ifndef TQT_NO_WHEELEVENT
    virtual void wheelEvent( TQWheelEvent * );
#endif
    virtual void keyPressEvent( TQKeyEvent * );
    virtual void keyReleaseEvent( TQKeyEvent * );
    virtual void focusInEvent( TQFocusEvent * );
    virtual void focusOutEvent( TQFocusEvent * );
    virtual void enterEvent( TQEvent * );
    virtual void leaveEvent( TQEvent * );
    virtual void paintEvent( TQPaintEvent * );
    virtual void moveEvent( TQMoveEvent * );
    virtual void resizeEvent( TQResizeEvent * );
    virtual void closeEvent( TQCloseEvent * );
    virtual void contextMenuEvent( TQContextMenuEvent * );
    virtual void imStartEvent( TQIMEvent * );
    virtual void imComposeEvent( TQIMEvent * );
    virtual void imEndEvent( TQIMEvent * );
    virtual void tabletEvent( TQTabletEvent * );

#ifndef TQT_NO_DRAGANDDROP
    virtual void dragEnterEvent( TQDragEnterEvent * );
    virtual void dragMoveEvent( TQDragMoveEvent * );
    virtual void dragLeaveEvent( TQDragLeaveEvent * );
    virtual void dropEvent( TQDropEvent * );
#endif

    virtual void showEvent( TQShowEvent * );
    virtual void hideEvent( TQHideEvent * );

#if defined(TQ_WS_MAC)
    virtual bool macEvent( MSG * );
#endif
#if defined(TQ_WS_WIN)
    virtual bool winEvent( MSG * );
#endif
#if defined(TQ_WS_X11)
    virtual bool x11Event( XEvent * );
#endif
#if defined(TQ_WS_TQWS)
    virtual bool qwsEvent( TQWSEvent * );
    virtual unsigned char *scanLine( int ) const;
    virtual int bytesPerLine() const;
#endif

    virtual void updateMask();

    // Misc. protected functions

#ifndef TQT_NO_STYLE
    virtual void styleChange( TQStyle& );
#endif
    virtual void enabledChange( bool oldEnabled );
#ifndef TQT_NO_PALETTE
    virtual void paletteChange( const TQPalette & );
#endif
    virtual void fontChange( const TQFont & );
    virtual void windowActivationChange( bool oldActive );

    int		 metric( int )	const;

    void	 resetInputContext();

    virtual void create( WId = 0, bool initializeWindow = TRUE,
			 bool destroyOldWindow = TRUE );
    virtual void destroy( bool destroyWindow = TRUE,
			  bool destroySubWindows = TRUE );
    uint	 getWState() const;
    virtual void setWState( uint );
    void	 clearWState( uint n );
    WFlags	 getWFlags() const;
    virtual void setWFlags( WFlags );
    void	 clearWFlags( WFlags n );

    virtual bool focusNextPrevChild( bool next );

    TQWExtra	*extraData();
    TQTLWExtra	*topData();
    TQFocusData	*focusData();

    virtual void setKeyCompression(bool);
    virtual void setMicroFocusHint(int x, int y, int w, int h, bool text=TRUE, TQFont *f = 0);

#if defined(TQ_WS_MAC)
    void dirtyClippedRegion(bool);
    bool isClippedRegionDirty();
    virtual void setRegionDirty(bool);
    virtual void macWidgetChangedWindow();
#endif

private Q_SLOTS:
    void	 focusProxyDestroyed();

private:
    void	 setFontSys( TQFont *f = 0 );
#if defined(TQ_WS_X11)
    void	 createInputContext();
    void	 destroyInputContext();
    void	 focusInputContext();
    void	 checkChildrenDnd();
#elif defined(TQ_WS_MAC)
    uint    own_id : 1, macDropEnabled : 1;
    EventHandlerRef window_event;
    //mac event functions
    void    propagateUpdates(bool update_rgn=TRUE);
    void    update( const TQRegion& );
    //friends, way too many - fix this immediately!
    friend void qt_clean_root_win();
    friend bool qt_recreate_root_win();
    friend TQPoint posInWindow(TQWidget *);
    friend bool qt_mac_update_sizer(TQWidget *, int);
    friend TQWidget *qt_recursive_match(TQWidget *widg, int x, int y);
    friend bool qt_paint_childrenListObject(TQWidget *,TQRegion &, uchar ops);
    friend TQMAC_PASCAL OStqStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
    friend void qt_event_request_updates(TQWidget *, const TQRegion &, bool subtract);
    friend bool qt_window_rgn(WId, short, RgnHandle, bool);
    friend class TQDragManager;
#endif

#ifndef TQT_NO_LAYOUT
    void 	 setLayout( TQLayout *l );
#endif
    void	 setWinId( WId );
    void	 showWindow();
    void	 hideWindow();
    void	 showChildren( bool spontaneous );
    void	 hideChildren( bool spontaneous );
    void	 reparentSys( TQWidget *tqparent, WFlags, const TQPoint &,  bool showIt);
    void	 createTLExtra();
    void	 createExtra();
    void	 deleteExtra();
    void	 createSysExtra();
    void	 deleteSysExtra();
    void	 createTLSysExtra();
    void	 deleteTLSysExtra();
    void	 deactivateWidgetCleanup();
    void	 internalSetGeometry( int, int, int, int, bool );
    void	 reparentFocusWidgets( TQWidget * );
    TQFocusData	*focusData( bool create );
    void         setBackgroundFromMode();
    void         setBackgroundColorDirect( const TQColor & );
    void   	 setBackgroundPixmapDirect( const TQPixmap & );
    void         setBackgroundModeDirect( BackgroundMode );
    void         setBackgroundEmpty();
    void	 updateFrameStrut() const;
#if defined(TQ_WS_X11)
    void         setBackgroundX11Relative();
#endif

    WId		 winid;
    uint	 widget_state;
    uint	 widget_flags;
    uint	 focus_policy : 4;
    uint 	 own_font :1;
    uint 	 own_palette :1;
    uint 	 sizehint_forced :1;
    uint 	 is_closing :1;
    uint 	 in_show : 1;
    uint 	 in_show_maximized : 1;
    uint	 fstrut_dirty : 1;
    uint	 im_enabled : 1;
    TQRect	 crect;
    TQColor	 bg_col;
#ifndef TQT_NO_PALETTE
    TQPalette	 pal;
#endif
    TQFont	 fnt;
#ifndef TQT_NO_LAYOUT
    TQLayout 	*lay_out;
#endif
    TQWExtra	*extra;
#if defined(TQ_WS_TQWS)
    TQRegion	 req_region;			// Requested region
    mutable TQRegion	 paintable_region;	// Paintable region
    mutable bool         paintable_region_dirty;// needs to be recalculated
    mutable TQRegion      alloc_region;          // Allocated region
    mutable bool         alloc_region_dirty;    // needs to be recalculated
    mutable int          overlapping_tqchildren;  // Handle overlapping tqchildren

    int		 alloc_region_index;
    int		 alloc_region_revision;

    void updateOverlappingChildren() const;
    void setChildrenAllocatedDirty();
    void setChildrenAllocatedDirty( const TQRegion &r, const TQWidget *dirty=0 );
    bool isAllocatedRegionDirty() const;
    void updateRequestedRegion( const TQPoint &gpos );
    TQRegion requestedRegion() const;
    TQRegion allocatedRegion() const;
    TQRegion paintableRegion() const;

    void updateGraphicsContext( TQGfx *qgfx_qws, bool clip_tqchildren ) const;
#ifndef TQT_NO_CURSOR
    void updateCursor( const TQRegion &r ) const;
#endif

    // used to accumulate dirty region when tqchildren moved/resized.
    TQRegion dirtyChildren;
    bool isSettingGeometry;
    friend class TQWSManager;
#endif
    static int instanceCounter;  // Current number of widget instances
    static int maxInstances;     // Maximum number of widget instances

    static void	 createMapper();
    static void	 destroyMapper();
    static TQWidgetList	 *wList();
    static TQWidgetList	 *tlwList();
    static TQWidgetMapper *mapper;
    friend class TQApplication;
    friend class TQBaseApplication;
    friend class TQPainter;
    friend class TQFontMetrics;
    friend class TQFontInfo;
    friend class TQETWidget;
    friend class TQLayout;

private:	// Disabled copy constructor and operator=
#if defined(TQ_DISABLE_COPY)
    TQWidget( const TQWidget & );
    TQWidget &operator=( const TQWidget & );
#endif

public: // obsolete functions to dissappear or to become inline in 3.0
#ifndef TQT_NO_PALETTE
    void setPalette( const TQPalette &p, bool ) { setPalette( p ); }
#endif
    void setFont( const TQFont &f, bool ) { setFont( f ); }
};


inline TQt::WState TQWidget::testWState( WState s ) const
{ return (widget_state & s); }

inline TQt::WFlags TQWidget::testWFlags( WFlags f ) const
{ return (widget_flags & f); }


inline WId TQWidget::winId() const
{ return winid; }

inline bool TQWidget::isTopLevel() const
{ return testWFlags(WType_TopLevel); }

inline bool TQWidget::isDialog() const
{ return testWFlags(WType_Dialog); }

inline bool TQWidget::isPopup() const
{ return testWFlags(WType_Popup); }

inline bool TQWidget::isDesktop() const
{ return testWFlags(WType_Desktop); }

inline bool TQWidget::isEnabled() const
{ return !testWState(WState_Disabled); }

inline bool TQWidget::isModal() const
{ return testWFlags(WShowModal); }

inline bool TQWidget::isEnabledToTLW() const
{ return isEnabled(); }

inline const TQRect &TQWidget::tqgeometry() const
{ return crect; }

inline TQSize TQWidget::size() const
{ return crect.size(); }

inline int TQWidget::width() const
{ return crect.width(); }

inline int TQWidget::height() const
{ return crect.height(); }

inline TQRect TQWidget::rect() const
{ return TQRect(0,0,crect.width(),crect.height()); }

inline int TQWidget::minimumWidth() const
{ return tqminimumSize().width(); }

inline int TQWidget::minimumHeight() const
{ return tqminimumSize().height(); }

inline int TQWidget::maximumWidth() const
{ return tqmaximumSize().width(); }

inline int TQWidget::maximumHeight() const
{ return tqmaximumSize().height(); }

inline void TQWidget::setMinimumSize( const TQSize &s )
{ setMinimumSize(s.width(),s.height()); }

inline void TQWidget::setMaximumSize( const TQSize &s )
{ setMaximumSize(s.width(),s.height()); }

inline void TQWidget::setSizeIncrement( const TQSize &s )
{ setSizeIncrement(s.width(),s.height()); }

inline void TQWidget::setBaseSize( const TQSize &s )
{ setBaseSize(s.width(),s.height()); }

inline const TQColor &TQWidget::eraseColor() const
{ return bg_col; }

#ifndef TQT_NO_PALETTE
inline const TQPalette &TQWidget::palette() const
{ return pal; }
#endif

inline TQFont TQWidget::font() const
{ return fnt; }

inline TQFontMetrics TQWidget::fontMetrics() const
{ return TQFontMetrics(font()); }

inline TQFontInfo TQWidget::fontInfo() const
{ return TQFontInfo(font()); }

inline bool TQWidget::hasMouseTracking() const
{ return testWState(WState_MouseTracking); }

inline bool TQWidget::hasMouse() const
{ return testWState(WState_HasMouse); }

inline bool  TQWidget::isFocusEnabled() const
{ return (FocusPolicy)focus_policy != NoFocus; }

inline TQWidget::FocusPolicy TQWidget::focusPolicy() const
{ return (FocusPolicy)focus_policy; }

inline bool TQWidget::isUpdatesEnabled() const
{ return !testWState(WState_BlockUpdates); }

inline void TQWidget::update( const TQRect &r )
{ update( r.x(), r.y(), r.width(), r.height() ); }

inline void TQWidget::tqrepaint()
{ tqrepaint( TRUE ); }

inline void TQWidget::tqrepaint( const TQRect &r, bool erase )
{ tqrepaint( r.x(), r.y(), r.width(), r.height(), erase ); }

inline void TQWidget::erase()
{ erase( 0, 0, crect.width(), crect.height() ); }

inline void TQWidget::erase( const TQRect &r )
{ erase( r.x(), r.y(), r.width(), r.height() ); }

inline bool TQWidget::close()
{ return close( FALSE ); }

inline bool TQWidget::isVisible() const
{ return testWState(WState_Visible); }

inline bool TQWidget::isVisibleToTLW() const // obsolete
{ return isVisible(); }

inline bool TQWidget::isHidden() const
{ return testWState(WState_ForceHide); }

inline bool TQWidget::isShown() const
{ return !testWState(WState_ForceHide); }

inline void TQWidget::move( const TQPoint &p )
{ move( p.x(), p.y() ); }

inline void TQWidget::resize( const TQSize &s )
{ resize( s.width(), s.height()); }

inline void TQWidget::setGeometry( const TQRect &r )
{ setGeometry( r.left(), r.top(), r.width(), r.height() ); }

inline void TQWidget::drawText( const TQPoint &p, const TQString &s )
{ drawText( p.x(), p.y(), s ); }

inline TQWidget *TQWidget::parentWidget( bool sameWindow ) const
{
    if ( sameWindow )
	return isTopLevel() ? 0 : (TQWidget *)TQObject::tqparent();
    return (TQWidget *)TQObject::tqparent();
}

inline TQWidgetMapper *TQWidget::wmapper()
{ return mapper; }

inline uint TQWidget::getWState() const
{ return widget_state; }

inline void TQWidget::setWState( uint f )
{ widget_state |= f; }

inline void TQWidget::clearWState( uint f )
{ widget_state &= ~f; }

inline TQt::WFlags TQWidget::getWFlags() const
{ return widget_flags; }

inline void TQWidget::setWFlags( WFlags f )
{ widget_flags |= f; }

inline void TQWidget::clearWFlags( WFlags f )
{ widget_flags &= ~f; }

inline void TQWidget::constPolish() const
{
    if ( !testWState(WState_Polished) ) {
	TQWidget* that = (TQWidget*) this;
	that->polish();
        that->setWState(WState_Polished); // be on the safe side...
    }
}
#ifndef TQT_NO_CURSOR
inline bool TQWidget::ownCursor() const
{
    return testWState( WState_OwnCursor );
}
#endif
inline bool TQWidget::ownFont() const
{
    return own_font;
}
#ifndef TQT_NO_PALETTE
inline bool TQWidget::ownPalette() const
{
    return own_palette;
}
#endif

inline void TQWidget::tqsetSizePolicy( TQSizePolicy::SizeType hor, TQSizePolicy::SizeType ver, bool hfw )
{
    tqsetSizePolicy( TQSizePolicy( hor, ver, hfw) );
}

inline bool TQWidget::isInputMethodEnabled() const
{
    return (bool)im_enabled;
}

// Extra TQWidget data
//  - to minimize memory usage for members that are seldom used.
//  - top-level widgets have extra extra data to reduce cost further

class TQFocusData;
class TQWSManager;
#if defined(TQ_WS_WIN)
class TQOleDropTarget;
#endif
#if defined(TQ_WS_MAC)
class TQMacDndExtra;
#endif

#endif // USE_QT4

#ifdef USE_QT4

#else // USE_QT4

struct TQ_EXPORT TQTLWExtra {
#ifndef TQT_NO_WIDGET_TOPEXTRA
    TQString  caption;				// widget caption
    TQString  iconText;				// widget icon text
    TQPixmap *icon;				// widget icon
#endif
    TQFocusData *focusData;			// focus data (for TLW)
    short    incw, inch;			// size increments
    // frame strut
    ulong    fleft, fright, ftop, fbottom;
    uint     unused : 8;                       // not used at this point...
#if defined( TQ_WS_WIN ) || defined( TQ_WS_MAC )
    uint     opacity : 8;		       // Stores opacity level on Windows/Mac OS X.
#endif
    uint     savedFlags;			// Save widgetflags while showing fullscreen
    short    basew, baseh;			// base sizes
#if defined(TQ_WS_X11)
    WId  parentWinId;				// tqparent window Id (valid after reparenting)
    uint     embedded : 1;			// window is embedded in another TQt application
    uint     spont_unmapped: 1;			// window was spontaneously unmapped
    uint     reserved: 1;			// reserved
    uint     dnd : 1;				// DND properties installed
    uint     uspos : 1;				// User defined position
    uint     ussize : 1;			// User defined size
    void    *xic;				// XIM Input Context
#endif
#if defined(TQ_WS_MAC)
    WindowGroupRef group;
    uint     is_moved: 1;
    uint     resizer : 4;
#endif
#if defined(TQ_WS_TQWS) && !defined ( TQT_NO_TQWS_MANAGER )
    TQRegion decor_allocated_region;		// decoration allocated region
    TQWSManager *qwsManager;
#endif
#if defined(TQ_WS_WIN)
    HICON    winIcon;				// internal Windows icon
#endif
    TQRect    normalGeometry;			// used by showMin/maximized/FullScreen
#ifdef TQ_WS_WIN
    uint style, exstyle;
#endif
};


#define TQWIDGETSIZE_MAX 32767

// dear user: you can see this struct, but it is internal. do not touch.

struct TQ_EXPORT TQWExtra {
    TQ_INT16  minw, minh;			// minimum size
    TQ_INT16  maxw, maxh;			// maximum size
    TQPixmap *bg_pix;				// background pixmap
    TQWidget *focus_proxy;
#ifndef TQT_NO_CURSOR
    TQCursor *curs;
#endif
    TQTLWExtra *topextra;			// only useful for TLWs
#if defined(TQ_WS_WIN)
    TQOleDropTarget *dropTarget;			// drop target
#endif
#if defined(TQ_WS_X11)
    WId xDndProxy;				// XDND forwarding to embedded windows
#endif
#if defined(TQ_WS_MAC)
    TQRegion clip_saved, clip_sibs, clip_tqchildren;
    TQMacDndExtra *macDndExtra;
    TQRegion dirty_area;
    uint clip_dirty : 1, clip_serial : 15;
    uint child_dirty : 1, child_serial : 15;
#ifndef TQMAC_NO_TQUARTZ
    uint ctx_tqchildren_clipped:1;
#endif // TQMAC_NO_TQUARTZ
    uint has_dirty_area:1;
#endif // TQ_WS_MAC
    uint bg_origin : 2;
#if defined(TQ_WS_X11)
    uint tqchildren_use_dnd : 1;
    uint compress_events : 1;
#endif
#if defined(TQ_WS_TQWS) || defined(TQ_WS_MAC)
    TQRegion tqmask;				// widget tqmask
#endif
    char     bg_mode;				// background mode
    char     bg_mode_visual;			// visual background mode
#ifndef TQT_NO_STYLE
    TQStyle* style;
#endif
    TQRect micro_focus_hint;			// micro focus hint
    TQSizePolicy size_policy;
};

#endif // USE_QT4

#define TQ_DEFINED_TQWIDGET
#include "tqwinexport.h"

#endif // TQWIDGET_H