home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qwidget.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  30KB  |  962 lines

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