Back to index

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


Class RoundedRect, A class to encapsulate all the rounded rect functionality, which are based on the QBCurve 4/13/99 dwc More...

#include <nsCSSRendering.h>

List of all members.

Public Member Functions

void RoundRect ()
 Construct a rounded rectangle object 4/19/99.
void Set (nscoord aLeft, nscoord aTop, PRInt32 aWidth, PRInt32 aHeight, PRInt16 aRadius[4], PRInt16 aNumTwipPerPix)
 Set the curves boundaries and then break it up into the curve pieces for rendering 4/13/99 dwc.
void CalcInsetCurves (QBCurve &aULCurve, QBCurve &aURCurve, QBCurve &aLLCurve, QBCurve &aLRCurve, nsMargin &aBorder)
 Calculate the inset of a curve based on a border 4/13/99 dwc.
void GetRoundedBorders (QBCurve &aULCurve, QBCurve &aURCurve, QBCurve &aLLCurve, QBCurve &aLRCurve)
 
set the passed in curves to the rounded borders of the rectangle 4/13/99 dwc

Public Attributes

PRInt32 mRoundness [4]
PRBool mDoRound
PRInt32 mLeft
PRInt32 mRight
PRInt32 mTop
PRInt32 mBottom

Detailed Description


Class RoundedRect, A class to encapsulate all the rounded rect functionality, which are based on the QBCurve 4/13/99 dwc

Definition at line 350 of file nsCSSRendering.h.


Member Function Documentation

void RoundedRect::CalcInsetCurves ( QBCurve aULCurve,
QBCurve aURCurve,
QBCurve aLLCurve,
QBCurve aLRCurve,
nsMargin aBorder 
)

Calculate the inset of a curve based on a border 4/13/99 dwc.


See documentation in nsCSSRendering.h 3/26/99 dwc

Parameters:
aLeft-- Left side of bounding box
aTop-- Top side of bounding box

Definition at line 3734 of file nsCSSRendering.cpp.

