]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/region.cpp
fixed (didn't work at all)
[wxWidgets.git] / src / motif / region.cpp
index d4ced6405db74940d03cb09a86e2fa8f70e151c9..a939adba66a8cd2483ed3289b81b4ae837e31a7a 100644 (file)
@@ -3,7 +3,7 @@
 // Purpose:   Region class
 // Author:    Markus Holzem/Julian Smart
 // Created:   Fri Oct 24 10:46:34 MET 1997
-// RCS-ID:       $Id$
+// RCS-ID:      $Id$
 // Copyright: (c) 1997 Markus Holzem/Julian Smart
 // Licence:   wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -19,8 +19,8 @@
 // #include "wx/motif/private.h"
 
 #if !USE_SHARED_LIBRARY
-       IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
-       IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
+    IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
+    IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
 #endif
 
 //-----------------------------------------------------------------------------
 
 class WXDLLEXPORT wxRegionRefData : public wxGDIRefData {
 public:
-       wxRegionRefData()
-       {
-               m_region = XCreateRegion();
-       }
-
-       wxRegionRefData(const wxRegionRefData& data)
-       {
-               m_region = XCreateRegion();
-               XUnionRegion(m_region, data.m_region, m_region);
-       }
-
-       ~wxRegionRefData()
-       {
-               XDestroyRegion(m_region);
-       }
+    wxRegionRefData()
+    {
+        m_region = XCreateRegion();
+    }
+
+    wxRegionRefData(const wxRegionRefData& data)
+    {
+        m_region = XCreateRegion();
+        XUnionRegion(m_region, data.m_region, m_region);
+    }
+
+    ~wxRegionRefData()
+    {
+        XDestroyRegion(m_region);
+    }
     Region  m_region;
 };
 
@@ -64,24 +64,24 @@ wxRegion::wxRegion(long x, long y, long w, long h)
 {
     m_refData = new wxRegionRefData;
 
-       XRectangle rect;
-       rect.x          = x;
-       rect.y          = y;
-       rect.width      = w;
-       rect.height = h;
-       XUnionRectWithRegion(&rect, M_REGION, M_REGION);
+    XRectangle rect;
+    rect.x        = x;
+    rect.y        = y;
+    rect.width    = w;
+    rect.height = h;
+    XUnionRectWithRegion(&rect, M_REGION, M_REGION);
 }
 
 wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
 {
     m_refData = new wxRegionRefData;
 
-       XRectangle rect;
-       rect.x          = topLeft.x;
-       rect.y          = topLeft.y;
-       rect.width      = bottomRight.x - topLeft.x;
-       rect.height = bottomRight.y - topLeft.y;
-       XUnionRectWithRegion(&rect, M_REGION, M_REGION);
+    XRectangle rect;
+    rect.x        = topLeft.x;
+    rect.y        = topLeft.y;
+    rect.width    = bottomRight.x - topLeft.x;
+    rect.height = bottomRight.y - topLeft.y;
+    XUnionRectWithRegion(&rect, M_REGION, M_REGION);
 }
 
 wxRegion::wxRegion(const wxRect& rect)
@@ -89,9 +89,9 @@ wxRegion::wxRegion(const wxRect& rect)
     m_refData = new wxRegionRefData;
 
     XRectangle rect1;
-    rect1.x            = rect.x;
-    rect1.y            = rect.y;
-    rect1.width        = rect.width;
+    rect1.x        = rect.x;
+    rect1.y        = rect.y;
+    rect1.width    = rect.width;
     rect1.height = rect.height;
     XUnionRectWithRegion(&rect1, M_REGION, M_REGION);
 }
