removed aWidth from DrawString(). added aFontID to DrawString() and GetWidth().

This commit is contained in:
michaelp%netscape.com 1999-01-28 05:03:05 +00:00
Родитель e45007f472
Коммит b4c034f217
12 изменённых файлов: 172 добавлений и 199 удалений

Просмотреть файл

@ -397,18 +397,26 @@ public:
* If no font has been Set, the results are undefined.
* @param aC character to measure
* @param aWidth out parameter for width
* @param aFontID an optional out parameter used to store a
* font identifier that can be passed into the DrawString()
* methods to speed rendering
* @return error status
*/
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth) = 0;
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID = nsnull) = 0;
/**
* Returns the width (in app units) of an nsString
* If no font has been Set, the results are undefined.
* @param aString string to measure
* @param aWidth out parameter for width
* @param aFontID an optional out parameter used to store a
* font identifier that can be passed into the DrawString()
* methods to speed rendering
* @return error status
*/
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth) = 0;
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID = nsnull) = 0;
/**
* Returns the width (in app units) of an 8-bit character string
@ -436,10 +444,13 @@ public:
* @param aString string to measure
* @param aLength number of characters in string
* @param aWidth out parameter for width
* @param aFontID an optional out parameter used to store a
* font identifier that can be passed into the DrawString()
* methods to speed rendering
* @return error status
*/
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth) = 0;
nscoord &aWidth, PRInt32 *aFontID = nsnull) = 0;
/**
* Draw a string in the RenderingContext
@ -447,12 +458,10 @@ public:
* @param aLength The length of the aString
* @param aX Horizontal starting point of baseline
* @param aY Vertical starting point of baseline.
* @param aWidth Width of the underline
* @param aSpacing inter-character spacing to apply
*/
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing = nsnull) = 0;
/**
@ -461,12 +470,14 @@ public:
* @param aLength The length of the aString
* @param aX Horizontal starting point of baseline
* @param aY Vertical starting point of baseline.
* @param aWidth length in twips of the underline
* @param aFontID an optional parameter used to speed font
* selection for complex unicode strings. the value
* passed is returned by the DrawString() methods.
* @param aSpacing inter-character spacing to apply
*/
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull) = 0;
/**
@ -474,11 +485,13 @@ public:
* @param aString A nsString of the string
* @param aX Horizontal starting point of baseline
* @param aY Vertical starting point of baseline.
* @param aWidth Width of the underline
* @param aFontID an optional parameter used to speed font
* selection for complex unicode strings. the value
* passed is returned by the DrawString() methods.
* @param aSpacing inter-character spacing to apply
*/
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull) = 0;
/**

Просмотреть файл

@ -816,20 +816,24 @@ NS_IMETHODIMP nsRenderingContextGTK::GetWidth(char aC, nscoord &aWidth)
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextGTK::GetWidth(PRUnichar aC, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextGTK::GetWidth(PRUnichar aC, nscoord &aWidth, PRInt32 *aFontID)
{
gint width;
GdkFont *font = (GdkFont *)mCurrentFont;
width = gdk_char_width_wc(font,(GdkWChar)aC);
aWidth = NSToCoordRound(width * mP2T);
if (nsnull != aFontID)
*aFontID = 0;
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextGTK::GetWidth(const nsString& aString, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextGTK::GetWidth(const nsString& aString, nscoord &aWidth, PRInt32 *aFontID)
{
char* cStr = aString.ToNewCString();
NS_IMETHODIMP ret = GetWidth(cStr, aString.Length(), aWidth);
delete[] cStr;
if (nsnull != aFontID)
*aFontID = 0;
return ret;
}
@ -859,7 +863,8 @@ NS_IMETHODIMP nsRenderingContextGTK::GetWidth(const char *aString,
NS_IMETHODIMP nsRenderingContextGTK::GetWidth(const PRUnichar *aString,
PRUint32 aLength, nscoord &aWidth)
PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID)
{
g_return_val_if_fail(aString != NULL, NS_ERROR_FAILURE);
/* this really shouldn't be 0, and this gets called quite a bit. not sure
@ -872,13 +877,16 @@ NS_IMETHODIMP nsRenderingContextGTK::GetWidth(const PRUnichar *aString,
char* cStr = nsStr.ToNewCString();
NS_IMETHODIMP ret = GetWidth(cStr, aLength, aWidth);
delete[] cStr;
if (nsnull != aFontID)
*aFontID = 0;
return ret;
}
NS_IMETHODIMP
nsRenderingContextGTK::DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing)
{
g_return_val_if_fail(aString != NULL, NS_ERROR_FAILURE);
@ -906,6 +914,9 @@ nsRenderingContextGTK::DrawString(const char *aString, PRUint32 aLength,
mRenderingSurface->gc,
x, y, aString, aLength);
#if 0
//this is no longer to be done by this API, but another
//will take it's place that will need this code again. MMP
if (mFontMetrics)
{
const nsFont *font;
@ -935,29 +946,30 @@ nsRenderingContextGTK::DrawString(const char *aString, PRUint32 aLength,
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
}
#endif
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextGTK::DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing)
{
nsString nsStr;
nsStr.SetString(aString, aLength);
char* cStr = nsStr.ToNewCString();
NS_IMETHODIMP ret = DrawString(cStr, aLength, aX, aY, aWidth, aSpacing);
NS_IMETHODIMP ret = DrawString(cStr, aLength, aX, aY, aFontID, aSpacing);
delete[] cStr;
return ret;
}
NS_IMETHODIMP nsRenderingContextGTK::DrawString(const nsString& aString,
nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing)
{
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aFontID, aSpacing);
}
NS_IMETHODIMP nsRenderingContextGTK::DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)

Просмотреть файл

@ -116,22 +116,24 @@ public:
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);

Просмотреть файл

@ -1323,18 +1323,18 @@ NS_IMETHODIMP nsRenderingContextMac :: GetWidth(char ch, nscoord &aWidth)
//------------------------------------------------------------------------
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(PRUnichar ch, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(PRUnichar ch, nscoord &aWidth, PRInt32 *aFontID)
{
PRUnichar buf[1];
buf[0] = ch;
return GetWidth(buf, 1, aWidth);
return GetWidth(buf, 1, aWidth, aFontID);
}
//------------------------------------------------------------------------
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const nsString& aString, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const nsString& aString, nscoord &aWidth, PRInt32 *aFontID)
{
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth, aFontID);
}
//------------------------------------------------------------------------
@ -1379,7 +1379,7 @@ nsRenderingContextMac :: GetWidth(const char* aString, PRUint32 aLength, nscoord
//------------------------------------------------------------------------
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, PRInt32 *aFontID)
{
nsString nsStr;
nsStr.SetString(aString, aLength);
@ -1387,6 +1387,8 @@ NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const PRUnichar *aString, PRUint
ConvertLatin1ToMacRoman ( cStr );
GetWidth(cStr, aLength, aWidth);
delete[] cStr;
if (nsnull != aFontID)
*aFontID = 0;
return NS_OK;
}
@ -1394,7 +1396,6 @@ NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const PRUnichar *aString, PRUint
NS_IMETHODIMP nsRenderingContextMac :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing)
{
StartDraw();
@ -1453,6 +1454,10 @@ NS_IMETHODIMP nsRenderingContextMac :: DrawString(const char *aString, PRUint32
delete [] spacing;
}
#if 0
//this is no longer to bew done here. another routine
//will take it's place with this functionality and this
//code will be needed there. MMP
if (mGS->mFontMetrics)
{
const nsFont* font;
@ -1481,6 +1486,8 @@ NS_IMETHODIMP nsRenderingContextMac :: DrawString(const char *aString, PRUint32
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
}
#endif
if ( macRomanString != stringBuffer )
free( macRomanString );
EndDraw();
@ -1607,7 +1614,7 @@ static Boolean IsATSUIAvailable()
//------------------------------------------------------------------------
NS_IMETHODIMP nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
#ifdef USE_ATSUI_HACK
@ -1661,35 +1668,6 @@ NS_IMETHODIMP nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUi
err = ATSUDisposeStyle(theStyle);
NS_ASSERTION((noErr == err), "ATSUDisposeStyle failed");
if (mGS->mFontMetrics)
{
const nsFont* font;
mGS->mFontMetrics->GetFont(font);
PRUint8 deco = font->decorations;
if (deco & NS_FONT_DECORATION_OVERLINE)
DrawLine(aX, aY, aX + aWidth, aY);
if (deco & NS_FONT_DECORATION_UNDERLINE)
{
nscoord ascent = 0;
nscoord descent = 0;
mGS->mFontMetrics->GetMaxAscent(ascent);
mGS->mFontMetrics->GetMaxDescent(descent);
DrawLine(aX, aY + ascent + (descent >> 1),
aX + aWidth, aY + ascent + (descent >> 1));
}
if (deco & NS_FONT_DECORATION_LINE_THROUGH)
{
nscoord height = 0;
mGS->mFontMetrics->GetHeight(height);
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
}
EndDraw();
return NS_OK;
}
@ -1700,7 +1678,7 @@ NS_IMETHODIMP nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUi
nsStr.SetString(aString, aLength);
char* cStr = nsStr.ToNewCString();
nsresult rv = DrawString(cStr, aLength, aX, aY, aWidth,aSpacing);
nsresult rv = DrawString(cStr, aLength, aX, aY, aSpacing);
delete[] cStr;
return rv;
@ -1711,10 +1689,10 @@ NS_IMETHODIMP nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUi
//------------------------------------------------------------------------
NS_IMETHODIMP nsRenderingContextMac :: DrawString(const nsString& aString,
nscoord aX, nscoord aY, nscoord aWidth,
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
nsresult rv = DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
nsresult rv = DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aFontID, aSpacing);
return rv;
}

Просмотреть файл

@ -93,14 +93,21 @@ public:
NS_IMETHOD FillArc(const nsRect& aRect,float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,nscoord aX, nscoord aY,const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);

Просмотреть файл

@ -1117,16 +1117,16 @@ NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(char ch, nscoord &aWidth)
return GetWidth(buf, 1, aWidth);
}
NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(PRUnichar ch, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(PRUnichar ch, nscoord &aWidth, PRInt32 *aFontID)
{
PRUnichar buf[1];
buf[0] = ch;
return GetWidth(buf, 1, aWidth);
return GetWidth(buf, 1, aWidth, aFontID);
}
NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const nsString& aString, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const nsString& aString, nscoord &aWidth, PRInt32 *aFontID)
{
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth, aFontID);
}
NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const char *aString, nscoord &aWidth)
@ -1149,7 +1149,7 @@ NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const char *aString,
NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const PRUnichar *aString,
PRUint32 aLength,
nscoord &aWidth)
nscoord &aWidth, PRInt32 *aFontID)
{
XChar2b * thischar ;
PRUint16 aunichar;
@ -1184,13 +1184,15 @@ NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const PRUnichar *aString,
width = ::XTextWidth16(font, mDrawStringBuf, aLength);
aWidth = nscoord(width * mP2T);
if (nsnull != aFontID)
*aFontID = 0;
return NS_OK;
}
NS_IMETHODIMP
nsRenderingContextMotif :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing)
{
nscoord x = aX;
@ -1209,6 +1211,10 @@ nsRenderingContextMotif :: DrawString(const char *aString, PRUint32 aLength,
mRenderingSurface->gc,
x, y, aString, aLength);
#if 0
//this code no longer needs to be here. another routine will
//take it places that does this stuff and this code will need
//to be there. MMP
if (mFontMetrics)
{
nsFont *font;
@ -1238,13 +1244,14 @@ nsRenderingContextMotif :: DrawString(const char *aString, PRUint32 aLength,
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsRenderingContextMotif :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
nscoord x = aX;
@ -1286,45 +1293,15 @@ nsRenderingContextMotif :: DrawString(const PRUnichar *aString, PRUint32 aLength
mRenderingSurface->gc,
x, y, mDrawStringBuf, aLength);
if (mFontMetrics)
{
nsFont *font;
mFontMetrics->GetFont(font);
PRUint8 deco = font->decorations;
if (deco & NS_FONT_DECORATION_OVERLINE)
DrawLine(aX, aY, aX + aWidth, aY);
if (deco & NS_FONT_DECORATION_UNDERLINE)
{
nscoord ascent,descent;
mFontMetrics->GetMaxAscent(ascent);
mFontMetrics->GetMaxDescent(descent);
DrawLine(aX, aY + ascent + (descent >> 1),
aX + aWidth, aY + ascent + (descent >> 1));
}
if (deco & NS_FONT_DECORATION_LINE_THROUGH)
{
nscoord height;
mFontMetrics->GetHeight(height);
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
}
return NS_OK;
}
NS_IMETHODIMP
nsRenderingContextMotif :: DrawString(const nsString& aString,
nscoord aX, nscoord aY, nscoord aWidth,
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aFontID, aSpacing);
}
NS_IMETHODIMP nsRenderingContextMotif :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)

Просмотреть файл

@ -125,22 +125,24 @@ public:
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);

Просмотреть файл

@ -923,11 +923,11 @@ nsRenderingContextPS :: GetWidth(char ch, nscoord& aWidth)
* @update 12/21/98 dwc
*/
NS_IMETHODIMP
nsRenderingContextPS :: GetWidth(PRUnichar ch, nscoord &aWidth)
nsRenderingContextPS :: GetWidth(PRUnichar ch, nscoord &aWidth, PRInt32 *aFontID)
{
PRUnichar buf[1];
buf[0] = ch;
return GetWidth(buf, 1, aWidth);
return GetWidth(buf, 1, aWidth, aFontID);
}
/** ---------------------------------------------------
@ -966,9 +966,9 @@ nsRenderingContextPS :: GetWidth(const char* aString,PRUint32 aLength,nscoord& a
* @update 12/21/98 dwc
*/
NS_IMETHODIMP
nsRenderingContextPS :: GetWidth(const nsString& aString, nscoord& aWidth)
nsRenderingContextPS :: GetWidth(const nsString& aString, nscoord& aWidth, PRInt32 *aFontID)
{
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth, aFontID);
}
/** ---------------------------------------------------
@ -976,7 +976,7 @@ nsRenderingContextPS :: GetWidth(const nsString& aString, nscoord& aWidth)
* @update 12/21/98 dwc
*/
NS_IMETHODIMP
nsRenderingContextPS :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoord &aWidth)
nsRenderingContextPS :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoord &aWidth, PRInt32 *aFontID)
{
if (nsnull != mFontMetrics){
SIZE size;
@ -986,6 +986,9 @@ nsRenderingContextPS :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoo
//::GetTextExtentPoint32W(mDelRenderingContext->mDC, aString, aLength, &size);
//aWidth = NSToCoordRound(float(size.cx) * mP2T);
if (nsnull != aFontID)
*aFontID = 0;
return NS_OK;
}
else
@ -999,7 +1002,6 @@ nsRenderingContextPS :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoo
NS_IMETHODIMP
nsRenderingContextPS :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing)
{
PRInt32 x = aX;
@ -1020,13 +1022,15 @@ PRInt32 y = aY;
mTMatrix->TransformCoord(&x, &y);
//::ExtTextOut(mDC, x, y, 0, NULL, aString, aLength, aSpacing ? dx0 : NULL);
//XXX: Remove ::ExtTextOut later
PostscriptTextOut(aString, aLength, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), aLength, aSpacing ? dx0 : NULL, FALSE);
PostscriptTextOut(aString, aLength, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), 0, aSpacing ? dx0 : NULL, FALSE);
if ((nsnull != aSpacing) && (dx0 != dxMem)) {
delete [] dx0;
}
#ifdef NOTNOW
#if 0
//this doesn't need to happen here anymore, but a
//new api will come along that will need this stuff. MMP
if (nsnull != mFontMetrics){
nsFont *font;
mFontMetrics->GetFont(font);
@ -1040,7 +1044,6 @@ PRInt32 y = aY;
}
}
#endif
return NS_OK;
@ -1052,7 +1055,7 @@ PRInt32 y = aY;
*/
NS_IMETHODIMP
nsRenderingContextPS :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
PRInt32 x = aX;
@ -1072,28 +1075,13 @@ nsIFontMetrics *fMetrics;
x = aX;
y = aY;
mTMatrix->TransformCoord(&x, &y);
PostscriptTextOut((const char *)aString, 1, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), aWidth, aSpacing, PR_TRUE);
PostscriptTextOut((const char *)aString, 1, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), aFontID, aSpacing, PR_TRUE);
aX += *aSpacing++;
aString++;
}
} else {
mTMatrix->TransformCoord(&x, &y);
PostscriptTextOut((const char *)aString, aLength, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), aWidth, aSpacing, PR_TRUE);
}
fMetrics = mFontMetrics;
if (nsnull != fMetrics){
nsFont *font;
fMetrics->GetFont(font);
PRUint8 decorations = font->decorations;
if (decorations & NS_FONT_DECORATION_OVERLINE){
nscoord offset;
nscoord size;
fMetrics->GetUnderline(offset, size);
FillRect(aX, aY, aWidth, size);
}
PostscriptTextOut((const char *)aString, aLength, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), aFontID, aSpacing, PR_TRUE);
}
return NS_OK;
}
@ -1103,10 +1091,10 @@ nsIFontMetrics *fMetrics;
* @update 12/21/98 dwc
*/
NS_IMETHODIMP
nsRenderingContextPS :: DrawString(const nsString& aString,nscoord aX, nscoord aY, nscoord aWidth,
nsRenderingContextPS :: DrawString(const nsString& aString,nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aFontID, aSpacing);
}
/** ---------------------------------------------------
@ -1307,7 +1295,7 @@ int postscriptFont = 0;
*/
void
nsRenderingContextPS :: PostscriptTextOut(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing, PRBool aIsUnicode)
{
int ptr = 0;

Просмотреть файл

@ -123,23 +123,24 @@ public:
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord& aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord& aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord& aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
nscoord& aWidth);
nscoord& aWidth, PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
@ -183,7 +184,7 @@ public:
* @update 12/21/98 dwc
*/
void PostscriptTextOut(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing, PRBool aIsUnicode);

