source: trunk/include/qwidget.h@ 10

Last change on this file since 10 was 8, checked in by dmik, 20 years ago

Transferred Qt for OS/2 version 3.3.1-rc5 sources from the CVS

  • Property svn:keywords set to Id
File size: 33.5 KB
RevLine 
[2]1/****************************************************************************
2** $Id: qwidget.h 8 2005-11-16 19:36:46Z 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
[8]467#if defined(Q_WS_PM)
468 WId winFId();
469#endif
[2]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
[8]516#if defined(Q_WS_PM)
517 virtual bool pmEvent( QMSG * );
518#endif
[2]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#endif
601
602#ifndef QT_NO_LAYOUT
603 void setLayout( QLayout *l );
604#endif
605 void setWinId( WId );
606 void showWindow();
607 void hideWindow();
608 void showChildren( bool spontaneous );
609 void hideChildren( bool spontaneous );
610 void reparentSys( QWidget *parent, WFlags, const QPoint &, bool showIt);
611 void createTLExtra();
612 void createExtra();
613 void deleteExtra();
614 void createSysExtra();
615 void deleteSysExtra();
616 void createTLSysExtra();
617 void deleteTLSysExtra();
618 void deactivateWidgetCleanup();
619 void internalSetGeometry( int, int, int, int, bool );
620 void reparentFocusWidgets( QWidget * );
621 QFocusData *focusData( bool create );
622 void setBackgroundFromMode();
623 void setBackgroundColorDirect( const QColor & );
624 void setBackgroundPixmapDirect( const QPixmap & );
625 void setBackgroundModeDirect( BackgroundMode );
626 void setBackgroundEmpty();
627 void updateFrameStrut() const;
628#if defined(Q_WS_X11)
629 void setBackgroundX11Relative();
630#endif
631
632 WId winid;
633 uint widget_state;
634 uint widget_flags;
635 uint focus_policy : 4;
636 uint own_font :1;
637 uint own_palette :1;
638 uint sizehint_forced :1;
639 uint is_closing :1;
640 uint in_show : 1;
641 uint in_show_maximized : 1;
642 uint fstrut_dirty : 1;
643 uint im_enabled : 1;
644 QRect crect;
645 QColor bg_col;
646#ifndef QT_NO_PALETTE
647 QPalette pal;
648#endif
649 QFont fnt;
650#ifndef QT_NO_LAYOUT
651 QLayout *lay_out;
652#endif
653 QWExtra *extra;
654#if defined(Q_WS_QWS)
655 QRegion req_region; // Requested region
656 mutable QRegion paintable_region; // Paintable region
657 mutable bool paintable_region_dirty;// needs to be recalculated
658 mutable QRegion alloc_region; // Allocated region
659 mutable bool alloc_region_dirty; // needs to be recalculated
660 mutable int overlapping_children; // Handle overlapping children
661
662 int alloc_region_index;
663 int alloc_region_revision;
664
665 void updateOverlappingChildren() const;
666 void setChildrenAllocatedDirty();
667 void setChildrenAllocatedDirty( const QRegion &r, const QWidget *dirty=0 );
668 bool isAllocatedRegionDirty() const;
669 void updateRequestedRegion( const QPoint &gpos );
670 QRegion requestedRegion() const;
671 QRegion allocatedRegion() const;
672 QRegion paintableRegion() const;
673
674 void updateGraphicsContext( QGfx *qgfx_qws, bool clip_children ) const;
675#ifndef QT_NO_CURSOR
676 void updateCursor( const QRegion &r ) const;
677#endif
678
679 // used to accumulate dirty region when children moved/resized.
680 QRegion dirtyChildren;
681 bool isSettingGeometry;
682 friend class QWSManager;
683#endif
684 static int instanceCounter; // Current number of widget instances
685 static int maxInstances; // Maximum number of widget instances
686
687 static void createMapper();
688 static void destroyMapper();
689 static QWidgetList *wList();
690 static QWidgetList *tlwList();
691 static QWidgetMapper *mapper;
692 friend class QApplication;
693 friend class QBaseApplication;
694 friend class QPainter;
695 friend class QFontMetrics;
696 friend class QFontInfo;
697 friend class QETWidget;
698 friend class QLayout;
699
700private: // Disabled copy constructor and operator=
701#if defined(Q_DISABLE_COPY)
702 QWidget( const QWidget & );
703 QWidget &operator=( const QWidget & );
704#endif
705
706public: // obsolete functions to dissappear or to become inline in 3.0
707#ifndef QT_NO_PALETTE
708 void setPalette( const QPalette &p, bool ) { setPalette( p ); }
709#endif
710 void setFont( const QFont &f, bool ) { setFont( f ); }
711};
712
713
714inline Qt::WState QWidget::testWState( WState s ) const
715{ return (widget_state & s); }
716
717inline Qt::WFlags QWidget::testWFlags( WFlags f ) const
718{ return (widget_flags & f); }
719
720
721inline WId QWidget::winId() const
722{ return winid; }
723
724inline bool QWidget::isTopLevel() const
725{ return testWFlags(WType_TopLevel); }
726
727inline bool QWidget::isDialog() const
728{ return testWFlags(WType_Dialog); }
729
730inline bool QWidget::isPopup() const
731{ return testWFlags(WType_Popup); }
732
733inline bool QWidget::isDesktop() const
734{ return testWFlags(WType_Desktop); }
735
736inline bool QWidget::isEnabled() const
737{ return !testWState(WState_Disabled); }
738
739inline bool QWidget::isModal() const
740{ return testWFlags(WShowModal); }
741
742inline bool QWidget::isEnabledToTLW() const
743{ return isEnabled(); }
744
745inline const QRect &QWidget::geometry() const
746{ return crect; }
747
748inline QSize QWidget::size() const
749{ return crect.size(); }
750
751inline int QWidget::width() const
752{ return crect.width(); }
753
754inline int QWidget::height() const
755{ return crect.height(); }
756
757inline QRect QWidget::rect() const
758{ return QRect(0,0,crect.width(),crect.height()); }
759
760inline int QWidget::minimumWidth() const
761{ return minimumSize().width(); }
762
763inline int QWidget::minimumHeight() const
764{ return minimumSize().height(); }
765
766inline int QWidget::maximumWidth() const
767{ return maximumSize().width(); }
768
769inline int QWidget::maximumHeight() const
770{ return maximumSize().height(); }
771
772inline void QWidget::setMinimumSize( const QSize &s )
773{ setMinimumSize(s.width(),s.height()); }
774
775inline void QWidget::setMaximumSize( const QSize &s )
776{ setMaximumSize(s.width(),s.height()); }
777
778inline void QWidget::setSizeIncrement( const QSize &s )
779{ setSizeIncrement(s.width(),s.height()); }
780
781inline void QWidget::setBaseSize( const QSize &s )
782{ setBaseSize(s.width(),s.height()); }
783
784inline const QColor &QWidget::eraseColor() const
785{ return bg_col; }
786
787#ifndef QT_NO_PALETTE
788inline const QPalette &QWidget::palette() const
789{ return pal; }
790#endif
791
792inline QFont QWidget::font() const
793{ return fnt; }
794
795inline QFontMetrics QWidget::fontMetrics() const
796{ return QFontMetrics(font()); }
797
798inline QFontInfo QWidget::fontInfo() const
799{ return QFontInfo(font()); }
800
801inline bool QWidget::hasMouseTracking() const
802{ return testWState(WState_MouseTracking); }
803
804inline bool QWidget::hasMouse() const
805{ return testWState(WState_HasMouse); }
806
807inline bool QWidget::isFocusEnabled() const
808{ return (FocusPolicy)focus_policy != NoFocus; }
809
810inline QWidget::FocusPolicy QWidget::focusPolicy() const
811{ return (FocusPolicy)focus_policy; }
812
813inline bool QWidget::isUpdatesEnabled() const
814{ return !testWState(WState_BlockUpdates); }
815
816inline void QWidget::update( const QRect &r )
817{ update( r.x(), r.y(), r.width(), r.height() ); }
818
819inline void QWidget::repaint()
820{ repaint( TRUE ); }
821
822inline void QWidget::repaint( const QRect &r, bool erase )
823{ repaint( r.x(), r.y(), r.width(), r.height(), erase ); }
824
825inline void QWidget::erase()
826{ erase( 0, 0, crect.width(), crect.height() ); }
827
828inline void QWidget::erase( const QRect &r )
829{ erase( r.x(), r.y(), r.width(), r.height() ); }
830
831inline bool QWidget::close()
832{ return close( FALSE ); }
833
834inline bool QWidget::isVisible() const
835{ return testWState(WState_Visible); }
836
837inline bool QWidget::isVisibleToTLW() const // obsolete
838{ return isVisible(); }
839
840inline bool QWidget::isHidden() const
841{ return testWState(WState_ForceHide); }
842
843inline bool QWidget::isShown() const
844{ return !testWState(WState_ForceHide); }
845
846inline void QWidget::move( const QPoint &p )
847{ move( p.x(), p.y() ); }
848
849inline void QWidget::resize( const QSize &s )
850{ resize( s.width(), s.height()); }
851
852inline void QWidget::setGeometry( const QRect &r )
853{ setGeometry( r.left(), r.top(), r.width(), r.height() ); }
854
855inline void QWidget::drawText( const QPoint &p, const QString &s )
856{ drawText( p.x(), p.y(), s ); }
857
858inline QWidget *QWidget::parentWidget( bool sameWindow ) const
859{
860 if ( sameWindow )
861 return isTopLevel() ? 0 : (QWidget *)QObject::parent();
862 return (QWidget *)QObject::parent();
863}
864
865inline QWidgetMapper *QWidget::wmapper()
866{ return mapper; }
867
868inline uint QWidget::getWState() const
869{ return widget_state; }
870
871inline void QWidget::setWState( uint f )
872{ widget_state |= f; }
873
874inline void QWidget::clearWState( uint f )
875{ widget_state &= ~f; }
876
877inline Qt::WFlags QWidget::getWFlags() const
878{ return widget_flags; }
879
880inline void QWidget::setWFlags( WFlags f )
881{ widget_flags |= f; }
882
883inline void QWidget::clearWFlags( WFlags f )
884{ widget_flags &= ~f; }
885
886inline void QWidget::constPolish() const
887{
888 if ( !testWState(WState_Polished) ) {
889 QWidget* that = (QWidget*) this;
890 that->polish();
891 that->setWState(WState_Polished); // be on the safe side...
892 }
893}
894#ifndef QT_NO_CURSOR
895inline bool QWidget::ownCursor() const
896{
897 return testWState( WState_OwnCursor );
898}
899#endif
900inline bool QWidget::ownFont() const
901{
902 return own_font;
903}
904#ifndef QT_NO_PALETTE
905inline bool QWidget::ownPalette() const
906{
907 return own_palette;
908}
909#endif
910
911inline void QWidget::setSizePolicy( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw )
912{
913 setSizePolicy( QSizePolicy( hor, ver, hfw) );
914}
915
916inline bool QWidget::isInputMethodEnabled() const
917{
918 return (bool)im_enabled;
919}
920
921// Extra QWidget data
922// - to minimize memory usage for members that are seldom used.
923// - top-level widgets have extra extra data to reduce cost further
924
925class QFocusData;
926class QWSManager;
927#if defined(Q_WS_WIN)
928class QOleDropTarget;
929#endif
930#if defined(Q_WS_MAC)
931class QMacDndExtra;
932#endif
933
934struct Q_EXPORT QTLWExtra {
935#ifndef QT_NO_WIDGET_TOPEXTRA
936 QString caption; // widget caption
937 QString iconText; // widget icon text
938 QPixmap *icon; // widget icon
939#endif
940 QFocusData *focusData; // focus data (for TLW)
941 short incw, inch; // size increments
942 // frame strut
943 ulong fleft, fright, ftop, fbottom;
944 uint unused : 8; // not used at this point...
945#if defined( Q_WS_WIN ) || defined( Q_WS_MAC )
946 uint opacity : 8; // Stores opacity level on Windows/Mac OS X.
947#endif
[8]948//@@TODO (dmik): savedFlags seems not to be used by OS/2 version. enclose it with ifndef?
[2]949 uint savedFlags; // Save widgetflags while showing fullscreen
950 short basew, baseh; // base sizes
951#if defined(Q_WS_X11)
952 WId parentWinId; // parent window Id (valid after reparenting)
953 uint embedded : 1; // window is embedded in another Qt application
954 uint spont_unmapped: 1; // window was spontaneously unmapped
955 uint reserved: 1; // reserved
956 uint dnd : 1; // DND properties installed
957 uint uspos : 1; // User defined position
958 uint ussize : 1; // User defined size
959 void *xic; // XIM Input Context
960#endif
961#if defined(Q_WS_MAC)
962 WindowGroupRef group;
963 uint is_moved: 1;
964 uint resizer : 4;
965#endif
966#if defined(Q_WS_QWS) && !defined ( QT_NO_QWS_MANAGER )
967 QRegion decor_allocated_region; // decoration allocated region
968 QWSManager *qwsManager;
969#endif
970#if defined(Q_WS_WIN)
971 HICON winIcon; // internal Windows icon
972#endif
[8]973#if defined(Q_WS_PM)
974 WId fId; // frame window handle
975 HSWITCH swEntry; // window list entry handle
976#endif
[2]977 QRect normalGeometry; // used by showMin/maximized/FullScreen
978};
979
980
981#define QWIDGETSIZE_MAX 32767
982
983// dear user: you can see this struct, but it is internal. do not touch.
984
985struct Q_EXPORT QWExtra {
986 Q_INT16 minw, minh; // minimum size
987 Q_INT16 maxw, maxh; // maximum size
988 QPixmap *bg_pix; // background pixmap
989 QWidget *focus_proxy;
990#ifndef QT_NO_CURSOR
991 QCursor *curs;
992#endif
993 QTLWExtra *topextra; // only useful for TLWs
994#if defined(Q_WS_WIN)
995 QOleDropTarget *dropTarget; // drop target
996#endif
997#if defined(Q_WS_X11)
998 WId xDndProxy; // XDND forwarding to embedded windows
999#endif
1000#if defined(Q_WS_MAC)
1001 QRegion clip_saved, clip_sibs, clip_children;
1002 QMacDndExtra *macDndExtra;
1003 QRegion dirty_area;
1004 uint clip_dirty : 1, clip_serial : 15;
1005 uint child_dirty : 1, child_serial : 15;
1006#ifndef QMAC_NO_QUARTZ
1007 uint ctx_children_clipped:1;
1008#endif // QMAC_NO_QUARTZ
1009 uint has_dirty_area:1;
1010#endif // Q_WS_MAC
1011 uint bg_origin : 2;
1012#if defined(Q_WS_X11)
1013 uint children_use_dnd : 1;
1014 uint compress_events : 1;
1015#endif
1016#if defined(Q_WS_QWS) || defined(Q_WS_MAC)
1017 QRegion mask; // widget mask
1018#endif
1019 char bg_mode; // background mode
1020 char bg_mode_visual; // visual background mode
1021#ifndef QT_NO_STYLE
1022 QStyle* style;
1023#endif
1024 QRect micro_focus_hint; // micro focus hint
1025 QSizePolicy size_policy;
1026};
1027
1028#define Q_DEFINED_QWIDGET
1029#include "qwinexport.h"
1030
1031#endif // QWIDGET_H
Note: See TracBrowser for help on using the repository browser.