mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
moved GetWidth() APIs from fontmetrics to the renderingcontext.
This commit is contained in:
parent
4cd7cc11a7
commit
85317fe4bd
@ -310,85 +310,6 @@ nsFontMetricsMac :: GetUnderline(nscoord& aOffset, nscoord& aSize)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsMac :: GetWidth(char ch, nscoord &aWidth)
|
||||
{
|
||||
char buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsMac :: GetWidth(PRUnichar ch, nscoord &aWidth)
|
||||
{
|
||||
PRUnichar buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsMac :: GetWidth(const nsString& aString, nscoord &aWidth)
|
||||
{
|
||||
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsMac :: GetWidth(const char *aString, nscoord &aWidth)
|
||||
{
|
||||
return GetWidth(aString, strlen(aString), aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsMac :: GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth)
|
||||
{
|
||||
if (nsnull == mContext)
|
||||
{
|
||||
aWidth = 0;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (mFont != nsnull)
|
||||
nsFontMetricsMac::SetFont(*mFont, mContext);
|
||||
|
||||
float dev2app;
|
||||
mContext->GetDevUnitsToAppUnits(dev2app);
|
||||
|
||||
short textWidth = ::TextWidth(aString, 0, aLength);
|
||||
aWidth = NSToCoordRound(float(textWidth) * dev2app);
|
||||
|
||||
if (mFont != nsnull) {
|
||||
switch (mFont->style)
|
||||
{
|
||||
case NS_FONT_STYLE_ITALIC:
|
||||
case NS_FONT_STYLE_OBLIQUE:
|
||||
nscoord aAdvance;
|
||||
GetMaxAdvance(aAdvance);
|
||||
aWidth += aAdvance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsMac :: GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth)
|
||||
{
|
||||
nsString nsStr;
|
||||
nsStr.SetString(aString, aLength);
|
||||
char* cStr = nsStr.ToNewCString();
|
||||
GetWidth(cStr, aLength, aWidth);
|
||||
delete[] cStr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsMac :: GetWidth(nsIDeviceContext *aContext, const nsString& aString, nscoord &aWidth)
|
||||
{
|
||||
nsIDeviceContext* saveContext = mContext;
|
||||
mContext = aContext;
|
||||
|
||||
char* cStr = aString.ToNewCString();
|
||||
nsresult res = GetWidth(cStr, aString.Length(), aWidth);
|
||||
delete[] cStr;
|
||||
|
||||
mContext = saveContext;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsMac :: GetHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = mHeight;
|
||||
|
@ -48,13 +48,6 @@ public:
|
||||
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
|
||||
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
|
||||
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
|
||||
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(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(nsIDeviceContext *aContext, const nsString& aString, nscoord &aWidth);
|
||||
NS_IMETHOD GetHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetLeading(nscoord &aLeading);
|
||||
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
|
||||
|
@ -547,15 +547,15 @@ void nsRenderingContextMac :: SetFont(nsIFontMetrics *aFontMetrics)
|
||||
|
||||
if (mFontMetrics)
|
||||
{
|
||||
//nsFont font;
|
||||
nsFont *font;
|
||||
|
||||
//XXX this is incredibly hokey. nothing should really
|
||||
//be done with the fontmetrics passed in (either here or in
|
||||
//SetFont() above) until you want to actually *use* the font
|
||||
//for somethin. MMP
|
||||
|
||||
//mFontMetrics->GetFont(&font);
|
||||
//nsFontMetricsMac::SetFont(font, mContext);
|
||||
mFontMetrics->GetFont(font);
|
||||
nsFontMetricsMac::SetFont(*font, mContext);
|
||||
}
|
||||
}
|
||||
|
||||
@ -886,6 +886,77 @@ Rect therect;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(char ch, nscoord &aWidth)
|
||||
{
|
||||
char buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(PRUnichar ch, nscoord &aWidth)
|
||||
{
|
||||
PRUnichar buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const nsString& aString, nscoord &aWidth)
|
||||
{
|
||||
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const char *aString, nscoord &aWidth)
|
||||
{
|
||||
return GetWidth(aString, strlen(aString), aWidth);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextMac :: GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth)
|
||||
{
|
||||
nsFont *font;
|
||||
|
||||
short textWidth = ::TextWidth(aString, 0, aLength);
|
||||
aWidth = NSToCoordRound(float(textWidth) * mP2T);
|
||||
|
||||
mFontMetrics->GetFont(font);
|
||||
|
||||
if (font != nsnull) {
|
||||
switch (font->style)
|
||||
{
|
||||
case NS_FONT_STYLE_ITALIC:
|
||||
case NS_FONT_STYLE_OBLIQUE:
|
||||
nscoord aAdvance;
|
||||
mFontMetrics->GetMaxAdvance(aAdvance);
|
||||
aWidth += aAdvance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth)
|
||||
{
|
||||
nsString nsStr;
|
||||
nsStr.SetString(aString, aLength);
|
||||
char* cStr = nsStr.ToNewCString();
|
||||
GetWidth(cStr, aLength, aWidth);
|
||||
delete[] cStr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void nsRenderingContextMac :: DrawString(const char *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
nscoord aWidth)
|
||||
|
@ -99,6 +99,12 @@ public:
|
||||
virtual void DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,float aStartAngle, float aEndAngle);
|
||||
virtual void FillArc(const nsRect& aRect,float aStartAngle, float aEndAngle);
|
||||
virtual void 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(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);
|
||||
virtual void DrawString(const char *aString, PRUint32 aLength,nscoord aX, nscoord aY,nscoord aWidth);
|
||||
virtual void DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY,nscoord aWidth);
|
||||
virtual void DrawString(const nsString& aString, nscoord aX, nscoord aY,nscoord aWidth);
|
||||
|
@ -33,8 +33,6 @@ nsFontMetricsUnix :: nsFontMetricsUnix()
|
||||
mFont = nsnull;
|
||||
mFontHandle = nsnull;
|
||||
mFontInfo = nsnull;
|
||||
mXstring = nsnull;
|
||||
mXstringSize = 0;
|
||||
}
|
||||
|
||||
nsFontMetricsUnix :: ~nsFontMetricsUnix()
|
||||
@ -44,9 +42,6 @@ nsFontMetricsUnix :: ~nsFontMetricsUnix()
|
||||
mFont = nsnull;
|
||||
}
|
||||
|
||||
if (nsnull != mXstring)
|
||||
PR_Free(mXstring);
|
||||
|
||||
if (nsnull != mFontHandle) {
|
||||
nsNativeWidget widget;
|
||||
mContext->GetNativeWidget(widget);
|
||||
@ -309,80 +304,6 @@ nsFontMetricsUnix :: GetUnderline(nscoord& aOffset, nscoord& aSize)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsUnix :: GetWidth(char ch, nscoord &aWidth)
|
||||
{
|
||||
char buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsUnix :: GetWidth(PRUnichar ch, nscoord &aWidth)
|
||||
{
|
||||
PRUnichar buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsUnix :: GetWidth(const nsString& aString, nscoord &aWidth)
|
||||
{
|
||||
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsUnix :: GetWidth(const char *aString, nscoord &aWidth)
|
||||
{
|
||||
return GetWidth(aString, strlen(aString), aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsUnix :: GetWidth(const char *aString,
|
||||
PRUint32 aLength, nscoord &aWidth)
|
||||
{
|
||||
PRInt32 rc = 0 ;
|
||||
|
||||
rc = (PRInt32) ::XTextWidth(mFontInfo, aString, aLength);
|
||||
|
||||
float dev2app;
|
||||
mContext->GetDevUnitsToAppUnits(dev2app);
|
||||
aWidth = nscoord(rc * dev2app);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsUnix :: GetWidth(const PRUnichar *aString,
|
||||
PRUint32 aLength,
|
||||
nscoord &aWidth)
|
||||
{
|
||||
XChar2b * thischar ;
|
||||
PRUint16 aunichar;
|
||||
nscoord width ;
|
||||
PRUint32 i ;
|
||||
PRUint32 desiredSize = sizeof(XChar2b) * aLength;
|
||||
|
||||
// Make the temporary buffer larger if needed.
|
||||
if (nsnull == mXstring) {
|
||||
mXstring = (XChar2b *) PR_Malloc(desiredSize);
|
||||
mXstringSize = desiredSize;
|
||||
}
|
||||
else {
|
||||
if (mXstringSize < desiredSize) {
|
||||
mXstring = (XChar2b *) PR_Realloc(mXstring, desiredSize);
|
||||
mXstringSize = desiredSize;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<aLength; i++) {
|
||||
thischar = (mXstring+i);
|
||||
aunichar = (PRUint16)(*(aString+i));
|
||||
thischar->byte2 = (aunichar & 0xff);
|
||||
thischar->byte1 = (aunichar & 0xff00) >> 8;
|
||||
}
|
||||
|
||||
width = ::XTextWidth16(mFontInfo, mXstring, aLength);
|
||||
|
||||
float dev2app;
|
||||
mContext->GetDevUnitsToAppUnits(dev2app);
|
||||
aWidth = nscoord(width * dev2app);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsUnix :: GetHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = mHeight;
|
||||
|
@ -50,12 +50,6 @@ public:
|
||||
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
|
||||
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
|
||||
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
|
||||
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(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 GetHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetLeading(nscoord &aLeading);
|
||||
@ -85,9 +79,6 @@ protected:
|
||||
nscoord mMaxAscent;
|
||||
nscoord mMaxDescent;
|
||||
nscoord mMaxAdvance;
|
||||
|
||||
XChar2b * mXstring;
|
||||
PRUint32 mXstringSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1038,6 +1038,83 @@ void nsRenderingContextUnix :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, n
|
||||
NSToIntRound(aEndAngle * 64.0f));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextUnix :: GetWidth(char ch, nscoord &aWidth)
|
||||
{
|
||||
char buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextUnix :: GetWidth(PRUnichar ch, nscoord &aWidth)
|
||||
{
|
||||
PRUnichar buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextUnix :: GetWidth(const nsString& aString, nscoord &aWidth)
|
||||
{
|
||||
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextUnix :: GetWidth(const char *aString, nscoord &aWidth)
|
||||
{
|
||||
return GetWidth(aString, strlen(aString), aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextUnix :: GetWidth(const char *aString,
|
||||
PRUint32 aLength, nscoord &aWidth)
|
||||
{
|
||||
PRInt32 rc;
|
||||
XFontStruct *font;
|
||||
|
||||
font = ::XQueryFont(mRenderingSurface->display, (Font)mCurrFontHandle);
|
||||
rc = (PRInt32) ::XTextWidth(font, aString, aLength);
|
||||
aWidth = nscoord(rc * mP2T);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextUnix :: GetWidth(const PRUnichar *aString,
|
||||
PRUint32 aLength,
|
||||
nscoord &aWidth)
|
||||
{
|
||||
XChar2b * thischar ;
|
||||
PRUint16 aunichar;
|
||||
nscoord width ;
|
||||
PRUint32 i ;
|
||||
PRUint32 desiredSize = sizeof(XChar2b) * aLength;
|
||||
XFontStruct *font;
|
||||
|
||||
// Make the temporary buffer larger if needed.
|
||||
if (nsnull == mDrawStringBuf) {
|
||||
mDrawStringBuf = (XChar2b *) PR_Malloc(aLength);
|
||||
mDrawStringSize = aLength;
|
||||
}
|
||||
else {
|
||||
if (mDrawStringSize < PRInt32(aLength)) {
|
||||
mDrawStringBuf = (XChar2b *) PR_Realloc(mDrawStringBuf, aLength);
|
||||
mDrawStringSize = aLength;
|
||||
}
|
||||
}
|
||||
|
||||
// Translate the unicode data into XChar2b's
|
||||
XChar2b* xc = mDrawStringBuf;
|
||||
XChar2b* end = xc + aLength;
|
||||
while (xc < end) {
|
||||
PRUnichar ch = *aString++;
|
||||
xc->byte2 = (ch & 0xff);
|
||||
xc->byte1 = (ch & 0xff00) >> 8;
|
||||
xc++;
|
||||
}
|
||||
|
||||
font = ::XQueryFont(mRenderingSurface->display, (Font)mCurrFontHandle);
|
||||
width = ::XTextWidth16(font, mDrawStringBuf, aLength);
|
||||
aWidth = nscoord(width * mP2T);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
nscoord aWidth)
|
||||
|
@ -127,6 +127,13 @@ public:
|
||||
virtual void 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(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);
|
||||
|
||||
virtual void DrawString(const char *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
nscoord aWidth);
|
||||
|
@ -183,6 +183,28 @@ NS_IMETHODIMP DeviceContextImpl :: CreateRenderingContext(nsIView *aView, nsIRen
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeviceContextImpl :: CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext)
|
||||
{
|
||||
nsIRenderingContext *pContext;
|
||||
nsresult rv;
|
||||
|
||||
static NS_DEFINE_IID(kRCCID, NS_RENDERING_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kRCIID, NS_IRENDERING_CONTEXT_IID);
|
||||
|
||||
aContext = nsnull;
|
||||
rv = nsRepository::CreateInstance(kRCCID, nsnull, kRCIID, (void **)&pContext);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = InitRenderingContext(pContext, aWidget);
|
||||
if (NS_OK != rv) {
|
||||
NS_RELEASE(pContext);
|
||||
}
|
||||
}
|
||||
|
||||
aContext = pContext;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeviceContextImpl :: InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWin)
|
||||
{
|
||||
return (aContext->Init(this, aWin));
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
NS_IMETHOD Init(nsNativeWidget aWidget);
|
||||
|
||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow);
|
||||
|
||||
NS_IMETHOD GetDevUnitsToTwips(float &aDevUnitsToTwips) const;
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
NS_IMETHOD Init(nsNativeWidget aWidget) = 0;
|
||||
|
||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) = 0;
|
||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) = 0;
|
||||
NS_IMETHOD InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow) = 0;
|
||||
|
||||
//these are queries to figure out how large an output unit
|
||||
|
@ -56,8 +56,7 @@ public:
|
||||
|
||||
/**
|
||||
* Destroy this font metrics. This breaks the association between
|
||||
* the font metrics and the device context (which means that calls
|
||||
* to GetWidth following this call will fail).
|
||||
* the font metrics and the device context.
|
||||
*/
|
||||
NS_IMETHOD Destroy() = 0;
|
||||
|
||||
@ -94,38 +93,6 @@ public:
|
||||
*/
|
||||
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character
|
||||
*/
|
||||
NS_IMETHOD GetWidth(char aC, nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of a unicode character
|
||||
*/
|
||||
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an nsString
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character string
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character string
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
|
||||
nscoord& aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of a Unicode character string
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
|
||||
nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the height (in app units) of the font. This is ascent plus descent
|
||||
* plus any internal leading
|
||||
|
@ -377,6 +377,38 @@ public:
|
||||
virtual void FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
float aStartAngle, float aEndAngle) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character
|
||||
*/
|
||||
NS_IMETHOD GetWidth(char aC, nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of a unicode character
|
||||
*/
|
||||
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an nsString
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character string
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character string
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
|
||||
nscoord& aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of a Unicode character string
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
|
||||
nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Draw a string in the RenderingContext
|
||||
* @param aString The string to draw
|
||||
|
@ -294,6 +294,8 @@ nsFontMetricsWin :: GetUnderline(nscoord& aOffset, nscoord& aSize)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsWin :: GetWidth(char ch, nscoord& aWidth)
|
||||
{
|
||||
@ -374,6 +376,8 @@ nsFontMetricsWin :: GetWidth(const PRUnichar *aString,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsWin :: GetHeight(nscoord &aHeight)
|
||||
{
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
|
||||
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
|
||||
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
|
||||
#if 0
|
||||
NS_IMETHOD GetWidth(char aC, nscoord& aWidth);
|
||||
NS_IMETHOD GetWidth(PRUnichar aC, nscoord& aWidth);
|
||||
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth);
|
||||
@ -57,6 +58,7 @@ public:
|
||||
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
|
||||
NS_IMETHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
|
||||
nscoord& aWidth);
|
||||
#endif
|
||||
|
||||
NS_IMETHOD GetHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetLeading(nscoord &aLeading);
|
||||
|
@ -1260,6 +1260,63 @@ void nsRenderingContextWin :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, ns
|
||||
::Pie(mDC, aX, aY, aX + aWidth, aY + aHeight, sx, sy, ex, ey);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin :: GetWidth(char ch, nscoord& aWidth)
|
||||
{
|
||||
char buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin :: GetWidth(PRUnichar ch, nscoord &aWidth)
|
||||
{
|
||||
PRUnichar buf[1];
|
||||
buf[0] = ch;
|
||||
return GetWidth(buf, 1, aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin :: GetWidth(const char* aString, nscoord& aWidth)
|
||||
{
|
||||
return GetWidth(aString, strlen(aString), aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin :: GetWidth(const char* aString,
|
||||
PRUint32 aLength,
|
||||
nscoord& aWidth)
|
||||
{
|
||||
SIZE size;
|
||||
|
||||
SetupFontAndColor();
|
||||
::GetTextExtentPoint32(mDC, aString, aLength, &size);
|
||||
aWidth = NSToCoordRound(float(size.cx) * mP2T);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin :: GetWidth(const nsString& aString, nscoord& aWidth)
|
||||
{
|
||||
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
|
||||
PRUint32 aLength,
|
||||
nscoord &aWidth)
|
||||
{
|
||||
SIZE size;
|
||||
|
||||
SetupFontAndColor();
|
||||
::GetTextExtentPoint32W(mDC, aString, aLength, &size);
|
||||
aWidth = NSToCoordRound(float(size.cx) * mP2T);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsRenderingContextWin :: DrawString(const char *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
nscoord aWidth)
|
||||
|
@ -119,6 +119,14 @@ public:
|
||||
virtual void 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(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);
|
||||
|
||||
virtual void DrawString(const char *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
nscoord aWidth);
|
||||
|
Loading…
Reference in New Issue
Block a user