mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
Minor Rendering fixes. FontMetric hardcoded to get by. Implemented
FillPolygon/DrawPolygon.
This commit is contained in:
parent
be6bd4ec1d
commit
34a35def2c
@ -72,35 +72,40 @@ void nsFontMetricsUnix::RealizeFont()
|
||||
|
||||
::XSetFont(aRenderingSurface->display, aRenderingSurface->gc, mFontHandle);
|
||||
|
||||
// XXX Temp hardcodes
|
||||
mHeight = 15 ;
|
||||
|
||||
PRUint32 i;
|
||||
for (i=0;i<256;i++)
|
||||
mCharWidths[i] = 9 ;
|
||||
|
||||
mMaxAscent = 12;
|
||||
mMaxDescent = 3;
|
||||
mMaxAdvance = 15;
|
||||
mLeading = 3;
|
||||
}
|
||||
|
||||
nscoord nsFontMetricsUnix :: GetWidth(char ch)
|
||||
{
|
||||
return 10 ;
|
||||
//return mCharWidths[PRUint8(ch)];
|
||||
return mCharWidths[PRUint8(ch)];
|
||||
}
|
||||
|
||||
nscoord nsFontMetricsUnix :: GetWidth(PRUnichar ch)
|
||||
{
|
||||
return 10 ;
|
||||
/*
|
||||
|
||||
if (ch < 256) {
|
||||
return mCharWidths[ch];
|
||||
}
|
||||
return 0;*//* XXX */
|
||||
return 0;/* XXX */
|
||||
}
|
||||
|
||||
nscoord nsFontMetricsUnix :: GetWidth(const nsString& aString)
|
||||
{
|
||||
return 10 ;
|
||||
//return GetWidth(aString.GetUnicode(), aString.Length());
|
||||
return GetWidth(aString.GetUnicode(), aString.Length());
|
||||
}
|
||||
|
||||
nscoord nsFontMetricsUnix :: GetWidth(const char *aString)
|
||||
{
|
||||
return 100 ;
|
||||
#if 0
|
||||
// XXX use native text measurement routine
|
||||
nscoord sum = 0;
|
||||
PRUint8 ch;
|
||||
@ -108,13 +113,10 @@ nscoord nsFontMetricsUnix :: GetWidth(const char *aString)
|
||||
sum += mCharWidths[ch];
|
||||
}
|
||||
return sum;
|
||||
#endif
|
||||
}
|
||||
|
||||
nscoord nsFontMetricsUnix :: GetWidth(const PRUnichar *aString, PRUint32 aLength)
|
||||
{
|
||||
return 100;
|
||||
#if 0
|
||||
// XXX use native text measurement routine
|
||||
nscoord sum = 0;
|
||||
while (aLength != 0) {
|
||||
@ -127,13 +129,11 @@ nscoord nsFontMetricsUnix :: GetWidth(const PRUnichar *aString, PRUint32 aLength
|
||||
--aLength;
|
||||
}
|
||||
return sum;
|
||||
#endif
|
||||
}
|
||||
|
||||
nscoord nsFontMetricsUnix :: GetHeight()
|
||||
{
|
||||
return 20;
|
||||
// return mHeight;
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
nscoord nsFontMetricsUnix :: GetLeading()
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "nsRenderingContextUnix.h"
|
||||
#include <math.h>
|
||||
#include "nspr.h"
|
||||
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
@ -34,6 +35,7 @@ nsRenderingContextUnix :: nsRenderingContextUnix()
|
||||
mContext = nsnull ;
|
||||
mRenderingSurface = nsnull ;
|
||||
mOffscreenSurface = nsnull ;
|
||||
mCurrentColor = 0;
|
||||
}
|
||||
|
||||
nsRenderingContextUnix :: ~nsRenderingContextUnix()
|
||||
@ -130,7 +132,10 @@ void nsRenderingContextUnix :: SetColor(nscolor aColor)
|
||||
{
|
||||
XGCValues values ;
|
||||
|
||||
mCurrentColor = aColor ;
|
||||
//mCurrentColor = aColor ;
|
||||
|
||||
// XXX
|
||||
mCurrentColor++;
|
||||
|
||||
values.foreground = mCurrentColor;
|
||||
values.background = mCurrentColor;
|
||||
@ -220,7 +225,7 @@ void nsRenderingContextUnix :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, n
|
||||
::XDrawLine(mRenderingSurface->display,
|
||||
mRenderingSurface->drawable,
|
||||
mRenderingSurface->gc,
|
||||
aX0, aX1, aY0, aY1);
|
||||
aX0, aY0, aX1, aY1);
|
||||
}
|
||||
|
||||
void nsRenderingContextUnix :: DrawRect(const nsRect& aRect)
|
||||
@ -243,20 +248,58 @@ void nsRenderingContextUnix :: FillRect(const nsRect& aRect)
|
||||
|
||||
void nsRenderingContextUnix :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
|
||||
::XFillRectangle(mRenderingSurface->display,
|
||||
mRenderingSurface->drawable,
|
||||
mRenderingSurface->gc,
|
||||
aX, aY,
|
||||
aWidth, aHeight);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void nsRenderingContextUnix::DrawPolygon(nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
PRUint32 i ;
|
||||
XPoint * xpoints;
|
||||
XPoint * thispoint;
|
||||
|
||||
xpoints = (XPoint *) PR_Malloc(sizeof(XPoint) * aNumPoints);
|
||||
|
||||
for (i = 0; i < aNumPoints; i++){
|
||||
thispoint = (xpoints+i);
|
||||
thispoint->x = aPoints[i].x;
|
||||
thispoint->y = aPoints[i].y;
|
||||
}
|
||||
|
||||
::XDrawLines(mRenderingSurface->display,
|
||||
mRenderingSurface->drawable,
|
||||
mRenderingSurface->gc,
|
||||
xpoints, aNumPoints, CoordModeOrigin);
|
||||
|
||||
PR_Free((void *)xpoints);
|
||||
}
|
||||
|
||||
void nsRenderingContextUnix::FillPolygon(nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
PRUint32 i ;
|
||||
XPoint * xpoints;
|
||||
XPoint * thispoint;
|
||||
|
||||
xpoints = (XPoint *) PR_Malloc(sizeof(XPoint) * aNumPoints);
|
||||
|
||||
for (i = 0; i < aNumPoints; i++){
|
||||
thispoint = (xpoints+i);
|
||||
thispoint->x = aPoints[i].x;
|
||||
thispoint->y = aPoints[i].y;
|
||||
}
|
||||
|
||||
::XFillPolygon(mRenderingSurface->display,
|
||||
mRenderingSurface->drawable,
|
||||
mRenderingSurface->gc,
|
||||
xpoints, aNumPoints, Convex, CoordModeOrigin);
|
||||
|
||||
PR_Free((void *)xpoints);
|
||||
}
|
||||
|
||||
void nsRenderingContextUnix :: DrawEllipse(const nsRect& aRect)
|
||||
@ -317,7 +360,7 @@ void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
|
||||
::XDrawString(mRenderingSurface->display,
|
||||
mRenderingSurface->drawable,
|
||||
mRenderingSurface->gc,
|
||||
aX, aY, aString, aWidth);
|
||||
aX, aY, aString, aLength);
|
||||
}
|
||||
|
||||
void nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLength,
|
||||
|
Loading…
Reference in New Issue
Block a user