2001-09-26 00:16:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 00:16:04 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:43:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* Contributor(s):
|
2003-07-23 14:10:12 +00:00
|
|
|
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
|
|
|
* Leon Sha <leon.sha@sun.com>
|
|
|
|
* Boris Zbarsky <bzbarsky@mit.edu>
|
2001-09-26 00:16:04 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-26 00:16:04 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 00:16:04 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-26 00:16:04 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#ifndef nsIRenderingContext_h___
|
|
|
|
#define nsIRenderingContext_h___
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsColor.h"
|
|
|
|
#include "nsCoord.h"
|
2005-08-23 02:11:54 +00:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsSize.h"
|
2004-09-20 06:46:16 +00:00
|
|
|
#include <stdio.h>
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
class nsIWidget;
|
|
|
|
class nsIFontMetrics;
|
|
|
|
class nsTransform2D;
|
|
|
|
class nsString;
|
|
|
|
class nsIDeviceContext;
|
1998-05-18 21:46:20 +00:00
|
|
|
class nsIRegion;
|
2002-05-24 20:11:14 +00:00
|
|
|
class nsIAtom;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
struct nsFont;
|
2001-09-27 18:29:17 +00:00
|
|
|
struct nsTextDimensions;
|
1999-11-11 04:24:51 +00:00
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
struct nsBoundingMetrics;
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-11-29 20:12:29 +00:00
|
|
|
class gfxASurface;
|
2006-02-15 23:35:53 +00:00
|
|
|
class gfxContext;
|
2005-11-29 20:12:29 +00:00
|
|
|
|
2001-03-22 04:45:42 +00:00
|
|
|
/* gfx2 */
|
|
|
|
class imgIContainer;
|
|
|
|
|
1998-05-27 02:13:28 +00:00
|
|
|
//cliprect/region combination methods
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
nsClipCombine_kIntersect = 0,
|
|
|
|
nsClipCombine_kUnion = 1,
|
|
|
|
nsClipCombine_kSubtract = 2,
|
|
|
|
nsClipCombine_kReplace = 3
|
|
|
|
} nsClipCombine;
|
|
|
|
|
1998-09-30 22:24:46 +00:00
|
|
|
//linestyles
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
nsLineStyle_kNone = 0,
|
|
|
|
nsLineStyle_kSolid = 1,
|
|
|
|
nsLineStyle_kDashed = 2,
|
|
|
|
nsLineStyle_kDotted = 3
|
|
|
|
} nsLineStyle;
|
|
|
|
|
2001-08-21 22:37:17 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
nsPenMode_kNone = 0,
|
2001-08-22 01:10:21 +00:00
|
|
|
nsPenMode_kInvert = 1
|
2001-08-21 22:37:17 +00:00
|
|
|
} nsPenMode;
|
|
|
|
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// IID for the nsIRenderingContext interface
|
2007-06-27 22:15:13 +00:00
|
|
|
// a67de6b9-fffa-465c-abea-d7b394588a07
|
1998-09-07 19:12:44 +00:00
|
|
|
#define NS_IRENDERING_CONTEXT_IID \
|
2007-06-27 22:15:13 +00:00
|
|
|
{ 0xa67de6b9, 0xfffa, 0x465c,{0xab, 0xea, 0xd7, 0xb3, 0x94, 0x58, 0x8a, 0x07}}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// RenderingContext interface
|
|
|
|
class nsIRenderingContext : public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRENDERING_CONTEXT_IID)
|
1998-12-17 22:13:41 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//TBD: bind/unbind, transformation of scalars (hacky),
|
|
|
|
//potential drawmode for selection, polygons. MMP
|
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Initialize the RenderingContext
|
|
|
|
* @param aContext the device context to use.
|
|
|
|
* @param aWidget the widget to hook up to
|
|
|
|
* @result The result of the initialization, NS_Ok if no errors
|
|
|
|
*/
|
1998-11-14 02:05:13 +00:00
|
|
|
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWidget) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
2005-11-29 20:12:29 +00:00
|
|
|
/**
|
|
|
|
* Initialize the RenderingContext
|
|
|
|
* @param aContext the device context to use for the drawing.
|
|
|
|
* @param aThebesSurface the Thebes gfxASurface to which to draw
|
|
|
|
* @result The result of the initialization, NS_Ok if no errors
|
|
|
|
*/
|
|
|
|
NS_IMETHOD Init(nsIDeviceContext* aContext, gfxASurface* aThebesSurface) = 0;
|
2006-02-15 23:35:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the RenderingContext
|
|
|
|
* @param aContext the device context to use for the drawing.
|
|
|
|
* @param aThebesContext an existing thebes context to use for the drawing
|
|
|
|
* @result The result of the initialization, NS_Ok if no errors
|
|
|
|
*/
|
|
|
|
NS_IMETHOD Init(nsIDeviceContext* aContext, gfxContext* aThebesContext) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
1998-05-05 22:11:50 +00:00
|
|
|
/**
|
2006-11-13 21:31:53 +00:00
|
|
|
* Get the DeviceContext that this RenderingContext was initialized
|
|
|
|
* with. This function addrefs the device context. Though it might
|
|
|
|
* be better if it just returned it directly, without addrefing.
|
1998-05-05 22:11:50 +00:00
|
|
|
* @result the device context
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD GetDeviceContext(nsIDeviceContext *& aDeviceContext) = 0;
|
1998-05-05 22:11:50 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Save a graphical state onto a stack.
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD PushState(void) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get and and set RenderingContext to this graphical state
|
|
|
|
*/
|
2004-04-18 13:13:35 +00:00
|
|
|
NS_IMETHOD PopState(void) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-08-23 02:11:54 +00:00
|
|
|
// XXX temporary
|
|
|
|
NS_IMETHOD PushFilter(const nsRect& aRect, PRBool aAreaIsOpaque, float aOpacity)
|
|
|
|
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
NS_IMETHOD PopFilter()
|
|
|
|
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
2003-04-06 02:49:40 +00:00
|
|
|
* Sets the clipping for the RenderingContext to the passed in rectangle.
|
|
|
|
* The rectangle is in app units!
|
1998-04-14 22:20:32 +00:00
|
|
|
* @param aRect The rectangle to set the clipping rectangle to
|
1998-05-27 02:13:28 +00:00
|
|
|
* @param aCombine how to combine this rect with the current clip region.
|
|
|
|
* see the bottom of nsIRenderingContext.h
|
1998-04-14 22:20:32 +00:00
|
|
|
*/
|
2004-04-23 15:21:24 +00:00
|
|
|
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
1998-09-30 22:24:46 +00:00
|
|
|
/**
|
|
|
|
* Sets the line style for the RenderingContext
|
|
|
|
* @param aLineStyle The line style
|
|
|
|
* @return NS_OK if the line style is correctly set
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle) = 0;
|
|
|
|
|
1998-05-18 21:46:20 +00:00
|
|
|
/**
|
2003-04-06 02:49:40 +00:00
|
|
|
* Sets the clipping for the RenderingContext to the passed in region.
|
|
|
|
* The region is in device coordinates!
|
2001-10-23 01:37:29 +00:00
|
|
|
* @param aRegion The region to set the clipping area to, IN DEVICE COORDINATES
|
1998-05-27 02:13:28 +00:00
|
|
|
* @param aCombine how to combine this region with the current clip region.
|
|
|
|
* see the bottom of nsIRenderingContext.h
|
|
|
|
*/
|
2004-04-23 15:21:24 +00:00
|
|
|
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine) = 0;
|
1998-05-27 02:13:28 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Sets the forground color for the RenderingContext
|
|
|
|
* @param aColor The color to set the RenderingContext to
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD SetColor(nscolor aColor) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the forground color for the RenderingContext
|
|
|
|
* @return The current forground color of the RenderingContext
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD GetColor(nscolor &aColor) const = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Sets the font for the RenderingContext
|
|
|
|
* @param aFont The font to use in the RenderingContext
|
|
|
|
*/
|
2002-05-24 20:11:14 +00:00
|
|
|
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
1998-10-01 03:36:06 +00:00
|
|
|
/**
|
|
|
|
* Sets the font for the RenderingContext
|
|
|
|
* @param aFontMetric The font metrics representing the
|
|
|
|
* font to use in the RenderingContext
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Get the current fontmetrics for the RenderingContext
|
|
|
|
* @return The current font of the RenderingContext
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Add in a translate to the RenderingContext's transformation matrix
|
|
|
|
* @param aX The horizontal translation
|
|
|
|
* @param aY The vertical translation
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD Translate(nscoord aX, nscoord aY) = 0;
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the translation compoennt of the current transformation matrix.
|
|
|
|
* Useful to set it to a known pixel value without incurring roundoff
|
|
|
|
* errors.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetTranslation(nscoord aX, nscoord aY) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add in a scale to the RenderingContext's transformation matrix
|
|
|
|
* @param aX The horizontal scale
|
|
|
|
* @param aY The vertical scale
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD Scale(float aSx, float aSy) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
2005-04-19 22:58:33 +00:00
|
|
|
struct PushedTranslation {
|
|
|
|
float mSavedX, mSavedY;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AutoPushTranslation {
|
|
|
|
nsIRenderingContext* mCtx;
|
|
|
|
PushedTranslation mPushed;
|
|
|
|
public:
|
|
|
|
AutoPushTranslation(nsIRenderingContext* aCtx, nscoord aX, nscoord aY)
|
|
|
|
: mCtx(aCtx) {
|
|
|
|
mCtx->PushTranslation(&mPushed);
|
|
|
|
mCtx->Translate(aX, aY);
|
|
|
|
}
|
|
|
|
~AutoPushTranslation() {
|
|
|
|
mCtx->PopTranslation(&mPushed);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHOD PushTranslation(PushedTranslation* aState) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD PopTranslation(PushedTranslation* aState) = 0;
|
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Get the current transformation matrix for the RenderingContext
|
|
|
|
* @return The transformation matrix for the RenderingContext
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Draw a line
|
|
|
|
* @param aXO starting horiztonal coord in twips
|
|
|
|
* @param aY0 starting vertical coord in twips
|
|
|
|
* @param aX1 end horiztonal coord in twips
|
|
|
|
* @param aY1 end vertical coord in twips
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Draw a rectangle
|
|
|
|
* @param aRect The rectangle to draw
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD DrawRect(const nsRect& aRect) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw a rectangle
|
|
|
|
* @param aX Horizontal left Coordinate in twips
|
|
|
|
* @param aY Vertical top Coordinate in twips
|
|
|
|
* @param aWidth Width of rectangle in twips
|
|
|
|
* @param aHeight Height of rectangle in twips
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill a rectangle in the current foreground color
|
|
|
|
* @param aRect The rectangle to draw
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD FillRect(const nsRect& aRect) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill a rectangle in the current foreground color
|
|
|
|
* @param aX Horizontal left Coordinate in twips
|
|
|
|
* @param aY Vertical top Coordinate in twips
|
|
|
|
* @param aWidth Width of rectangle in twips
|
|
|
|
* @param aHeight Height of rectangle in twips
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-07-20 07:26:09 +00:00
|
|
|
/**
|
|
|
|
* XOR Invert a rectangle in the current foreground color
|
|
|
|
* @param aRect The rectangle to draw
|
|
|
|
*/
|
|
|
|
NS_IMETHOD InvertRect(const nsRect& aRect) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XOR Invert a rectangle in the current foreground color
|
|
|
|
* @param aX Horizontal left Coordinate in twips
|
|
|
|
* @param aY Vertical top Coordinate in twips
|
|
|
|
* @param aWidth Width of rectangle in twips
|
|
|
|
* @param aHeight Height of rectangle in twips
|
|
|
|
*/
|
|
|
|
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Fill a poly in the current foreground color
|
|
|
|
* @param aPoints points to use for the drawing, last must equal first
|
|
|
|
* @param aNumPonts number of points in the polygon
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Draw an ellipse in the current foreground color
|
|
|
|
* @param aRect The rectangle define bounds of ellipse to draw
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD DrawEllipse(const nsRect& aRect) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw an ellipse in the current foreground color
|
|
|
|
* @param aX Horizontal left Coordinate in twips
|
|
|
|
* @param aY Vertical top Coordinate in twips
|
|
|
|
* @param aWidth Width of horizontal axis in twips
|
|
|
|
* @param aHeight Height of vertical axis in twips
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
1998-04-14 22:20:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill an ellipse in the current foreground color
|
|
|
|
* @param aRect The rectangle define bounds of ellipse to draw
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD FillEllipse(const nsRect& aRect) = 0;
|
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Fill an ellipse in the current foreground color
|
|
|
|
* @param aX Horizontal left Coordinate in twips
|
|
|
|
* @param aY Vertical top Coordinate in twips
|
|
|
|
* @param aWidth Width of horizontal axis in twips
|
|
|
|
* @param aHeight Height of vertical axis in twips
|
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
|
|
|
|
1998-10-02 01:07:56 +00:00
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of an 8-bit character
|
1998-10-02 18:19:30 +00:00
|
|
|
* If no font has been Set, the results are undefined.
|
|
|
|
* @param aC character to measure
|
|
|
|
* @param aWidth out parameter for width
|
|
|
|
* @return error status
|
1998-10-02 01:07:56 +00:00
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD GetWidth(char aC, nscoord &aWidth) = 0;
|
1998-10-02 01:07:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of a unicode character
|
1998-10-02 18:19:30 +00:00
|
|
|
* If no font has been Set, the results are undefined.
|
|
|
|
* @param aC character to measure
|
|
|
|
* @param aWidth out parameter for width
|
1999-01-28 05:03:05 +00:00
|
|
|
* @param aFontID an optional out parameter used to store a
|
|
|
|
* font identifier that can be passed into the DrawString()
|
|
|
|
* methods to speed rendering
|
1998-10-02 18:19:30 +00:00
|
|
|
* @return error status
|
1998-10-02 01:07:56 +00:00
|
|
|
*/
|
1999-01-28 05:03:05 +00:00
|
|
|
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
|
|
|
|
PRInt32 *aFontID = nsnull) = 0;
|
1998-10-02 01:07:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of an nsString
|
1998-10-02 18:19:30 +00:00
|
|
|
* If no font has been Set, the results are undefined.
|
|
|
|
* @param aString string to measure
|
|
|
|
* @param aWidth out parameter for width
|
1999-01-28 05:03:05 +00:00
|
|
|
* @param aFontID an optional out parameter used to store a
|
|
|
|
* font identifier that can be passed into the DrawString()
|
|
|
|
* methods to speed rendering
|
1998-10-02 18:19:30 +00:00
|
|
|
* @return error status
|
1998-10-02 01:07:56 +00:00
|
|
|
*/
|
1999-01-28 05:03:05 +00:00
|
|
|
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
|
|
|
|
PRInt32 *aFontID = nsnull) = 0;
|
1998-10-02 01:07:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of an 8-bit character string
|
1998-10-02 18:19:30 +00:00
|
|
|
* If no font has been Set, the results are undefined.
|
|
|
|
* @param aString string to measure
|
|
|
|
* @param aWidth out parameter for width
|
|
|
|
* @return error status
|
1998-10-02 01:07:56 +00:00
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth) = 0;
|
1998-10-02 01:07:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of an 8-bit character string
|
1998-10-02 18:19:30 +00:00
|
|
|
* If no font has been Set, the results are undefined.
|
|
|
|
* @param aString string to measure
|
|
|
|
* @param aLength number of characters in string
|
|
|
|
* @param aWidth out parameter for width
|
|
|
|
* @return error status
|
1998-10-02 01:07:56 +00:00
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
|
|
|
|
nscoord& aWidth) = 0;
|
1998-10-02 01:07:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of a Unicode character string
|
1998-10-02 18:19:30 +00:00
|
|
|
* If no font has been Set, the results are undefined.
|
|
|
|
* @param aString string to measure
|
|
|
|
* @param aLength number of characters in string
|
|
|
|
* @param aWidth out parameter for width
|
1999-01-28 05:03:05 +00:00
|
|
|
* @param aFontID an optional out parameter used to store a
|
|
|
|
* font identifier that can be passed into the DrawString()
|
|
|
|
* methods to speed rendering
|
1998-10-02 18:19:30 +00:00
|
|
|
* @return error status
|
1998-10-02 01:07:56 +00:00
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
|
1999-01-28 05:03:05 +00:00
|
|
|
nscoord &aWidth, PRInt32 *aFontID = nsnull) = 0;
|
1998-10-02 01:07:56 +00:00
|
|
|
|
2000-03-31 03:34:05 +00:00
|
|
|
/**
|
2001-09-27 18:29:17 +00:00
|
|
|
* 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.
|
|
|
|
* @param aString string to measure
|
2000-04-12 14:49:46 +00:00
|
|
|
* @param aLength number of characters in string
|
|
|
|
* @param aFontID an optional out parameter used to store a
|
|
|
|
* font identifier that can be passed into the DrawString()
|
2001-09-27 18:29:17 +00:00
|
|
|
* methods to speed measurements
|
|
|
|
* @return aDimensions struct that contains the extent of the string (see below)
|
2000-04-12 14:49:46 +00:00
|
|
|
*/
|
2001-09-27 18:29:17 +00:00
|
|
|
NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
|
|
|
|
nsTextDimensions& aDimensions) = 0;
|
|
|
|
NS_IMETHOD GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
|
|
|
|
nsTextDimensions& aDimensions, PRInt32* aFontID = nsnull) = 0;
|
2000-04-12 14:49:46 +00:00
|
|
|
|
2003-04-19 16:40:06 +00:00
|
|
|
#if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11) || defined(XP_BEOS)
|
2000-04-12 14:49:46 +00:00
|
|
|
/**
|
|
|
|
* Given an available width and an array of break points,
|
2001-09-27 18:29:17 +00:00
|
|
|
* returns the dimensions (in app units) of the text that fit and
|
2000-04-12 14:49:46 +00:00
|
|
|
* the number of characters that fit. The number of characters
|
|
|
|
* corresponds to an entry in the break array.
|
2001-09-27 18:29:17 +00:00
|
|
|
* If no font has been set, the results are undefined.
|
|
|
|
* @param aString, string to measure
|
|
|
|
* @param aLength, number of characters in string
|
|
|
|
* @param aAvailWidth, the available space in which the text must fit
|
|
|
|
* @param aBreaks, array of places to break. Specified as offsets from the
|
2000-03-31 03:34:05 +00:00
|
|
|
* start of the string
|
2001-09-27 18:29:17 +00:00
|
|
|
* @param aNumBreaks, the number of entries in the break array. The last
|
2000-03-31 03:34:05 +00:00
|
|
|
* entry in the break array must equal the length of the string
|
2001-09-27 18:29:17 +00:00
|
|
|
* @param aDimensions, out parameter for the dimensions, the ascent and descent
|
|
|
|
* of the last word are left out to allow possible line-breaking before
|
|
|
|
* the last word. However, the width of the last word is included.
|
|
|
|
* @param aNumCharsFit, the number of characters that fit in the available space
|
|
|
|
* @param aLastWordDimensions, dimensions of the last word, the width field,
|
|
|
|
* dimensions.width, should be -1 for an unknown width. But the
|
|
|
|
* ascent and descent are expected to be known.
|
|
|
|
* @param aFontID, an optional out parameter used to store a
|
2000-03-31 03:34:05 +00:00
|
|
|
* font identifier that can be passed into the DrawString()
|
|
|
|
* methods to speed rendering
|
|
|
|
* @return error status
|
|
|
|
*/
|
2001-09-27 18:29:17 +00:00
|
|
|
NS_IMETHOD GetTextDimensions(const char* aString,
|
|
|
|
PRInt32 aLength,
|
|
|
|
PRInt32 aAvailWidth,
|
|
|
|
PRInt32* aBreaks,
|
|
|
|
PRInt32 aNumBreaks,
|
|
|
|
nsTextDimensions& aDimensions,
|
|
|
|
PRInt32& aNumCharsFit,
|
|
|
|
nsTextDimensions& aLastWordDimensions,
|
|
|
|
PRInt32* aFontID = nsnull) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
|
|
|
|
PRInt32 aLength,
|
|
|
|
PRInt32 aAvailWidth,
|
|
|
|
PRInt32* aBreaks,
|
|
|
|
PRInt32 aNumBreaks,
|
|
|
|
nsTextDimensions& aDimensions,
|
|
|
|
PRInt32& aNumCharsFit,
|
|
|
|
nsTextDimensions& aLastWordDimensions,
|
|
|
|
PRInt32* aFontID = nsnull) = 0;
|
2000-03-31 03:34:05 +00:00
|
|
|
#endif
|
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Draw a string in the RenderingContext
|
|
|
|
* @param aString The string to draw
|
|
|
|
* @param aLength The length of the aString
|
|
|
|
* @param aX Horizontal starting point of baseline
|
|
|
|
* @param aY Vertical starting point of baseline.
|
1998-10-26 17:12:39 +00:00
|
|
|
* @param aSpacing inter-character spacing to apply
|
1998-04-14 22:20:32 +00:00
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
|
|
|
|
nscoord aX, nscoord aY,
|
|
|
|
const nscoord* aSpacing = nsnull) = 0;
|
1998-09-07 19:12:44 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Draw a string in the RenderingContext
|
|
|
|
* @param aString A PRUnichar of the string
|
|
|
|
* @param aLength The length of the aString
|
|
|
|
* @param aX Horizontal starting point of baseline
|
|
|
|
* @param aY Vertical starting point of baseline.
|
1999-01-28 05:03:05 +00:00
|
|
|
* @param aFontID an optional parameter used to speed font
|
|
|
|
* selection for complex unicode strings. the value
|
|
|
|
* passed is returned by the DrawString() methods.
|
1998-10-26 17:12:39 +00:00
|
|
|
* @param aSpacing inter-character spacing to apply
|
1998-04-14 22:20:32 +00:00
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
|
|
|
|
nscoord aX, nscoord aY,
|
1999-01-28 05:03:05 +00:00
|
|
|
PRInt32 aFontID = -1,
|
1998-10-30 02:08:25 +00:00
|
|
|
const nscoord* aSpacing = nsnull) = 0;
|
1998-09-07 19:12:44 +00:00
|
|
|
|
1998-04-14 22:20:32 +00:00
|
|
|
/**
|
|
|
|
* Draw a string in the RenderingContext
|
|
|
|
* @param aString A nsString of the string
|
|
|
|
* @param aX Horizontal starting point of baseline
|
|
|
|
* @param aY Vertical starting point of baseline.
|
1999-01-28 05:03:05 +00:00
|
|
|
* @param aFontID an optional parameter used to speed font
|
|
|
|
* selection for complex unicode strings. the value
|
|
|
|
* passed is returned by the DrawString() methods.
|
1998-10-26 17:12:39 +00:00
|
|
|
* @param aSpacing inter-character spacing to apply
|
1998-04-14 22:20:32 +00:00
|
|
|
*/
|
1998-10-30 02:08:25 +00:00
|
|
|
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
|
1999-01-28 05:03:05 +00:00
|
|
|
PRInt32 aFontID = -1,
|
1998-10-30 02:08:25 +00:00
|
|
|
const nscoord* aSpacing = nsnull) = 0;
|
2000-05-08 14:25:51 +00:00
|
|
|
|
2005-08-23 02:11:54 +00:00
|
|
|
enum GraphicDataType {
|
|
|
|
NATIVE_CAIRO_CONTEXT = 1,
|
|
|
|
NATIVE_GDK_DRAWABLE = 2,
|
|
|
|
NATIVE_WINDOWS_DC = 3,
|
|
|
|
NATIVE_MAC_THING = 4,
|
2008-03-11 00:10:55 +00:00
|
|
|
NATIVE_THEBES_CONTEXT = 5,
|
|
|
|
NATIVE_OS2_PS = 6
|
2005-08-23 02:11:54 +00:00
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Retrieve the native graphic data given by aType. Return
|
|
|
|
* nsnull if not available.
|
|
|
|
*/
|
|
|
|
virtual void* GetNativeGraphicData(GraphicDataType aType) = 0;
|
2001-12-12 01:35:31 +00:00
|
|
|
|
1999-11-11 04:24:51 +00:00
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
/**
|
|
|
|
* Returns bounding metrics (in app units) of an 8-bit character string
|
|
|
|
* @param aString string to measure
|
|
|
|
* @param aLength number of characters in string
|
|
|
|
* @return aBoundingMetrics struct that contains various metrics (see below)
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD
|
|
|
|
GetBoundingMetrics(const char* aString,
|
|
|
|
PRUint32 aLength,
|
|
|
|
nsBoundingMetrics& aBoundingMetrics) = 0;
|
|
|
|
/**
|
|
|
|
* Returns bounding metrics (in app units) of an Unicode character string
|
|
|
|
* @param aString string to measure
|
|
|
|
* @param aLength number of characters in string
|
|
|
|
* @param aFontID an optional out parameter used to store a
|
|
|
|
* font identifier that can be passed into the GetBoundingMetrics()
|
|
|
|
* methods to speed measurements
|
|
|
|
* @return aBoundingMetrics struct that contains various metrics (see below)
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD
|
|
|
|
GetBoundingMetrics(const PRUnichar* aString,
|
|
|
|
PRUint32 aLength,
|
|
|
|
nsBoundingMetrics& aBoundingMetrics,
|
|
|
|
PRInt32* aFontID = nsnull) = 0;
|
|
|
|
#endif
|
2001-03-22 04:45:42 +00:00
|
|
|
|
|
|
|
|
2001-04-11 23:02:32 +00:00
|
|
|
/**
|
|
|
|
* Let the device context know whether we want text reordered with
|
|
|
|
* right-to-left base direction
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL) = 0;
|
|
|
|
|
2007-01-23 02:58:55 +00:00
|
|
|
/**
|
|
|
|
* This sets the direction of the text; all characters should be
|
|
|
|
* overridden to have this direction.
|
|
|
|
*/
|
2007-06-27 21:53:34 +00:00
|
|
|
virtual void SetTextRunRTL(PRBool aIsRTL) = 0;
|
2001-03-22 04:45:42 +00:00
|
|
|
|
2003-05-29 23:29:37 +00:00
|
|
|
/*
|
|
|
|
* Tiles an image over an area
|
|
|
|
* @param aImage Image to tile
|
|
|
|
* @param aXImageStart x location where the origin (0,0) of the image starts
|
|
|
|
* @param aYImageStart y location where the origin (0,0) of the image starts
|
|
|
|
* @param aTargetRect area to draw to
|
2008-03-31 09:40:53 +00:00
|
|
|
* @param aSubimageRect the subimage (in tile space) which we expect to
|
|
|
|
* sample from; may be null to indicate that the whole image is
|
|
|
|
* OK to sample from
|
2003-05-29 23:29:37 +00:00
|
|
|
*/
|
|
|
|
NS_IMETHOD DrawTile(imgIContainer *aImage,
|
|
|
|
nscoord aXImageStart, nscoord aYImageStart,
|
2008-03-31 09:40:53 +00:00
|
|
|
const nsRect * aTargetRect,
|
|
|
|
const nsIntRect * aSubimageRect) = 0;
|
2005-05-02 20:48:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param aText Text on which to operate.
|
|
|
|
* @param aLength Length of the text.
|
|
|
|
* @param aPt the x/y position in the string to check.
|
|
|
|
*
|
|
|
|
* @return 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetPosition(const PRUnichar *aText,
|
|
|
|
PRUint32 aLength,
|
|
|
|
nsPoint aPt) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param aText Text on which to operate
|
|
|
|
* @param aLength Length of the text
|
|
|
|
* @param aStart Start index into the string
|
|
|
|
* @param aEnd End index into the string (inclusive)
|
|
|
|
* @param aWidth Returned with in app coordinates
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetRangeWidth(const PRUnichar *aText,
|
|
|
|
PRUint32 aLength,
|
|
|
|
PRUint32 aStart,
|
|
|
|
PRUint32 aEnd,
|
|
|
|
PRUint32 &aWidth) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the width for the specific range of a given string.
|
|
|
|
*
|
|
|
|
* Same as GetRangeWidth for PRUnichar, but takes a char * as the
|
|
|
|
* text argument.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetRangeWidth(const char *aText,
|
|
|
|
PRUint32 aLength,
|
|
|
|
PRUint32 aStart,
|
|
|
|
PRUint32 aEnd,
|
|
|
|
PRUint32 &aWidth) = 0;
|
|
|
|
|
2003-07-23 14:10:12 +00:00
|
|
|
/**
|
2004-09-20 06:46:16 +00:00
|
|
|
* Render an encapsulated postscript object onto the current rendering
|
2003-07-23 14:10:12 +00:00
|
|
|
* surface.
|
|
|
|
*
|
2004-09-20 06:46:16 +00:00
|
|
|
* 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.
|
2003-07-23 14:10:12 +00:00
|
|
|
*
|
2004-09-20 06:46:16 +00:00
|
|
|
* @param aRect Rectangle in which to render the EPSF.
|
|
|
|
* @param aDataFile - plugin data stored in a file
|
|
|
|
* @return NS_OK for success, or a suitable error value.
|
|
|
|
* NS_ERROR_NOT_IMPLEMENTED is returned if the rendering context
|
|
|
|
* doesn't support rendering EPSF,
|
2003-07-23 14:10:12 +00:00
|
|
|
*/
|
2004-09-20 06:46:16 +00:00
|
|
|
NS_IMETHOD RenderEPS(const nsRect& aRect, FILE *aDataFile) = 0;
|
2007-12-18 23:01:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the Thebes gfxContext associated with this nsIRenderingContext.
|
|
|
|
*/
|
|
|
|
virtual gfxContext *ThebesContext() = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIRenderingContext, NS_IRENDERING_CONTEXT_IID)
|
|
|
|
|
1998-10-23 17:58:18 +00:00
|
|
|
//flags for copy CopyOffScreenBits
|
|
|
|
|
|
|
|
//when performing the blit, use the region, if any,
|
|
|
|
//that exists in the source drawingsurface as a
|
|
|
|
//blit mask.
|
|
|
|
#define NS_COPYBITS_USE_SOURCE_CLIP_REGION 0x0001
|
|
|
|
|
|
|
|
//transform the source offsets by the xform in the
|
|
|
|
//rendering context
|
|
|
|
#define NS_COPYBITS_XFORM_SOURCE_VALUES 0x0002
|
|
|
|
|
|
|
|
//transform the destination rect by the xform in the
|
|
|
|
//rendering context
|
|
|
|
#define NS_COPYBITS_XFORM_DEST_VALUES 0x0004
|
|
|
|
|
|
|
|
//this is basically a hack and is used by callers
|
|
|
|
//who have selected an alternate drawing surface and
|
|
|
|
//wish the copy to happen to that buffer rather than
|
|
|
|
//the "front" buffer. i'm not proud of this. MMP
|
1999-08-19 22:34:22 +00:00
|
|
|
//XXX: This is no longer needed by the XPCODE. It will
|
|
|
|
//be removed once all of the platform specific nsRenderingContext's
|
|
|
|
//stop using it.
|
1998-10-23 17:58:18 +00:00
|
|
|
#define NS_COPYBITS_TO_BACK_BUFFER 0x0008
|
|
|
|
|
2001-09-27 18:29:17 +00:00
|
|
|
/* Struct used to represent the overall extent of a string
|
|
|
|
whose rendering may involve switching between different
|
|
|
|
fonts that have different metrics.
|
|
|
|
*/
|
|
|
|
struct nsTextDimensions {
|
|
|
|
// max ascent amongst all the fonts needed to represent the string
|
|
|
|
nscoord ascent;
|
|
|
|
|
|
|
|
// max descent amongst all the fonts needed to represent the string
|
|
|
|
nscoord descent;
|
|
|
|
|
|
|
|
// width of the string
|
|
|
|
nscoord width;
|
|
|
|
|
|
|
|
|
|
|
|
nsTextDimensions()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set all member data to zero */
|
|
|
|
void
|
|
|
|
Clear() {
|
|
|
|
ascent = descent = width = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sum with another dimension */
|
|
|
|
void
|
|
|
|
Combine(const nsTextDimensions& aOther) {
|
|
|
|
if (ascent < aOther.ascent) ascent = aOther.ascent;
|
|
|
|
if (descent < aOther.descent) descent = aOther.descent;
|
|
|
|
width += aOther.width;
|
|
|
|
}
|
|
|
|
};
|
1999-11-11 04:24:51 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
/* Struct used for accurate measurements of a string in order
|
2000-01-07 14:16:02 +00:00
|
|
|
to allow precise positioning when processing MathML.
|
1999-11-11 04:24:51 +00:00
|
|
|
*/
|
|
|
|
struct nsBoundingMetrics {
|
|
|
|
|
|
|
|
///////////
|
|
|
|
// Metrics that _exactly_ enclose the text:
|
|
|
|
|
2000-01-14 06:15:37 +00:00
|
|
|
// The character coordinate system is the one used on X Windows:
|
|
|
|
// 1. The origin is located at the intersection of the baseline
|
|
|
|
// with the left of the character's cell.
|
|
|
|
// 2. All horizontal bearings are oriented from left to right.
|
|
|
|
// 3. The ascent is oriented from bottom to top (being 0 at the orgin).
|
|
|
|
// 4. The descent is oriented from top to bottom (being 0 at the origin).
|
|
|
|
|
|
|
|
// Note that Win32/Mac/PostScript use a different convention for
|
|
|
|
// the descent (all vertical measurements are oriented from bottom
|
2001-03-21 01:53:52 +00:00
|
|
|
// to top on these palatforms). Make sure to flip the sign of the
|
2000-01-14 06:15:37 +00:00
|
|
|
// descent on these platforms for cross-platform compatibility.
|
|
|
|
|
|
|
|
// Any of the following member variables listed here can have
|
|
|
|
// positive or negative value.
|
|
|
|
|
1999-11-11 04:24:51 +00:00
|
|
|
nscoord leftBearing;
|
|
|
|
/* The horizontal distance from the origin of the drawing
|
|
|
|
operation to the left-most part of the drawn string. */
|
|
|
|
|
|
|
|
nscoord rightBearing;
|
|
|
|
/* The horizontal distance from the origin of the drawing
|
|
|
|
operation to the right-most part of the drawn string.
|
|
|
|
The _exact_ width of the string is therefore:
|
|
|
|
rightBearing - leftBearing */
|
|
|
|
|
|
|
|
nscoord ascent;
|
|
|
|
/* The vertical distance from the origin of the drawing
|
|
|
|
operation to the top-most part of the drawn string. */
|
|
|
|
|
|
|
|
nscoord descent;
|
|
|
|
/* The vertical distance from the origin of the drawing
|
|
|
|
operation to the bottom-most part of the drawn string.
|
|
|
|
The _exact_ height of the string is therefore:
|
2000-01-14 06:15:37 +00:00
|
|
|
ascent + descent */
|
1999-11-11 04:24:51 +00:00
|
|
|
|
|
|
|
//////////
|
|
|
|
// Metrics for placing other surrounding text:
|
|
|
|
|
|
|
|
nscoord width;
|
|
|
|
/* The horizontal distance from the origin of the drawing
|
|
|
|
operation to the correct origin for drawing another string
|
|
|
|
to follow the current one. Depending on the font, this
|
|
|
|
could be greater than or less than the right bearing. */
|
|
|
|
|
2002-02-15 14:39:50 +00:00
|
|
|
nsBoundingMetrics() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
1999-11-11 04:24:51 +00:00
|
|
|
//////////
|
|
|
|
// Utility methods and operators:
|
|
|
|
|
|
|
|
/* Set all member data to zero */
|
|
|
|
void
|
|
|
|
Clear() {
|
|
|
|
leftBearing = rightBearing = 0;
|
|
|
|
ascent = descent = width = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append another bounding metrics */
|
|
|
|
void
|
|
|
|
operator += (const nsBoundingMetrics& bm) {
|
2008-01-03 04:32:12 +00:00
|
|
|
if (ascent + descent == 0 && rightBearing - leftBearing == 0) {
|
|
|
|
ascent = bm.ascent;
|
|
|
|
descent = bm.descent;
|
|
|
|
leftBearing = width + bm.leftBearing;
|
|
|
|
rightBearing = width + bm.rightBearing;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (ascent < bm.ascent) ascent = bm.ascent;
|
|
|
|
if (descent < bm.descent) descent = bm.descent;
|
|
|
|
leftBearing = PR_MIN(leftBearing, width + bm.leftBearing);
|
|
|
|
rightBearing = PR_MAX(rightBearing, width + bm.rightBearing);
|
|
|
|
}
|
1999-11-11 04:24:51 +00:00
|
|
|
width += bm.width;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif // MOZ_MATHML
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#endif /* nsIRenderingContext_h___ */
|