Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qwidget.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of QWidget class 00005 ** 00006 ** Created : 931029 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the kernel module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QWIDGET_H 00039 #define QWIDGET_H 00040 00041 #ifndef QT_H 00042 #include "qwindowdefs.h" 00043 #include "qobject.h" 00044 #include "qpaintdevice.h" 00045 #include "qpalette.h" 00046 #include "qfont.h" 00047 #include "qfontmetrics.h" 00048 #include "qfontinfo.h" 00049 #include "qsizepolicy.h" 00050 #endif // QT_H 00051 00052 class QLayout; 00053 struct QWExtra; 00054 struct QTLWExtra; 00055 class QFocusData; 00056 class QCursor; 00057 class QWSRegionManager; 00058 class QStyle; 00059 00060 class Q_EXPORT QWidget : public QObject, public QPaintDevice 00061 { 00062 Q_OBJECT 00063 Q_ENUMS( BackgroundMode FocusPolicy BackgroundOrigin ) 00064 Q_PROPERTY( bool isTopLevel READ isTopLevel ) 00065 Q_PROPERTY( bool isDialog READ isDialog ) 00066 Q_PROPERTY( bool isModal READ isModal ) 00067 Q_PROPERTY( bool isPopup READ isPopup ) 00068 Q_PROPERTY( bool isDesktop READ isDesktop ) 00069 Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled ) 00070 Q_PROPERTY( QRect geometry READ geometry WRITE setGeometry ) 00071 Q_PROPERTY( QRect frameGeometry READ frameGeometry ) 00072 Q_PROPERTY( int x READ x ) 00073 Q_PROPERTY( int y READ y ) 00074 Q_PROPERTY( QPoint pos READ pos WRITE move DESIGNABLE false STORED false ) 00075 Q_PROPERTY( QSize frameSize READ frameSize ) 00076 Q_PROPERTY( QSize size READ size WRITE resize DESIGNABLE false STORED false ) 00077 Q_PROPERTY( int width READ width ) 00078 Q_PROPERTY( int height READ height ) 00079 Q_PROPERTY( QRect rect READ rect ) 00080 Q_PROPERTY( QRect childrenRect READ childrenRect ) 00081 Q_PROPERTY( QRegion childrenRegion READ childrenRegion ) 00082 Q_PROPERTY( QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy ) 00083 Q_PROPERTY( QSize minimumSize READ minimumSize WRITE setMinimumSize ) 00084 Q_PROPERTY( QSize maximumSize READ maximumSize WRITE setMaximumSize ) 00085 Q_PROPERTY( int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false ) 00086 Q_PROPERTY( int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false ) 00087 Q_PROPERTY( int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false ) 00088 Q_PROPERTY( int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false ) 00089 Q_PROPERTY( QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement ) 00090 Q_PROPERTY( QSize baseSize READ baseSize WRITE setBaseSize ) 00091 Q_PROPERTY( BackgroundMode backgroundMode READ backgroundMode WRITE setBackgroundMode DESIGNABLE false ) 00092 Q_PROPERTY( QColor paletteForegroundColor READ paletteForegroundColor WRITE setPaletteForegroundColor RESET unsetPalette ) 00093 Q_PROPERTY( QColor paletteBackgroundColor READ paletteBackgroundColor WRITE setPaletteBackgroundColor RESET unsetPalette ) 00094 Q_PROPERTY( QPixmap paletteBackgroundPixmap READ paletteBackgroundPixmap WRITE setPaletteBackgroundPixmap RESET unsetPalette ) 00095 Q_PROPERTY( QBrush backgroundBrush READ backgroundBrush ) 00096 Q_PROPERTY( QColorGroup colorGroup READ colorGroup ) 00097 Q_PROPERTY( QPalette palette READ palette WRITE setPalette RESET unsetPalette STORED ownPalette ) 00098 Q_PROPERTY( BackgroundOrigin backgroundOrigin READ backgroundOrigin WRITE setBackgroundOrigin ) 00099 Q_PROPERTY( bool ownPalette READ ownPalette ) 00100 Q_PROPERTY( QFont font READ font WRITE setFont RESET unsetFont STORED ownFont ) 00101 Q_PROPERTY( bool ownFont READ ownFont ) 00102 #ifndef QT_NO_CURSOR 00103 Q_PROPERTY( QCursor cursor READ cursor WRITE setCursor RESET unsetCursor STORED ownCursor ) 00104 Q_PROPERTY( bool ownCursor READ ownCursor ) 00105 #endif 00106 #ifndef QT_NO_WIDGET_TOPEXTRA 00107 Q_PROPERTY( QString caption READ caption WRITE setCaption ) 00108 Q_PROPERTY( QPixmap icon READ icon WRITE setIcon ) 00109 Q_PROPERTY( QString iconText READ iconText WRITE setIconText ) 00110 #endif 00111 Q_PROPERTY( bool mouseTracking READ hasMouseTracking WRITE setMouseTracking ) 00112 Q_PROPERTY( bool underMouse READ hasMouse ) 00113 Q_PROPERTY( bool isActiveWindow READ isActiveWindow ) 00114 Q_PROPERTY( bool focusEnabled READ isFocusEnabled ) 00115 Q_PROPERTY( FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy ) 00116 Q_PROPERTY( bool focus READ hasFocus ) 00117 Q_PROPERTY( bool updatesEnabled READ isUpdatesEnabled WRITE setUpdatesEnabled DESIGNABLE false ) 00118 Q_PROPERTY( bool visible READ isVisible ) 00119 Q_PROPERTY( QRect visibleRect READ visibleRect ) // obsolete 00120 Q_PROPERTY( bool hidden READ isHidden WRITE setHidden DESIGNABLE false SCRIPTABLE false ) 00121 Q_PROPERTY( bool shown READ isShown WRITE setShown DESIGNABLE false SCRIPTABLE false ) 00122 Q_PROPERTY( bool minimized READ isMinimized ) 00123 Q_PROPERTY( bool maximized READ isMaximized ) 00124 Q_PROPERTY( bool fullScreen READ isFullScreen ) 00125 Q_PROPERTY( QSize sizeHint READ sizeHint ) 00126 Q_PROPERTY( QSize minimumSizeHint READ minimumSizeHint ) 00127 Q_PROPERTY( QRect microFocusHint READ microFocusHint ) 00128 Q_PROPERTY( bool acceptDrops READ acceptDrops WRITE setAcceptDrops ) 00129 Q_PROPERTY( bool autoMask READ autoMask WRITE setAutoMask DESIGNABLE false SCRIPTABLE false ) 00130 Q_PROPERTY( bool customWhatsThis READ customWhatsThis ) 00131 Q_PROPERTY( bool inputMethodEnabled READ isInputMethodEnabled WRITE setInputMethodEnabled DESIGNABLE false SCRIPTABLE false ) 00132 Q_PROPERTY( double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE false ) 00133 00134 public: 00135 Q_EXPLICIT QWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 00136 ~QWidget(); 00137 00138 WId winId() const; 00139 void setName( const char *name ); 00140 #ifndef QT_NO_STYLE 00141 // GUI style setting 00142 00143 QStyle &style() const; 00144 void setStyle( QStyle * ); 00145 QStyle* setStyle( const QString& ); 00146 #endif 00147 // Widget types and states 00148 00149 bool isTopLevel() const; 00150 bool isDialog() const; 00151 bool isPopup() const; 00152 bool isDesktop() const; 00153 bool isModal() const; 00154 00155 bool isEnabled() const; 00156 bool isEnabledTo(QWidget*) const; 00157 bool isEnabledToTLW() const; 00158 00159 public slots: 00160 virtual void setEnabled( bool ); 00161 void setDisabled( bool ); 00162 00163 // Widget coordinates 00164 00165 public: 00166 QRect frameGeometry() const; 00167 const QRect &geometry() const; 00168 int x() const; 00169 int y() const; 00170 QPoint pos() const; 00171 QSize frameSize() const; 00172 QSize size() const; 00173 int width() const; 00174 int height() const; 00175 QRect rect() const; 00176 QRect childrenRect() const; 00177 QRegion childrenRegion() const; 00178 00179 QSize minimumSize() const; 00180 QSize maximumSize() const; 00181 int minimumWidth() const; 00182 int minimumHeight() const; 00183 int maximumWidth() const; 00184 int maximumHeight() const; 00185 void setMinimumSize( const QSize & ); 00186 virtual void setMinimumSize( int minw, int minh ); 00187 void setMaximumSize( const QSize & ); 00188 virtual void setMaximumSize( int maxw, int maxh ); 00189 void setMinimumWidth( int minw ); 00190 void setMinimumHeight( int minh ); 00191 void setMaximumWidth( int maxw ); 00192 void setMaximumHeight( int maxh ); 00193 00194 QSize sizeIncrement() const; 00195 void setSizeIncrement( const QSize & ); 00196 virtual void setSizeIncrement( int w, int h ); 00197 QSize baseSize() const; 00198 void setBaseSize( const QSize & ); 00199 void setBaseSize( int basew, int baseh ); 00200 00201 void setFixedSize( const QSize & ); 00202 void setFixedSize( int w, int h ); 00203 void setFixedWidth( int w ); 00204 void setFixedHeight( int h ); 00205 00206 // Widget coordinate mapping 00207 00208 QPoint mapToGlobal( const QPoint & ) const; 00209 QPoint mapFromGlobal( const QPoint & ) const; 00210 QPoint mapToParent( const QPoint & ) const; 00211 QPoint mapFromParent( const QPoint & ) const; 00212 QPoint mapTo( QWidget *, const QPoint & ) const; 00213 QPoint mapFrom( QWidget *, const QPoint & ) const; 00214 00215 QWidget *topLevelWidget() const; 00216 00217 // Widget attribute functions 00218 00219 BackgroundMode backgroundMode() const; 00220 virtual void setBackgroundMode( BackgroundMode ); 00221 void setBackgroundMode( BackgroundMode, BackgroundMode ); 00222 00223 const QColor & foregroundColor() const; 00224 00225 const QColor & eraseColor() const; 00226 virtual void setEraseColor( const QColor & ); 00227 00228 const QPixmap * erasePixmap() const; 00229 virtual void setErasePixmap( const QPixmap & ); 00230 00231 #ifndef QT_NO_PALETTE 00232 const QColorGroup & colorGroup() const; 00233 const QPalette & palette() const; 00234 bool ownPalette() const; 00235 virtual void setPalette( const QPalette & ); 00236 void unsetPalette(); 00237 #endif 00238 00239 const QColor & paletteForegroundColor() const; 00240 void setPaletteForegroundColor( const QColor & ); 00241 00242 const QColor & paletteBackgroundColor() const; 00243 virtual void setPaletteBackgroundColor( const QColor & ); 00244 00245 const QPixmap * paletteBackgroundPixmap() const; 00246 virtual void setPaletteBackgroundPixmap( const QPixmap & ); 00247 00248 const QBrush& backgroundBrush() const; 00249 00250 QFont font() const; 00251 bool ownFont() const; 00252 virtual void setFont( const QFont & ); 00253 void unsetFont(); 00254 QFontMetrics fontMetrics() const; 00255 QFontInfo fontInfo() const; 00256 00257 #ifndef QT_NO_CURSOR 00258 const QCursor &cursor() const; 00259 bool ownCursor() const; 00260 virtual void setCursor( const QCursor & ); 00261 virtual void unsetCursor(); 00262 #endif 00263 #ifndef QT_NO_WIDGET_TOPEXTRA 00264 QString caption() const; 00265 const QPixmap *icon() const; 00266 QString iconText() const; 00267 #endif 00268 bool hasMouseTracking() const; 00269 bool hasMouse() const; 00270 00271 virtual void setMask( const QBitmap & ); 00272 virtual void setMask( const QRegion & ); 00273 void clearMask(); 00274 00275 const QColor & backgroundColor() const; // obsolete, use eraseColor() 00276 virtual void setBackgroundColor( const QColor & ); // obsolete, use setEraseColor() 00277 const QPixmap * backgroundPixmap() const; // obsolete, use erasePixmap() 00278 virtual void setBackgroundPixmap( const QPixmap & ); // obsolete, use setErasePixmap() 00279 00280 public slots: 00281 #ifndef QT_NO_WIDGET_TOPEXTRA 00282 virtual void setCaption( const QString &); 00283 virtual void setIcon( const QPixmap & ); 00284 virtual void setIconText( const QString &); 00285 #endif 00286 virtual void setMouseTracking( bool enable ); 00287 00288 // Keyboard input focus functions 00289 00290 virtual void setFocus(); 00291 void clearFocus(); 00292 00293 public: 00294 enum FocusPolicy { 00295 NoFocus = 0, 00296 TabFocus = 0x1, 00297 ClickFocus = 0x2, 00298 StrongFocus = TabFocus | ClickFocus | 0x8, 00299 WheelFocus = StrongFocus | 0x4 00300 }; 00301 00302 bool isActiveWindow() const; 00303 virtual void setActiveWindow(); 00304 bool isFocusEnabled() const; 00305 00306 FocusPolicy focusPolicy() const; 00307 virtual void setFocusPolicy( FocusPolicy ); 00308 bool hasFocus() const; 00309 static void setTabOrder( QWidget *, QWidget * ); 00310 virtual void setFocusProxy( QWidget * ); 00311 QWidget * focusProxy() const; 00312 00313 void setInputMethodEnabled( bool b ); 00314 bool isInputMethodEnabled() const; 00315 // Grab functions 00316 00317 void grabMouse(); 00318 #ifndef QT_NO_CURSOR 00319 void grabMouse( const QCursor & ); 00320 #endif 00321 void releaseMouse(); 00322 void grabKeyboard(); 00323 void releaseKeyboard(); 00324 static QWidget * mouseGrabber(); 00325 static QWidget * keyboardGrabber(); 00326 00327 // Update/refresh functions 00328 00329 bool isUpdatesEnabled() const; 00330 00331 #if 0 //def Q_WS_QWS 00332 void repaintUnclipped( const QRegion &, bool erase = TRUE ); 00333 #endif 00334 public slots: 00335 virtual void setUpdatesEnabled( bool enable ); 00336 void update(); 00337 void update( int x, int y, int w, int h ); 00338 void update( const QRect& ); 00339 void repaint(); 00340 void repaint( bool erase ); 00341 void repaint( int x, int y, int w, int h, bool erase=TRUE ); 00342 void repaint( const QRect &, bool erase = TRUE ); 00343 void repaint( const QRegion &, bool erase = TRUE ); 00344 00345 // Widget management functions 00346 00347 virtual void show(); 00348 virtual void hide(); 00349 void setShown( bool show ); 00350 void setHidden( bool hide ); 00351 #ifndef QT_NO_COMPAT 00352 void iconify() { showMinimized(); } 00353 #endif 00354 virtual void showMinimized(); 00355 virtual void showMaximized(); 00356 void showFullScreen(); 00357 virtual void showNormal(); 00358 virtual void polish(); 00359 void constPolish() const; 00360 bool close(); 00361 00362 void raise(); 00363 void lower(); 00364 void stackUnder( QWidget* ); 00365 virtual void move( int x, int y ); 00366 void move( const QPoint & ); 00367 virtual void resize( int w, int h ); 00368 void resize( const QSize & ); 00369 virtual void setGeometry( int x, int y, int w, int h ); 00370 virtual void setGeometry( const QRect & ); // ### make non virtual in Qt 4? 00371 00372 public: 00373 virtual bool close( bool alsoDelete ); 00374 bool isVisible() const; 00375 bool isVisibleTo(QWidget*) const; 00376 bool isVisibleToTLW() const; // obsolete 00377 QRect visibleRect() const; // obsolete 00378 bool isHidden() const; 00379 bool isShown() const; 00380 bool isMinimized() const; 00381 bool isMaximized() const; 00382 bool isFullScreen() const; 00383 00384 uint windowState() const; 00385 void setWindowState(uint windowState); 00386 00387 virtual QSize sizeHint() const; 00388 virtual QSize minimumSizeHint() const; 00389 virtual QSizePolicy sizePolicy() const; 00390 virtual void setSizePolicy( QSizePolicy ); 00391 void setSizePolicy( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw = FALSE ); 00392 virtual int heightForWidth(int) const; 00393 00394 QRegion clipRegion() const; 00395 00396 // ### move together with other slots in Qt 4.0 00397 public slots: 00398 virtual void adjustSize(); 00399 00400 public: 00401 #ifndef QT_NO_LAYOUT 00402 QLayout * layout() const { return lay_out; } 00403 #endif 00404 void updateGeometry(); 00405 virtual void reparent( QWidget *parent, WFlags, const QPoint &, 00406 bool showIt=FALSE ); 00407 void reparent( QWidget *parent, const QPoint &, 00408 bool showIt=FALSE ); 00409 #ifndef QT_NO_COMPAT 00410 void recreate( QWidget *parent, WFlags f, const QPoint & p, 00411 bool showIt=FALSE ) { reparent(parent,f,p,showIt); } 00412 #endif 00413 00414 void erase(); 00415 void erase( int x, int y, int w, int h ); 00416 void erase( const QRect & ); 00417 void erase( const QRegion & ); 00418 void scroll( int dx, int dy ); 00419 void scroll( int dx, int dy, const QRect& ); 00420 00421 void drawText( int x, int y, const QString &); 00422 void drawText( const QPoint &, const QString &); 00423 00424 // Misc. functions 00425 00426 QWidget * focusWidget() const; 00427 QRect microFocusHint() const; 00428 00429 // drag and drop 00430 00431 bool acceptDrops() const; 00432 virtual void setAcceptDrops( bool on ); 00433 00434 // transparency and pseudo transparency 00435 00436 virtual void setAutoMask(bool); 00437 bool autoMask() const; 00438 00439 enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin }; 00440 00441 virtual void setBackgroundOrigin( BackgroundOrigin ); 00442 BackgroundOrigin backgroundOrigin() const; 00443 QPoint backgroundOffset() const; 00444 00445 // whats this help 00446 virtual bool customWhatsThis() const; 00447 00448 QWidget * parentWidget( bool sameWindow = FALSE ) const; 00449 WState testWState( WState s ) const; 00450 WFlags testWFlags( WFlags f ) const; 00451 static QWidget * find( WId ); 00452 static QWidgetMapper *wmapper(); 00453 00454 QWidget *childAt( int x, int y, bool includeThis = FALSE ) const; 00455 QWidget *childAt( const QPoint &, bool includeThis = FALSE ) const; 00456 00457 #if defined(Q_WS_QWS) 00458 virtual QGfx * graphicsContext(bool clip_children=TRUE) const; 00459 #endif 00460 #if defined(Q_WS_MAC) 00461 QRegion clippedRegion(bool do_children=TRUE); 00462 uint clippedSerial(bool do_children=TRUE); 00463 #ifndef QMAC_NO_QUARTZ 00464 CGContextRef macCGContext(bool clipped=TRUE) const; 00465 #endif 00466 #endif 00467 00468 void setWindowOpacity(double level); 00469 double windowOpacity() const; 00470 00471 protected: 00472 // Event handlers 00473 bool event( QEvent * ); 00474 virtual void mousePressEvent( QMouseEvent * ); 00475 virtual void mouseReleaseEvent( QMouseEvent * ); 00476 virtual void mouseDoubleClickEvent( QMouseEvent * ); 00477 virtual void mouseMoveEvent( QMouseEvent * ); 00478 #ifndef QT_NO_WHEELEVENT 00479 virtual void wheelEvent( QWheelEvent * ); 00480 #endif 00481 virtual void keyPressEvent( QKeyEvent * ); 00482 virtual void keyReleaseEvent( QKeyEvent * ); 00483 virtual void focusInEvent( QFocusEvent * ); 00484 virtual void focusOutEvent( QFocusEvent * ); 00485 virtual void enterEvent( QEvent * ); 00486 virtual void leaveEvent( QEvent * ); 00487 virtual void paintEvent( QPaintEvent * ); 00488 virtual void moveEvent( QMoveEvent * ); 00489 virtual void resizeEvent( QResizeEvent * ); 00490 virtual void closeEvent( QCloseEvent * ); 00491 virtual void contextMenuEvent( QContextMenuEvent * ); 00492 virtual void imStartEvent( QIMEvent * ); 00493 virtual void imComposeEvent( QIMEvent * ); 00494 virtual void imEndEvent( QIMEvent * ); 00495 virtual void tabletEvent( QTabletEvent * ); 00496 00497 #ifndef QT_NO_DRAGANDDROP 00498 virtual void dragEnterEvent( QDragEnterEvent * ); 00499 virtual void dragMoveEvent( QDragMoveEvent * ); 00500 virtual void dragLeaveEvent( QDragLeaveEvent * ); 00501 virtual void dropEvent( QDropEvent * ); 00502 #endif 00503 00504 virtual void showEvent( QShowEvent * ); 00505 virtual void hideEvent( QHideEvent * ); 00506 00507 #if defined(Q_WS_MAC) 00508 virtual bool macEvent( MSG * ); 00509 #endif 00510 #if defined(Q_WS_WIN) 00511 virtual bool winEvent( MSG * ); 00512 #endif 00513 #if defined(Q_WS_X11) 00514 virtual bool x11Event( XEvent * ); 00515 #endif 00516 #if defined(Q_WS_QWS) 00517 virtual bool qwsEvent( QWSEvent * ); 00518 virtual unsigned char *scanLine( int ) const; 00519 virtual int bytesPerLine() const; 00520 #endif 00521 00522 virtual void updateMask(); 00523 00524 // Misc. protected functions 00525 00526 #ifndef QT_NO_STYLE 00527 virtual void styleChange( QStyle& ); 00528 #endif 00529 virtual void enabledChange( bool oldEnabled ); 00530 #ifndef QT_NO_PALETTE 00531 virtual void paletteChange( const QPalette & ); 00532 #endif 00533 virtual void fontChange( const QFont & ); 00534 virtual void windowActivationChange( bool oldActive ); 00535 00536 int metric( int ) const; 00537 00538 void resetInputContext(); 00539 00540 virtual void create( WId = 0, bool initializeWindow = TRUE, 00541 bool destroyOldWindow = TRUE ); 00542 virtual void destroy( bool destroyWindow = TRUE, 00543 bool destroySubWindows = TRUE ); 00544 uint getWState() const; 00545 virtual void setWState( uint ); 00546 void clearWState( uint n ); 00547 WFlags getWFlags() const; 00548 virtual void setWFlags( WFlags ); 00549 void clearWFlags( WFlags n ); 00550 00551 virtual bool focusNextPrevChild( bool next ); 00552 00553 QWExtra *extraData(); 00554 QTLWExtra *topData(); 00555 QFocusData *focusData(); 00556 00557 virtual void setKeyCompression(bool); 00558 virtual void setMicroFocusHint(int x, int y, int w, int h, bool text=TRUE, QFont *f = 0); 00559 00560 #if defined(Q_WS_MAC) 00561 void dirtyClippedRegion(bool); 00562 bool isClippedRegionDirty(); 00563 virtual void setRegionDirty(bool); 00564 virtual void macWidgetChangedWindow(); 00565 #endif 00566 00567 private slots: 00568 void focusProxyDestroyed(); 00569 00570 private: 00571 void setFontSys( QFont *f = 0 ); 00572 #if defined(Q_WS_X11) 00573 void createInputContext(); 00574 void destroyInputContext(); 00575 void focusInputContext(); 00576 void checkChildrenDnd(); 00577 #elif defined(Q_WS_MAC) 00578 uint own_id : 1, macDropEnabled : 1; 00579 EventHandlerRef window_event; 00580 //mac event functions 00581 void propagateUpdates(bool update_rgn=TRUE); 00582 void update( const QRegion& ); 00583 //friends, way too many - fix this immediately! 00584 friend void qt_clean_root_win(); 00585 friend bool qt_recreate_root_win(); 00586 friend QPoint posInWindow(QWidget *); 00587 friend bool qt_mac_update_sizer(QWidget *, int); 00588 friend QWidget *qt_recursive_match(QWidget *widg, int x, int y); 00589 friend bool qt_paint_children(QWidget *,QRegion &, uchar ops); 00590 friend QMAC_PASCAL OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *); 00591 friend void qt_event_request_updates(QWidget *, const QRegion &, bool subtract); 00592 friend bool qt_window_rgn(WId, short, RgnHandle, bool); 00593 friend class QDragManager; 00594 #endif 00595 00596 #ifndef QT_NO_LAYOUT 00597 void setLayout( QLayout *l ); 00598 #endif 00599 void setWinId( WId ); 00600 void showWindow(); 00601 void hideWindow(); 00602 void showChildren( bool spontaneous ); 00603 void hideChildren( bool spontaneous ); 00604 void reparentSys( QWidget *parent, WFlags, const QPoint &, bool showIt); 00605 void createTLExtra(); 00606 void createExtra(); 00607 void deleteExtra(); 00608 void createSysExtra(); 00609 void deleteSysExtra(); 00610 void createTLSysExtra(); 00611 void deleteTLSysExtra(); 00612 void deactivateWidgetCleanup(); 00613 void internalSetGeometry( int, int, int, int, bool ); 00614 void reparentFocusWidgets( QWidget * ); 00615 QFocusData *focusData( bool create ); 00616 void setBackgroundFromMode(); 00617 void setBackgroundColorDirect( const QColor & ); 00618 void setBackgroundPixmapDirect( const QPixmap & ); 00619 void setBackgroundModeDirect( BackgroundMode ); 00620 void setBackgroundEmpty(); 00621 void updateFrameStrut() const; 00622 #if defined(Q_WS_X11) 00623 void setBackgroundX11Relative(); 00624 #endif 00625 00626 WId winid; 00627 uint widget_state; 00628 uint widget_flags; 00629 uint focus_policy : 4; 00630 uint own_font :1; 00631 uint own_palette :1; 00632 uint sizehint_forced :1; 00633 uint is_closing :1; 00634 uint in_show : 1; 00635 uint in_show_maximized : 1; 00636 uint fstrut_dirty : 1; 00637 uint im_enabled : 1; 00638 QRect crect; 00639 QColor bg_col; 00640 #ifndef QT_NO_PALETTE 00641 QPalette pal; 00642 #endif 00643 QFont fnt; 00644 #ifndef QT_NO_LAYOUT 00645 QLayout *lay_out; 00646 #endif 00647 QWExtra *extra; 00648 #if defined(Q_WS_QWS) 00649 QRegion req_region; // Requested region 00650 mutable QRegion paintable_region; // Paintable region 00651 mutable bool paintable_region_dirty;// needs to be recalculated 00652 mutable QRegion alloc_region; // Allocated region 00653 mutable bool alloc_region_dirty; // needs to be recalculated 00654 mutable int overlapping_children; // Handle overlapping children 00655 00656 int alloc_region_index; 00657 int alloc_region_revision; 00658 00659 void updateOverlappingChildren() const; 00660 void setChildrenAllocatedDirty(); 00661 void setChildrenAllocatedDirty( const QRegion &r, const QWidget *dirty=0 ); 00662 bool isAllocatedRegionDirty() const; 00663 void updateRequestedRegion( const QPoint &gpos ); 00664 QRegion requestedRegion() const; 00665 QRegion allocatedRegion() const; 00666 QRegion paintableRegion() const; 00667 00668 void updateGraphicsContext( QGfx *qgfx_qws, bool clip_children ) const; 00669 #ifndef QT_NO_CURSOR 00670 void updateCursor( const QRegion &r ) const; 00671 #endif 00672 00673 // used to accumulate dirty region when children moved/resized. 00674 QRegion dirtyChildren; 00675 bool isSettingGeometry; 00676 friend class QWSManager; 00677 #endif 00678 static int instanceCounter; // Current number of widget instances 00679 static int maxInstances; // Maximum number of widget instances 00680 00681 static void createMapper(); 00682 static void destroyMapper(); 00683 static QWidgetList *wList(); 00684 static QWidgetList *tlwList(); 00685 static QWidgetMapper *mapper; 00686 friend class QApplication; 00687 friend class QBaseApplication; 00688 friend class QPainter; 00689 friend class QFontMetrics; 00690 friend class QFontInfo; 00691 friend class QETWidget; 00692 friend class QLayout; 00693 00694 private: // Disabled copy constructor and operator= 00695 #if defined(Q_DISABLE_COPY) 00696 QWidget( const QWidget & ); 00697 QWidget &operator=( const QWidget & ); 00698 #endif 00699 00700 public: // obsolete functions to dissappear or to become inline in 3.0 00701 #ifndef QT_NO_PALETTE 00702 void setPalette( const QPalette &p, bool ) { setPalette( p ); } 00703 #endif 00704 void setFont( const QFont &f, bool ) { setFont( f ); } 00705 }; 00706 00707 00708 inline Qt::WState QWidget::testWState( WState s ) const 00709 { return (widget_state & s); } 00710 00711 inline Qt::WFlags QWidget::testWFlags( WFlags f ) const 00712 { return (widget_flags & f); } 00713 00714 00715 inline WId QWidget::winId() const 00716 { return winid; } 00717 00718 inline bool QWidget::isTopLevel() const 00719 { return testWFlags(WType_TopLevel); } 00720 00721 inline bool QWidget::isDialog() const 00722 { return testWFlags(WType_Dialog); } 00723 00724 inline bool QWidget::isPopup() const 00725 { return testWFlags(WType_Popup); } 00726 00727 inline bool QWidget::isDesktop() const 00728 { return testWFlags(WType_Desktop); } 00729 00730 inline bool QWidget::isEnabled() const 00731 { return !testWState(WState_Disabled); } 00732 00733 inline bool QWidget::isModal() const 00734 { return testWFlags(WShowModal); } 00735 00736 inline bool QWidget::isEnabledToTLW() const 00737 { return isEnabled(); } 00738 00739 inline const QRect &QWidget::geometry() const 00740 { return crect; } 00741 00742 inline QSize QWidget::size() const 00743 { return crect.size(); } 00744 00745 inline int QWidget::width() const 00746 { return crect.width(); } 00747 00748 inline int QWidget::height() const 00749 { return crect.height(); } 00750 00751 inline QRect QWidget::rect() const 00752 { return QRect(0,0,crect.width(),crect.height()); } 00753 00754 inline int QWidget::minimumWidth() const 00755 { return minimumSize().width(); } 00756 00757 inline int QWidget::minimumHeight() const 00758 { return minimumSize().height(); } 00759 00760 inline int QWidget::maximumWidth() const 00761 { return maximumSize().width(); } 00762 00763 inline int QWidget::maximumHeight() const 00764 { return maximumSize().height(); } 00765 00766 inline void QWidget::setMinimumSize( const QSize &s ) 00767 { setMinimumSize(s.width(),s.height()); } 00768 00769 inline void QWidget::setMaximumSize( const QSize &s ) 00770 { setMaximumSize(s.width(),s.height()); } 00771 00772 inline void QWidget::setSizeIncrement( const QSize &s ) 00773 { setSizeIncrement(s.width(),s.height()); } 00774 00775 inline void QWidget::setBaseSize( const QSize &s ) 00776 { setBaseSize(s.width(),s.height()); } 00777 00778 inline const QColor &QWidget::eraseColor() const 00779 { return bg_col; } 00780 00781 #ifndef QT_NO_PALETTE 00782 inline const QPalette &QWidget::palette() const 00783 { return pal; } 00784 #endif 00785 00786 inline QFont QWidget::font() const 00787 { return fnt; } 00788 00789 inline QFontMetrics QWidget::fontMetrics() const 00790 { return QFontMetrics(font()); } 00791 00792 inline QFontInfo QWidget::fontInfo() const 00793 { return QFontInfo(font()); } 00794 00795 inline bool QWidget::hasMouseTracking() const 00796 { return testWState(WState_MouseTracking); } 00797 00798 inline bool QWidget::hasMouse() const 00799 { return testWState(WState_HasMouse); } 00800 00801 inline bool QWidget::isFocusEnabled() const 00802 { return (FocusPolicy)focus_policy != NoFocus; } 00803 00804 inline QWidget::FocusPolicy QWidget::focusPolicy() const 00805 { return (FocusPolicy)focus_policy; } 00806 00807 inline bool QWidget::isUpdatesEnabled() const 00808 { return !testWState(WState_BlockUpdates); } 00809 00810 inline void QWidget::update( const QRect &r ) 00811 { update( r.x(), r.y(), r.width(), r.height() ); } 00812 00813 inline void QWidget::repaint() 00814 { repaint( TRUE ); } 00815 00816 inline void QWidget::repaint( const QRect &r, bool erase ) 00817 { repaint( r.x(), r.y(), r.width(), r.height(), erase ); } 00818 00819 inline void QWidget::erase() 00820 { erase( 0, 0, crect.width(), crect.height() ); } 00821 00822 inline void QWidget::erase( const QRect &r ) 00823 { erase( r.x(), r.y(), r.width(), r.height() ); } 00824 00825 inline bool QWidget::close() 00826 { return close( FALSE ); } 00827 00828 inline bool QWidget::isVisible() const 00829 { return testWState(WState_Visible); } 00830 00831 inline bool QWidget::isVisibleToTLW() const // obsolete 00832 { return isVisible(); } 00833 00834 inline bool QWidget::isHidden() const 00835 { return testWState(WState_ForceHide); } 00836 00837 inline bool QWidget::isShown() const 00838 { return !testWState(WState_ForceHide); } 00839 00840 inline void QWidget::move( const QPoint &p ) 00841 { move( p.x(), p.y() ); } 00842 00843 inline void QWidget::resize( const QSize &s ) 00844 { resize( s.width(), s.height()); } 00845 00846 inline void QWidget::setGeometry( const QRect &r ) 00847 { setGeometry( r.left(), r.top(), r.width(), r.height() ); } 00848 00849 inline void QWidget::drawText( const QPoint &p, const QString &s ) 00850 { drawText( p.x(), p.y(), s ); } 00851 00852 inline QWidget *QWidget::parentWidget( bool sameWindow ) const 00853 { 00854 if ( sameWindow ) 00855 return isTopLevel() ? 0 : (QWidget *)QObject::parent(); 00856 return (QWidget *)QObject::parent(); 00857 } 00858 00859 inline QWidgetMapper *QWidget::wmapper() 00860 { return mapper; } 00861 00862 inline uint QWidget::getWState() const 00863 { return widget_state; } 00864 00865 inline void QWidget::setWState( uint f ) 00866 { widget_state |= f; } 00867 00868 inline void QWidget::clearWState( uint f ) 00869 { widget_state &= ~f; } 00870 00871 inline Qt::WFlags QWidget::getWFlags() const 00872 { return widget_flags; } 00873 00874 inline void QWidget::setWFlags( WFlags f ) 00875 { widget_flags |= f; } 00876 00877 inline void QWidget::clearWFlags( WFlags f ) 00878 { widget_flags &= ~f; } 00879 00880 inline void QWidget::constPolish() const 00881 { 00882 if ( !testWState(WState_Polished) ) { 00883 QWidget* that = (QWidget*) this; 00884 that->polish(); 00885 that->setWState(WState_Polished); // be on the safe side... 00886 } 00887 } 00888 #ifndef QT_NO_CURSOR 00889 inline bool QWidget::ownCursor() const 00890 { 00891 return testWState( WState_OwnCursor ); 00892 } 00893 #endif 00894 inline bool QWidget::ownFont() const 00895 { 00896 return own_font; 00897 } 00898 #ifndef QT_NO_PALETTE 00899 inline bool QWidget::ownPalette() const 00900 { 00901 return own_palette; 00902 } 00903 #endif 00904 00905 inline void QWidget::setSizePolicy( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw ) 00906 { 00907 setSizePolicy( QSizePolicy( hor, ver, hfw) ); 00908 } 00909 00910 inline bool QWidget::isInputMethodEnabled() const 00911 { 00912 return (bool)im_enabled; 00913 } 00914 00915 // Extra QWidget data 00916 // - to minimize memory usage for members that are seldom used. 00917 // - top-level widgets have extra extra data to reduce cost further 00918 00919 class QFocusData; 00920 class QWSManager; 00921 #if defined(Q_WS_WIN) 00922 class QOleDropTarget; 00923 #endif 00924 #if defined(Q_WS_MAC) 00925 class QMacDndExtra; 00926 #endif 00927 00928 struct Q_EXPORT QTLWExtra { 00929 #ifndef QT_NO_WIDGET_TOPEXTRA 00930 QString caption; // widget caption 00931 QString iconText; // widget icon text 00932 QPixmap *icon; // widget icon 00933 #endif 00934 QFocusData *focusData; // focus data (for TLW) 00935 short incw, inch; // size increments 00936 // frame strut 00937 ulong fleft, fright, ftop, fbottom; 00938 uint unused : 8; // not used at this point... 00939 #if defined( Q_WS_WIN ) || defined( Q_WS_MAC ) 00940 uint opacity : 8; // Stores opacity level on Windows/Mac OS X. 00941 #endif 00942 uint savedFlags; // Save widgetflags while showing fullscreen 00943 short basew, baseh; // base sizes 00944 #if defined(Q_WS_X11) 00945 WId parentWinId; // parent window Id (valid after reparenting) 00946 uint embedded : 1; // window is embedded in another Qt application 00947 uint spont_unmapped: 1; // window was spontaneously unmapped 00948 uint reserved: 1; // reserved 00949 uint dnd : 1; // DND properties installed 00950 uint uspos : 1; // User defined position 00951 uint ussize : 1; // User defined size 00952 void *xic; // XIM Input Context 00953 #endif 00954 #if defined(Q_WS_MAC) 00955 WindowGroupRef group; 00956 uint is_moved: 1; 00957 uint resizer : 4; 00958 #endif 00959 #if defined(Q_WS_QWS) && !defined ( QT_NO_QWS_MANAGER ) 00960 QRegion decor_allocated_region; // decoration allocated region 00961 QWSManager *qwsManager; 00962 #endif 00963 #if defined(Q_WS_WIN) 00964 HICON winIcon; // internal Windows icon 00965 #endif 00966 QRect normalGeometry; // used by showMin/maximized/FullScreen 00967 #ifdef Q_WS_WIN 00968 uint style, exstyle; 00969 #endif 00970 }; 00971 00972 00973 #define QWIDGETSIZE_MAX 32767 00974 00975 // dear user: you can see this struct, but it is internal. do not touch. 00976 00977 struct Q_EXPORT QWExtra { 00978 Q_INT16 minw, minh; // minimum size 00979 Q_INT16 maxw, maxh; // maximum size 00980 QPixmap *bg_pix; // background pixmap 00981 QWidget *focus_proxy; 00982 #ifndef QT_NO_CURSOR 00983 QCursor *curs; 00984 #endif 00985 QTLWExtra *topextra; // only useful for TLWs 00986 #if defined(Q_WS_WIN) 00987 QOleDropTarget *dropTarget; // drop target 00988 #endif 00989 #if defined(Q_WS_X11) 00990 WId xDndProxy; // XDND forwarding to embedded windows 00991 #endif 00992 #if defined(Q_WS_MAC) 00993 QRegion clip_saved, clip_sibs, clip_children; 00994 QMacDndExtra *macDndExtra; 00995 QRegion dirty_area; 00996 uint clip_dirty : 1, clip_serial : 15; 00997 uint child_dirty : 1, child_serial : 15; 00998 #ifndef QMAC_NO_QUARTZ 00999 uint ctx_children_clipped:1; 01000 #endif // QMAC_NO_QUARTZ 01001 uint has_dirty_area:1; 01002 #endif // Q_WS_MAC 01003 uint bg_origin : 2; 01004 #if defined(Q_WS_X11) 01005 uint children_use_dnd : 1; 01006 uint compress_events : 1; 01007 #endif 01008 #if defined(Q_WS_QWS) || defined(Q_WS_MAC) 01009 QRegion mask; // widget mask 01010 #endif 01011 char bg_mode; // background mode 01012 char bg_mode_visual; // visual background mode 01013 #ifndef QT_NO_STYLE 01014 QStyle* style; 01015 #endif 01016 QRect micro_focus_hint; // micro focus hint 01017 QSizePolicy size_policy; 01018 }; 01019 01020 #define Q_DEFINED_QWIDGET 01021 #include "qwinexport.h" 01022 01023 #endif // QWIDGET_H