Back to index

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

#include <nsRenderingContextQt.h>

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

List of all members.

Public Member Functions

 nsRenderingContextQt ()
virtual ~nsRenderingContextQt ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS NS_IMETHOD 
Init (nsIDeviceContext *aContext, nsIWidget *aWindow)
 Initialize the RenderingContext.
NS_IMETHOD Init (nsIDeviceContext *aContext, nsIDrawingSurface *aSurface)
 Initialize the RenderingContext.
NS_IMETHOD Reset (void)
 Reset the rendering context.
NS_IMETHOD GetDeviceContext (nsIDeviceContext *&aContext)
 Get the DeviceContext that this RenderingContext was initialized with.
NS_IMETHOD LockDrawingSurface (PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight, void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes, PRUint32 aFlags)
 Lock a rect of the drawing surface associated with the rendering context.
NS_IMETHOD UnlockDrawingSurface (void)
 Unlock a rect of the drawing surface associated with the rendering context.
NS_IMETHOD SelectOffScreenDrawingSurface (nsIDrawingSurface *aSurface)
 Selects an offscreen drawing surface into the RenderingContext to draw to.
NS_IMETHOD GetDrawingSurface (nsIDrawingSurface **aSurface)
 Get the currently selected drawing surface.
NS_IMETHOD GetHints (PRUint32 &aResult)
 Returns in aResult any rendering hints that the context has.
NS_IMETHOD PushState (void)
 Save a graphical state onto a stack.
NS_IMETHOD PopState (void)
 Get and and set RenderingContext to this graphical state.
NS_IMETHOD IsVisibleRect (const nsRect &aRect, PRBool &aVisible)
 Tells if a given rectangle is visible within the rendering context.
NS_IMETHOD SetClipRect (const nsRect &aRect, nsClipCombine aCombine)
 Sets the clipping for the RenderingContext to the passed in rectangle.
NS_IMETHOD CopyClipRegion (nsIRegion &aRegion)
 Fills in |aRegion| with a copy of the current clip region.
NS_IMETHOD GetClipRect (nsRect &aRect, PRBool &aClipValid)
 Gets the bounds of the clip region of the RenderingContext.
NS_IMETHOD SetClipRegion (const nsIRegion &aRegion, nsClipCombine aCombine)
 Sets the clipping for the RenderingContext to the passed in region.
NS_IMETHOD GetClipRegion (nsIRegion **aRegion)
 Gets the current clipping region for the RenderingContext The region is in device coordinates!
NS_IMETHOD SetLineStyle (nsLineStyle aLineStyle)
 Sets the line style for the RenderingContext.
NS_IMETHOD GetLineStyle (nsLineStyle &aLineStyle)
 Gets the line style for the RenderingContext.
NS_IMETHOD SetColor (nscolor aColor)
 Sets the forground color for the RenderingContext.
NS_IMETHOD GetColor (nscolor &aColor) const
 Get the forground color for the RenderingContext.
NS_IMETHOD SetFont (const nsFont &aFont, nsIAtom *aLangGroup)
 Sets the font for the RenderingContext.
NS_IMETHOD SetFont (nsIFontMetrics *aFontMetrics)
 Sets the font for the RenderingContext.
NS_IMETHOD GetFontMetrics (nsIFontMetrics *&aFontMetrics)
 Get the current fontmetrics for the RenderingContext.
NS_IMETHOD Translate (nscoord aX, nscoord aY)
 Add in a translate to the RenderingContext's transformation matrix.
NS_IMETHOD Scale (float aSx, float aSy)
 Add in a scale to the RenderingContext's transformation matrix.
NS_IMETHOD GetCurrentTransform (nsTransform2D *&aTransform)
 Get the current transformation matrix for the RenderingContext.
NS_IMETHOD CreateDrawingSurface (const nsRect &aBounds, PRUint32 aSurfFlags, nsIDrawingSurface *&aSurface)
 Create an offscreen drawing surface compatible with this RenderingContext.
NS_IMETHOD DestroyDrawingSurface (nsIDrawingSurface *aDS)
 Destroy a drawing surface created by CreateDrawingSurface()