Просмотреть файл

@ -1512,11 +1512,11 @@ NS_IMETHODIMP nsRenderingContextWin :: GetWidth(char ch, nscoord& aWidth)
return GetWidth(buf, 1, aWidth);
}
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(PRUnichar ch, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(PRUnichar ch, nscoord &aWidth, PRInt32 *aFontID)
{
PRUnichar buf[1];
buf[0] = ch;
return GetWidth(buf, 1, aWidth);
return GetWidth(buf, 1, aWidth, aFontID);
}
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const char* aString, nscoord& aWidth)
@ -1525,8 +1525,8 @@ NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const char* aString, nscoord& aW
}
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const char* aString,
PRUint32 aLength,
nscoord& aWidth)
PRUint32 aLength,
nscoord& aWidth)
{
if (nsnull != mFontMetrics)
{
@ -1542,14 +1542,15 @@ NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const char* aString,
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const nsString& aString, nscoord& aWidth)
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const nsString& aString, nscoord& aWidth, PRInt32 *aFontID)
{
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth, aFontID);
}
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
PRUint32 aLength,
nscoord &aWidth)
PRUint32 aLength,
nscoord &aWidth,
PRInt32 *aFontID)
{
if (nsnull != mFontMetrics)
{
@ -1559,6 +1560,9 @@ NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
::GetTextExtentPoint32W(mDC, aString, aLength, &size);
aWidth = NSToCoordRound(float(size.cx) * mP2T);
if (nsnull != aFontID)
*aFontID = 0;
return NS_OK;
}
else
@ -1566,9 +1570,8 @@ NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
}
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing)
nscoord aX, nscoord aY,
const nscoord* aSpacing)
{
PRInt32 x = aX;
PRInt32 y = aY;
@ -1592,27 +1595,13 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawString(const char *aString, PRUint32
delete [] dx0;
}
if (nsnull != mFontMetrics)
{
nsFont *font;
mFontMetrics->GetFont(font);
PRUint8 decorations = font->decorations;
if (decorations & NS_FONT_DECORATION_OVERLINE)
{
nscoord offset;
nscoord size;
mFontMetrics->GetUnderline(offset, size);
FillRect(aX, aY, aWidth, size);
}
}
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
const nscoord* aSpacing)
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing)
{
PRInt32 x = aX;
PRInt32 y = aY;
@ -1645,6 +1634,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUi
::ExtTextOutW(mDC, x, y, 0, NULL, aString, aLength, NULL);
}
#if 0
if (nsnull != mFontMetrics)
{
nsFont *font;
@ -1659,15 +1649,17 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUi
FillRect(aX, aY, aWidth, size);
}
}
#endif
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const nsString& aString,
nscoord aX, nscoord aY, nscoord aWidth,
const nscoord* aSpacing)
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing)
{
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aFontID, aSpacing);
}
NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)

