Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
CircleArea Class Reference
Inheritance diagram for CircleArea:
Inheritance graph
[legend]
Collaboration diagram for CircleArea:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CircleArea (nsIContent *aArea)
virtual void ParseCoords (const nsAString &aSpec)
virtual PRBool IsInside (nscoord x, nscoord y) const
virtual void Draw (nsPresContext *aCX, nsIRenderingContext &aRC)
virtual void GetRect (nsPresContext *aCX, nsRect &aRect)
void HasFocus (PRBool aHasFocus)
void GetHREF (nsAString &aHref) const
void GetArea (nsIContent **aArea) const

Public Attributes

nsCOMPtr< nsIContentmArea
nscoordmCoords
PRInt32 mNumCoords
PRPackedBool mHasFocus

Detailed Description

Definition at line 616 of file nsImageMap.cpp.


Constructor & Destructor Documentation

Definition at line 627 of file nsImageMap.cpp.

  : Area(aArea)
{
}

Member Function Documentation

void CircleArea::Draw ( nsPresContext aCX,
nsIRenderingContext aRC 
) [virtual]

Implements Area.

Definition at line 682 of file nsImageMap.cpp.

{
  if (mHasFocus) {
    if (mNumCoords >= 3) {
      float p2t;
      p2t = aCX->PixelsToTwips();
      nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t);
      nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t);
      nscoord radius = NSIntPixelsToTwips(mCoords[2], p2t);
      if (radius < 0) {
        return;
      }
      nscoord x = x1 - radius;
      nscoord y = y1 - radius;
      nscoord w = 2 * radius;
      aRC.DrawEllipse(x, y, w, w);
    }
  }
}

Here is the call graph for this function:

void Area::GetArea ( nsIContent **  aArea) const [inherited]

Definition at line 123 of file nsImageMap.cpp.

{
  *aArea = mArea;
  NS_IF_ADDREF(*aArea);
}

Here is the caller graph for this function:

void Area::GetHREF ( nsAString &  aHref) const [inherited]

Definition at line 114 of file nsImageMap.cpp.

{
  aHref.Truncate();
  if (mArea) {
    mArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, aHref);
  }
}
void CircleArea::GetRect ( nsPresContext aCX,
nsRect aRect 
) [virtual]

Implements Area.

Definition at line 702 of file nsImageMap.cpp.

{
  if (mNumCoords >= 3) {
    float p2t;
    p2t = aCX->PixelsToTwips();
    nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t);
    nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t);
    nscoord radius = NSIntPixelsToTwips(mCoords[2], p2t);
    if (radius < 0) {
      return;
    }

    aRect.SetRect(x1 - radius, y1 - radius, x1 + radius, y1 + radius);
  }
}

Here is the call graph for this function:

void Area::HasFocus ( PRBool  aHasFocus) [inherited]

Definition at line 329 of file nsImageMap.cpp.

{
  mHasFocus = aHasFocus;
}

Here is the caller graph for this function:

PRBool CircleArea::IsInside ( nscoord  x,
nscoord  y 
) const [virtual]

Implements Area.

Definition at line 662 of file nsImageMap.cpp.

{
  // Note: > is for nav compatabilty
  if (mNumCoords >= 3) {
    nscoord x1 = mCoords[0];
    nscoord y1 = mCoords[1];
    nscoord radius = mCoords[2];
    if (radius < 0) {
      return PR_FALSE;
    }
    nscoord dx = x1 - x;
    nscoord dy = y1 - y;
    nscoord dist = (dx * dx) + (dy * dy);
    if (dist <= (radius * radius)) {
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

void CircleArea::ParseCoords ( const nsAString &  aSpec) [virtual]

Reimplemented from Area.

Definition at line 632 of file nsImageMap.cpp.

{
  Area::ParseCoords(aSpec);

  PRBool wrongNumberOfCoords = PR_FALSE;
  PRInt32 flag = nsIScriptError::warningFlag;
  if (mNumCoords >= 3) {
    if (mCoords[2] < 0) {
      logMessage(mArea,
                 aSpec,
                 nsIScriptError::errorFlag,
                 "ImageMapCircleNegativeRadius");
    }
  
    if (mNumCoords > 3) {
      wrongNumberOfCoords = PR_TRUE;
    }
  } else {
    wrongNumberOfCoords = PR_TRUE;
    flag = nsIScriptError::errorFlag;
  }

  if (wrongNumberOfCoords) {
    logMessage(mArea,
               aSpec,
               flag,
               "ImageMapCircleWrongNumberOfCoords");
  }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 90 of file nsImageMap.cpp.

nscoord* Area::mCoords [inherited]

Definition at line 91 of file nsImageMap.cpp.

Definition at line 93 of file nsImageMap.cpp.

Definition at line 92 of file nsImageMap.cpp.


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