NS_IMETHOD DrawLine (nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
 Draw a line.
NS_IMETHOD DrawStdLine (nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
NS_IMETHOD DrawPolyline (const nsPoint aPoints[], PRInt32 aNumPoints)
 Draw a polyline.
NS_IMETHOD DrawRect (const nsRect &aRect)
 Draw a rectangle.
NS_IMETHOD DrawRect (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 Draw a rectangle.
NS_IMETHOD FillRect (const nsRect &aRect)
 Fill a rectangle in the current foreground color.
NS_IMETHOD FillRect (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 Fill a rectangle in the current foreground color.
NS_IMETHOD InvertRect (const nsRect &aRect)
 XOR Invert a rectangle in the current foreground color.
NS_IMETHOD InvertRect (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 XOR Invert a rectangle in the current foreground color.
NS_IMETHOD DrawPolygon (const nsPoint aPoints[], PRInt32 aNumPoints)
 Draw a poly in the current foreground color.
NS_IMETHOD FillPolygon (const nsPoint aPoints[], PRInt32 aNumPoints)
 Fill a poly in the current foreground color.
NS_IMETHOD DrawEllipse (const nsRect &aRect)
 Draw an ellipse in the current foreground color.
NS_IMETHOD DrawEllipse (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 Draw an ellipse in the current foreground color.
NS_IMETHOD FillEllipse (const nsRect &aRect)
 Fill an ellipse in the current foreground color.
NS_IMETHOD FillEllipse (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 Fill an ellipse in the current foreground color.
NS_IMETHOD DrawArc (const nsRect &aRect, float aStartAngle, float aEndAngle)
 Draw an arc in the current forground color.
NS_IMETHOD DrawArc (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, float aStartAngle, float aEndAngle)
 Draw an arc in the current forground color.
NS_IMETHOD FillArc (const nsRect &aRect, float aStartAngle, float aEndAngle)
 Fill an arc in the current forground color.
NS_IMETHOD FillArc (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, float aStartAngle, float aEndAngle)
 Fill an arc in the current forground color.
NS_IMETHOD GetWidth (char aC, nscoord &aWidth)
 Returns the width (in app units) of an 8-bit character If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (PRUnichar aC, nscoord &aWidth, PRInt32 *aFontID)
 Returns the width (in app units) of a unicode character If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (const nsString &aString, nscoord &aWidth, PRInt32 *aFontID)
 Returns the width (in app units) of an nsString If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (const char *aString, nscoord &aWidth)
 Returns the width (in app units) of an 8-bit character string If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (const char *aString, PRUint32 aLength, nscoord &aWidth)
 Returns the width (in app units) of an 8-bit character string If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, PRInt32 *aFontID)
 Returns the width (in app units) of a Unicode character string If no font has been Set, the results are undefined.
NS_IMETHOD GetTextDimensions (const char *aString, PRUint32 aLength, nsTextDimensions &aDimensions)
 Returns the dimensions of a string, i.e., the overall extent of a string whose rendering may involve switching between different fonts that have different metrics.
NS_IMETHOD GetTextDimensions (const PRUnichar *aString, PRUint32 aLength, nsTextDimensions &aDimensions, PRInt32 *aFontID)
NS_IMETHOD GetTextDimensions (const char *aString, PRInt32 aLength, PRInt32 aAvailWidth, PRInt32 *aBreaks, PRInt32 aNumBreaks, nsTextDimensions &aDimensions, PRInt32 &aNumCharsFit, nsTextDimensions &aLastWordDimensions, PRInt32 *aFontID)
NS_IMETHOD GetTextDimensions (const PRUnichar *aString, PRInt32 aLength, PRInt32 aAvailWidth, PRInt32 *aBreaks, PRInt32 aNumBreaks, nsTextDimensions &aDimensions, PRInt32 &aNumCharsFit, nsTextDimensions &aLastWordDimensions, PRInt32 *aFontID)
NS_IMETHOD DrawString (const char *aString, PRUint32 aLength, nscoord aX, nscoord aY, const nscoord *aSpacing)
 Draw a string in the RenderingContext.
NS_IMETHOD DrawString (const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY, PRInt32 aFontID, const nscoord *aSpacing)
 Draw a string in the RenderingContext.
NS_IMETHOD DrawString (const nsString &aString, nscoord aX, nscoord aY, PRInt32 aFontID, const nscoord *aSpacing)
 Draw a string in the RenderingContext.
NS_IMETHOD CopyOffScreenBits (nsIDrawingSurface *aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, const nsRect &aDestBounds, PRUint32 aCopyFlags)
 Copy offscreen pixelmap to this RenderingContext.
NS_IMETHOD RetrieveCurrentNativeGraphicData (PRUint32 *ngd)
NS_IMETHOD CommonInit ()
void UpdateGC ()
void ConditionRect (nscoord &x, nscoord &y, nscoord &w, nscoord &h)
void CreateClipRegion ()
QPainter * painter () const
QPaintDevice * paintDevice () const
nsTransform2D * matrix () const
QRect qRect (const nsRect &aRect)
NS_IMETHOD FlushRect (const nsRect &aRect)
 For platforms (e.g., Cocoa) that implicitly double buffer, this call can be used to force a buffer flush following the painting of a rectangle.
NS_IMETHOD FlushRect (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHOD GetPenMode (nsPenMode &aPenMode)
 Gets the Pen Mode for the RenderingContext.
NS_IMETHOD SetPenMode (nsPenMode aPenMode)
 Sets the Pen Mode for the RenderingContext.
NS_IMETHOD GetBackbuffer (const nsRect &aRequestedSize, const nsRect &aMaxSize, PRBool aForBlending, nsIDrawingSurface *&aBackbuffer)
 Get a drawing surface used as a backbuffer.
NS_IMETHOD ReleaseBackbuffer (void)
 Release a drawing surface used as the backbuffer If the platform caches the backbuffer this call will destroy it.
NS_IMETHOD DestroyCachedBackbuffer (void)
 Destroy the drawing surface used as the backbuffer.
NS_IMETHOD UseBackbuffer (PRBool *aUseBackbuffer)
 Some platforms may not want a backbuffer at all.
NS_IMETHOD PushTranslation (PushedTranslation *aState)
NS_IMETHOD PopTranslation (PushedTranslation *aState)
virtual PRInt32 GetMaxStringLength ()
 Return the maximum length of a string that can be handled by the platform using the current font metrics.
NS_IMETHOD SetRightToLeftText (PRBool aIsRTL)
 Let the device context know whether we want text reordered with right-to-left base direction.
NS_IMETHOD GetRightToLeftText (PRBool *aIsRTL)
NS_IMETHOD DrawImage (imgIContainer *aImage, const nsRect &aSrcRect, const nsRect &aDestRect)
 Draw a portion of an image, scaling it to fit within a specified rect.
NS_IMETHOD DrawTile (imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect *aTargetRect)
NS_IMETHOD GetClusterInfo (const PRUnichar *aText, PRUint32 aLength, PRUint8 *aClusterStarts)
 Get cluster details for a chunk of text.
virtual PRInt32 GetPosition (const PRUnichar *aText, PRUint32 aLength, nsPoint aPt)
 Find the closest cursor position for a given x coordinate.
NS_IMETHOD GetRangeWidth (const PRUnichar *aText, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd, PRUint32 &aWidth)
 Get the width for the specific range of a given string.
NS_IMETHOD GetRangeWidth (const char *aText, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd, PRUint32 &aWidth)
 Get the width for the specific range of a given string.
NS_IMETHOD GetWidthInternal (const char *aString, PRUint32 aLength, nscoord &aWidth)
NS_IMETHOD GetWidthInternal (const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, PRInt32 *aFontID=nsnull)
NS_IMETHOD GetTextDimensionsInternal (const char *aString, PRUint32 aLength, nsTextDimensions &aDimensions)
NS_IMETHOD GetTextDimensionsInternal (const PRUnichar *aString, PRUint32 aLength, nsTextDimensions &aDimensions, PRInt32 *aFontID=nsnull)
NS_IMETHOD DrawStringInternal (const char *aString, PRUint32 aLength, nscoord aX, nscoord aY, const nscoord *aSpacing=nsnull)
NS_IMETHOD DrawStringInternal (const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY, PRInt32 aFontID=-1, const nscoord *aSpacing=nsnull)
NS_IMETHOD RenderEPS (const nsRect &aRect, FILE *aDataFile)
 Render an encapsulated postscript object onto the current rendering surface.
NS_IMETHOD RetrieveCurrentNativeGraphicData (void **ngd)=0

Protected Member Functions

PRBool RectFitsInside (const nsRect &aRect, PRInt32 aWidth, PRInt32 aHeight) const
 Determine if a rect's width and height will fit within a specified width and height.
PRBool BothRectsFitInside (const nsRect &aRect1, const nsRect &aRect2, PRInt32 aWidth, PRInt32 aHeight, nsRect &aNewSize) const
 Determine if two rectangles width and height will fit within a specified width and height.
void CalculateDiscreteSurfaceSize (const nsRect &aMaxBackbufferSize, const nsRect &aRequestedSize, nsRect &aSize)
 Return an offscreen surface size from a set of discrete surface sizes.
void GetDrawingSurfaceSize (const nsRect &aMaxBackbufferSize, const nsRect &aRequestedSize, nsRect &aSurfaceSize)
 Get the size of the offscreen drawing surface.
nsresult AllocateBackbuffer (const nsRect &aRequestedSize, const nsRect &aMaxSize, nsIDrawingSurface *&aBackbuffer, PRBool aCacheBackbuffer, PRUint32 aSurfFlags)
 Utility method used to implement NS_IMETHOD GetBackbuffer.

Protected Attributes

nsDrawingSurfaceQtmOffscreenSurface
nsDrawingSurfaceQtmSurface
nsIDeviceContextmContext
nsIFontMetricsmFontMetrics
nsCOMPtr< nsIRegionmClipRegion
float mP2T
nsVoidArray mStateCache
nscolor mCurrentColor
nsLineStyle mCurrentLineStyle
nsFontQtmCurrentFont
Qt::PenStyle mQLineStyle
Qt::RasterOp mFunction
nsTransform2D * mTranMatrix
int mAct
EdgemActive
nsPenMode mPenMode

Detailed Description

Definition at line 65 of file nsRenderingContextQt.h.


Constructor & Destructor Documentation

Definition at line 88 of file nsRenderingContextQt.cpp.

Here is the call graph for this function:

Definition at line 107 of file nsRenderingContextQt.cpp.

{
  // Destroy the State Machine
  PRInt32 cnt = mStateCache.Count();

  while (--cnt >= 0) {
      PopState();
  }

  delete mTranMatrix;

  NS_IF_RELEASE(mOffscreenSurface);
  NS_IF_RELEASE(mFontMetrics);
  NS_IF_RELEASE(mContext);
}

Here is the call graph for this function:


Member Function Documentation

nsresult nsRenderingContextImpl::AllocateBackbuffer ( const nsRect aRequestedSize,
const nsRect aMaxSize,
nsIDrawingSurface *&  aBackbuffer,
PRBool  aCacheBackbuffer,
PRUint32  aSurfFlags 
) [protected, inherited]

Utility method used to implement NS_IMETHOD GetBackbuffer.

Parameters:
aRequestedSizesize of the backbuffer area requested
aMaxSizemaximum size that may be requested for the backbuffer
aBackbufferdrawing surface used as the backbuffer
aCacheBackbufferPR_TRUE then the backbuffer will be cached, if PR_FALSE it is created each time
aSurfFlagsflags passed to CreateDrawingSurface()

Definition at line 86 of file nsRenderingContextImpl.cpp.

{
  nsRect newBounds;
  nsresult rv = NS_OK;

   if (! aCacheBackbuffer) {
    newBounds = aRequestedSize;
  } else {
    GetDrawingSurfaceSize(aMaxSize, aRequestedSize, newBounds);
  }

  if ((nsnull == gBackbuffer)
      || (gBackbufferBounds.width != newBounds.width)
      || (gBackbufferBounds.height != newBounds.height))
    {
      if (gBackbuffer) {
        //destroy existing DS
        DestroyDrawingSurface(gBackbuffer);
        gBackbuffer = nsnull;
      }

      rv = CreateDrawingSurface(newBounds, aSurfFlags, gBackbuffer);
      //   printf("Allocating a new drawing surface %d %d\n", newBounds.width, newBounds.height);
      if (NS_SUCCEEDED(rv)) {
        gBackbufferBounds = newBounds;
        SelectOffScreenDrawingSurface(gBackbuffer);
      } else {
        gBackbufferBounds.SetRect(0,0,0,0);
        gBackbuffer = nsnull;
      }
    } else {
      SelectOffScreenDrawingSurface(gBackbuffer);

      float p2t;
      nsCOMPtr<nsIDeviceContext>  dx;
      GetDeviceContext(*getter_AddRefs(dx));
      p2t = dx->DevUnitsToAppUnits();
      nsRect bounds = aRequestedSize;
      bounds *= p2t;

      SetClipRect(bounds, nsClipCombine_kReplace);
    }

  aBackbuffer = gBackbuffer;
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsRenderingContextImpl::BothRectsFitInside ( const nsRect aRect1,
const nsRect aRect2,
PRInt32  aWidth,
PRInt32  aHeight,
nsRect aNewSize 
) const [protected, inherited]

Determine if two rectangles width and height will fit within a specified width and height.

Parameters:
aRect1first rectangle to test
aRect1second rectangle to test
aWidthwidth to determine if both rectangle's width will fit within
aHeightheight to determine if both rectangles height will fit within
Returns:
PR_TRUE if the rect1's and rect2's width and height fits with aWidth, aHeight, PR_FALSE otherwise.

Definition at line 199 of file nsRenderingContextImpl.cpp.

{
  if (PR_FALSE == RectFitsInside(aRect1, aWidth, aHeight)) {
    return PR_FALSE;
  }

  if (PR_FALSE == RectFitsInside(aRect2, aWidth, aHeight)) {
    return PR_FALSE;
  }

  aNewSize.width = aWidth;
  aNewSize.height = aHeight;

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsRenderingContextImpl::CalculateDiscreteSurfaceSize ( const nsRect aMaxBackbufferSize,
const nsRect aRequestedSize,
nsRect aSize 
) [protected, inherited]

Return an offscreen surface size from a set of discrete surface sizes.

The smallest discrete surface size that can enclose both the Maximum widget size (

See also:
GetMaxWidgetBounds) and the requested size is returned.
Parameters:
aMaxBackbufferSizeMaximum size that may be requested for the backbuffer
aRequestedSizeRequested size for the offscreen.
aSurfaceSizecontains the surface size

Definition at line 221 of file nsRenderingContextImpl.cpp.

{
  // Get the height and width of the screen
  PRInt32 height;
  PRInt32 width;

  nsCOMPtr<nsIDeviceContext>  dx;
  GetDeviceContext(*getter_AddRefs(dx));
  dx->GetDeviceSurfaceDimensions(width, height);

  float devUnits;
  devUnits = dx->DevUnitsToAppUnits();
  PRInt32 screenHeight = NSToIntRound(float( height) / devUnits );
  PRInt32 screenWidth = NSToIntRound(float( width) / devUnits );

  // These tests must go from smallest rectangle to largest rectangle.

  // 1/8 screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, screenWidth / 8, screenHeight / 8, aSurfaceSize)) {
    return;
  }

  // 1/4 screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, screenWidth / 4, screenHeight / 4, aSurfaceSize)) {
    return;
  }

  // 1/2 screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, screenWidth / 2, screenHeight / 2, aSurfaceSize)) {
    return;
  }

  // 3/4 screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, (screenWidth * 3) / 4, (screenHeight * 3) / 4, aSurfaceSize)) {
    return;
  }

  // 3/4 screen width full screen height
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, (screenWidth * 3) / 4, screenHeight, aSurfaceSize)) {
    return;
  }

  // Full screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, screenWidth, screenHeight, aSurfaceSize)) {
    return;
  }

  // Bigger than Full Screen use the largest request every made.
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, gLargestRequestedSize.width, gLargestRequestedSize.height, aSurfaceSize)) {
    return;
  } else {
    gLargestRequestedSize.width = PR_MAX(aRequestedSize.width, aMaxBackbufferSize.width);
    gLargestRequestedSize.height = PR_MAX(aRequestedSize.height, aMaxBackbufferSize.height);
    aSurfaceSize.width = gLargestRequestedSize.width;
    aSurfaceSize.height = gLargestRequestedSize.height;
    //   printf("Expanding the largested requested size to %d %d\n", gLargestRequestedSize.width, gLargestRequestedSize.height);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 155 of file nsRenderingContextQt.cpp.

{
  mP2T = mContext->DevUnitsToAppUnits();
  float app2dev;

  app2dev = mContext->AppUnitsToDevUnits();
  mTranMatrix->SetToIdentity();
  mTranMatrix->AddScale(app2dev,app2dev);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 707 of file nsRenderingContextQt.cpp.

{
  if (y < -32766) {
    y = -32766;
  }
  if (y + h > 32766) {
    h  = 32766 - y;
  }
  if (x < -32766) {
    x = -32766;
  }
  if (x + w > 32766) {
    w  = 32766 - x;
  }
}

Here is the caller graph for this function:

Fills in |aRegion| with a copy of the current clip region.

Implements nsIRenderingContext.

Definition at line 329 of file nsRenderingContextQt.cpp.

{
  if (!mClipRegion)
    return NS_ERROR_FAILURE;

  aRegion.SetTo(*mClipRegion);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::CopyOffScreenBits ( nsIDrawingSurface aSrcSurf,
PRInt32  aSrcX,
PRInt32  aSrcY,
const nsRect aDestBounds,
PRUint32  aCopyFlags 
) [virtual]

Copy offscreen pixelmap to this RenderingContext.

Parameters:
aSrcSurfdrawing surface to copy bits from
aSrcXx offset into source pixelmap to copy from
aSrcYy offset into source pixelmap to copy from
aDestBoundsDestination rectangle to copy to
aCopyFlagssee below

Implements nsIRenderingContext.

Definition at line 1207 of file nsRenderingContextQt.cpp.

{
    PRInt32            x = aSrcX;
    PRInt32            y = aSrcY;
    nsRect             drect = aDestBounds;
    nsDrawingSurfaceQt *destsurf;

    if (nsnull == aSrcSurf || nsnull == mTranMatrix || nsnull == mSurface
        || nsnull == mSurface->GetPaintDevice() || nsnull == mSurface->GetGC())
        return NS_ERROR_FAILURE;

    if (aCopyFlags & NS_COPYBITS_TO_BACK_BUFFER) {
        NS_ASSERTION(!(nsnull == mSurface), "no back buffer");
        destsurf = mSurface;
    }
    else
        destsurf = mOffscreenSurface;

    if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES)
        mTranMatrix->TransformCoord(&x,&y);

    if (aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES)
        mTranMatrix->TransformCoord(&drect.x,&drect.y,
                                    &drect.width,&drect.height);
    QPixmap pm = *(QPixmap*)((nsDrawingSurfaceQt*)aSrcSurf)->GetPaintDevice();

    QPainter *p = destsurf->GetGC();
    UpdateGC();

//     qDebug("copy offscreen bits: aSrcX=%d, aSrcY=%d, w/h = %d/%d aCopyFlags=%d",
//            aSrcX, aSrcY, pm.width(), pm.height(), aCopyFlags);

    //XXX flags are unused. that would seem to mean that there is
    //inefficiency somewhere... MMP

    p->drawPixmap(drect.x,drect.y, pm, x, y, drect.width, drect.height);
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 338 of file nsRenderingContextQt.cpp.

{
  if (mClipRegion)
    return;

  mClipRegion = do_CreateInstance(kRegionCID);
  if (mClipRegion) {
    PRUint32 w,h;

    mSurface->GetDimensions(&w,&h);
    mClipRegion->Init();
    mClipRegion->SetTo(0,0,w,h);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextQt::CreateDrawingSurface ( const nsRect aBounds,
PRUint32  aSurfFlags,
nsIDrawingSurface *&  aSurface 
) [virtual]

Create an offscreen drawing surface compatible with this RenderingContext.

The rect passed in is not affected by any transforms in the rendering context and the values are in device units.

Parameters:
aBoundsA rectangle representing the size for the drawing surface. if nsnull then a bitmap will not be created and associated with the new drawing surface
aSurfFlagssee bottom of nsIRenderingContext.h
Returns:
A nsIDrawingSurface*

Implements nsIRenderingContext.

Definition at line 565 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mSurface) {
    aSurface = nsnull;
    return NS_ERROR_FAILURE;
  }
  if (aBounds.width <= 0 || aBounds.height <= 0)
    return NS_ERROR_FAILURE;

  nsDrawingSurfaceQt *surface = new nsDrawingSurfaceQt();

  if (surface) {
    //QPainter *gc = mSurface->GetGC();
    QPainter *gc = new QPainter();
    NS_ADDREF(surface);
    //PushState();
    surface->Init(gc,aBounds.width,aBounds.height,aSurfFlags);
    //PopState();
  }
  else {
    aSurface = nsnull;
    return NS_ERROR_FAILURE;
  }
  aSurface = surface;
  return NS_OK;
}

Here is the call graph for this function:

Destroy the drawing surface used as the backbuffer.

If the platform does not maintain a cached backbuffer this call will do nothing.

Implements nsIRenderingContext.

Definition at line 140 of file nsRenderingContextImpl.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Destroy a drawing surface created by CreateDrawingSurface()

Parameters:
aDSA drawing surface to destroy

Implements nsIRenderingContext.

Definition at line 594 of file nsRenderingContextQt.cpp.

{
  nsDrawingSurfaceQt *surface = (nsDrawingSurfaceQt*)aDS;

  if (surface == NULL)
    return NS_ERROR_FAILURE;

  NS_IF_RELEASE(surface);
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextQt::DrawArc ( const nsRect aRect,
float  aStartAngle,
float  aEndAngle 
) [virtual]

Draw an arc in the current forground color.

Parameters:
aRectThe rectangle define bounds of ellipse to use
aStartAnglethe starting angle of the arc, in degrees
aEndAngleThe ending angle of the arc, in degrees

Implements nsIRenderingContext.

Definition at line 923 of file nsRenderingContextQt.cpp.

{
  return DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,
                 aStartAngle,aEndAngle);
}
NS_IMETHODIMP nsRenderingContextQt::DrawArc ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight,
float  aStartAngle,
float  aEndAngle 
) [virtual]

Draw an arc in the current forground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of horizontal axis in twips
aHeightHeight of vertical axis in twips
aStartAnglethe starting angle of the arc, in degrees
aEndAngleThe ending angle of the arc, in degrees

Implements nsIRenderingContext.

Definition at line 930 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  nscoord x,y,w,h;

  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
  UpdateGC();

   mSurface->GetGC()->drawArc(x,y,w,h,NSToIntRound(aStartAngle * 16.0f),
                              NSToIntRound(aEndAngle * 16.0f));
  return NS_OK;
}

Here is the call graph for this function:

Draw an ellipse in the current foreground color.

Parameters:
aRectThe rectangle define bounds of ellipse to draw

Implements nsIRenderingContext.

Definition at line 873 of file nsRenderingContextQt.cpp.

{
  return DrawEllipse(aRect.x,aRect.y,aRect.width,aRect.height);
}
NS_IMETHODIMP nsRenderingContextQt::DrawEllipse ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

Draw an ellipse in the current foreground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of horizontal axis in twips
aHeightHeight of vertical axis in twips

Implements nsIRenderingContext.

Definition at line 878 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  nscoord x,y,w,h;

  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
  UpdateGC();

  mSurface->GetGC()->drawEllipse(x,y,w,h);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextImpl::DrawImage ( imgIContainer aImage,
const nsRect aSrcRect,
const nsRect aDestRect 
) [virtual, inherited]

Draw a portion of an image, scaling it to fit within a specified rect.

Parameters:
aImageThe image to draw
aSrcRectThe rect (in twips) of the image to draw. [x,y] denotes the top left corner of the region.
aDestRectThe device context rect (in twips) that the image portion should occupy. [x,y] denotes the top left corner. [height,width] denotes the desired image size.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK, nsRenderingContextPS, nsRenderingContextXlib, nsRenderingContextMac, and nsRenderingContextXp.

Definition at line 304 of file nsRenderingContextImpl.cpp.

{
  nsRect dr = aDestRect;
  mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);

  nsRect sr = aSrcRect;
  mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
  
  if (sr.IsEmpty() || dr.IsEmpty())
    return NS_OK;

  sr.x = aSrcRect.x;
  sr.y = aSrcRect.y;
  mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);

  nsCOMPtr<gfxIImageFrame> iframe;
  aImage->GetCurrentFrame(getter_AddRefs(iframe));
  if (!iframe) return NS_ERROR_FAILURE;

  nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
  if (!img) return NS_ERROR_FAILURE;

  nsIDrawingSurface *surface = nsnull;
  GetDrawingSurface(&surface);
  if (!surface) return NS_ERROR_FAILURE;

  // For Bug 87819
  // iframe may want image to start at different position, so adjust
  nsRect iframeRect;
  iframe->GetRect(iframeRect);
  
  if (iframeRect.x > 0) {
    // Adjust for the iframe offset before we do scaling.
    sr.x -= iframeRect.x;

    nscoord scaled_x = sr.x;
    if (dr.width != sr.width) {
      PRFloat64 scale_ratio = PRFloat64(dr.width) / PRFloat64(sr.width);
      scaled_x = NSToCoordRound(scaled_x * scale_ratio);
    }
    if (sr.x < 0) {
      dr.x -= scaled_x;
      sr.width += sr.x;
      dr.width += scaled_x;
      if (sr.width <= 0 || dr.width <= 0)
        return NS_OK;
      sr.x = 0;
    } else if (sr.x > iframeRect.width) {
      return NS_OK;
    }
  }

  if (iframeRect.y > 0) {
    // Adjust for the iframe offset before we do scaling.
    sr.y -= iframeRect.y;

    nscoord scaled_y = sr.y;
    if (dr.height != sr.height) {
      PRFloat64 scale_ratio = PRFloat64(dr.height) / PRFloat64(sr.height);
      scaled_y = NSToCoordRound(scaled_y * scale_ratio);
    }
    if (sr.y < 0) {
      dr.y -= scaled_y;
      sr.height += sr.y;
      dr.height += scaled_y;
      if (sr.height <= 0 || dr.height <= 0)
        return NS_OK;
      sr.y = 0;
    } else if (sr.y > iframeRect.height) {
      return NS_OK;
    }
  }

  // Multiple paint rects may have been coalesced into a bounding box, so
  // ensure that this rect is actually within the clip region before we draw.
  nsCOMPtr<nsIRegion> clipRegion;
  GetClipRegion(getter_AddRefs(clipRegion));
  if (clipRegion && !clipRegion->ContainsRect(dr.x, dr.y, dr.width, dr.height))
    return NS_OK;

  return img->Draw(*this, surface, sr.x, sr.y, sr.width, sr.height,
                   dr.x, dr.y, dr.width, dr.height);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::DrawLine ( nscoord  aX0,
nscoord  aY0,
nscoord  aX1,
nscoord  aY1 
) [virtual]

Draw a line.

Parameters:
aXOstarting horiztonal coord in twips
aY0starting vertical coord in twips
aX1end horiztonal coord in twips
aY1end vertical coord in twips

Implements nsIRenderingContext.

Definition at line 632 of file nsRenderingContextQt.cpp.

{
  nscoord diffX,diffY;

  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  mTranMatrix->TransformCoord(&aX0,&aY0);
  mTranMatrix->TransformCoord(&aX1,&aY1);

  diffX = aX1 - aX0;
  diffY = aY1 - aY0;

  if (0 != diffX) {
    diffX = (diffX > 0 ? 1 : -1);
  }
  if (0 != diffY) {
    diffY = (diffY > 0 ? 1 : -1);
  }
  UpdateGC();
  mSurface->GetGC()->drawLine(aX0,aY0,aX1 - diffX,aY1 - diffY);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::DrawPolygon ( const nsPoint  aPoints[],
PRInt32  aNumPoints 
) [virtual]

Draw a poly in the current foreground color.

Parameters:
aPointspoints to use for the drawing, last must equal first
aNumPontsnumber of points in the polygon

Implements nsIRenderingContext.

Definition at line 831 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  QPointArray pts(aNumPoints);
  for (PRInt32 i = 0; i < aNumPoints; i++) {
    nsPoint p = aPoints[i];

    mTranMatrix->TransformCoord(&p.x,&p.y);
    pts.setPoint(i,p.x,p.y);
  }
  UpdateGC();

  mSurface->GetGC()->drawPolyline(pts);

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::DrawPolyline ( const nsPoint  aPoints[],
PRInt32  aNumPoints 
) [virtual]

Draw a polyline.

Parameters:
aPointsarray of endpoints
aNumPontsnumber of points

Implements nsIRenderingContext.

Definition at line 684 of file nsRenderingContextQt.cpp.

{
  PRInt32 i;

  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  QPointArray pts(aNumPoints);
  for (i = 0; i < aNumPoints; i++) {
    nsPoint p = aPoints[i];

    mTranMatrix->TransformCoord(&p.x,&p.y);
    pts.setPoint(i,p.x,p.y);
  }
  UpdateGC();

  mSurface->GetGC()->drawPolyline(pts);

  return NS_OK;
}

Here is the call graph for this function:

Draw a rectangle.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 724 of file nsRenderingContextQt.cpp.

{
  return DrawRect(aRect.x,aRect.y,aRect.width,aRect.height);
}
NS_IMETHODIMP nsRenderingContextQt::DrawRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

Draw a rectangle.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of rectangle in twips
aHeightHeight of rectangle in twips

Implements nsIRenderingContext.

Definition at line 729 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  nscoord x,y,w,h;

  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;
  mTranMatrix->TransformCoord(&x,&y,&w,&h);

  // After the transform, if the numbers are huge, chop them, because
  // they're going to be converted from 32 bit to 16 bit.
  // It's all way off the screen anyway.
  ConditionRect(x,y,w,h);

  if (w && h) {
    UpdateGC();
    mSurface->GetGC()->drawRect(x,y,w,h);
  }
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 658 of file nsRenderingContextQt.cpp.

{
  nscoord diffX,diffY;

  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  mTranMatrix->TransformCoord(&aX0,&aY0);
  mTranMatrix->TransformCoord(&aX1,&aY1);

  diffX = aX1 - aX0;
  diffY = aY1 - aY0;

  if (0 != diffX) {
    diffX = (diffX > 0 ? 1 : -1);
  }
  if (0 != diffY) {
    diffY = (diffY > 0 ? 1 : -1);
  }
  UpdateGC();
  mSurface->GetGC()->drawLine(aX0,aY0,aX1 - diffX,aY1 - diffY);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::DrawString ( const char *  aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
const nscoord aSpacing 
) [virtual]

Draw a string in the RenderingContext.

Parameters:
aStringThe string to draw
aLengthThe length of the aString
aXHorizontal starting point of baseline
aYVertical starting point of baseline.
aSpacinginter-character spacing to apply

Reimplemented from nsRenderingContextImpl.

Definition at line 1125 of file nsRenderingContextQt.cpp.

{
    if (0 == aLength)
        return NS_OK;

    if (!mCurrentFont || nsnull == mTranMatrix || nsnull == mSurface
        || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice()
        || nsnull == aString)
        return NS_ERROR_FAILURE;

    nscoord x = aX;
    nscoord y = aY;

    UpdateGC();

    QString str = QString::fromLatin1(aString, aLength);

    if (nsnull != aSpacing) {
        // Render the string, one character at a time...
        for (uint i = 0; i < aLength; ++i) {
            nscoord xx = x;
            nscoord yy = y;
            mTranMatrix->TransformCoord(&xx,&yy);
            mSurface->GetGC()->drawText(xx, yy, str, i, 1);
            x += *aSpacing++;
        }
    } else {
        mTranMatrix->TransformCoord(&x,&y);
        mSurface->GetGC()->drawText(x, y, str, aLength, QPainter::LTR);
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextQt::DrawString ( const PRUnichar aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
PRInt32  aFontID,
const nscoord aSpacing 
) [virtual]

Draw a string in the RenderingContext.

Parameters:
aStringA PRUnichar of the string
aLengthThe length of the aString
aXHorizontal starting point of baseline
aYVertical starting point of baseline.
aFontIDan optional parameter used to speed font selection for complex unicode strings. the value passed is returned by the DrawString() methods.
aSpacinginter-character spacing to apply

Reimplemented from nsRenderingContextImpl.

Definition at line 1161 of file nsRenderingContextQt.cpp.

{
    if (!aLength)
        return NS_OK;

    if (!mCurrentFont || nsnull == mTranMatrix || nsnull == mSurface
        || nsnull == mSurface->GetGC()
        || nsnull == mSurface->GetPaintDevice() || nsnull == aString)
        return NS_ERROR_FAILURE;

    nscoord x = aX;
    nscoord y = aY;

    UpdateGC();
    QConstString str((const QChar *)aString, aLength);

    if (nsnull != aSpacing) {
        // Render the string, one character at a time...
        for (uint i = 0; i < aLength; ++i) {
            nscoord xx = x;
            nscoord yy = y;
            mTranMatrix->TransformCoord(&xx,&yy);
            mSurface->GetGC()->drawText(xx, yy, str.string(), i, 1);
            x += *aSpacing++;
        }
    }
    else {
        mTranMatrix->TransformCoord(&x,&y);
        mSurface->GetGC()->drawText(x, y, str.string(), aLength, QPainter::LTR);
    }
    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::DrawString ( const nsString aString,
nscoord  aX,
nscoord  aY,
PRInt32  aFontID,
const nscoord aSpacing 
) [virtual]

Draw a string in the RenderingContext.

Parameters:
aStringA nsString of the string
aXHorizontal starting point of baseline
aYVertical starting point of baseline.
aFontIDan optional parameter used to speed font selection for complex unicode strings. the value passed is returned by the DrawString() methods.
aSpacinginter-character spacing to apply

Reimplemented from nsRenderingContextImpl.

Definition at line 1198 of file nsRenderingContextQt.cpp.

{
  return DrawString(aString.get(), aString.Length(), aX, aY, aFontID, aSpacing);
}

Here is the call graph for this function:

NS_IMETHOD nsRenderingContextImpl::DrawStringInternal ( const char *  aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
const nscoord aSpacing = nsnull 
) [inline, inherited]

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 250 of file nsRenderingContextImpl.h.

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::DrawStringInternal ( const PRUnichar aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
PRInt32  aFontID = -1,
const nscoord aSpacing = nsnull 
) [inline, inherited]
NS_IMETHODIMP nsRenderingContextImpl::DrawTile ( imgIContainer aImage,
nscoord  aXOffset,
nscoord  aYOffset,
const nsRect aTargetRect 
) [virtual, inherited]

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextPS, nsRenderingContextMac, and nsRenderingContextXp.

Definition at line 390 of file nsRenderingContextImpl.cpp.

{
  nsRect dr(*aTargetRect);
  mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
  mTranMatrix->TransformCoord(&aXImageStart, &aYImageStart);

  // may have become empty due to transform shinking small number to 0
  if (dr.IsEmpty())
    return NS_OK;

  nscoord width, height;
  aImage->GetWidth(&width);
  aImage->GetHeight(&height);

  if (width == 0 || height == 0)
    return NS_OK;

  nscoord xOffset = (dr.x - aXImageStart) % width;
  nscoord yOffset = (dr.y - aYImageStart) % height;

  nsCOMPtr<gfxIImageFrame> iframe;
  aImage->GetCurrentFrame(getter_AddRefs(iframe));
  if (!iframe) return NS_ERROR_FAILURE;

  nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
  if (!img) return NS_ERROR_FAILURE;

  nsIDrawingSurface *surface = nsnull;
  GetDrawingSurface(&surface);
  if (!surface) return NS_ERROR_FAILURE;

  /* bug 113561 - frame can be smaller than container */
  nsRect iframeRect;
  iframe->GetRect(iframeRect);
  PRInt32 padx = width - iframeRect.width;
  PRInt32 pady = height - iframeRect.height;

  return img->DrawTile(*this, surface,
                       xOffset - iframeRect.x, yOffset - iframeRect.y,
                       padx, pady,
                       dr);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::FillArc ( const nsRect aRect,
float  aStartAngle,
float  aEndAngle 
) [virtual]

Fill an arc in the current forground color.

Parameters:
aRectThe rectangle define bounds of ellipse to use
aStartAnglethe starting angle of the arc, in degrees
aEndAngleThe ending angle of the arc, in degrees

Implements nsIRenderingContext.

Definition at line 952 of file nsRenderingContextQt.cpp.

{
  return FillArc(aRect.x,aRect.y,aRect.width,aRect.height,
                 aStartAngle,aEndAngle);
}
NS_IMETHODIMP nsRenderingContextQt::FillArc ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight,
float  aStartAngle,
float  aEndAngle 
) [virtual]

Fill an arc in the current forground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of horizontal axis in twips
aHeightHeight of vertical axis in twips
aStartAnglethe starting angle of the arc, in degrees
aEndAngleThe ending angle of the arc, in degrees

Implements nsIRenderingContext.

Definition at line 959 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  nscoord x,y,w,h;

  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
  UpdateGC();

  mSurface->GetGC()->drawPie(x,y,w,h,NSToIntRound(aStartAngle * 16.0f),
                             NSToIntRound(aEndAngle * 16.0f));
  return NS_OK;
}

Here is the call graph for this function:

Fill an ellipse in the current foreground color.

Parameters:
aRectThe rectangle define bounds of ellipse to draw

Implements nsIRenderingContext.

Definition at line 898 of file nsRenderingContextQt.cpp.

{
  return FillEllipse(aRect.x,aRect.y,aRect.width,aRect.height);
}
NS_IMETHODIMP nsRenderingContextQt::FillEllipse ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

Fill an ellipse in the current foreground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of horizontal axis in twips
aHeightHeight of vertical axis in twips

Implements nsIRenderingContext.

Definition at line 903 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  nscoord x,y,w,h;

  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
  UpdateGC();

  mSurface->GetGC()->drawChord(x,y,w,h,0,16 * 360);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::FillPolygon ( const nsPoint  aPoints[],
PRInt32  aNumPoints 
) [virtual]

Fill a poly in the current foreground color.

Parameters:
aPointspoints to use for the drawing, last must equal first
aNumPontsnumber of points in the polygon

Implements nsIRenderingContext.

Definition at line 852 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  QPointArray pts(aNumPoints);
  for (PRInt32 i = 0; i < aNumPoints; i++) {
    nsPoint p = aPoints[i];

    mTranMatrix->TransformCoord(&p.x,&p.y);
    pts.setPoint(i,p.x,p.y);
  }
  UpdateGC();

  mSurface->GetGC()->drawPolygon(pts);

  return NS_OK;
}

Here is the call graph for this function:

Fill a rectangle in the current foreground color.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 756 of file nsRenderingContextQt.cpp.

{
  return FillRect(aRect.x,aRect.y,aRect.width,aRect.height);
}
NS_IMETHODIMP nsRenderingContextQt::FillRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

Fill a rectangle in the current foreground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of rectangle in twips
aHeightHeight of rectangle in twips

Implements nsIRenderingContext.

Definition at line 761 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  nscoord x,y,w,h;

  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;
  mTranMatrix->TransformCoord(&x,&y,&w,&h);

  // After the transform, if the numbers are huge, chop them, because
  // they're going to be converted from 32 bit to 16 bit.
  // It's all way off the screen anyway.
  ConditionRect(x,y,w,h);
  UpdateGC();

  QColor color(NS_GET_R(mCurrentColor),
               NS_GET_G(mCurrentColor),
               NS_GET_B(mCurrentColor));

  mSurface->GetGC()->fillRect(x,y,w,h,color);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextImpl::FlushRect ( const nsRect aRect) [virtual, inherited]

For platforms (e.g., Cocoa) that implicitly double buffer, this call can be used to force a buffer flush following the painting of a rectangle.

This call needs to be used any time drawing of rects is being done "on the fly", outside of the normal painting process. Examples include the blinking caret and tabbing through subimages in an image map.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextMac.

Definition at line 436 of file nsRenderingContextImpl.cpp.

{
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextImpl::FlushRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual, inherited]

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextMac.

Definition at line 442 of file nsRenderingContextImpl.cpp.

{
    return NS_OK;
}
NS_IMETHODIMP nsRenderingContextImpl::GetBackbuffer ( const nsRect aRequestedSize,
const nsRect aMaxSize,
PRBool  aForBlending,
nsIDrawingSurface *&  aBackbuffer 
) [virtual, inherited]

Get a drawing surface used as a backbuffer.

Depending on the platform this will either cause a backbuffer surface to be allocated or an existing cached backbuffer will be returned. If the backbuffer is being cached asking for aMaxSize which is different from a previous request may cause the platform to dump it's cached backbuffer and reallocate a backbuffer of a size which will allow aMaxSize buffer to be allocated.

Parameters:
aRequestedSizesize of the backbuffer area requested
aMaxSizemaximum size that may be requested for the backbuffer
aForBlendingparameter telling if the buffer will be used for blending
aBackbufferdrawing surface used as the backbuffer

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK, nsRenderingContextWin, and nsRenderingContextXlib.

Definition at line 77 of file nsRenderingContextImpl.cpp.

{
  // Default implementation assumes the backbuffer will be cached.
  // If the platform implementation does not require the backbuffer to
  // be cached override this method and make the following call instead:
  // AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_FALSE);
  return AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_TRUE, 0);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetClipRect ( nsRect aRect,
PRBool aHasLocalClip 
) [virtual]

Gets the bounds of the clip region of the RenderingContext.

The bounds are returned in device units!

Parameters:
aRectout parameter to contain the clip region bounds for the RenderingContext
Returns:
PR_TRUE if the rendering context has a local cliprect set else aRect is undefined

Implements nsIRenderingContext.

Definition at line 306 of file nsRenderingContextQt.cpp.

{
  PRInt32 x,y,w,h;

  if (!mClipRegion)
    return NS_ERROR_FAILURE;

  if (!mClipRegion->IsEmpty()) {
    mClipRegion->GetBoundingBox(&x,&y,&w,&h);
    aRect.SetRect(x,y,w,h);
    aClipValid = PR_TRUE;
  }
  else {
    aRect.SetRect(0,0,0,0);
    aClipValid = PR_FALSE;
  }
  return NS_OK;
}

Gets the current clipping region for the RenderingContext The region is in device coordinates!

Parameters:
aRegionout parameter representing the clip region. if SetClipRegion() is called, do not assume that GetClipRegion() will return the same object.

Implements nsIRenderingContext.

Definition at line 442 of file nsRenderingContextQt.cpp.

{
  nsresult  rv = NS_ERROR_FAILURE;

  if (!aRegion || !mClipRegion)
    return NS_ERROR_NULL_POINTER;

  if (*aRegion) {
    (*aRegion)->SetTo(*mClipRegion);
    rv = NS_OK;
  }
  else {
    nsCOMPtr<nsIRegion> newRegion = do_CreateInstance(kRegionCID,&rv);
    if (NS_SUCCEEDED(rv)) {
      newRegion->Init();
      newRegion->SetTo(*mClipRegion);
      NS_ADDREF(*aRegion = newRegion);
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextImpl::GetClusterInfo ( const PRUnichar aText,
PRUint32  aLength,
PRUint8 aClusterStarts 
) [virtual, inherited]

Get cluster details for a chunk of text.

This will fill in the aClusterStarts array with information about what characters are the start of clusters for display. The information is just a bitfield that is set to 1 if the character is the start of a cluster. aClusterStarts must already be allocated to at least aLength items in length. Array index zero being set to one indicates that the first character is the beginning of a cluster.

Parameters:
aTextText on which to get details.
aLengthLength of the text.
aClusterStartsArray of ints that will be populated with information about which characters are the starts of clusters.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK.

Definition at line 448 of file nsRenderingContextImpl.cpp.

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetColor ( nscolor aColor) const [virtual]

Get the forground color for the RenderingContext.

Returns:
The current forground color of the RenderingContext

Implements nsIRenderingContext.

Definition at line 473 of file nsRenderingContextQt.cpp.

{
  aColor = mCurrentColor;
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextQt::GetCurrentTransform ( nsTransform2D *&  aTransform) [virtual]

Get the current transformation matrix for the RenderingContext.

Returns:
The transformation matrix for the RenderingContext

Implements nsIRenderingContext.

Definition at line 558 of file nsRenderingContextQt.cpp.

{
  aTransform = mTranMatrix;
  return NS_OK;
}

Get the DeviceContext that this RenderingContext was initialized with.

Returns:
the device context

Implements nsIRenderingContext.

Definition at line 226 of file nsRenderingContextQt.cpp.

Get the currently selected drawing surface.

Parameters:
aSurfaceout parameter for the current drawing surface

Implements nsIRenderingContext.

Definition at line 214 of file nsRenderingContextQt.cpp.

{
  *aSurface = mSurface;
  return NS_OK;
}
void nsRenderingContextImpl::GetDrawingSurfaceSize ( const nsRect aMaxBackbufferSize,
const nsRect aRequestedSize,
nsRect aSurfaceSize 
) [protected, inherited]

Get the size of the offscreen drawing surface.

Parameters:
aMaxBackbufferSizeMaximum size that may be requested for the backbuffer
aRequestedSizeDesired size for the offscreen.
aSurfaceSizeOffscreen adjusted to a discrete size which encloses aRequestedSize.

Definition at line 215 of file nsRenderingContextImpl.cpp.

{ 
  CalculateDiscreteSurfaceSize(aMaxBackbufferSize, aRequestedSize, aNewSize);
  aNewSize.MoveTo(aRequestedSize.x, aRequestedSize.y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Get the current fontmetrics for the RenderingContext.

Returns:
The current font of the RenderingContext

Implements nsIRenderingContext.

Definition at line 536 of file nsRenderingContextQt.cpp.

{
  NS_IF_ADDREF(mFontMetrics);
  aFontMetrics = mFontMetrics;
  return NS_OK;
}

Returns in aResult any rendering hints that the context has.

See below for the hints bits. Always returns NS_OK.

Implements nsIRenderingContext.

Definition at line 167 of file nsRenderingContextQt.cpp.

{
  PRUint32 result = 0;

  // Most X servers implement 8 bit text rendering alot faster than
  // XChar2b rendering. In addition, we can avoid the PRUnichar to
  // XChar2b conversion. So we set this bit...
  //result |= NS_RENDERING_HINT_FAST_8BIT_TEXT;

  // XXX see if we are rendering to the local display or to a remote
  // dispaly and set the NS_RENDERING_HINT_REMOTE_RENDERING accordingly
  aResult = result;
  return NS_OK;
}

Gets the line style for the RenderingContext.

Parameters:
aLineStyleThe line style to be retrieved
Returns:
NS_OK if the line style is correctly retrieved

Implements nsIRenderingContext.

Definition at line 529 of file nsRenderingContextQt.cpp.

{
  aLineStyle = mCurrentLineStyle;
  return NS_OK;
}
virtual PRInt32 nsRenderingContextImpl::GetMaxStringLength ( ) [inline, virtual, inherited]

Return the maximum length of a string that can be handled by the platform using the current font metrics.

The implementation here is just a stub; classes that don't override the safe string methods need to implement this.

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 106 of file nsRenderingContextImpl.h.

{ return 1; }

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetPenMode ( nsPenMode aPenMode) [inline, virtual, inherited]

Gets the Pen Mode for the RenderingContext.

Parameters:
aPenModeThe Pen Mode to be retrieved
Returns:
NS_OK if the Pen Mode is correctly retrieved

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextWin.

Definition at line 83 of file nsRenderingContextImpl.h.

{ return NS_ERROR_FAILURE;}
PRInt32 nsRenderingContextImpl::GetPosition ( const PRUnichar aText,
PRUint32  aLength,
nsPoint  aPt 
) [virtual, inherited]

Find the closest cursor position for a given x coordinate.

This will find the closest byte index for a given x coordinate. This takes into account grapheme clusters and bidi text.

Parameters:
aTextText on which to operate.
aLengthLength of the text.
aPtthe x/y position in the string to check.
Returns:
Index where the cursor falls. If the return is zero, it's before the first character, if it falls off the end of the string it's the length of the string + 1.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK.

Definition at line 456 of file nsRenderingContextImpl.cpp.

{
  return -1;
}
NS_IMETHODIMP nsRenderingContextImpl::GetRangeWidth ( const PRUnichar aText,
PRUint32  aLength,
PRUint32  aStart,
PRUint32  aEnd,
PRUint32 aWidth 
) [virtual, inherited]

Get the width for the specific range of a given string.

This function is similar to other GetWidth functions, except that it gets the width for a part of the string instead of the entire string. This is useful when you're interested in finding out the length of a chunk in the middle of the string. Lots of languages require you to include surrounding information to accurately determine the length of a substring.

Parameters:
aTextText on which to operate
aLengthLength of the text
aStartStart index into the string
aEndEnd index into the string (inclusive)
aWidthReturned with in app coordinates

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK.

Definition at line 464 of file nsRenderingContextImpl.cpp.

NS_IMETHODIMP nsRenderingContextImpl::GetRangeWidth ( const char *  aText,
PRUint32  aLength,
PRUint32  aStart,
PRUint32  aEnd,
PRUint32 aWidth 
) [virtual, inherited]

Get the width for the specific range of a given string.

Same as GetRangeWidth for PRUnichar, but takes a char * as the text argument.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK.

Definition at line 474 of file nsRenderingContextImpl.cpp.

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 293 of file nsRenderingContextImpl.cpp.

{
  *aIsRTL = PR_FALSE;
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetTextDimensions ( const char *  aString,
PRUint32  aLength,
nsTextDimensions aDimensions 
) [virtual]

Returns the dimensions of a string, i.e., the overall extent of a string whose rendering may involve switching between different fonts that have different metrics.

Parameters:
aStringstring to measure
aLengthnumber of characters in string
aFontIDan optional out parameter used to store a font identifier that can be passed into the DrawString() methods to speed measurements
Returns:
aDimensions struct that contains the extent of the string (see below)

Reimplemented from nsRenderingContextImpl.

Definition at line 1054 of file nsRenderingContextQt.cpp.

{
    aDimensions.Clear();
    if (aLength == 0)
        return NS_OK;
    if (nsnull == aString)
        return NS_ERROR_FAILURE;

    QString str = QString::fromLatin1(aString, aLength);
    QFontMetrics fm(mCurrentFont->font);
    aDimensions.ascent = NSToCoordRound(fm.ascent()*mP2T);
    aDimensions.descent = NSToCoordRound(fm.descent()*mP2T);
    aDimensions.width = NSToCoordRound(fm.width(str)*mP2T);
    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetTextDimensions ( const PRUnichar aString,
PRUint32  aLength,
nsTextDimensions aDimensions,
PRInt32 aFontID 
) [virtual]

Reimplemented from nsRenderingContextImpl.

Definition at line 1072 of file nsRenderingContextQt.cpp.

{
    aDimensions.Clear();
    if (0 == aLength)
        return NS_OK;
    if (nsnull == aString)
        return NS_ERROR_FAILURE;

    QConstString str((const QChar *)aString, aLength);
    QFontMetrics fm(mCurrentFont->font);
    aDimensions.ascent = NSToCoordRound(fm.ascent()*mP2T);
    aDimensions.descent = NSToCoordRound(fm.descent()*mP2T);
    aDimensions.width = NSToCoordRound(fm.width(str.string())*mP2T);

    if (nsnull != aFontID)
        *aFontID = 0;

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetTextDimensions ( const char *  aString,
PRInt32  aLength,
PRInt32  aAvailWidth,
PRInt32 aBreaks,
PRInt32  aNumBreaks,
nsTextDimensions aDimensions,
PRInt32 aNumCharsFit,
nsTextDimensions aLastWordDimensions,
PRInt32 aFontID 
)

Definition at line 1096 of file nsRenderingContextQt.cpp.

{
    NS_NOTREACHED("nsRenderingContextQt::GetTextDimensions not implemented\n");
    return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsRenderingContextQt::GetTextDimensions ( const PRUnichar aString,
PRInt32  aLength,
PRInt32  aAvailWidth,
PRInt32 aBreaks,
PRInt32  aNumBreaks,
nsTextDimensions aDimensions,
PRInt32 aNumCharsFit,
nsTextDimensions aLastWordDimensions,
PRInt32 aFontID 
)

Definition at line 1110 of file nsRenderingContextQt.cpp.

{
    NS_NOTREACHED("nsRenderingContextQt::GetTextDimensions not implemented\n");
    return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHOD nsRenderingContextImpl::GetTextDimensionsInternal ( const char *  aString,
PRUint32  aLength,
nsTextDimensions aDimensions 
) [inline, inherited]

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 207 of file nsRenderingContextImpl.h.

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetTextDimensionsInternal ( const PRUnichar aString,
PRUint32  aLength,
nsTextDimensions aDimensions,
PRInt32 aFontID = nsnull 
) [inline, inherited]
NS_IMETHODIMP nsRenderingContextQt::GetWidth ( char  aC,
nscoord aWidth 
) [virtual]

Returns the width (in app units) of an 8-bit character If no font has been Set, the results are undefined.

Parameters:
aCcharacter to measure
aWidthout parameter for width
Returns:
error status

Implements nsRenderingContextImpl.

Definition at line 981 of file nsRenderingContextQt.cpp.

{
    if (!mFontMetrics)
        return NS_ERROR_FAILURE;
    if (aC == ' ') {
        aWidth = mCurrentFont->mSpaceWidth;
    } else {
        QFontMetrics fm(mCurrentFont->font);
        aWidth = NSToCoordRound(fm.width(aC) * mP2T);
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetWidth ( PRUnichar  aC,
nscoord aWidth,
PRInt32 aFontID 
) [virtual]

Returns the width (in app units) of a unicode character If no font has been Set, the results are undefined.

Parameters:
aCcharacter to measure
aWidthout parameter for width
aFontIDan optional out parameter used to store a font identifier that can be passed into the DrawString() methods to speed rendering
Returns:
error status

Implements nsRenderingContextImpl.

Definition at line 994 of file nsRenderingContextQt.cpp.

{
    if (!mFontMetrics)
        return NS_ERROR_FAILURE;
    if (aC == ' ') {
        aWidth = mCurrentFont->mSpaceWidth;
    } else {
        QFontMetrics fm(mCurrentFont->font);
        aWidth = NSToCoordRound(fm.width(QChar(aC)) * mP2T);
    }
    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetWidth ( const nsString aString,
nscoord aWidth,
PRInt32 aFontID 
) [virtual]

Returns the width (in app units) of an nsString If no font has been Set, the results are undefined.

Parameters:
aStringstring to measure
aWidthout parameter for width
aFontIDan optional out parameter used to store a font identifier that can be passed into the DrawString() methods to speed rendering
Returns:
error status

Reimplemented from nsRenderingContextImpl.

Definition at line 1008 of file nsRenderingContextQt.cpp.

{
  return GetWidth(aString.get(), aString.Length(), aWidth, aFontID);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetWidth ( const char *  aString,
nscoord aWidth 
) [virtual]

Returns the width (in app units) of an 8-bit character string If no font has been Set, the results are undefined.

Parameters:
aStringstring to measure
aWidthout parameter for width
Returns:
error status

Reimplemented from nsRenderingContextImpl.

Definition at line 1013 of file nsRenderingContextQt.cpp.

{
  return GetWidth(aString,strlen(aString),aWidth);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetWidth ( const char *  aString,
PRUint32  aLength,
nscoord aWidth 
) [virtual]

Returns the width (in app units) of an 8-bit character string If no font has been Set, the results are undefined.

Parameters:
aStringstring to measure
aLengthnumber of characters in string
aWidthout parameter for width
Returns:
error status

Reimplemented from nsRenderingContextImpl.

Definition at line 1018 of file nsRenderingContextQt.cpp.

{
    if (0 == aLength) {
    aWidth = 0;
    return NS_OK;
    }
    if (nsnull == aString || nsnull == mCurrentFont)
        return NS_ERROR_FAILURE;

    QFontMetrics curFontMetrics(mCurrentFont->font);
    int rawWidth = curFontMetrics.width(QString::fromLatin1(aString, aLength));
    aWidth = NSToCoordRound(rawWidth * mP2T);
    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::GetWidth ( const PRUnichar aString,
PRUint32  aLength,
nscoord aWidth,
PRInt32 aFontID 
) [virtual]

Returns the width (in app units) of a Unicode character string If no font has been Set, the results are undefined.

Parameters:
aStringstring to measure
aLengthnumber of characters in string
aWidthout parameter for width
aFontIDan optional out parameter used to store a font identifier that can be passed into the DrawString() methods to speed rendering
Returns:
error status

Reimplemented from nsRenderingContextImpl.

Definition at line 1033 of file nsRenderingContextQt.cpp.

{
    if (aFontID)
        *aFontID = 0;
    if (0 == aLength) {
        aWidth = 0;
        return NS_OK;
    }
    if (!aString || !mFontMetrics)
        return NS_ERROR_FAILURE;

    QConstString cstr((const QChar *)aString, aLength);
    QFontMetrics curFontMetrics(mCurrentFont->font);
    int rawWidth = curFontMetrics.width(cstr.string());
    aWidth = NSToCoordRound(rawWidth * mP2T);
    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetWidthInternal ( const char *  aString,
PRUint32  aLength,
nscoord aWidth 
) [inline, inherited]

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 201 of file nsRenderingContextImpl.h.

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetWidthInternal ( const PRUnichar aString,
PRUint32  aLength,
nscoord aWidth,
PRInt32 aFontID = nsnull 
) [inline, inherited]
NS_IMETHODIMP nsRenderingContextQt::Init ( nsIDeviceContext aContext,
nsIWidget aWidget 
) [virtual]

Initialize the RenderingContext.

Parameters:
aContextthe device context to use.
aWidgetthe widget to hook up to
Returns:
The result of the initialization, NS_Ok if no errors

Implements nsIRenderingContext.

Definition at line 123 of file nsRenderingContextQt.cpp.

{
  mContext = aContext;
  NS_IF_ADDREF(mContext);

  mSurface = new nsDrawingSurfaceQt();

  QPaintDevice *pdevice = (QWidget*)aWindow->GetNativeData(NS_NATIVE_WINDOW);
  Q_ASSERT(pdevice);
  QPainter *gc = new QPainter();

  mSurface->Init(pdevice,gc);

  mOffscreenSurface = mSurface;

  NS_ADDREF(mSurface);

  return(CommonInit());
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::Init ( nsIDeviceContext aContext,
nsIDrawingSurface aSurface 
) [virtual]

Initialize the RenderingContext.

Parameters:
aContextthe device context to use for the drawing.
aSurfacethe surface to draw into
Returns:
The result of the initialization, NS_Ok if no errors

Implements nsIRenderingContext.

Definition at line 144 of file nsRenderingContextQt.cpp.

Here is the call graph for this function:

XOR Invert a rectangle in the current foreground color.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 790 of file nsRenderingContextQt.cpp.

{
  return InvertRect(aRect.x,aRect.y,aRect.width,aRect.height);
}
NS_IMETHODIMP nsRenderingContextQt::InvertRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

XOR Invert a rectangle in the current foreground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of rectangle in twips
aHeightHeight of rectangle in twips

Implements nsIRenderingContext.

Definition at line 795 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mTranMatrix || nsnull == mSurface
      || nsnull == mSurface->GetGC() || nsnull == mSurface->GetPaintDevice())
    return NS_ERROR_FAILURE;

  nscoord x,y,w,h;

  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;
  mTranMatrix->TransformCoord(&x,&y,&w,&h);

  // After the transform, if the numbers are huge, chop them, because
  // they're going to be converted from 32 bit to 16 bit.
  // It's all way off the screen anyway.
  ConditionRect(x,y,w,h);

  // Set XOR drawing mode
  mFunction = Qt::XorROP;
  UpdateGC();

  // Fill the rect
  QColor color(NS_GET_R(mCurrentColor),
               NS_GET_G(mCurrentColor),
               NS_GET_B(mCurrentColor));

  mSurface->GetGC()->fillRect(x,y,w,h,color);

  // Back to normal copy drawing mode
  mFunction = Qt::CopyROP;
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextQt::IsVisibleRect ( const nsRect aRect,
PRBool aIsVisible 
) [virtual]

Tells if a given rectangle is visible within the rendering context.

Parameters:
aRectis the rectangle that will be checked for visiblity
Returns:
If true, that rectanglular area is visable.

Implements nsIRenderingContext.

Definition at line 299 of file nsRenderingContextQt.cpp.

{
  aVisible = PR_TRUE;
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextQt::LockDrawingSurface ( PRInt32  aX,
PRInt32  aY,
PRUint32  aWidth,
PRUint32  aHeight,
void **  aBits,
PRInt32 aStride,
PRInt32 aWidthBytes,
PRUint32  aFlags 
) [virtual]

Lock a rect of the drawing surface associated with the rendering context.

do not attempt to use any of the Rendering Context rendering or state management methods until the drawing surface has been Unlock()ed. if a drawing surface is Lock()ed with this method, it must be Unlock()ed by calling UnlockDrawingSurface() rather than just calling the Unlock() method on the drawing surface directly. see nsIDrawingSurface.h for more information

Returns:
error status

Implements nsIRenderingContext.

Definition at line 182 of file nsRenderingContextQt.cpp.

{
  PushState();
  return mSurface->Lock(aX,aY,aWidth,aHeight,aBits,aStride,
                        aWidthBytes,aFlags);
}

Here is the call graph for this function:

nsTransform2D* nsRenderingContextQt::matrix ( ) const [inline]

Definition at line 222 of file nsRenderingContextQt.h.

{ return mTranMatrix; }
QPaintDevice* nsRenderingContextQt::paintDevice ( ) const [inline]

Definition at line 221 of file nsRenderingContextQt.h.

{ return mSurface->GetPaintDevice(); }

Here is the call graph for this function:

QPainter* nsRenderingContextQt::painter ( ) const [inline]

Definition at line 220 of file nsRenderingContextQt.h.

{ return mSurface->GetGC(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Get and and set RenderingContext to this graphical state.

Implements nsIRenderingContext.

Definition at line 263 of file nsRenderingContextQt.cpp.

{
  GraphicsState *state;
  PRUint32 cnt = mStateCache.Count();

  if (cnt > 0) {
    state = (GraphicsState*)mStateCache.ElementAt(cnt - 1);
    mStateCache.RemoveElementAt(cnt - 1);

    // Assign all local attributes from the state object just popped
    if (state->mMatrix) {
        delete mTranMatrix;
        mTranMatrix = state->mMatrix;
    }
    mClipRegion.swap(state->mClipRegion);

    if (state->mColor != mCurrentColor)
      SetColor(state->mColor);

    if (state->mLineStyle != mCurrentLineStyle)
      SetLineStyle(state->mLineStyle);

    if (state->mFontMetrics && (mFontMetrics != state->mFontMetrics))
      SetFont(state->mFontMetrics);

    // Delete this graphics state object
#ifdef USE_GS_POOL
    nsGraphicsStatePool::ReleaseGS(state);
#else
    delete state;
#endif
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIRenderingContext.

Definition at line 178 of file nsRenderingContextImpl.cpp.

{
  nsTransform2D *theTransform; 
  GetCurrentTransform(theTransform);
  NS_ASSERTION(theTransform != nsnull, "The rendering context transform is null");
  theTransform->SetTranslation(aState->mSavedX, aState->mSavedY);

  return NS_OK;
}

Here is the call graph for this function:

Save a graphical state onto a stack.

Implements nsIRenderingContext.

Definition at line 233 of file nsRenderingContextQt.cpp.

{
#ifdef USE_GS_POOL
  nsGraphicsState *state = nsGraphicsStatePool::GetNewGS();
#else
  GraphicsState *state = new GraphicsState();
#endif
  if (!state)
    return NS_ERROR_FAILURE;

  // Push into this state object, add to vector
  state->mMatrix = mTranMatrix;

  if (nsnull == mTranMatrix)
    mTranMatrix = new nsTransform2D();
  else
    mTranMatrix = new nsTransform2D(mTranMatrix);

  state->mClipRegion = mClipRegion;

  NS_IF_ADDREF(mFontMetrics);
  state->mFontMetrics = mFontMetrics;

  state->mColor = mCurrentColor;
  state->mLineStyle = mCurrentLineStyle;

  mStateCache.AppendElement(state);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIRenderingContext.

Definition at line 155 of file nsRenderingContextImpl.cpp.

{
  // The transform components are saved and restored instead 
  // of using PushState and PopState because they are too slow
  // because they also save and restore the clip state.
  // Note: Setting a negative translation to restore the 
  // state does not work because the floating point errors can accumulate
  // causing the display of some frames to be off by one pixel. 
  // This happens frequently when running in 120DPI mode where frames are
  // often positioned at 1/2 pixel locations and small floating point errors
  // will cause the frames to vary their pixel x location during scrolling
  // operations causes a single scan line of pixels to be shifted left relative
  // to the other scan lines for the same text. 
  
  // Save the transformation matrix's translation components.
  nsTransform2D *theTransform; 
  GetCurrentTransform(theTransform);
  NS_ASSERTION(theTransform != nsnull, "The rendering context transform is null");
  theTransform->GetTranslation(&aState->mSavedX, &aState->mSavedY);
  
  return NS_OK;
}

Here is the call graph for this function:

QRect nsRenderingContextQt::qRect ( const nsRect aRect) [inline]

Definition at line 224 of file nsRenderingContextQt.h.

                                     {
        int x = aRect.x;
        int y = aRect.y;
        int w = aRect.width;
        int h = aRect.height;
        mTranMatrix->TransformCoord(&x,&y,&w,&h);
        return QRect (x, y, w, h);
    }

Here is the caller graph for this function:

PRBool nsRenderingContextImpl::RectFitsInside ( const nsRect aRect,
PRInt32  aWidth,
PRInt32  aHeight 
) const [protected, inherited]

Determine if a rect's width and height will fit within a specified width and height.

Parameters:
aRectrectangle to test
aWidthwidth to determine if the rectangle's width will fit within
aHeightheight to determine if the rectangles height will fit within
Returns:
PR_TRUE if the rect width and height fits with aWidth, aHeight, PR_FALSE otherwise.

Definition at line 188 of file nsRenderingContextImpl.cpp.

{
  if (aRect.width > aWidth)
    return (PR_FALSE);

  if (aRect.height > aHeight)
    return (PR_FALSE);

  return PR_TRUE;
}

Here is the caller graph for this function:

Release a drawing surface used as the backbuffer If the platform caches the backbuffer this call will destroy it.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK, nsRenderingContextWin, nsRenderingContextXlib, and nsRenderingContextMac.

Definition at line 133 of file nsRenderingContextImpl.cpp.

{
  // If the platform does not require the backbuffer to be cached
  // override this method and call DestroyCachedBackbuffer
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextImpl::RenderEPS ( const nsRect aRect,
FILE aDataFile 
) [virtual, inherited]

Render an encapsulated postscript object onto the current rendering surface.

The EPS object must conform to the EPSF standard. See Adobe specification #5002, "Encapsulated PostScript File Format Specification" at http://partners.adobe.com/asn/developer/pdfs/tn/5002.EPSF_Spec.pdf. In particular, the EPS object must contain a BoundingBox comment.

Parameters:
aRectRectangle in which to render the EPSF.
aDataFile- plugin data stored in a file
Returns:
NS_OK for success, or a suitable error value. NS_ERROR_NOT_IMPLEMENTED is returned if the rendering context doesn't support rendering EPSF,

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextPS, and nsRenderingContextXp.

Definition at line 931 of file nsRenderingContextImpl.cpp.

Reset the rendering context.

Implements nsIRenderingContext.

Definition at line 220 of file nsRenderingContextQt.cpp.

{
  return NS_OK;
}

Definition at line 1251 of file nsRenderingContextQt.cpp.

{
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextQt::Scale ( float  aSx,
float  aSy 
) [virtual]

Add in a scale to the RenderingContext's transformation matrix.

Parameters:
aXThe horizontal scale
aYThe vertical scale

Implements nsIRenderingContext.

Definition at line 551 of file nsRenderingContextQt.cpp.

{
    mTranMatrix->AddScale(aSx,aSy);
    return NS_OK;
}

Selects an offscreen drawing surface into the RenderingContext to draw to.

Parameters:
aSurfaceis the offscreen surface we are going to draw to. if nsnull, the original drawing surface obtained at initialization should be selected.

Implements nsIRenderingContext.

Definition at line 204 of file nsRenderingContextQt.cpp.

{
  if (nsnull == aSurface)
    mSurface = mOffscreenSurface;
  else
    mSurface = (nsDrawingSurfaceQt*)aSurface;
  return NS_OK;
}

Sets the clipping for the RenderingContext to the passed in rectangle.

The rectangle is in app units!

Parameters:
aRectThe rectangle to set the clipping rectangle to
aCombinehow to combine this rect with the current clip region. see the bottom of nsIRenderingContext.h

Implements nsIRenderingContext.

Definition at line 353 of file nsRenderingContextQt.cpp.

{
  GraphicsState *state = nsnull;
  PRUint32 cnt = mStateCache.Count();

  if (cnt > 0) {
    state = (GraphicsState*)mStateCache.ElementAt(cnt - 1);
  }
  if (state) {
    if (state->mClipRegion) {
      if (state->mClipRegion == mClipRegion) {
        nsCOMPtr<nsIRegion> tmpRgn;

        GetClipRegion(getter_AddRefs(tmpRgn));
        mClipRegion = tmpRgn;
      }
    }
  }
  CreateClipRegion();

  nsRect trect = aRect;

  mTranMatrix->TransformCoord(&trect.x,&trect.y,
                              &trect.width,&trect.height);

  switch (aCombine) {
    case nsClipCombine_kIntersect:
      mClipRegion->Intersect(trect.x,trect.y,trect.width,trect.height);
      break;

    case nsClipCombine_kUnion:
      mClipRegion->Union(trect.x,trect.y,trect.width,trect.height);
      break;

    case nsClipCombine_kSubtract:
      mClipRegion->Subtract(trect.x,trect.y,trect.width,trect.height);
      break;

    case nsClipCombine_kReplace:
      mClipRegion->SetTo(trect.x,trect.y,trect.width,trect.height);
      break;
  }

  return NS_OK;
}

Here is the call graph for this function:

Sets the clipping for the RenderingContext to the passed in region.

The region is in device coordinates!

Parameters:
aRegionThe region to set the clipping area to, IN DEVICE COORDINATES
aCombinehow to combine this region with the current clip region. see the bottom of nsIRenderingContext.h

Implements nsIRenderingContext.

Definition at line 400 of file nsRenderingContextQt.cpp.

{
  PRUint32 cnt = mStateCache.Count();
  GraphicsState *state = nsnull;

  if (cnt > 0) {
    state = (GraphicsState *)mStateCache.ElementAt(cnt - 1);
  }
  if (state) {
    if (state->mClipRegion) {
      if (state->mClipRegion == mClipRegion) {
        nsCOMPtr<nsIRegion> tmpRgn;

        GetClipRegion(getter_AddRefs(tmpRgn));
        mClipRegion = tmpRgn;
      }
    }
  }
  CreateClipRegion();

  switch(aCombine) {
    case nsClipCombine_kIntersect:
      mClipRegion->Intersect(aRegion);
      break;

    case nsClipCombine_kUnion:
      mClipRegion->Union(aRegion);
      break;

    case nsClipCombine_kSubtract:
      mClipRegion->Subtract(aRegion);
      break;

    case nsClipCombine_kReplace:
      mClipRegion->SetTo(aRegion);
      break;
  }

  return NS_OK;
}

Here is the call graph for this function:

Sets the forground color for the RenderingContext.

Parameters:
aColorThe color to set the RenderingContext to

Implements nsIRenderingContext.

Definition at line 464 of file nsRenderingContextQt.cpp.

{
  if (nsnull == mContext)
    return NS_ERROR_FAILURE;

  mCurrentColor = aColor;
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextQt::SetFont ( const nsFont aFont,
nsIAtom aLangGroup 
) [virtual]

Sets the font for the RenderingContext.

Parameters:
aFontThe font to use in the RenderingContext

Implements nsIRenderingContext.

Definition at line 479 of file nsRenderingContextQt.cpp.

{
  nsCOMPtr<nsIFontMetrics> newMetrics;
  nsresult rv = mContext->GetMetricsFor(aFont, aLangGroup, *getter_AddRefs(newMetrics));

  if (NS_SUCCEEDED(rv)) {
    rv = SetFont(newMetrics);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Sets the font for the RenderingContext.

Parameters:
aFontMetricThe font metrics representing the font to use in the RenderingContext

Implements nsIRenderingContext.

Definition at line 490 of file nsRenderingContextQt.cpp.

{
  NS_IF_RELEASE(mFontMetrics);
  mFontMetrics = aFontMetrics;
  NS_IF_ADDREF(mFontMetrics);

  if (mFontMetrics) {
    nsFontHandle fontHandle;

    mFontMetrics->GetFontHandle(fontHandle);
    mCurrentFont = (nsFontQt*)fontHandle;
  }
  return NS_OK;
}

Here is the call graph for this function:

Sets the line style for the RenderingContext.

Parameters:
aLineStyleThe line style
Returns:
NS_OK if the line style is correctly set

Implements nsIRenderingContext.

Definition at line 505 of file nsRenderingContextQt.cpp.

{
  if (aLineStyle != mCurrentLineStyle) {
    switch (aLineStyle) {
      case nsLineStyle_kSolid:
        mQLineStyle = QPen::SolidLine;
        break;

      case nsLineStyle_kDashed:
        mQLineStyle = QPen::DashLine;
        break;

      case nsLineStyle_kDotted:
        mQLineStyle = QPen::DotLine;
        break;

      default:
        break;
    }
    mCurrentLineStyle = aLineStyle ;
  }
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::SetPenMode ( nsPenMode  aPenMode) [inline, virtual, inherited]

Sets the Pen Mode for the RenderingContext.

Parameters:
aPenModeThe Pen Mode
Returns:
NS_OK if the Pen Mode is correctly set

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextWin.

Definition at line 90 of file nsRenderingContextImpl.h.

{ return NS_ERROR_FAILURE;};

Let the device context know whether we want text reordered with right-to-left base direction.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 287 of file nsRenderingContextImpl.cpp.

{
  return NS_OK;
}

Add in a translate to the RenderingContext's transformation matrix.

Parameters:
aXThe horizontal translation
aYThe vertical translation

Implements nsIRenderingContext.

Definition at line 544 of file nsRenderingContextQt.cpp.

{
    mTranMatrix->AddTranslation((float)aX,(float)aY);
    return NS_OK;
}

Unlock a rect of the drawing surface associated with the rendering context.

see nsIDrawingSurface.h for more information.

Returns:
error status

Implements nsIRenderingContext.

Definition at line 196 of file nsRenderingContextQt.cpp.

{
  PopState();
  mSurface->Unlock();
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 605 of file nsRenderingContextQt.cpp.

{
  QPainter *pGC;
  QColor color(NS_GET_R(mCurrentColor),
               NS_GET_G(mCurrentColor),
               NS_GET_B(mCurrentColor));
  QPen   pen(color,0,mQLineStyle);
  QBrush brush(color);

  pGC = mSurface->GetGC();
  pGC->setPen(pen);
  pGC->setBrush(brush);
  pGC->setRasterOp(mFunction);
  if (mCurrentFont)
    pGC->setFont(mCurrentFont->font);
  if (mClipRegion) {
     QRegion *rgn = nsnull;

     pGC->setClipping(TRUE);
     mClipRegion->GetNativeRegion((void*&)rgn);
     pGC->setClipRegion(*rgn);
  }
  else {
    pGC->setClipping(FALSE);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextImpl::UseBackbuffer ( PRBool aUseBackbuffer) [virtual, inherited]

Some platforms may not want a backbuffer at all.

Returning false here allows them to achieve that

Parameters:
aUseBackbufferPR_TRUE if we should use a backbuffer, PR_FALSE if not

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextMac.

Definition at line 149 of file nsRenderingContextImpl.cpp.

{
  *aUseBackbuffer = PR_TRUE;
  return NS_OK;
}

Member Data Documentation

int nsRenderingContextImpl::mAct [protected, inherited]

Definition at line 65 of file nsRenderingContextImpl.h.

Edge* nsRenderingContextImpl::mActive [protected, inherited]

Definition at line 66 of file nsRenderingContextImpl.h.

Definition at line 238 of file nsRenderingContextQt.h.

Definition at line 236 of file nsRenderingContextQt.h.

Definition at line 244 of file nsRenderingContextQt.h.

Definition at line 247 of file nsRenderingContextQt.h.

Definition at line 245 of file nsRenderingContextQt.h.

Definition at line 237 of file nsRenderingContextQt.h.

Qt::RasterOp nsRenderingContextQt::mFunction [protected]

Definition at line 249 of file nsRenderingContextQt.h.

Definition at line 234 of file nsRenderingContextQt.h.

float nsRenderingContextQt::mP2T [protected]

Definition at line 239 of file nsRenderingContextQt.h.

Definition at line 321 of file nsRenderingContextImpl.h.

Qt::PenStyle nsRenderingContextQt::mQLineStyle [protected]

Definition at line 248 of file nsRenderingContextQt.h.

Definition at line 242 of file nsRenderingContextQt.h.

Definition at line 235 of file nsRenderingContextQt.h.

nsTransform2D* nsRenderingContextImpl::mTranMatrix [protected, inherited]

Definition at line 64 of file nsRenderingContextImpl.h.


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