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

  1. /****************************************************************************
  2. ** $Id:  qt/qregion.h   3.0.0   edited Aug 8 16:28 $
  3. **
  4. ** Definition of QRegion class
  5. **
  6. ** Created : 940514
  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 QREGION_H
  39. #define QREGION_H
  40.  
  41. #ifndef QT_H
  42. #include "qshared.h"
  43. #include "qrect.h"
  44. #endif // QT_H
  45.  
  46.  
  47. class Q_EXPORT QRegion
  48. {
  49. public:
  50.     enum RegionType { Rectangle, Ellipse };
  51.  
  52.     QRegion();
  53.     QRegion( int x, int y, int w, int h, RegionType = Rectangle );
  54.     QRegion( const QRect &, RegionType = Rectangle );
  55.     QRegion( const QPointArray &, bool winding=FALSE );
  56.     QRegion( const QRegion & );
  57.     QRegion( const QBitmap & );
  58.    ~QRegion();
  59.     QRegion &operator=( const QRegion & );
  60.  
  61.     bool    isNull()   const;
  62.     bool    isEmpty()  const;
  63.  
  64.     bool    contains( const QPoint &p ) const;
  65.     bool    contains( const QRect &r )    const;
  66.  
  67.     void    translate( int dx, int dy );
  68.  
  69.     QRegion unite( const QRegion & )    const;
  70.     QRegion intersect( const QRegion &) const;
  71.     QRegion subtract( const QRegion & ) const;
  72.     QRegion eor( const QRegion & )    const;
  73.  
  74.     QRect   boundingRect() const;
  75.     QMemArray<QRect> rects() const;
  76.     void setRects( const QRect *, int );
  77.  
  78.     const QRegion operator|( const QRegion & ) const;
  79.     const QRegion operator+( const QRegion & ) const;
  80.     const QRegion operator&( const QRegion & ) const;
  81.     const QRegion operator-( const QRegion & ) const;
  82.     const QRegion operator^( const QRegion & ) const;
  83.     QRegion& operator|=( const QRegion & );
  84.     QRegion& operator+=( const QRegion & );
  85.     QRegion& operator&=( const QRegion & );
  86.     QRegion& operator-=( const QRegion & );
  87.     QRegion& operator^=( const QRegion & );
  88.  
  89.     bool    operator==( const QRegion & )  const;
  90.     bool    operator!=( const QRegion &r ) const
  91.             { return !(operator==(r)); }
  92.  
  93. #if defined(Q_WS_WIN)
  94.     HRGN    handle() const { return data->rgn; }
  95. #elif defined(Q_WS_X11)
  96.     Region  handle() const { return data->rgn; }
  97. #elif defined(Q_WS_MAC)
  98.     RgnHandle handle(bool require_rgn=FALSE) const;
  99. #elif defined(Q_WS_QWS)
  100.     // QGfx_QWS needs this for region drawing
  101.     void * handle() const { return data->rgn; }
  102. #endif
  103.  
  104. #ifndef QT_NO_DATASTREAM
  105.     friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QRegion & );
  106.     friend Q_EXPORT QDataStream &operator>>( QDataStream &, QRegion & );
  107. #endif
  108. private:
  109.     QRegion( bool );
  110.     QRegion copy() const;
  111.     void    detach();
  112. #if defined(Q_WS_WIN)
  113.     QRegion winCombine( const QRegion &, int ) const;
  114. #endif
  115. #if defined(Q_WS_MAC)
  116.     void rectifyRegion();
  117. #endif
  118.     void    exec( const QByteArray &, int ver = 0 );
  119.     struct QRegionData : public QShared {
  120. #if defined(Q_WS_WIN)
  121.     HRGN   rgn;
  122. #elif defined(Q_WS_X11)
  123.     Region rgn;
  124. #elif defined(Q_WS_MAC)
  125.     uint is_rect:1;
  126.     QRect rect;
  127.     RgnHandle rgn;
  128. #elif defined(Q_WS_QWS)
  129.     void * rgn;
  130. #endif
  131.     bool   is_null;
  132.     } *data;
  133. };
  134.  
  135.  
  136. #define QRGN_SETRECT        1        // region stream commands
  137. #define QRGN_SETELLIPSE        2        //  (these are internal)
  138. #define QRGN_SETPTARRAY_ALT    3
  139. #define QRGN_SETPTARRAY_WIND    4
  140. #define QRGN_TRANSLATE        5
  141. #define QRGN_OR            6
  142. #define QRGN_AND        7
  143. #define QRGN_SUB        8
  144. #define QRGN_XOR        9
  145. #define QRGN_RECTS           10
  146.  
  147.  
  148. /*****************************************************************************
  149.   QRegion stream functions
  150.  *****************************************************************************/
  151.  
  152. #ifndef QT_NO_DATASTREAM
  153. Q_EXPORT QDataStream &operator<<( QDataStream &, const QRegion & );
  154. Q_EXPORT QDataStream &operator>>( QDataStream &, QRegion & );
  155. #endif
  156.  
  157.  
  158. #endif // QREGION_H
  159.