home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / REGION.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.8 KB  |  102 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   source\owl\region.cpp
  4. //   Implementation of GDI Region object class
  5. //----------------------------------------------------------------------------
  6. #include <owl\owlpch.h>
  7. #include <owl\gdiobjec.h>
  8.  
  9. DIAG_DECLARE_GROUP(OwlGDI);        // General GDI diagnostic group
  10.  
  11. TRegion::TRegion()
  12. {
  13.   Handle = ::CreateRectRgn(0, 0, 0, 0);
  14.   WARNX(OwlGDI, !Handle, 0, "Cannot create empty rect region");
  15.   CheckValid();
  16. }
  17.  
  18. TRegion::TRegion(HRGN handle, TAutoDelete autoDelete)
  19.   : TGdiBase(handle, autoDelete)
  20. {
  21. }
  22.  
  23. TRegion::TRegion(const TRegion& source)
  24. {
  25.   Handle = ::CreateRectRgn(0, 0, 0, 0);
  26.   WARNX(OwlGDI, !Handle, 0, "Cannot create copy of region " << 
  27.         UINT(HRGN(source)));
  28.   CheckValid();
  29.   ::CombineRgn((HRGN)Handle, source, 0, RGN_COPY);
  30. }
  31.  
  32. TRegion::TRegion(const TRect& rect)
  33. {
  34.   Handle = ::CreateRectRgnIndirect(&rect);
  35.   WARNX(OwlGDI, !Handle, 0, "Cannot create rect region " << rect);
  36.   CheckValid();
  37. }
  38.  
  39. TRegion::TRegion(const TRect& rect, TRegion::TEllipse)
  40. {
  41.   Handle = ::CreateEllipticRgnIndirect(&rect);
  42.   WARNX(OwlGDI, !Handle, 0, "Cannot create elliptic region " << rect);
  43.   CheckValid();
  44. }
  45.  
  46. TRegion::TRegion(const TRect& rect, const TSize& corner)
  47. {
  48.   Handle = ::CreateRoundRectRgn(rect.left, rect.top, rect.right, rect.bottom,
  49.                                 corner.cx, corner.cy);
  50.   WARNX(OwlGDI, !Handle, 0, "Cannot create roundrect region " << rect << corner);
  51.   CheckValid();
  52. }
  53.  
  54. TRegion::TRegion(const TPoint* points, int count, int fillMode)
  55. {
  56.   Handle = ::CreatePolygonRgn(points, count, fillMode);
  57.   WARNX(OwlGDI, !Handle, 0, "Cannot create poly region " << count << 
  58.         "pts @" << hex << DWORD(LPVOID(points)));
  59.   CheckValid();
  60. }
  61.  
  62. TRegion::TRegion(const TPoint* points, const int* polyCounts, int count,
  63.                  int fillMode)
  64. {
  65.   Handle = ::CreatePolyPolygonRgn(points, polyCounts, count, fillMode);
  66.   WARNX(OwlGDI, !Handle, 0, "Cannot create polypoly region " << count << 
  67.         "polies @" << hex << DWORD(LPVOID(points)));
  68.   CheckValid();
  69. }
  70.  
  71. //
  72. // No orphan control for regions since they are not selectable into DCs,
  73. // just delete
  74. //
  75. TRegion::~TRegion()
  76. {
  77.   if (ShouldDelete)
  78.     if (!::DeleteObject(Handle))
  79.       THROW( TGdiObject::TXGdi(IDS_GDIDELETEFAIL, Handle) );
  80. }
  81.  
  82. TRegion&
  83. TRegion::operator &=(const TRect& source)
  84. {
  85.   ::CombineRgn((HRGN)Handle, (HRGN)Handle, TRegion(source), RGN_AND);
  86.   return *this;
  87. }
  88.  
  89. TRegion&
  90. TRegion::operator |=(const TRect& source)
  91. {
  92.   ::CombineRgn((HRGN)Handle, (HRGN)Handle, TRegion(source), RGN_OR);
  93.   return *this;
  94. }
  95.  
  96. TRegion&
  97. TRegion::operator ^=(const TRect& source)
  98. {
  99.   ::CombineRgn((HRGN)Handle, (HRGN)Handle, TRegion(source), RGN_XOR);
  100.   return *this;
  101. }
  102.