{
PRInt32   nLeft,nTop,nRight,nBottom;
PRInt32   tLeft,bLeft,tRight,bRight,lTop,rTop,lBottom,rBottom;
PRInt16   adjust=0;

  if(mDoRound)
    adjust = mRoundness[0]>>3;

  nLeft = mLeft + aBorder.left;
  tLeft = mLeft + mRoundness[0];
  bLeft = mLeft + mRoundness[3];

  if(tLeft < nLeft){
    tLeft = nLeft;
  }

  if(bLeft < nLeft){
    bLeft = nLeft;
  }

  nRight = mRight - aBorder.right;
  tRight = mRight - mRoundness[1];
  bRight = mRight - mRoundness[2];

  if(tRight > nRight){
    tRight = nRight;
  }

  if(bRight > nRight){
    bRight = nRight;
  }

  nTop = mTop + aBorder.top;
  lTop = mTop + mRoundness[0];
  rTop = mTop + mRoundness[1];

  if(lTop < nTop){
    lTop = nTop;
  }

  if(rTop < nTop){
    rTop = nTop;
  }

  nBottom = mBottom - aBorder.bottom;
  lBottom = mBottom - mRoundness[3];
  rBottom = mBottom - mRoundness[2];

  if(lBottom > nBottom){
    lBottom = nBottom;
  }

  if(rBottom > nBottom){
    rBottom = nBottom;
  }


  // set the passed in curves to the rounded borders of the rectangle
  aULCurve.SetPoints( (float)nLeft,(float)lTop,
                      (float)nLeft+adjust,(float)nTop+adjust,
                      (float)tLeft,(float)nTop);
  aURCurve.SetPoints( (float)tRight,(float)nTop,
                      (float)nRight-adjust,(float)nTop+adjust,
                      (float)nRight,(float)rTop);
  aLRCurve.SetPoints( (float)nRight,(float)rBottom,
                      (float)nRight-adjust,(float)nBottom-adjust,
                      (float)bRight,(float)nBottom);
  aLLCurve.SetPoints( (float)bLeft,(float)nBottom,
                      (float)nLeft+adjust,(float)nBottom-adjust,
                      (float)nLeft,(float)lBottom);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void RoundedRect::GetRoundedBorders ( QBCurve aULCurve,
QBCurve aURCurve,
QBCurve aLLCurve,
QBCurve aLRCurve 
)


set the passed in curves to the rounded borders of the rectangle 4/13/99 dwc


See documentation in nsCSSRendering.h 4/13/99 dwc

Parameters:
aULCurve-- upperleft curve
aURCurve-- upperright curve
aLRCurve-- lowerright curve
aLLCurve-- lowerleft curve

Definition at line 3871 of file nsCSSRendering.cpp.

{

  PRInt16 adjust=0;

  if(mDoRound)
    adjust = mRoundness[0]>>3;

  // set the passed in curves to the rounded borders of the rectangle
  aULCurve.SetPoints( (float)mLeft,(float)mTop + mRoundness[0],
                      (float)mLeft+adjust,(float)mTop+adjust,
                      (float)mLeft+mRoundness[0],(float)mTop);
  aURCurve.SetPoints( (float)mRight - mRoundness[1],(float)mTop,
                      (float)mRight-adjust,(float)mTop+adjust,
                      (float)mRight,(float)mTop + mRoundness[1]);
  aLRCurve.SetPoints( (float)mRight,(float)mBottom - mRoundness[2],
                      (float)mRight-adjust,(float)mBottom-adjust,
                      (float)mRight - mRoundness[2],(float)mBottom);
  aLLCurve.SetPoints( (float)mLeft + mRoundness[3],(float)mBottom,
                      (float)mLeft+adjust,(float)mBottom-adjust,
                      (float)mLeft,(float)mBottom - mRoundness[3]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Construct a rounded rectangle object 4/19/99.

Definition at line 367 of file nsCSSRendering.h.

{mRoundness[0]=0;}
void RoundedRect::Set ( nscoord  aLeft,
nscoord  aTop,
PRInt32  aWidth,
PRInt32  aHeight,
PRInt16  aRadius[4],
PRInt16  aNumTwipPerPix 
)

Set the curves boundaries and then break it up into the curve pieces for rendering 4/13/99 dwc.


See documentation in nsCSSRendering.h 4/13/99 dwc

Parameters:
aLeft-- Left side of bounding box
aTop-- Top side of bounding box
aWidth-- Width of bounding box
aHeight-- Height of bounding box
aRadius-- radius for the rounding

Definition at line 3813 of file nsCSSRendering.cpp.

{
  nscoord x,y,width,height;
  int     i;

  // convert this rect to pixel boundaries
  x = (aLeft/aNumTwipPerPix)*aNumTwipPerPix;
  y = (aTop/aNumTwipPerPix)*aNumTwipPerPix;
  width = (aWidth/aNumTwipPerPix)*aNumTwipPerPix;
  height = (aHeight/aNumTwipPerPix)*aNumTwipPerPix;


  for(i=0;i<4;i++) {
    if( (aRadius[i]) > (aWidth>>1) ){
      mRoundness[i] = (aWidth>>1); 
    } else {
      mRoundness[i] = aRadius[i];
    }

    if( mRoundness[i] > (aHeight>>1) )
      mRoundness[i] = aHeight>>1;
  }


  // if we are drawing a circle
  mDoRound = PR_FALSE;
  if(aHeight==aWidth){
    PRBool doRound = PR_TRUE;
    for(i=0;i<4;i++){
      if(mRoundness[i]<(aWidth>>1)){
        doRound = PR_FALSE;
        break;
      }
    }

    if(doRound){
      mDoRound = PR_TRUE;
      for(i=0;i<4;i++){
        mRoundness[i] = aWidth>>1;
      }
    }
  }



  // important coordinates that the path hits
  mLeft = x;
  mTop = y;
  mRight = x+width;
  mBottom = y+height;

}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 361 of file nsCSSRendering.h.

Definition at line 356 of file nsCSSRendering.h.

Definition at line 358 of file nsCSSRendering.h.

Definition at line 359 of file nsCSSRendering.h.

Definition at line 354 of file nsCSSRendering.h.

Definition at line 360 of file nsCSSRendering.h.


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