Back to index

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

#include <nsRegionBeOS.h>

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

List of all members.

Public Member Functions

 nsRegionBeOS ()
virtual ~nsRegionBeOS ()
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
void SetTo (const nsRegionBeOS *aRegion)
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.
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.

Protected Member Functions

void SetRegionType (void)

Private Attributes

BRegion mRegion
nsRegionComplexity mRegionType

Detailed Description

Definition at line 45 of file nsRegionBeOS.h.


Constructor & Destructor Documentation

Definition at line 48 of file nsRegionBeOS.cpp.

{
#ifdef DEBUG_REGIONS 
  ++nRegions; 
  printf("REGIONS+ = %i\n", nRegions); 
#endif 
 
  mRegion.MakeEmpty();
  mRegionType = eRegionComplexity_empty;
}

Definition at line 59 of file nsRegionBeOS.cpp.

{
#ifdef DEBUG_REGIONS 
  --nRegions; 
  printf("REGIONS- = %i\n", nRegions); 
#endif 
 
  mRegion.MakeEmpty();
}

Member Function Documentation

PRBool nsRegionBeOS::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 185 of file nsRegionBeOS.cpp.

{
       return mRegion.Intersects(BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
}

Free a rect set returned by GetRects.

Parameters:
aRectsrects to free
Returns:
error status

Implements nsIRegion.

Definition at line 242 of file nsRegionBeOS.cpp.

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

       return NS_OK;
}
void nsRegionBeOS::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 155 of file nsRegionBeOS.cpp.

{
  if( mRegion.CountRects() ) {
    BRect rect = mRegion.Frame();
    *aX = nscoord(rect.left);
    *aY = nscoord(rect.top);
    *aWidth = nscoord(rect.Width()+1);
    *aHeight = nscoord(rect.Height()+1);
  }
  else
  {
       *aX = *aY = *aWidth = *aHeight = 0;
  }
}
NS_IMETHODIMP nsRegionBeOS::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 250 of file nsRegionBeOS.cpp.

{
       aRegion = (void *)&mRegion;
       return NS_OK;
}
NS_IMETHOD nsRegionBeOS::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 nsRegionBeOS.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 190 of file nsRegionBeOS.cpp.

{
       nsRegionRectSet   *rects;
       int               nbox;
       nsRegionRect      *rect;
       
       NS_ASSERTION(!(nsnull == aRects), "bad ptr");
       
       //code lifted from old xfe. MMP
       
       nbox = mRegion.CountRects();
       
       rects = *aRects;
       
       if ((nsnull == rects) || (rects->mRectsLen < (PRUint32)nbox))
       {
              void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 1)));

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

                     return NS_OK;
              }

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

       rects->mNumRects = nbox;
       rects->mArea = 0;
       rect = &rects->mRects[0];

       for(int32 i = 0; i < nbox; i++)
       {
              BRect r = mRegion.RectAt(i);
    rect->x = nscoord(r.left); 
    rect->width = nscoord(r.right - r.left + 1); 
    rect->y = nscoord(r.top); 
    rect->height = nscoord(r.bottom - r.top + 1); 

              rects->mArea += rect->width * rect->height;

              rect++;
       }

       *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 256 of file nsRegionBeOS.cpp.

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

Implements nsIRegion.

Definition at line 71 of file nsRegionBeOS.cpp.

{
  mRegion.MakeEmpty();
  mRegionType = eRegionComplexity_empty;
  return NS_OK;
}

Here is the caller graph for this function:

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

destructively intersect another region with this one

Parameters:
regionto intersect
Returns:
void

Implements nsIRegion.

Definition at line 96 of file nsRegionBeOS.cpp.

{
       nsRegionBeOS *pRegion = (nsRegionBeOS*)&aRegion;

       mRegion.IntersectWith(&pRegion->mRegion);
       SetRegionType();
}

Here is the call graph for this function:

void nsRegionBeOS::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 104 of file nsRegionBeOS.cpp.

{
  BRegion tRegion;
  tRegion.Set( BRect( aX, aY, aX + aWidth - 1, aY + aHeight - 1 ) );
  mRegion.IntersectWith(&tRegion);
  SetRegionType();
}

Here is the call graph for this function:

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 140 of file nsRegionBeOS.cpp.

{
  if( mRegionType == eRegionComplexity_empty )
    return PR_TRUE;
  return PR_FALSE;
}
PRBool nsRegionBeOS::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 147 of file nsRegionBeOS.cpp.

{
#ifdef DEBUG
  printf(" - nsRegionBeOS :: IsEqual not implemented!\n");
#endif
  return PR_FALSE;
}
void nsRegionBeOS::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 170 of file nsRegionBeOS.cpp.

{
       mRegion.OffsetBy( aXOffset, aYOffset );
}

Definition at line 175 of file nsRegionBeOS.cpp.

Here is the caller graph for this function:

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

copy operator equivalent that takes another region

Parameters:
regionto copy
Returns:
void

Implements nsIRegion.

Definition at line 78 of file nsRegionBeOS.cpp.

{
  Init();
  
  nsRegionBeOS *pRegion = (nsRegionBeOS *)&aRegion;

  mRegion = pRegion->mRegion;
  SetRegionType();
}

Here is the call graph for this function:

void nsRegionBeOS::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 88 of file nsRegionBeOS.cpp.

{
  Init();
  
       mRegion.Set(BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
       SetRegionType();
}

Here is the call graph for this function:

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

destructively subtract another region with this one

Parameters:
regionto subtract
Returns:
void

Implements nsIRegion.

Definition at line 126 of file nsRegionBeOS.cpp.

{
  nsRegionBeOS *pRegion = (nsRegionBeOS*)&aRegion;

  mRegion.Exclude(&pRegion->mRegion);
  SetRegionType();
}

Here is the call graph for this function:

void nsRegionBeOS::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 134 of file nsRegionBeOS.cpp.

{
       mRegion.Exclude(BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
       SetRegionType();
}

Here is the call graph for this function:

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

destructively union another region with this one

Parameters:
regionto union
Returns:
void

Implements nsIRegion.

Definition at line 112 of file nsRegionBeOS.cpp.

{
       nsRegionBeOS *pRegion = (nsRegionBeOS*)&aRegion;

       mRegion.Include(&pRegion->mRegion);
       SetRegionType();
}

Here is the call graph for this function:

void nsRegionBeOS::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 120 of file nsRegionBeOS.cpp.

{
       mRegion.Include(BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
       SetRegionType();
}

Here is the call graph for this function:


Member Data Documentation

BRegion nsRegionBeOS::mRegion [private]

Definition at line 80 of file nsRegionBeOS.h.

Definition at line 81 of file nsRegionBeOS.h.


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