added GetExtents().

This commit is contained in:
michaelp%netscape.com 1999-04-16 04:50:02 +00:00
parent 8706314a4e
commit fdc84978d8
3 changed files with 43 additions and 0 deletions

View File

@ -452,6 +452,14 @@ public:
*/
NS_IMETHOD GetScratchPoint(nsPoint **aPoint) = 0;
/**
* Get the extents of the view tree from 'this' down.
* 'this' is the coordinate system origin.
* @param aExtents out paramemter for extents
* @return error status
*/
NS_IMETHOD GetExtents(nsRect *aExtents) = 0;
private:
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
NS_IMETHOD_(nsrefcnt) Release(void) = 0;

View File

@ -1371,3 +1371,37 @@ NS_IMETHODIMP nsView :: GetScratchPoint(nsPoint **aPoint)
return NS_OK;
}
static void calc_extents(nsIView *view, nsRect *extents, nscoord ox, nscoord oy)
{
nsIView *kid;
PRInt32 numkids, cnt;
nsRect bounds;
view->GetChildCount(numkids);
for (cnt = 0; cnt < numkids; cnt++)
{
view->GetChild(cnt, kid);
kid->GetBounds(bounds);
bounds.x += ox;
bounds.y += oy;
extents->IntersectRect(*extents, bounds);
calc_extents(kid, extents, bounds.x, bounds.y);
}
}
NS_IMETHODIMP nsView :: GetExtents(nsRect *aExtents)
{
GetBounds(*aExtents);
aExtents->x = 0;
aExtents->y = 0;
calc_extents(this, aExtents, 0, 0);
return NS_OK;
}

View File

@ -97,6 +97,7 @@ public:
NS_IMETHOD ClearViewFlags(PRUint32 aFlags);
NS_IMETHOD GetViewFlags(PRUint32 *aFlags);
NS_IMETHOD GetScratchPoint(nsPoint **aPoint);
NS_IMETHOD GetExtents(nsRect *aExtents);
// Helper function to get the view that's associated with a widget
static nsIView* GetViewFor(nsIWidget* aWidget);