Back to index

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

List of all members.

Public Member Functions

 RectArea (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 366 of file nsImageMap.cpp.


Constructor & Destructor Documentation

Definition at line 377 of file nsImageMap.cpp.

  : Area(aArea)
{
}

Member Function Documentation

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

Implements Area.

Definition at line 435 of file nsImageMap.cpp.

{
  if (mHasFocus) {
    if (mNumCoords >= 4) {
      float p2t;
      p2t = aCX->PixelsToTwips();
      nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t);
      nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t);
      nscoord x2 = NSIntPixelsToTwips(mCoords[2], p2t);
      nscoord y2 = NSIntPixelsToTwips(mCoords[3], p2t);
      NS_ASSERTION(x1 <= x2 && y1 <= y2,
                   "Someone screwed up RectArea::ParseCoords");
      aRC.DrawLine(x1, y1, x1, y2);
      aRC.DrawLine(x1, y2, x2, y2);
      aRC.DrawLine(x1, y1, x2, y1);
      aRC.DrawLine(x2, y1, x2, y2);
    }
  }
}

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 RectArea::GetRect ( nsPresContext aCX,
nsRect aRect 
) [virtual]

Implements Area.

Definition at line 455 of file nsImageMap.cpp.

{
  if (mNumCoords >= 4) {
    float p2t;
    p2t = aCX->PixelsToTwips();
    nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t);
    nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t);
    nscoord x2 = NSIntPixelsToTwips(mCoords[2], p2t);
    nscoord y2 = NSIntPixelsToTwips(mCoords[3], p2t);
    NS_ASSERTION(x1 <= x2 && y1 <= y2,
                 "Someone screwed up RectArea::ParseCoords");

    aRect.SetRect(x1, y1, x2, y2);
  }
}

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 RectArea::IsInside ( nscoord  x,
nscoord  y 
) const [virtual]

Implements Area.

Definition at line 419 of file nsImageMap.cpp.

{
  if (mNumCoords >= 4) {       // Note: > is for nav compatabilty
    nscoord x1 = mCoords[0];
    nscoord y1 = mCoords[1];
    nscoord x2 = mCoords[2];
    nscoord y2 = mCoords[3];
    NS_ASSERTION(x1 <= x2 && y1 <= y2,
                 "Someone screwed up RectArea::ParseCoords");
    if ((x >= x1) && (x <= x2) && (y >= y1) && (y <= y2)) {
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

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

Reimplemented from Area.

Definition at line 382 of file nsImageMap.cpp.

{
  Area::ParseCoords(aSpec);

  PRBool saneRect = PR_TRUE;
  PRInt32 flag = nsIScriptError::warningFlag;
  if (mNumCoords >= 4) {
    if (mCoords[0] > mCoords[2]) {
      // x-coords in reversed order
      nscoord x = mCoords[2];
      mCoords[2] = mCoords[0];
      mCoords[0] = x;
      saneRect = PR_FALSE;
    }
  
    if (mCoords[1] > mCoords[3]) {
      // y-coords in reversed order
      nscoord y = mCoords[3];
      mCoords[3] = mCoords[1];
      mCoords[1] = y;
      saneRect = PR_FALSE;
    }

    if (mNumCoords > 4) {
      // Someone missed the concept of a rect here
      saneRect = PR_FALSE;
    }
  } else {
    saneRect = PR_FALSE;
    flag = nsIScriptError::errorFlag;
  }

  if (!saneRect) {
    logMessage(mArea, aSpec, flag, "ImageMapRectBoundsError");
  }
}

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: