source: trunk/include/qwidget.h@ 63

Last change on this file since 63 was 63, checked in by dmik, 19 years ago

Fixed QWidget::erase() broken by changeset:61.

  • Property svn:keywords set to Id
File size: 33.8 KB
Line 
1/****************************************************************************
2** $Id: qwidget.h 63 2006-02-25 20:58:01Z dmik $
3**
4** Definition of QWidget class
5**
6** Created : 931029
7**
8** Copyright (C) 1992-2003 Trolltech AS. 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 AS 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
52class QLayout;
53struct QWExtra;
54struct QTLWExtra;
55class QFocusData;
56class QCursor;
57class QWSRegionManager;
58class QStyle;
59
60class 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
134public:
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
159public slots:
160 virtual void setEnabled( bool );
161 void setDisabled( bool );
162
163 // Widget coordinates
164
165public:
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
280public 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
293public:
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
334public 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
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
372public:
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
397public slots:
398 virtual void adjustSize();
399
400public:
401#ifndef QT_NO_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#if defined(Q_WS_PM)
468 WId winFId();
469#endif
470
471 void setWindowOpacity(double level);
472 double windowOpacity() const;
473
474protected:
475 // Event handlers
476 bool event( QEvent * );
477 virtual void mousePressEvent( QMouseEvent * );
478 virtual void mouseReleaseEvent( QMouseEvent * );
479 virtual void mouseDoubleClickEvent( QMouseEvent * );
480 virtual void mouseMoveEvent( QMouseEvent * );
481#ifndef QT_NO_WHEELEVENT
482 virtual void wheelEvent( QWheelEvent * );
483#endif
484 virtual void keyPressEvent( QKeyEvent * );
485 virtual void keyReleaseEvent( QKeyEvent * );
486 virtual void focusInEvent( QFocusEvent * );
487 virtual void focusOutEvent( QFocusEvent * );
488 virtual void enterEvent( QEvent * );
489 virtual void leaveEvent( QEvent * );
490 virtual void paintEvent( QPaintEvent * );
491 virtual void moveEvent( QMoveEvent * );
492 virtual void resizeEvent( QResizeEvent * );
493 virtual void closeEvent( QCloseEvent * );
494 virtual void contextMenuEvent( QContextMenuEvent * );
495 virtual void imStartEvent( QIMEvent * );
496 virtual void imComposeEvent( QIMEvent * );
497 virtual void imEndEvent( QIMEvent * );
498 virtual void tabletEvent( QTabletEvent * );
499
500#ifndef QT_NO_DRAGANDDROP
501 virtual void dragEnterEvent( QDragEnterEvent * );
502 virtual void dragMoveEvent( QDragMoveEvent * );
503 virtual void dragLeaveEvent( QDragLeaveEvent * );
504 virtual void dropEvent( QDropEvent * );
505#endif
506
507 virtual void showEvent( QShowEvent * );
508 virtual void hideEvent( QHideEvent * );
509
510#if defined(Q_WS_MAC)
511 virtual bool macEvent( MSG * );
512#endif
513#if defined(Q_WS_WIN)
514 virtual bool winEvent( MSG * );
515#endif
516#if defined(Q_WS_PM)
517 virtual bool pmEvent( QMSG * );
518#endif
519#if defined(Q_WS_X11)
520 virtual bool x11Event( XEvent * );
521#endif
522#if defined(Q_WS_QWS)
523 virtual bool qwsEvent( QWSEvent * );
524 virtual unsigned char *scanLine( int ) const;
525 virtual int bytesPerLine() const;
526#endif
527
528 virtual void updateMask();
529
530 // Misc. protected functions
531
532#ifndef QT_NO_STYLE
533 virtual void styleChange( QStyle& );
534#endif
535 virtual void enabledChange( bool oldEnabled );
536#ifndef QT_NO_PALETTE
537 virtual void paletteChange( const QPalette & );
538#endif
539 virtual void fontChange( const QFont & );
540 virtual void windowActivationChange( bool oldActive );
541
542 int metric( int ) const;
543
544 void resetInputContext();
545
546 virtual void create( WId = 0, bool initializeWindow = TRUE,
547 bool destroyOldWindow = TRUE );
548 virtual void destroy( bool destroyWindow = TRUE,
549 bool destroySubWindows = TRUE );
550 uint getWState() const;
551 virtual void setWState( uint );
552 void clearWState( uint n );
553 WFlags getWFlags() const;
554 virtual void setWFlags( WFlags );
555 void clearWFlags( WFlags n );
556
557 virtual bool focusNextPrevChild( bool next );
558
559 QWExtra *extraData();
560 QTLWExtra *topData();
561 QFocusData *focusData();
562
563 virtual void setKeyCompression(bool);
564 virtual void setMicroFocusHint(int x, int y, int w, int h, bool text=TRUE, QFont *f = 0);
565
566#if defined(Q_WS_MAC)
567 void dirtyClippedRegion(bool);
568 bool isClippedRegionDirty();
569 virtual void setRegionDirty(bool);
570 virtual void macWidgetChangedWindow();
571#endif
572
573private slots:
574 void focusProxyDestroyed();
575
576private:
577 void setFontSys( QFont *f = 0 );
578#if defined(Q_WS_X11)
579 void createInputContext();
580 void destroyInputContext();
581 void focusInputContext();
582 void checkChildrenDnd();
583#elif defined(Q_WS_MAC)
584 uint own_id : 1, macDropEnabled : 1;
585 EventHandlerRef window_event;
586 //mac event functions
587 void propagateUpdates(bool update_rgn=TRUE);
588 void update( const QRegion& );
589 //friends, way too many - fix this immediately!
590 friend void qt_clean_root_win();
591 friend bool qt_recreate_root_win();
592 friend QPoint posInWindow(QWidget *);
593 friend bool qt_mac_update_sizer(QWidget *, int);
594 friend QWidget *qt_recursive_match(QWidget *widg, int x, int y);
595 friend bool qt_paint_children(QWidget *,QRegion &, uchar ops);
596 friend QMAC_PASCAL OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
597 friend void qt_event_request_updates(QWidget *, const QRegion &, bool subtract=FALSE);
598 friend bool qt_window_rgn(WId, short, RgnHandle, bool);
599 friend class QDragManager;
600#elif defined (Q_WS_PM)
601 enum ClipMode { ClipDefault, Unclipped, ClipAll, ClipSiblings };
602 HPS getTargetPS( ClipMode m = ClipDefault );
603 friend Q_EXPORT void bitBlt( QPaintDevice *, int, int,
604 const QPaintDevice *,
605 int, int, int, int, RasterOp, bool );
606#endif
607
608#ifndef QT_NO_LAYOUT
609 void setLayout( QLayout *l );
610#endif
611 void setWinId( WId );
612 void showWindow();
613 void hideWindow();
614 void showChildren( bool spontaneous );
615 void hideChildren( bool spontaneous );
616 void reparentSys( QWidget *parent, WFlags, const QPoint &, bool showIt);
617 void createTLExtra();
618 void createExtra();
619 void deleteExtra();
620 void createSysExtra();
621 void deleteSysExtra();
622 void createTLSysExtra();
623 void deleteTLSysExtra();
624 void deactivateWidgetCleanup();
625 void internalSetGeometry( int, int, int, int, bool );
626 void reparentFocusWidgets( QWidget * );
627 QFocusData *focusData( bool create );
628 void setBackgroundFromMode();
629 void setBackgroundColorDirect( const QColor & );
630 void setBackgroundPixmapDirect( const QPixmap & );
631 void setBackgroundModeDirect( BackgroundMode );
632 void setBackgroundEmpty();
633 void updateFrameStrut() const;
634#if defined(Q_WS_X11)
635 void setBackgroundX11Relative();
636#endif
637
638 WId winid;
639 uint widget_state;
640 uint widget_flags;
641 uint focus_policy : 4;
642 uint own_font :1;
643 uint own_palette :1;
644 uint sizehint_forced :1;
645 uint is_closing :1;
646 uint in_show : 1;
647 uint in_show_maximized : 1;
648 uint fstrut_dirty : 1;
649 uint im_enabled : 1;
650 QRect crect;
651 QColor bg_col;
652#ifndef QT_NO_PALETTE
653 QPalette pal;
654#endif
655 QFont fnt;
656#ifndef QT_NO_LAYOUT
657 QLayout *lay_out;
658#endif
659 QWExtra *extra;
660#if defined(Q_WS_QWS)
661 QRegion req_region; // Requested region
662 mutable QRegion paintable_region; // Paintable region
663 mutable bool paintable_region_dirty;// needs to be recalculated
664 mutable QRegion alloc_region; // Allocated region
665 mutable bool alloc_region_dirty; // needs to be recalculated
666 mutable int overlapping_children; // Handle overlapping children
667
668 int alloc_region_index;
669 int alloc_region_revision;
670
671 void updateOverlappingChildren() const;
672 void setChildrenAllocatedDirty();
673 void setChildrenAllocatedDirty( const QRegion &r, const QWidget *dirty=0 );
674 bool isAllocatedRegionDirty() const;
675 void updateRequestedRegion( const QPoint &gpos );
676 QRegion requestedRegion() const;
677 QRegion allocatedRegion() const;
678 QRegion paintableRegion() const;
679
680 void updateGraphicsContext( QGfx *qgfx_qws, bool clip_children ) const;
681#ifndef QT_NO_CURSOR
682 void updateCursor( const QRegion &r ) const;
683#endif
684
685 // used to accumulate dirty region when children moved/resized.
686 QRegion dirtyChildren;
687 bool isSettingGeometry;
688 friend class QWSManager;
689#endif
690 static int instanceCounter; // Current number of widget instances
691 static int maxInstances; // Maximum number of widget instances
692
693 static void createMapper();
694 static void destroyMapper();
695 static QWidgetList *wList();
696 static QWidgetList *tlwList();
697 static QWidgetMapper *mapper;
698 friend class QApplication;
699 friend class QBaseApplication;
700 friend class QPainter;
701 friend class QFontMetrics;
702 friend class QFontInfo;
703 friend class QETWidget;
704 friend class QLayout;
705
706private: // Disabled copy constructor and operator=
707#if defined(Q_DISABLE_COPY)
708 QWidget( const QWidget & );
709 QWidget &operator=( const QWidget & );
710#endif
711
712public: // obsolete functions to dissappear or to become inline in 3.0
713#ifndef QT_NO_PALETTE
714 void setPalette( const QPalette &p, bool ) { setPalette( p ); }
715#endif
716 void setFont( const QFont &f, bool ) { setFont( f ); }
717};
718
719
720inline Qt::WState QWidget::testWState( WState s ) const
721{ return (widget_state & s); }
722
723inline Qt::WFlags QWidget::testWFlags( WFlags f ) const
724{ return (widget_flags & f); }
725
726
727inline WId QWidget::winId() const
728{ return winid; }
729
730inline bool QWidget::isTopLevel() const
731{ return testWFlags(WType_TopLevel); }
732
733inline bool QWidget::isDialog() const
734{ return testWFlags(WType_Dialog); }
735
736inline bool QWidget::isPopup() const
737{ return testWFlags(WType_Popup); }
738
739inline bool QWidget::isDesktop() const
740{ return testWFlags(WType_Desktop); }
741
742inline bool QWidget::isEnabled() const
743{ return !testWState(WState_Disabled); }
744
745inline bool QWidget::isModal() const
746{ return testWFlags(WShowModal); }
747
748inline bool QWidget::isEnabledToTLW() const
749{ return isEnabled(); }
750
751inline const QRect &QWidget::geometry() const
752{ return crect; }
753
754inline QSize QWidget::size() const
755{ return crect.size(); }
756
757inline int QWidget::width() const
758{ return crect.width(); }
759
760inline int QWidget::height() const
761{ return crect.height(); }
762
763inline QRect QWidget::rect() const
764{ return QRect(0,0,crect.width(),crect.height()); }
765
766inline int QWidget::minimumWidth() const
767{ return minimumSize().width(); }
768
769inline int QWidget::minimumHeight() const
770{ return minimumSize().height(); }
771
772inline int QWidget::maximumWidth() const
773{ return maximumSize().width(); }
774
775inline int QWidget::maximumHeight() const
776{ return maximumSize().height(); }
777
778inline void QWidget::setMinimumSize( const QSize &s )
779{ setMinimumSize(s.width(),s.height()); }
780
781inline void QWidget::setMaximumSize( const QSize &s )
782{ setMaximumSize(s.width(),s.height()); }
783
784inline void QWidget::setSizeIncrement( const QSize &s )
785{ setSizeIncrement(s.width(),s.height()); }
786
787inline void QWidget::setBaseSize( const QSize &s )
788{ setBaseSize(s.width(),s.height()); }
789
790inline const QColor &QWidget::eraseColor() const
791{ return bg_col; }
792
793#ifndef QT_NO_PALETTE
794inline const QPalette &QWidget::palette() const
795{ return pal; }
796#endif
797
798inline QFont QWidget::font() const
799{ return fnt; }
800
801inline QFontMetrics QWidget::fontMetrics() const
802{ return QFontMetrics(font()); }
803
804inline QFontInfo QWidget::fontInfo() const
805{ return QFontInfo(font()); }
806
807inline bool QWidget::hasMouseTracking() const
808{ return testWState(WState_MouseTracking); }
809
810inline bool QWidget::hasMouse() const
811{ return testWState(WState_HasMouse); }
812
813inline bool QWidget::isFocusEnabled() const
814{ return (FocusPolicy)focus_policy != NoFocus; }
815
816inline QWidget::FocusPolicy QWidget::focusPolicy() const
817{ return (FocusPolicy)focus_policy; }
818
819inline bool QWidget::isUpdatesEnabled() const
820{ return !testWState(WState_BlockUpdates); }
821
822inline void QWidget::update( const QRect &r )
823{ update( r.x(), r.y(), r.width(), r.height() ); }
824
825inline void QWidget::repaint()
826{ repaint( TRUE ); }
827
828inline void QWidget::repaint( const QRect &r, bool erase )
829{ repaint( r.x(), r.y(), r.width(), r.height(), erase ); }
830
831inline void QWidget::erase()
832{ erase( 0, 0, crect.width(), crect.height() ); }
833
834inline void QWidget::erase( const QRect &r )
835{ erase( r.x(), r.y(), r.width(), r.height() ); }
836
837inline bool QWidget::close()
838{ return close( FALSE ); }
839
840inline bool QWidget::isVisible() const
841{ return testWState(WState_Visible); }
842
843inline bool QWidget::isVisibleToTLW() const // obsolete
844{ return isVisible(); }
845
846inline bool QWidget::isHidden() const
847{ return testWState(WState_ForceHide); }
848
849inline bool QWidget::isShown() const
850{ return !testWState(WState_ForceHide); }
851
852inline void QWidget::move( const QPoint &p )
853{ move( p.x(), p.y() ); }
854
855inline void QWidget::resize( const QSize &s )
856{ resize( s.width(), s.height()); }
857
858inline void QWidget::setGeometry( const QRect &r )
859{ setGeometry( r.left(), r.top(), r.width(), r.height() ); }
860
861inline void QWidget::drawText( const QPoint &p, const QString &s )
862{ drawText( p.x(), p.y(), s ); }
863
864inline QWidget *QWidget::parentWidget( bool sameWindow ) const
865{
866 if ( sameWindow )
867 return isTopLevel() ? 0 : (QWidget *)QObject::parent();
868 return (QWidget *)QObject::parent();
869}
870
871inline QWidgetMapper *QWidget::wmapper()
872{ return mapper; }
873
874inline uint QWidget::getWState() const
875{ return widget_state; }
876
877inline void QWidget::setWState( uint f )
878{ widget_state |= f; }
879
880inline void QWidget::clearWState( uint f )
881{ widget_state &= ~f; }
882
883inline Qt::WFlags QWidget::getWFlags() const
884{ return widget_flags; }
885
886inline void QWidget::setWFlags( WFlags f )
887{ widget_flags |= f; }
888
889inline void QWidget::clearWFlags( WFlags f )
890{ widget_flags &= ~f; }
891
892inline void QWidget::constPolish() const
893{
894 if ( !testWState(WState_Polished) ) {
895 QWidget* that = (QWidget*) this;
896 that->polish();
897 that->setWState(WState_Polished); // be on the safe side...
898 }
899}
900#ifndef QT_NO_CURSOR
901inline bool QWidget::ownCursor() const
902{
903 return testWState( WState_OwnCursor );
904}
905#endif
906inline bool QWidget::ownFont() const
907{
908 return own_font;
909}
910#ifndef QT_NO_PALETTE
911inline bool QWidget::ownPalette() const
912{
913 return own_palette;
914}
915#endif
916
917inline void QWidget::setSizePolicy( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw )
918{
919 setSizePolicy( QSizePolicy( hor, ver, hfw) );
920}
921
922inline bool QWidget::isInputMethodEnabled() const
923{
924 return (bool)im_enabled;
925}
926
927// Extra QWidget data
928// - to minimize memory usage for members that are seldom used.
929// - top-level widgets have extra extra data to reduce cost further
930
931class QFocusData;
932class QWSManager;
933#if defined(Q_WS_WIN)
934class QOleDropTarget;
935#endif
936#if defined(Q_WS_MAC)
937class QMacDndExtra;
938#endif
939
940struct Q_EXPORT QTLWExtra {
941#ifndef QT_NO_WIDGET_TOPEXTRA
942 QString caption; // widget caption
943 QString iconText; // widget icon text
944 QPixmap *icon; // widget icon
945#endif
946 QFocusData *focusData; // focus data (for TLW)
947 short incw, inch; // size increments
948 // frame strut
949 ulong fleft, fright, ftop, fbottom;
950 uint unused : 8; // not used at this point...
951#if defined( Q_WS_WIN ) || defined( Q_WS_MAC )
952 uint opacity : 8; // Stores opacity level on Windows/Mac OS X.
953#endif
954#if !defined(Q_WS_PM)
955 uint savedFlags; // Save widgetflags while showing fullscreen
956#endif
957 short basew, baseh; // base sizes
958#if defined(Q_WS_X11)
959 WId parentWinId; // parent window Id (valid after reparenting)
960 uint embedded : 1; // window is embedded in another Qt application
961 uint spont_unmapped: 1; // window was spontaneously unmapped
962 uint reserved: 1; // reserved
963 uint dnd : 1; // DND properties installed
964 uint uspos : 1; // User defined position
965 uint ussize : 1; // User defined size
966 void *xic; // XIM Input Context
967#endif
968#if defined(Q_WS_MAC)
969 WindowGroupRef group;
970 uint is_moved: 1;
971 uint resizer : 4;
972#endif
973#if defined(Q_WS_QWS) && !defined ( QT_NO_QWS_MANAGER )
974 QRegion decor_allocated_region; // decoration allocated region
975 QWSManager *qwsManager;
976#endif
977#if defined(Q_WS_WIN)
978 HICON winIcon; // internal Windows icon
979#endif
980#if defined(Q_WS_PM)
981 WId fId; // frame window handle
982 HSWITCH swEntry; // window list entry handle
983 HPOINTER pmIcon; // internal OS/2 icon
984#endif
985 QRect normalGeometry; // used by showMin/maximized/FullScreen
986};
987
988
989#define QWIDGETSIZE_MAX 32767
990
991// dear user: you can see this struct, but it is internal. do not touch.
992
993struct Q_EXPORT QWExtra {
994 Q_INT16 minw, minh; // minimum size
995 Q_INT16 maxw, maxh; // maximum size
996 QPixmap *bg_pix; // background pixmap
997 QWidget *focus_proxy;
998#ifndef QT_NO_CURSOR
999 QCursor *curs;
1000#endif
1001 QTLWExtra *topextra; // only useful for TLWs
1002#if defined(Q_WS_WIN)
1003 QOleDropTarget *dropTarget; // drop target
1004#endif
1005#if defined(Q_WS_X11)
1006 WId xDndProxy; // XDND forwarding to embedded windows
1007#endif
1008#if defined(Q_WS_MAC)
1009 QRegion clip_saved, clip_sibs, clip_children;
1010 QMacDndExtra *macDndExtra;
1011 QRegion dirty_area;
1012 uint clip_dirty : 1, clip_serial : 15;
1013 uint child_dirty : 1, child_serial : 15;
1014#ifndef QMAC_NO_QUARTZ
1015 uint ctx_children_clipped:1;
1016#endif // QMAC_NO_QUARTZ
1017 uint has_dirty_area:1;
1018#endif // Q_WS_MAC
1019 uint bg_origin : 2;
1020#if defined(Q_WS_X11)
1021 uint children_use_dnd : 1;
1022 uint compress_events : 1;
1023#endif
1024#if defined(Q_WS_QWS) || defined(Q_WS_MAC)
1025 QRegion mask; // widget mask
1026#endif
1027 char bg_mode; // background mode
1028 char bg_mode_visual; // visual background mode
1029#ifndef QT_NO_STYLE
1030 QStyle* style;
1031#endif
1032 QRect micro_focus_hint; // micro focus hint
1033 QSizePolicy size_policy;
1034};
1035
1036#define Q_DEFINED_QWIDGET
1037#include "qwinexport.h"
1038
1039#endif // QWIDGET_H
Note: See TracBrowser for help on using the repository browser.