1 /****************************************************************************
2 ** $Id: qt/qwidget.h   3.3.8   edited Jan 11 14:38 $
3 **
4 ** Definition of QWidget class
5 **
6 ** Created : 931029
7 **
8 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
9 **
10 ** This file is part of the kernel module of the Qt GUI Toolkit.
11 **
12 ** This file may be distributed under the terms of the Q Public License
13 ** as defined by Trolltech ASA of Norway and appearing in the file
14 ** LICENSE.QPL included in the packaging of this file.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22 ** licenses may use this file in accordance with the Qt Commercial License
23 ** Agreement provided with the Software.
24 **
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 **
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29 **   information about Qt Commercial License Agreements.
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
32 **
33 ** Contact info@trolltech.com if any conditions of this licensing are
34 ** not clear to you.
35 **
36 **********************************************************************/
37 
38 #ifndef QWIDGET_H
39 #define QWIDGET_H
40 
41 #ifndef QT_H
42 #include "qwindowdefs.h"
43 #include "qobject.h"
44 #include "qpaintdevice.h"
45 #include "qpalette.h"
46 #include "qfont.h"
47 #include "qfontmetrics.h"
48 #include "qfontinfo.h"
49 #include "qsizepolicy.h"
50 #endif // QT_H
51 
52 class QLayout;
53 struct QWExtra;
54 struct QTLWExtra;
55 class QFocusData;
56 class QCursor;
57 class QWSRegionManager;
58 class QStyle;
59 
60 class Q_EXPORT QWidget : public QObject, public QPaintDevice
61 {
62     Q_OBJECT
63     Q_ENUMS( BackgroundMode FocusPolicy BackgroundOrigin )
64     Q_PROPERTY( bool isTopLevel READ isTopLevel )
65     Q_PROPERTY( bool isDialog READ isDialog )
66     Q_PROPERTY( bool isModal READ isModal )
67     Q_PROPERTY( bool isPopup READ isPopup )
68     Q_PROPERTY( bool isDesktop READ isDesktop )
69     Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
70     Q_PROPERTY( QRect geometry READ geometry WRITE setGeometry )
71     Q_PROPERTY( QRect frameGeometry READ frameGeometry )
72     Q_PROPERTY( int x READ x )
73     Q_PROPERTY( int y READ y )
74     Q_PROPERTY( QPoint pos READ pos WRITE move DESIGNABLE false STORED false )
75     Q_PROPERTY( QSize frameSize READ frameSize )
76     Q_PROPERTY( QSize size READ size WRITE resize DESIGNABLE false STORED false )
77     Q_PROPERTY( int width READ width )
78     Q_PROPERTY( int height READ height )
79     Q_PROPERTY( QRect rect READ rect )
80     Q_PROPERTY( QRect childrenRect READ childrenRect )
81     Q_PROPERTY( QRegion childrenRegion READ childrenRegion )
82     Q_PROPERTY( QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy )
83     Q_PROPERTY( QSize minimumSize READ minimumSize WRITE setMinimumSize )
84     Q_PROPERTY( QSize maximumSize READ maximumSize WRITE setMaximumSize )
85     Q_PROPERTY( int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false )
86     Q_PROPERTY( int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false )
87     Q_PROPERTY( int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false )
88     Q_PROPERTY( int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false )
89     Q_PROPERTY( QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement )
90     Q_PROPERTY( QSize baseSize READ baseSize WRITE setBaseSize )
91     Q_PROPERTY( BackgroundMode backgroundMode READ backgroundMode WRITE setBackgroundMode DESIGNABLE false )
92     Q_PROPERTY( QColor paletteForegroundColor READ paletteForegroundColor WRITE setPaletteForegroundColor RESET unsetPalette )
93     Q_PROPERTY( QColor paletteBackgroundColor READ paletteBackgroundColor WRITE setPaletteBackgroundColor RESET unsetPalette )
94     Q_PROPERTY( QPixmap paletteBackgroundPixmap READ paletteBackgroundPixmap WRITE setPaletteBackgroundPixmap RESET unsetPalette )
95     Q_PROPERTY( QBrush backgroundBrush READ backgroundBrush )
96     Q_PROPERTY( QColorGroup colorGroup READ colorGroup )
97     Q_PROPERTY( QPalette palette READ palette WRITE setPalette RESET unsetPalette  STORED ownPalette )
98     Q_PROPERTY( BackgroundOrigin backgroundOrigin READ backgroundOrigin WRITE setBackgroundOrigin )
99     Q_PROPERTY( bool ownPalette READ ownPalette )
100     Q_PROPERTY( QFont font READ font WRITE setFont RESET unsetFont STORED ownFont )
101     Q_PROPERTY( bool ownFont READ ownFont )
102 #ifndef QT_NO_CURSOR
103     Q_PROPERTY( QCursor cursor READ cursor WRITE setCursor RESET unsetCursor STORED ownCursor )
104     Q_PROPERTY( bool ownCursor READ ownCursor )
105 #endif
106 #ifndef QT_NO_WIDGET_TOPEXTRA
107     Q_PROPERTY( QString caption READ caption WRITE setCaption )
108     Q_PROPERTY( QPixmap icon READ icon WRITE setIcon )
109     Q_PROPERTY( QString iconText READ iconText WRITE setIconText )
110 #endif
111     Q_PROPERTY( bool mouseTracking READ hasMouseTracking WRITE setMouseTracking )
112     Q_PROPERTY( bool underMouse READ hasMouse )
113     Q_PROPERTY( bool isActiveWindow READ isActiveWindow )
114     Q_PROPERTY( bool focusEnabled READ isFocusEnabled )
115     Q_PROPERTY( FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy )
116     Q_PROPERTY( bool focus READ hasFocus )
117     Q_PROPERTY( bool updatesEnabled READ isUpdatesEnabled WRITE setUpdatesEnabled DESIGNABLE false )
118     Q_PROPERTY( bool visible READ isVisible )
119     Q_PROPERTY( QRect visibleRect READ visibleRect ) // obsolete
120     Q_PROPERTY( bool hidden READ isHidden WRITE setHidden DESIGNABLE false SCRIPTABLE false )
121     Q_PROPERTY( bool shown READ isShown WRITE setShown DESIGNABLE false SCRIPTABLE false )
122     Q_PROPERTY( bool minimized READ isMinimized )
123     Q_PROPERTY( bool maximized READ isMaximized )
124     Q_PROPERTY( bool fullScreen READ isFullScreen )
125     Q_PROPERTY( QSize sizeHint READ sizeHint )
126     Q_PROPERTY( QSize minimumSizeHint READ minimumSizeHint )
127     Q_PROPERTY( QRect microFocusHint READ microFocusHint )
128     Q_PROPERTY( bool acceptDrops READ acceptDrops WRITE setAcceptDrops )
129     Q_PROPERTY( bool autoMask READ autoMask WRITE setAutoMask DESIGNABLE false SCRIPTABLE false )
130     Q_PROPERTY( bool customWhatsThis READ customWhatsThis )
131     Q_PROPERTY( bool inputMethodEnabled READ isInputMethodEnabled WRITE setInputMethodEnabled DESIGNABLE false SCRIPTABLE false )
132     Q_PROPERTY( double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE false )
133 
134 public:
135     Q_EXPLICIT QWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
136     ~QWidget();
137 
138     WId		 winId() const;
139     void	 setName( const char *name );
140 #ifndef QT_NO_STYLE
141     // GUI style setting
142 
143     QStyle     &style() const;
144     void        setStyle( QStyle * );
145     QStyle*	setStyle( const QString& );
146 #endif
147     // Widget types and states
148 
149     bool	 isTopLevel()	const;
150     bool	 isDialog()	const;
151     bool	 isPopup()	const;
152     bool	 isDesktop()	const;
153     bool	 isModal()	const;
154 
155     bool	 isEnabled()	const;
156     bool	 isEnabledTo(QWidget*) const;
157     bool	 isEnabledToTLW() const;
158 
159 public slots:
160     virtual void setEnabled( bool );
161     void setDisabled( bool );
162 
163     // Widget coordinates
164 
165 public:
166     QRect	 frameGeometry() const;
167     const QRect &geometry()	const;
168     int		 x()		const;
169     int		 y()		const;
170     QPoint	 pos()		const;
171     QSize	 frameSize()    const;
172     QSize	 size()		const;
173     int		 width()	const;
174     int		 height()	const;
175     QRect	 rect()		const;
176     QRect	 childrenRect() const;
177     QRegion	 childrenRegion() const;
178 
179     QSize	 minimumSize()	 const;
180     QSize	 maximumSize()	 const;
181     int		 minimumWidth()	 const;
182     int		 minimumHeight() const;
183     int		 maximumWidth()	 const;
184     int		 maximumHeight() const;
185     void	 setMinimumSize( const QSize & );
186     virtual void setMinimumSize( int minw, int minh );
187     void	 setMaximumSize( const QSize & );
188     virtual void setMaximumSize( int maxw, int maxh );
189     void	 setMinimumWidth( int minw );
190     void	 setMinimumHeight( int minh );
191     void	 setMaximumWidth( int maxw );
192     void	 setMaximumHeight( int maxh );
193 
194     QSize	 sizeIncrement() const;
195     void	 setSizeIncrement( const QSize & );
196     virtual void setSizeIncrement( int w, int h );
197     QSize	 baseSize() const;
198     void	 setBaseSize( const QSize & );
199     void	 setBaseSize( int basew, int baseh );
200 
201     void	setFixedSize( const QSize & );
202     void	setFixedSize( int w, int h );
203     void	setFixedWidth( int w );
204     void	setFixedHeight( int h );
205 
206     // Widget coordinate mapping
207 
208     QPoint	 mapToGlobal( const QPoint & )	 const;
209     QPoint	 mapFromGlobal( const QPoint & ) const;
210     QPoint	 mapToParent( const QPoint & )	 const;
211     QPoint	 mapFromParent( const QPoint & ) const;
212     QPoint	 mapTo( QWidget *, const QPoint & ) const;
213     QPoint	 mapFrom( QWidget *, const QPoint & ) const;
214 
215     QWidget	*topLevelWidget()   const;
216 
217     // Widget attribute functions
218 
219     BackgroundMode	backgroundMode() const;
220     virtual void	setBackgroundMode( BackgroundMode );
221     void 		setBackgroundMode( BackgroundMode, BackgroundMode );
222 
223     const QColor &	foregroundColor() const;
224 
225     const QColor &	eraseColor() const;
226     virtual void	setEraseColor( const QColor & );
227 
228     const QPixmap *	erasePixmap() const;
229     virtual void	setErasePixmap( const QPixmap & );
230 
231 #ifndef QT_NO_PALETTE
232     const QColorGroup & colorGroup() const;
233     const QPalette &	palette()    const;
234     bool		ownPalette() const;
235     virtual void	setPalette( const QPalette & );
236     void		unsetPalette();
237 #endif
238 
239     const QColor &	paletteForegroundColor() const;
240     void		setPaletteForegroundColor( const QColor & );
241 
242     const QColor &	paletteBackgroundColor() const;
243     virtual void	setPaletteBackgroundColor( const QColor & );
244 
245     const QPixmap *	paletteBackgroundPixmap() const;
246     virtual void 	setPaletteBackgroundPixmap( const QPixmap & );
247 
248     const QBrush&	backgroundBrush() const;
249 
250     QFont		font() const;
251     bool		ownFont() const;
252     virtual void	setFont( const QFont & );
253     void		unsetFont();
254     QFontMetrics	fontMetrics() const;
255     QFontInfo	 	fontInfo() const;
256 
257 #ifndef QT_NO_CURSOR
258     const QCursor      &cursor() const;
259     bool		ownCursor() const;
260     virtual void	setCursor( const QCursor & );
261     virtual void	unsetCursor();
262 #endif
263 #ifndef QT_NO_WIDGET_TOPEXTRA
264     QString		caption() const;
265     const QPixmap      *icon() const;
266     QString		iconText() const;
267 #endif
268     bool		hasMouseTracking() const;
269     bool		hasMouse() const;
270 
271     virtual void	setMask( const QBitmap & );
272     virtual void	setMask( const QRegion & );
273     void		clearMask();
274 
275     const QColor &	backgroundColor() const; // obsolete, use eraseColor()
276     virtual void	setBackgroundColor( const QColor & ); // obsolete, use setEraseColor()
277     const QPixmap *	backgroundPixmap() const; // obsolete, use erasePixmap()
278     virtual void	setBackgroundPixmap( const QPixmap & ); // obsolete, use setErasePixmap()
279 
280 public slots:
281 #ifndef QT_NO_WIDGET_TOPEXTRA
282     virtual void	setCaption( const QString &);
283     virtual void	setIcon( const QPixmap & );
284     virtual void	setIconText( const QString &);
285 #endif
286     virtual void	setMouseTracking( bool enable );
287 
288     // Keyboard input focus functions
289 
290     virtual void	setFocus();
291     void		clearFocus();
292 
293 public:
294     enum FocusPolicy {
295 	NoFocus = 0,
296 	TabFocus = 0x1,
297 	ClickFocus = 0x2,
298 	StrongFocus = TabFocus | ClickFocus | 0x8,
299 	WheelFocus = StrongFocus | 0x4
300     };
301 
302     bool		isActiveWindow() const;
303     virtual void	setActiveWindow();
304     bool		isFocusEnabled() const;
305 
306     FocusPolicy		focusPolicy() const;
307     virtual void	setFocusPolicy( FocusPolicy );
308     bool		hasFocus() const;
309     static void		setTabOrder( QWidget *, QWidget * );
310     virtual void	setFocusProxy( QWidget * );
311     QWidget *		focusProxy() const;
312 
313     void setInputMethodEnabled( bool b );
314     bool isInputMethodEnabled() const;
315     // Grab functions
316 
317     void		grabMouse();
318 #ifndef QT_NO_CURSOR
319     void		grabMouse( const QCursor & );
320 #endif
321     void		releaseMouse();
322     void		grabKeyboard();
323     void		releaseKeyboard();
324     static QWidget *	mouseGrabber();
325     static QWidget *	keyboardGrabber();
326 
327     // Update/refresh functions
328 
329     bool	 	isUpdatesEnabled() const;
330 
331 #if 0 //def Q_WS_QWS
332     void		repaintUnclipped( const QRegion &, bool erase = TRUE );
333 #endif
334 public slots:
335     virtual void	setUpdatesEnabled( bool enable );
336     void		update();
337     void		update( int x, int y, int w, int h );
338     void		update( const QRect& );
339     void		repaint();
340     void		repaint( bool erase );
341     void		repaint( int x, int y, int w, int h, bool erase=TRUE );
342     void		repaint( const QRect &, bool erase = TRUE );
343     void		repaint( const QRegion &, bool erase = TRUE );
344 
345     // Widget management functions
346 
347     virtual void	show();
348     virtual void	hide();
349     void		setShown( bool show );
350     void		setHidden( bool hide );
351 #ifndef QT_NO_COMPAT
iconify()352     void		iconify() { showMinimized(); }
353 #endif
354     virtual void	showMinimized();
355     virtual void	showMaximized();
356     void		showFullScreen();
357     virtual void	showNormal();
358     virtual void	polish();
359     void 		constPolish() const;
360     bool		close();
361 
362     void		raise();
363     void		lower();
364     void		stackUnder( QWidget* );
365     virtual void	move( int x, int y );
366     void		move( const QPoint & );
367     virtual void	resize( int w, int h );
368     void		resize( const QSize & );
369     virtual void	setGeometry( int x, int y, int w, int h );
370     virtual void	setGeometry( const QRect & ); // ### make non virtual in Qt 4?
371 
372 public:
373     virtual bool	close( bool alsoDelete );
374     bool		isVisible()	const;
375     bool		isVisibleTo(QWidget*) const;
376     bool		isVisibleToTLW() const; // obsolete
377     QRect		visibleRect() const; // obsolete
378     bool 		isHidden() const;
379     bool 		isShown() const;
380     bool		isMinimized() const;
381     bool		isMaximized() const;
382     bool		isFullScreen() const;
383 
384     uint windowState() const;
385     void setWindowState(uint windowState);
386 
387     virtual QSize	sizeHint() const;
388     virtual QSize	minimumSizeHint() const;
389     virtual QSizePolicy	sizePolicy() const;
390     virtual void	setSizePolicy( QSizePolicy );
391     void 		setSizePolicy( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw = FALSE );
392     virtual int heightForWidth(int) const;
393 
394     QRegion	clipRegion() const;
395 
396 // ### move together with other slots in Qt 4.0
397 public slots:
398     virtual void  	adjustSize();
399 
400 public:
401 #ifndef QT_NO_LAYOUT
layout()402     QLayout *		layout() const { return lay_out; }
403 #endif
404     void		updateGeometry();
405     virtual void 	reparent( QWidget *parent, WFlags, const QPoint &,
406 				  bool showIt=FALSE );
407     void		reparent( QWidget *parent, const QPoint &,
408 				  bool showIt=FALSE );
409 #ifndef QT_NO_COMPAT
410     void		recreate( QWidget *parent, WFlags f, const QPoint & p,
411 				  bool showIt=FALSE ) { reparent(parent,f,p,showIt); }
412 #endif
413 
414     void		erase();
415     void		erase( int x, int y, int w, int h );
416     void		erase( const QRect & );
417     void		erase( const QRegion & );
418     void		scroll( int dx, int dy );
419     void		scroll( int dx, int dy, const QRect& );
420 
421     void		drawText( int x, int y, const QString &);
422     void		drawText( const QPoint &, const QString &);
423 
424     // Misc. functions
425 
426     QWidget *		focusWidget() const;
427     QRect               microFocusHint() const;
428 
429     // drag and drop
430 
431     bool		acceptDrops() const;
432     virtual void	setAcceptDrops( bool on );
433 
434     // transparency and pseudo transparency
435 
436     virtual void	setAutoMask(bool);
437     bool		autoMask() const;
438 
439     enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin };
440 
441     virtual void setBackgroundOrigin( BackgroundOrigin );
442     BackgroundOrigin backgroundOrigin() const;
443     QPoint backgroundOffset() const;
444 
445     // whats this help
446     virtual bool customWhatsThis() const;
447 
448     QWidget *		parentWidget( bool sameWindow = FALSE ) const;
449     WState		testWState( WState s ) const;
450     WFlags		testWFlags( WFlags f ) const;
451     static QWidget *	find( WId );
452     static QWidgetMapper *wmapper();
453 
454     QWidget  *childAt( int x, int y, bool includeThis = FALSE ) const;
455     QWidget  *childAt( const QPoint &, bool includeThis = FALSE ) const;
456 
457 #if defined(Q_WS_QWS)
458     virtual QGfx * graphicsContext(bool clip_children=TRUE) const;
459 #endif
460 #if defined(Q_WS_MAC)
461     QRegion clippedRegion(bool do_children=TRUE);
462     uint clippedSerial(bool do_children=TRUE);
463 #ifndef QMAC_NO_QUARTZ
464     CGContextRef macCGContext(bool clipped=TRUE) const;
465 #endif
466 #endif
467 
468     void setWindowOpacity(double level);
469     double windowOpacity() const;
470 
471 protected:
472     // Event handlers
473     bool	 event( QEvent * );
474     virtual void mousePressEvent( QMouseEvent * );
475     virtual void mouseReleaseEvent( QMouseEvent * );
476     virtual void mouseDoubleClickEvent( QMouseEvent * );
477     virtual void mouseMoveEvent( QMouseEvent * );
478 #ifndef QT_NO_WHEELEVENT
479     virtual void wheelEvent( QWheelEvent * );
480 #endif
481     virtual void keyPressEvent( QKeyEvent * );
482     virtual void keyReleaseEvent( QKeyEvent * );
483     virtual void focusInEvent( QFocusEvent * );
484     virtual void focusOutEvent( QFocusEvent * );
485     virtual void enterEvent( QEvent * );
486     virtual void leaveEvent( QEvent * );
487     virtual void paintEvent( QPaintEvent * );
488     virtual void moveEvent( QMoveEvent * );
489     virtual void resizeEvent( QResizeEvent * );
490     virtual void closeEvent( QCloseEvent * );
491     virtual void contextMenuEvent( QContextMenuEvent * );
492     virtual void imStartEvent( QIMEvent * );
493     virtual void imComposeEvent( QIMEvent * );
494     virtual void imEndEvent( QIMEvent * );
495     virtual void tabletEvent( QTabletEvent * );
496 
497 #ifndef QT_NO_DRAGANDDROP
498     virtual void dragEnterEvent( QDragEnterEvent * );
499     virtual void dragMoveEvent( QDragMoveEvent * );
500     virtual void dragLeaveEvent( QDragLeaveEvent * );
501     virtual void dropEvent( QDropEvent * );
502 #endif
503 
504     virtual void showEvent( QShowEvent * );
505     virtual void hideEvent( QHideEvent * );
506 
507 #if defined(Q_WS_MAC)
508     virtual bool macEvent( MSG * );
509 #endif
510 #if defined(Q_WS_WIN)
511     virtual bool winEvent( MSG * );
512 #endif
513 #if defined(Q_WS_X11)
514     virtual bool x11Event( XEvent * );
515 #endif
516 #if defined(Q_WS_QWS)
517     virtual bool qwsEvent( QWSEvent * );
518     virtual unsigned char *scanLine( int ) const;
519     virtual int bytesPerLine() const;
520 #endif
521 
522     virtual void updateMask();
523 
524     // Misc. protected functions
525 
526 #ifndef QT_NO_STYLE
527     virtual void styleChange( QStyle& );
528 #endif
529     virtual void enabledChange( bool oldEnabled );
530 #ifndef QT_NO_PALETTE
531     virtual void paletteChange( const QPalette & );
532 #endif
533     virtual void fontChange( const QFont & );
534     virtual void windowActivationChange( bool oldActive );
535 
536     int		 metric( int )	const;
537 
538     void	 resetInputContext();
539 
540     virtual void create( WId = 0, bool initializeWindow = TRUE,
541 			 bool destroyOldWindow = TRUE );
542     virtual void destroy( bool destroyWindow = TRUE,
543 			  bool destroySubWindows = TRUE );
544     uint	 getWState() const;
545     virtual void setWState( uint );
546     void	 clearWState( uint n );
547     WFlags	 getWFlags() const;
548     virtual void setWFlags( WFlags );
549     void	 clearWFlags( WFlags n );
550 
551     virtual bool focusNextPrevChild( bool next );
552 
553     QWExtra	*extraData();
554     QTLWExtra	*topData();
555     QFocusData	*focusData();
556 
557     virtual void setKeyCompression(bool);
558     virtual void setMicroFocusHint(int x, int y, int w, int h, bool text=TRUE, QFont *f = 0);
559 
560 #if defined(Q_WS_MAC)
561     void dirtyClippedRegion(bool);
562     bool isClippedRegionDirty();
563     virtual void setRegionDirty(bool);
564     virtual void macWidgetChangedWindow();
565 #endif
566 
567 private slots:
568     void	 focusProxyDestroyed();
569 
570 private:
571     void	 setFontSys( QFont *f = 0 );
572 #if defined(Q_WS_X11)
573     void	 createInputContext();
574     void	 destroyInputContext();
575     void	 focusInputContext();
576     void	 checkChildrenDnd();
577 #elif defined(Q_WS_MAC)
578     uint    own_id : 1, macDropEnabled : 1;
579     EventHandlerRef window_event;
580     //mac event functions
581     void    propagateUpdates(bool update_rgn=TRUE);
582     void    update( const QRegion& );
583     //friends, way too many - fix this immediately!
584     friend void qt_clean_root_win();
585     friend bool qt_recreate_root_win();
586     friend QPoint posInWindow(QWidget *);
587     friend bool qt_mac_update_sizer(QWidget *, int);
588     friend QWidget *qt_recursive_match(QWidget *widg, int x, int y);
589     friend bool qt_paint_children(QWidget *,QRegion &, uchar ops);
590     friend QMAC_PASCAL OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
591     friend void qt_event_request_updates(QWidget *, const QRegion &, bool subtract);
592     friend bool qt_window_rgn(WId, short, RgnHandle, bool);
593     friend class QDragManager;
594 #endif
595 
596 #ifndef QT_NO_LAYOUT
597     void 	 setLayout( QLayout *l );
598 #endif
599     void	 setWinId( WId );
600     void	 showWindow();
601     void	 hideWindow();
602     void	 showChildren( bool spontaneous );
603     void	 hideChildren( bool spontaneous );
604     void	 reparentSys( QWidget *parent, WFlags, const QPoint &,  bool showIt);
605     void	 createTLExtra();
606     void	 createExtra();
607     void	 deleteExtra();
608     void	 createSysExtra();
609     void	 deleteSysExtra();
610     void	 createTLSysExtra();
611     void	 deleteTLSysExtra();
612     void	 deactivateWidgetCleanup();
613     void	 internalSetGeometry( int, int, int, int, bool );
614     void	 reparentFocusWidgets( QWidget * );
615     QFocusData	*focusData( bool create );
616     void         setBackgroundFromMode();
617     void         setBackgroundColorDirect( const QColor & );
618     void   	 setBackgroundPixmapDirect( const QPixmap & );
619     void         setBackgroundModeDirect( BackgroundMode );
620     void         setBackgroundEmpty();
621     void	 updateFrameStrut() const;
622 #if defined(Q_WS_X11)
623     void         setBackgroundX11Relative();
624 #endif
625 
626     WId		 winid;
627     uint	 widget_state;
628     uint	 widget_flags;
629     uint	 focus_policy : 4;
630     uint 	 own_font :1;
631     uint 	 own_palette :1;
632     uint 	 sizehint_forced :1;
633     uint 	 is_closing :1;
634     uint 	 in_show : 1;
635     uint 	 in_show_maximized : 1;
636     uint	 fstrut_dirty : 1;
637     uint	 im_enabled : 1;
638     QRect	 crect;
639     QColor	 bg_col;
640 #ifndef QT_NO_PALETTE
641     QPalette	 pal;
642 #endif
643     QFont	 fnt;
644 #ifndef QT_NO_LAYOUT
645     QLayout 	*lay_out;
646 #endif
647     QWExtra	*extra;
648 #if defined(Q_WS_QWS)
649     QRegion	 req_region;			// Requested region
650     mutable QRegion	 paintable_region;	// Paintable region
651     mutable bool         paintable_region_dirty;// needs to be recalculated
652     mutable QRegion      alloc_region;          // Allocated region
653     mutable bool         alloc_region_dirty;    // needs to be recalculated
654     mutable int          overlapping_children;  // Handle overlapping children
655 
656     int		 alloc_region_index;
657     int		 alloc_region_revision;
658 
659     void updateOverlappingChildren() const;
660     void setChildrenAllocatedDirty();
661     void setChildrenAllocatedDirty( const QRegion &r, const QWidget *dirty=0 );
662     bool isAllocatedRegionDirty() const;
663     void updateRequestedRegion( const QPoint &gpos );
664     QRegion requestedRegion() const;
665     QRegion allocatedRegion() const;
666     QRegion paintableRegion() const;
667 
668     void updateGraphicsContext( QGfx *qgfx_qws, bool clip_children ) const;
669 #ifndef QT_NO_CURSOR
670     void updateCursor( const QRegion &r ) const;
671 #endif
672 
673     // used to accumulate dirty region when children moved/resized.
674     QRegion dirtyChildren;
675     bool isSettingGeometry;
676     friend class QWSManager;
677 #endif
678     static int instanceCounter;  // Current number of widget instances
679     static int maxInstances;     // Maximum number of widget instances
680 
681     static void	 createMapper();
682     static void	 destroyMapper();
683     static QWidgetList	 *wList();
684     static QWidgetList	 *tlwList();
685     static QWidgetMapper *mapper;
686     friend class QApplication;
687     friend class QBaseApplication;
688     friend class QPainter;
689     friend class QFontMetrics;
690     friend class QFontInfo;
691     friend class QETWidget;
692     friend class QLayout;
693 
694 private:	// Disabled copy constructor and operator=
695 #if defined(Q_DISABLE_COPY)
696     QWidget( const QWidget & );
697     QWidget &operator=( const QWidget & );
698 #endif
699 
700 public: // obsolete functions to dissappear or to become inline in 3.0
701 #ifndef QT_NO_PALETTE
setPalette(const QPalette & p,bool)702     void setPalette( const QPalette &p, bool ) { setPalette( p ); }
703 #endif
setFont(const QFont & f,bool)704     void setFont( const QFont &f, bool ) { setFont( f ); }
705 };
706 
707 
testWState(WState s)708 inline Qt::WState QWidget::testWState( WState s ) const
709 { return (widget_state & s); }
710 
testWFlags(WFlags f)711 inline Qt::WFlags QWidget::testWFlags( WFlags f ) const
712 { return (widget_flags & f); }
713 
714 
winId()715 inline WId QWidget::winId() const
716 { return winid; }
717 
isTopLevel()718 inline bool QWidget::isTopLevel() const
719 { return testWFlags(WType_TopLevel); }
720 
isDialog()721 inline bool QWidget::isDialog() const
722 { return testWFlags(WType_Dialog); }
723 
isPopup()724 inline bool QWidget::isPopup() const
725 { return testWFlags(WType_Popup); }
726 
isDesktop()727 inline bool QWidget::isDesktop() const
728 { return testWFlags(WType_Desktop); }
729 
isEnabled()730 inline bool QWidget::isEnabled() const
731 { return !testWState(WState_Disabled); }
732 
isModal()733 inline bool QWidget::isModal() const
734 { return testWFlags(WShowModal); }
735 
isEnabledToTLW()736 inline bool QWidget::isEnabledToTLW() const
737 { return isEnabled(); }
738 
geometry()739 inline const QRect &QWidget::geometry() const
740 { return crect; }
741 
size()742 inline QSize QWidget::size() const
743 { return crect.size(); }
744 
width()745 inline int QWidget::width() const
746 { return crect.width(); }
747 
height()748 inline int QWidget::height() const
749 { return crect.height(); }
750 
rect()751 inline QRect QWidget::rect() const
752 { return QRect(0,0,crect.width(),crect.height()); }
753 
minimumWidth()754 inline int QWidget::minimumWidth() const
755 { return minimumSize().width(); }
756 
minimumHeight()757 inline int QWidget::minimumHeight() const
758 { return minimumSize().height(); }
759 
maximumWidth()760 inline int QWidget::maximumWidth() const
761 { return maximumSize().width(); }
762 
maximumHeight()763 inline int QWidget::maximumHeight() const
764 { return maximumSize().height(); }
765 
setMinimumSize(const QSize & s)766 inline void QWidget::setMinimumSize( const QSize &s )
767 { setMinimumSize(s.width(),s.height()); }
768 
setMaximumSize(const QSize & s)769 inline void QWidget::setMaximumSize( const QSize &s )
770 { setMaximumSize(s.width(),s.height()); }
771 
setSizeIncrement(const QSize & s)772 inline void QWidget::setSizeIncrement( const QSize &s )
773 { setSizeIncrement(s.width(),s.height()); }
774 
setBaseSize(const QSize & s)775 inline void QWidget::setBaseSize( const QSize &s )
776 { setBaseSize(s.width(),s.height()); }
777 
eraseColor()778 inline const QColor &QWidget::eraseColor() const
779 { return bg_col; }
780 
781 #ifndef QT_NO_PALETTE
palette()782 inline const QPalette &QWidget::palette() const
783 { return pal; }
784 #endif
785 
font()786 inline QFont QWidget::font() const
787 { return fnt; }
788 
fontMetrics()789 inline QFontMetrics QWidget::fontMetrics() const
790 { return QFontMetrics(font()); }
791 
fontInfo()792 inline QFontInfo QWidget::fontInfo() const
793 { return QFontInfo(font()); }
794 
hasMouseTracking()795 inline bool QWidget::hasMouseTracking() const
796 { return testWState(WState_MouseTracking); }
797 
hasMouse()798 inline bool QWidget::hasMouse() const
799 { return testWState(WState_HasMouse); }
800 
isFocusEnabled()801 inline bool  QWidget::isFocusEnabled() const
802 { return (FocusPolicy)focus_policy != NoFocus; }
803 
focusPolicy()804 inline QWidget::FocusPolicy QWidget::focusPolicy() const
805 { return (FocusPolicy)focus_policy; }
806 
isUpdatesEnabled()807 inline bool QWidget::isUpdatesEnabled() const
808 { return !testWState(WState_BlockUpdates); }
809 
update(const QRect & r)810 inline void QWidget::update( const QRect &r )
811 { update( r.x(), r.y(), r.width(), r.height() ); }
812 
repaint()813 inline void QWidget::repaint()
814 { repaint( TRUE ); }
815 
repaint(const QRect & r,bool erase)816 inline void QWidget::repaint( const QRect &r, bool erase )
817 { repaint( r.x(), r.y(), r.width(), r.height(), erase ); }
818 
erase()819 inline void QWidget::erase()
820 { erase( 0, 0, crect.width(), crect.height() ); }
821 
erase(const QRect & r)822 inline void QWidget::erase( const QRect &r )
823 { erase( r.x(), r.y(), r.width(), r.height() ); }
824 
close()825 inline bool QWidget::close()
826 { return close( FALSE ); }
827 
isVisible()828 inline bool QWidget::isVisible() const
829 { return testWState(WState_Visible); }
830 
isVisibleToTLW()831 inline bool QWidget::isVisibleToTLW() const // obsolete
832 { return isVisible(); }
833 
isHidden()834 inline bool QWidget::isHidden() const
835 { return testWState(WState_ForceHide); }
836 
isShown()837 inline bool QWidget::isShown() const
838 { return !testWState(WState_ForceHide); }
839 
move(const QPoint & p)840 inline void QWidget::move( const QPoint &p )
841 { move( p.x(), p.y() ); }
842 
resize(const QSize & s)843 inline void QWidget::resize( const QSize &s )
844 { resize( s.width(), s.height()); }
845 
setGeometry(const QRect & r)846 inline void QWidget::setGeometry( const QRect &r )
847 { setGeometry( r.left(), r.top(), r.width(), r.height() ); }
848 
drawText(const QPoint & p,const QString & s)849 inline void QWidget::drawText( const QPoint &p, const QString &s )
850 { drawText( p.x(), p.y(), s ); }
851 
parentWidget(bool sameWindow)852 inline QWidget *QWidget::parentWidget( bool sameWindow ) const
853 {
854     if ( sameWindow )
855 	return isTopLevel() ? 0 : (QWidget *)QObject::parent();
856     return (QWidget *)QObject::parent();
857 }
858 
wmapper()859 inline QWidgetMapper *QWidget::wmapper()
860 { return mapper; }
861 
getWState()862 inline uint QWidget::getWState() const
863 { return widget_state; }
864 
setWState(uint f)865 inline void QWidget::setWState( uint f )
866 { widget_state |= f; }
867 
clearWState(uint f)868 inline void QWidget::clearWState( uint f )
869 { widget_state &= ~f; }
870 
getWFlags()871 inline Qt::WFlags QWidget::getWFlags() const
872 { return widget_flags; }
873 
setWFlags(WFlags f)874 inline void QWidget::setWFlags( WFlags f )
875 { widget_flags |= f; }
876 
clearWFlags(WFlags f)877 inline void QWidget::clearWFlags( WFlags f )
878 { widget_flags &= ~f; }
879 
constPolish()880 inline void QWidget::constPolish() const
881 {
882     if ( !testWState(WState_Polished) ) {
883 	QWidget* that = (QWidget*) this;
884 	that->polish();
885         that->setWState(WState_Polished); // be on the safe side...
886     }
887 }
888 #ifndef QT_NO_CURSOR
ownCursor()889 inline bool QWidget::ownCursor() const
890 {
891     return testWState( WState_OwnCursor );
892 }
893 #endif
ownFont()894 inline bool QWidget::ownFont() const
895 {
896     return own_font;
897 }
898 #ifndef QT_NO_PALETTE
ownPalette()899 inline bool QWidget::ownPalette() const
900 {
901     return own_palette;
902 }
903 #endif
904 
setSizePolicy(QSizePolicy::SizeType hor,QSizePolicy::SizeType ver,bool hfw)905 inline void QWidget::setSizePolicy( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw )
906 {
907     setSizePolicy( QSizePolicy( hor, ver, hfw) );
908 }
909 
isInputMethodEnabled()910 inline bool QWidget::isInputMethodEnabled() const
911 {
912     return (bool)im_enabled;
913 }
914 
915 // Extra QWidget data
916 //  - to minimize memory usage for members that are seldom used.
917 //  - top-level widgets have extra extra data to reduce cost further
918 
919 class QFocusData;
920 class QWSManager;
921 #if defined(Q_WS_WIN)
922 class QOleDropTarget;
923 #endif
924 #if defined(Q_WS_MAC)
925 class QMacDndExtra;
926 #endif
927 
928 struct Q_EXPORT QTLWExtra {
929 #ifndef QT_NO_WIDGET_TOPEXTRA
930     QString  caption;				// widget caption
931     QString  iconText;				// widget icon text
932     QPixmap *icon;				// widget icon
933 #endif
934     QFocusData *focusData;			// focus data (for TLW)
935     short    incw, inch;			// size increments
936     // frame strut
937     ulong    fleft, fright, ftop, fbottom;
938     uint     unused : 8;                       // not used at this point...
939 #if defined( Q_WS_WIN ) || defined( Q_WS_MAC )
940     uint     opacity : 8;		       // Stores opacity level on Windows/Mac OS X.
941 #endif
942     uint     savedFlags;			// Save widgetflags while showing fullscreen
943     short    basew, baseh;			// base sizes
944 #if defined(Q_WS_X11)
945     WId  parentWinId;				// parent window Id (valid after reparenting)
946     uint     embedded : 1;			// window is embedded in another Qt application
947     uint     spont_unmapped: 1;			// window was spontaneously unmapped
948     uint     reserved: 1;			// reserved
949     uint     dnd : 1;				// DND properties installed
950     uint     uspos : 1;				// User defined position
951     uint     ussize : 1;			// User defined size
952     void    *xic;				// XIM Input Context
953 #endif
954 #if defined(Q_WS_MAC)
955     WindowGroupRef group;
956     uint     is_moved: 1;
957     uint     resizer : 4;
958 #endif
959 #if defined(Q_WS_QWS) && !defined ( QT_NO_QWS_MANAGER )
960     QRegion decor_allocated_region;		// decoration allocated region
961     QWSManager *qwsManager;
962 #endif
963 #if defined(Q_WS_WIN)
964     HICON    winIcon;				// internal Windows icon
965 #endif
966     QRect    normalGeometry;			// used by showMin/maximized/FullScreen
967 #ifdef Q_WS_WIN
968     uint style, exstyle;
969 #endif
970 };
971 
972 
973 #define QWIDGETSIZE_MAX 32767
974 
975 // dear user: you can see this struct, but it is internal. do not touch.
976 
977 struct Q_EXPORT QWExtra {
978     Q_INT16  minw, minh;			// minimum size
979     Q_INT16  maxw, maxh;			// maximum size
980     QPixmap *bg_pix;				// background pixmap
981     QWidget *focus_proxy;
982 #ifndef QT_NO_CURSOR
983     QCursor *curs;
984 #endif
985     QTLWExtra *topextra;			// only useful for TLWs
986 #if defined(Q_WS_WIN)
987     QOleDropTarget *dropTarget;			// drop target
988 #endif
989 #if defined(Q_WS_X11)
990     WId xDndProxy;				// XDND forwarding to embedded windows
991 #endif
992 #if defined(Q_WS_MAC)
993     QRegion clip_saved, clip_sibs, clip_children;
994     QMacDndExtra *macDndExtra;
995     QRegion dirty_area;
996     uint clip_dirty : 1, clip_serial : 15;
997     uint child_dirty : 1, child_serial : 15;
998 #ifndef QMAC_NO_QUARTZ
999     uint ctx_children_clipped:1;
1000 #endif // QMAC_NO_QUARTZ
1001     uint has_dirty_area:1;
1002 #endif // Q_WS_MAC
1003     uint bg_origin : 2;
1004 #if defined(Q_WS_X11)
1005     uint children_use_dnd : 1;
1006     uint compress_events : 1;
1007 #endif
1008 #if defined(Q_WS_QWS) || defined(Q_WS_MAC)
1009     QRegion mask;				// widget mask
1010 #endif
1011     char     bg_mode;				// background mode
1012     char     bg_mode_visual;			// visual background mode
1013 #ifndef QT_NO_STYLE
1014     QStyle* style;
1015 #endif
1016     QRect micro_focus_hint;			// micro focus hint
1017     QSizePolicy size_policy;
1018 };
1019 
1020 #define Q_DEFINED_QWIDGET
1021 #include "qwinexport.h"
1022 
1023 #endif // QWIDGET_H
1024