Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsRegionMac Class Reference

#include <nsRegionMac.h>

Inheritance diagram for nsRegionMac:
Inheritance graph
[legend]
Collaboration diagram for nsRegionMac:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsRegionMac ()
virtual ~nsRegionMac ()
virtual NS_DECL_ISUPPORTS nsresult Init ()
virtual void SetTo (const nsIRegion &aRegion)
 copy operator equivalent that takes another region
virtual void SetTo (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 copy operator equivalent that takes a rect
virtual void Intersect (const nsIRegion &aRegion)
 destructively intersect another region with this one
virtual void Intersect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 destructively intersect a rect with this region
virtual void Union (const nsIRegion &aRegion)
 destructively union another region with this one
virtual void Union (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 destructively union a rect with this region
virtual void Subtract (const nsIRegion &aRegion)
 destructively subtract another region with this one
virtual void Subtract (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 destructively subtract a rect from this region
virtual PRBool IsEmpty (void)
 is this region empty? i.e.
virtual PRBool IsEqual (const nsIRegion &aRegion)
 == operator equivalent i.e.
virtual void GetBoundingBox (PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
 returns the bounding box of the region i.e.
virtual void Offset (PRInt32 aXOffset, PRInt32 aYOffset)
 offsets the region in x and y
virtual PRBool ContainsRect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 does the region intersect the rectangle?
NS_IMETHOD GetRects (nsRegionRectSet **aRects)
 get the set of rects which make up this region.
NS_IMETHOD FreeRects (nsRegionRectSet *aRects)
 Free a rect set returned by GetRects.
NS_IMETHOD GetNativeRegion (void *&aRegion) const
 Get the native region that this nsIRegion represents.
virtual nsresult SetNativeRegion (void *aRegion)
NS_IMETHOD GetRegionComplexity (nsRegionComplexity &aComplexity) const
 Get the complexity of the region as defined by the nsRegionComplexity enum.
NS_IMETHOD GetNumRects (PRUint32 *aRects) const
 get the number of rects which make up this region.

Private Member Functions

virtual void SetRegionType ()
virtual void SetRegionEmpty ()
virtual RgnHandle CreateRectRegion (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)

Private Attributes

RgnHandle mRegion
nsRegionComplexity mRegionType

Detailed Description

Definition at line 46 of file nsRegionMac.h.


Constructor & Destructor Documentation

Definition at line 74 of file nsRegionMac.cpp.

Here is the call graph for this function:

Definition at line 86 of file nsRegionMac.cpp.

Here is the call graph for this function:


Member Function Documentation

PRBool nsRegionMac::ContainsRect ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual]

does the region intersect the rectangle?

Parameters:
rectto check for containment
Returns:
true if the region intersects the rect

Implements nsIRegion.

Definition at line 234 of file nsRegionMac.cpp.

{
       Rect macRect;
       ::SetRect(&macRect, aX, aY, aX + aWidth, aY + aHeight);
       return(::RectInRgn(&macRect, mRegion));
}
RgnHandle nsRegionMac::CreateRectRegion ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [private, virtual]

Definition at line 339 of file nsRegionMac.cpp.

{
       RgnHandle rectRgn = sNativeRegionPool.GetNewRegion();
       if (rectRgn != nsnull)
              ::SetRectRgn(rectRgn, aX, aY, aX + aWidth, aY + aHeight);
       return rectRgn;
}

Here is the call graph for this function:

Free a rect set returned by GetRects.

Parameters:
aRectsrects to free
Returns:
error status

Implements nsIRegion.

Definition at line 276 of file nsRegionMac.cpp.

{
       if (nsnull != aRects)
              PR_Free((void *)aRects);

       return NS_OK;
}
void nsRegionMac::GetBoundingBox ( PRInt32 aX,
PRInt32 aY,
PRInt32 aWidth,
PRInt32 aHeight 
) [virtual]

returns the bounding box of the region i.e.

the smallest rectangle that completely contains the region.

Parameters:
aXout parameter for xoffset of bounding rect for region
aYout parameter for yoffset of bounding rect for region
aWidthout parameter for width of bounding rect for region
aHeightout parameter for height of bounding rect for region
Returns:
void

Implements nsIRegion.

Definition at line 214 of file nsRegionMac.cpp.

{
       Rect macRect;
       ::GetRegionBounds (mRegion, &macRect);

       *aX = macRect.left;
       *aY = macRect.top;
       *aWidth  = macRect.right - macRect.left;
       *aHeight = macRect.bottom - macRect.top;
}
NS_IMETHODIMP nsRegionMac::GetNativeRegion ( void *&  aRegion) const [virtual]

Get the native region that this nsIRegion represents.

Parameters:
aRegionout parameter for native region handle
Returns:
error status

Implements nsIRegion.

Definition at line 287 of file nsRegionMac.cpp.

{
       aRegion = (void *)mRegion;
       return NS_OK;
}
NS_IMETHOD nsRegionMac::GetNumRects ( PRUint32 aRects) const [inline, virtual]

get the number of rects which make up this region.

Parameters:
aRectsout parameter containing the number of rects comprising the region
Returns:
error status

Implements nsIRegion.

Definition at line 74 of file nsRegionMac.h.

{ *aRects = 0; return NS_OK; }

get the set of rects which make up this region.

the aRects parameter must be freed by calling FreeRects before the region is deleted. aRects may be passed in again when requesting the rect list as a recycling method.

Parameters:
aRectsout parameter containing set of rects comprising the region
Returns:
error status

Implements nsIRegion.

Definition at line 243 of file nsRegionMac.cpp.

{
  NS_ASSERTION(aRects, "bad ptr");

  nsRegionRectSet* rects = *aRects;
  long numrects = 0;
  QDRegionToRects(mRegion, kQDParseRegionFromTopLeft, sCountRectProc, &numrects);

  if (!rects || rects->mRectsLen < (PRUint32) numrects) {
    void* buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + sizeof(nsRegionRect) * (numrects - 1));

    if (!buf) {
      if (rects)
        rects->mNumRects = 0;

      return NS_ERROR_OUT_OF_MEMORY;
    }

    rects = (nsRegionRectSet*) buf;
    rects->mRectsLen = numrects;
  }

  rects->mNumRects = 0;
  rects->mArea = 0;
  QDRegionToRects(mRegion, kQDParseRegionFromTopLeft, sAddRectToArrayProc, rects);

  *aRects = rects;

  return NS_OK;
}

Here is the call graph for this function:

Get the complexity of the region as defined by the nsRegionComplexity enum.

Parameters:
aComplexityout parameter for region complexity
Returns:
error status

Implements nsIRegion.

Definition at line 307 of file nsRegionMac.cpp.

{
       aComplexity = mRegionType;
       return NS_OK;
}
nsresult nsRegionMac::Init ( void  ) [virtual]

Implements nsIRegion.

Definition at line 98 of file nsRegionMac.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsRegionMac::Intersect ( const nsIRegion aRegion) [virtual]

destructively intersect another region with this one

Parameters:
regionto intersect
Returns:
void

Implements nsIRegion.

Definition at line 130 of file nsRegionMac.cpp.

{
       nsRegionMac* pRegion = (nsRegionMac*)&aRegion;
       ::SectRgn(mRegion, pRegion->mRegion, mRegion);
       SetRegionType();
}

Here is the call graph for this function:

void nsRegionMac::Intersect ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual]

destructively intersect a rect with this region

Parameters:
aXxoffset of rect to intersect with region
aYyoffset of rect to intersect with region
aWidthwidth of rect to intersect with region
aHeightheight of rect to intersect with region
Returns:
void

Implements nsIRegion.

Definition at line 139 of file nsRegionMac.cpp.

{
       RgnHandle rectRgn = sNativeRegionPool.GetNewRegion();
       if (rectRgn != nsnull) {
              ::SetRectRgn(rectRgn, aX, aY, aX + aWidth, aY + aHeight);
              ::SectRgn(mRegion, rectRgn, mRegion);
              sNativeRegionPool.ReleaseRegion(rectRgn);
              SetRegionType();
       }
}

Here is the call graph for this function:

PRBool nsRegionMac::IsEmpty ( void  ) [virtual]

is this region empty? i.e.

does it contain any pixels

Parameters:
none
Returns:
returns whether the region is empty

Implements nsIRegion.

Definition at line 196 of file nsRegionMac.cpp.

{
       if (mRegionType == eRegionComplexity_empty)
       return PR_TRUE;
       else
              return PR_FALSE;
}
PRBool nsRegionMac::IsEqual ( const nsIRegion aRegion) [virtual]

== operator equivalent i.e.

do the regions contain exactly the same pixels

Parameters:
regionto compare
Returns:
whether the regions are identical

Implements nsIRegion.

Definition at line 206 of file nsRegionMac.cpp.

{
       nsRegionMac* pRegion = (nsRegionMac*)&aRegion;
       return(::EqualRgn(mRegion, pRegion->mRegion));
}
void nsRegionMac::Offset ( PRInt32  aXOffset,
PRInt32  aYOffset 
) [virtual]

offsets the region in x and y

Parameters:
xoffsetpixel offset in x
yoffsetpixel offset in y
Returns:
void

Implements nsIRegion.

Definition at line 227 of file nsRegionMac.cpp.

{
       ::OffsetRgn(mRegion, aXOffset, aYOffset);
}
nsresult nsRegionMac::SetNativeRegion ( void aRegion) [virtual]

Definition at line 294 of file nsRegionMac.cpp.

{
       if (aRegion) {
              ::CopyRgn((RgnHandle)aRegion, mRegion);
       SetRegionType();
       } else {
              Init();
       }
       return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsRegionMac::SetRegionEmpty ( ) [private, virtual]

Definition at line 331 of file nsRegionMac.cpp.

{
       ::SetEmptyRgn(mRegion);
       SetRegionType();
}

Here is the call graph for this function:

void nsRegionMac::SetRegionType ( void  ) [private, virtual]

Definition at line 316 of file nsRegionMac.cpp.

Here is the caller graph for this function:

void nsRegionMac::SetTo ( const nsIRegion aRegion) [virtual]

copy operator equivalent that takes another region

Parameters:
regionto copy
Returns:
void

Implements nsIRegion.

Definition at line 113 of file nsRegionMac.cpp.

{
       nsRegionMac* pRegion = (nsRegionMac*)&aRegion;
       ::CopyRgn(pRegion->mRegion, mRegion);
       SetRegionType();
}

Here is the call graph for this function:

void nsRegionMac::SetTo ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual]

copy operator equivalent that takes a rect

Parameters:
aXxoffset of rect to set region to
aYyoffset of rect to set region to
aWidthwidth of rect to set region to
aHeightheight of rect to set region to
Returns:
void

Implements nsIRegion.

Definition at line 122 of file nsRegionMac.cpp.

{
       ::SetRectRgn(mRegion, aX, aY, aX + aWidth, aY + aHeight);
       SetRegionType();
}

Here is the call graph for this function:

void nsRegionMac::Subtract ( const nsIRegion aRegion) [virtual]

destructively subtract another region with this one

Parameters:
regionto subtract
Returns:
void

Implements nsIRegion.

Definition at line 174 of file nsRegionMac.cpp.

{
       nsRegionMac* pRegion = (nsRegionMac*)&aRegion;
       ::DiffRgn(mRegion, pRegion->mRegion, mRegion);
       SetRegionType();
}

Here is the call graph for this function:

void nsRegionMac::Subtract ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual]