@@ -125,33 +125,32 @@ void wxRegion::Clear()
 //! Combine rectangle (x, y, w, h) with this.
 bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op)
 {
-       // Don't change shared data
-       if (!m_refData) {
-               m_refData = new wxRegionRefData();
-       } else if (m_refData->GetRefCount() > 1) {
-               wxRegionRefData* ref = (wxRegionRefData*)m_refData;
-               UnRef();
-               m_refData = new wxRegionRefData(*ref);
-       }
+    // Don't change shared data
+    if (!m_refData) {
+        m_refData = new wxRegionRefData();
+    } else if (m_refData->GetRefCount() > 1) {
+        wxRegionRefData* ref = (wxRegionRefData*)m_refData;
+        UnRef();
+        m_refData = new wxRegionRefData(*ref);
+    }
     // If ref count is 1, that means it's 'ours' anyway so no action.
 
     Region rectRegion = XCreateRegion();
 
-       XRectangle rect;
-       rect.x          = x;
-       rect.y          = y;
-       rect.width      = width;
-       rect.height = height;
-       XUnionRectWithRegion(&rect, rectRegion, rectRegion);
+    XRectangle rect;
+    rect.x        = x;
+    rect.y        = y;
+    rect.width    = width;
+    rect.height = height;
+    XUnionRectWithRegion(&rect, rectRegion, rectRegion);
 
-    int mode = 0; // TODO platform-specific code
     switch (op)
     {
         case wxRGN_AND:
-               XIntersectRegion(M_REGION, rectRegion, M_REGION);
+            XIntersectRegion(M_REGION, rectRegion, M_REGION);
             break ;
         case wxRGN_OR:
-               XUnionRegion(M_REGION, rectRegion, M_REGION);
+            XUnionRegion(M_REGION, rectRegion, M_REGION);
             break ;
         case wxRGN_XOR:
             // TODO
@@ -171,28 +170,27 @@ bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op)
 //! Union /e region with this.
 bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
 {
-       if (region.Empty())
-               return FALSE;
-
-       // Don't change shared data
-       if (!m_refData) {
-               m_refData = new wxRegionRefData();
-       } else  if (m_refData->GetRefCount() > 1) {
-               wxRegionRefData* ref = (wxRegionRefData*)m_refData;
-               UnRef();
-               m_refData = new wxRegionRefData(*ref);
-       }
-
-    int mode = 0; // TODO platform-specific code
+    if (region.Empty())
+        return FALSE;
+
+    // Don't change shared data
+    if (!m_refData) {
+        m_refData = new wxRegionRefData();
+    } else    if (m_refData->GetRefCount() > 1) {
+        wxRegionRefData* ref = (wxRegionRefData*)m_refData;
+        UnRef();
+        m_refData = new wxRegionRefData(*ref);
+    }
+
     switch (op)
     {
         case wxRGN_AND:
-               XIntersectRegion(M_REGION, ((wxRegionRefData*)region.m_refData)->m_region,
-                                M_REGION);
+            XIntersectRegion(M_REGION, ((wxRegionRefData*)region.m_refData)->m_region,
+                 M_REGION);
             break ;
         case wxRGN_OR:
-               XUnionRegion(M_REGION, ((wxRegionRefData*)region.m_refData)->m_region,
-                                M_REGION);
+            XUnionRegion(M_REGION, ((wxRegionRefData*)region.m_refData)->m_region,
+                 M_REGION);
             break ;
         case wxRGN_XOR:
             // TODO
@@ -221,16 +219,16 @@ bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
 // Outer bounds of region
 void wxRegion::GetBox(long& x, long& y, long&w, long &h) const
 {
-       if (m_refData) {
-               XRectangle rect;
-               XClipBox(M_REGION, &rect);
-               x = rect.x;
-               y = rect.y;
-               w = rect.width;
-               h = rect.height;
-       } else {
-               x = y = w = h = 0;
-       }
+    if (m_refData) {
+        XRectangle rect;
+        XClipBox(M_REGION, &rect);
+        x = rect.x;
+        y = rect.y;
+        w = rect.width;
+        h = rect.height;
+    } else {
+        x = y = w = h = 0;
+    }
 }
 
 wxRect wxRegion::GetBox() const
@@ -243,7 +241,7 @@ wxRect wxRegion::GetBox() const
 // Is region empty?
 bool wxRegion::Empty() const
 {
-       return m_refData ? XEmptyRegion(M_REGION) : TRUE;
+    return m_refData ? XEmptyRegion(M_REGION) : TRUE;
 }
 
 //-----------------------------------------------------------------------------
@@ -253,8 +251,8 @@ bool wxRegion::Empty() const
 // Does the region contain the point (x,y)?
 wxRegionContain wxRegion::Contains(long x, long y) const
 {
-       if (!m_refData)
-               return wxOutRegion;
+    if (!m_refData)
+        return wxOutRegion;
 
     // TODO. Return wxInRegion if within region.
     if (0)
@@ -265,30 +263,30 @@ wxRegionContain wxRegion::Contains(long x, long y) const
 // Does the region contain the point pt?
 wxRegionContain wxRegion::Contains(const wxPoint& pt) const
 {
-       if (!m_refData)
-               return wxOutRegion;
+    if (!m_refData)
+        return wxOutRegion;
 
-       return XPointInRegion(M_REGION, pt.x, pt.y) ? wxInRegion : wxOutRegion;
+    return XPointInRegion(M_REGION, pt.x, pt.y) ? wxInRegion : wxOutRegion;
 }
 
 // Does the region contain the rectangle (x, y, w, h)?
 wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const
 {
-       if (!m_refData)
-               return wxOutRegion;
-
-       switch (XRectInRegion(M_REGION, x, y, w, h)) {
-           case RectangleIn:   return wxInRegion;
-           case RectanglePart: return wxPartRegion;
-       }
-       return wxOutRegion;
+    if (!m_refData)
+        return wxOutRegion;
+
+    switch (XRectInRegion(M_REGION, x, y, w, h)) {
+        case RectangleIn:    return wxInRegion;
+        case RectanglePart: return wxPartRegion;
+    }
+    return wxOutRegion;
 }
 
 // Does the region contain the rectangle rect
 wxRegionContain wxRegion::Contains(const wxRect& rect) const
 {
-       if (!m_refData)
-               return wxOutRegion;
+    if (!m_refData)
+        return wxOutRegion;
 
     long x, y, w, h;
     x = rect.x;
@@ -299,9 +297,9 @@ wxRegionContain wxRegion::Contains(const wxRect& rect) const
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-//                                                                                                                                                      //
-//                                                        wxRegionIterator                                                              //
-//                                                                                                                                                      //
+//                                                                             //
+//                               wxRegionIterator                                 //
+//                                                                             //
 ///////////////////////////////////////////////////////////////////////////////
 
 /*!
@@ -324,7 +322,7 @@ wxRegionIterator::wxRegionIterator(const wxRegion& region)
 {
     m_rects = NULL;
 
-       Reset(region);
+    Reset(region);
 }
 
 /*!
@@ -332,17 +330,17 @@ wxRegionIterator::wxRegionIterator(const wxRegion& region)
  */
 void wxRegionIterator::Reset(const wxRegion& region)
 {
-       m_current = 0;
-       m_region = region;
+    m_current = 0;
+    m_region = region;
 
     if (m_rects)
         delete[] m_rects;
 
     m_rects = NULL;
 
-       if (m_region.Empty())
-               m_numRects = 0;
-       else
+    if (m_region.Empty())
+        m_numRects = 0;
+    else
     {
         // TODO create m_rects and fill with rectangles for this region
         m_numRects = 0;
@@ -355,8 +353,8 @@ void wxRegionIterator::Reset(const wxRegion& region)
  */
 void wxRegionIterator::operator ++ ()
 {
-       if (m_current < m_numRects)
-               ++m_current;
+    if (m_current < m_numRects)
+        ++m_current;
 }
 
 /*!
@@ -365,35 +363,35 @@ void wxRegionIterator::operator ++ ()
  */
 void wxRegionIterator::operator ++ (int)
 {
-       if (m_current < m_numRects)
-               ++m_current;
+    if (m_current < m_numRects)
+        ++m_current;
 }
 
 long wxRegionIterator::GetX() const
 {
-       if (m_current < m_numRects)
-               return m_rects[m_current].x;
-       return 0;
+    if (m_current < m_numRects)
+        return m_rects[m_current].x;
+    return 0;
 }
 
 long wxRegionIterator::GetY() const
 {
-       if (m_current < m_numRects)
-               return m_rects[m_current].y;
-       return 0;
+    if (m_current < m_numRects)
+        return m_rects[m_current].y;
+    return 0;
 }
 
 long wxRegionIterator::GetW() const
 {
-       if (m_current < m_numRects)
-               return m_rects[m_current].width ;
-       return 0;
+    if (m_current < m_numRects)
+        return m_rects[m_current].width ;
+    return 0;
 }
 
 long wxRegionIterator::GetH() const
 {
-       if (m_current < m_numRects)
-               return m_rects[m_current].height;
-       return 0;
+    if (m_current < m_numRects)
+        return m_rects[m_current].height;
+    return 0;
 }