Просмотреть файл

@ -125,23 +125,24 @@ public:
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord& aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord& aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord& aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
nscoord& aWidth);
nscoord& aWidth, PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);

Просмотреть файл

@ -656,18 +656,18 @@ nscolor white,black;
aSurface->DrawArc(20, 20,50,100,(float)0.0,(float)90.0);
aSurface->FillArc(70, 20,50,100,(float)0.0,(float)90.0);
aSurface->DrawArc(150, 20,50,100,(float)90.0,(float)0.0);
aSurface->DrawString("0 to 90\0",20,8,30);
aSurface->DrawString("Reverse (eg 90 to 0)\0",120,8,30);
aSurface->DrawString("0 to 90\0",20,8);
aSurface->DrawString("Reverse (eg 90 to 0)\0",120,8);
aSurface->DrawArc(20, 140,100,50,(float)130.0,(float)180.0);
aSurface->FillArc(70, 140,100,50,(float)130.0,(float)180.0);
aSurface->DrawArc(150, 140,100,50,(float)180.0,(float)130.0);
aSurface->DrawString("130 to 180\0",20,130,30);
aSurface->DrawString("130 to 180\0",20,130);
aSurface->DrawArc(20, 200,50,100,(float)170.0,(float)300.0);
aSurface->FillArc(70, 200,50,100,(float)170.0,(float)300.0);
aSurface->DrawArc(150, 200,50,100,(float)300.0,(float)170.0);
aSurface->DrawString("170 to 300\0",20,190,30);
aSurface->DrawString("170 to 300\0",20,190);
return(30);
@ -694,7 +694,7 @@ nscolor white,black;
aSurface->SetColor(black);
aSurface->DrawRect(20, 20, 100, 100);
aSurface->DrawString("This is a Rectangle\0",20,5,30);
aSurface->DrawString("This is a Rectangle\0",20,5);
aSurface->DrawLine(0,0,300,400);
@ -706,7 +706,7 @@ nscolor white,black;
pointlist[4].x = 175;pointlist[4].y = 175;
pointlist[5].x = 150;pointlist[5].y = 150;
aSurface->DrawPolygon(pointlist,6);
aSurface->DrawString("This is a closed Polygon\0",210,150,30);
aSurface->DrawString("This is a closed Polygon\0",210,150);
delete [] pointlist;
#ifdef WINDOWSBROKEN
@ -717,12 +717,12 @@ nscolor white,black;
pointlist[3].x = 260;pointlist[3].y = 240;
pointlist[4].x = 225;pointlist[4].y = 225;
aSurface->DrawPolygon(pointlist,6);
aSurface->DrawString("This is an open Polygon\0",250,200,30);
aSurface->DrawString("This is an open Polygon\0",250,200);
delete [] pointlist;
#endif
aSurface->DrawEllipse(30, 150,50,100);
aSurface->DrawString("This is an Ellipse\0",30,140,30);
aSurface->DrawString("This is an Ellipse\0",30,140);
return(30);
@ -748,7 +748,7 @@ nscolor white,black;
aSurface->SetColor(black);
aSurface->FillRect(20, 20, 100, 100);
aSurface->DrawString("This is a Rectangle\0",20,5,30);
aSurface->DrawString("This is a Rectangle\0",20,5);
pointlist = new nsPoint[6];
pointlist[0].x = 150;pointlist[0].y = 150;
@ -758,7 +758,7 @@ nscolor white,black;
pointlist[4].x = 175;pointlist[4].y = 175;
pointlist[5].x = 150;pointlist[5].y = 150;
aSurface->FillPolygon(pointlist,6);
aSurface->DrawString("This is a closed Polygon\0",210,150,30);
aSurface->DrawString("This is a closed Polygon\0",210,150);
delete [] pointlist;
@ -770,12 +770,12 @@ nscolor white,black;
pointlist[3].x = 260;pointlist[3].y = 240;
pointlist[4].x = 225;pointlist[4].y = 225;
aSurface->FillPolygon(pointlist,6);
aSurface->DrawString("This is an open Polygon\0",250,200,30);
aSurface->DrawString("This is an open Polygon\0",250,200);
delete [] pointlist;
#endif
aSurface->FillEllipse(30, 150,50,100);
aSurface->DrawString("This is an Ellipse\0",30,140,30);
aSurface->DrawString("This is an Ellipse\0",30,140);
return(30);
}