destructively subtract a rect from this region

Parameters:
aXxoffset of rect to subtract with region
aYyoffset of rect to subtract with region
aWidthwidth of rect to subtract with region
aHeightheight of rect to subtract with region
Returns:
void

Implements nsIRegion.

Definition at line 183 of file nsRegionMac.cpp.

{
       RgnHandle rectRgn = sNativeRegionPool.GetNewRegion();
       if (rectRgn != nsnull) {
              ::SetRectRgn(rectRgn, aX, aY, aX + aWidth, aY + aHeight);
              ::DiffRgn(mRegion, rectRgn, mRegion);
              sNativeRegionPool.ReleaseRegion(rectRgn);
              SetRegionType();
       }
}

Here is the call graph for this function:

void nsRegionMac::Union ( const nsIRegion aRegion) [virtual]

destructively union another region with this one

Parameters:
regionto union
Returns:
void

Implements nsIRegion.

Definition at line 152 of file nsRegionMac.cpp.

{
       nsRegionMac* pRegion = (nsRegionMac*)&aRegion;
       ::UnionRgn(mRegion, pRegion->mRegion, mRegion);
       SetRegionType();
}

Here is the call graph for this function:

void nsRegionMac::Union ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual]

destructively union a rect with this region

Parameters:
aXxoffset of rect to union with region
aYyoffset of rect to union with region
aWidthwidth of rect to union with region
aHeightheight of rect to union with region
Returns:
void

Implements nsIRegion.

Definition at line 161 of file nsRegionMac.cpp.

{
       RgnHandle rectRgn = sNativeRegionPool.GetNewRegion();
       if (rectRgn != nsnull) {
              ::SetRectRgn(rectRgn, aX, aY, aX + aWidth, aY + aHeight);
              ::UnionRgn(mRegion, rectRgn, mRegion);
              sNativeRegionPool.ReleaseRegion(rectRgn);
              SetRegionType();
       }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 77 of file nsRegionMac.h.

Definition at line 78 of file nsRegionMac.h.


The documentation for this class was generated from the following files: