- Added line style support

This commit is contained in:
Dale.Stansberry%Nexwarecorp.com 1999-07-16 14:11:15 +00:00
parent 8538bfa431
commit f4d6984856
2 changed files with 58 additions and 27 deletions

View File

@ -139,24 +139,23 @@ nsRenderingContextPh :: nsRenderingContextPh()
mWidget = nsnull;
mPhotonFontName = nsnull;
Mask = nsnull;
mLineStyle = nsLineStyle_kSolid;
//default objects
//state management
mStates = nsnull;
mStateCache = new nsVoidArray();
mCurrFontMetrics = nsnull;
mGammaTable = nsnull;
#ifdef NS_DEBUG
mInitialized = PR_FALSE;
#endif
mScriptObject = nsnull;
if( mPtGC == nsnull )
mPtGC = PgGetGC();
#ifdef NS_DEBUG
mInitialized = PR_FALSE;
#endif
PushState();
}
@ -715,7 +714,8 @@ NS_IMETHODIMP nsRenderingContextPh :: GetColor(nscolor &aColor) const
NS_IMETHODIMP nsRenderingContextPh :: SetLineStyle(nsLineStyle aLineStyle)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::SetLineStyle - Not Implemented\n"));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::SetLineStyle\n"));
mLineStyle = aLineStyle;
return NS_OK;
}
@ -723,6 +723,7 @@ NS_IMETHODIMP nsRenderingContextPh :: SetLineStyle(nsLineStyle aLineStyle)
NS_IMETHODIMP nsRenderingContextPh :: GetLineStyle(nsLineStyle &aLineStyle)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::GetLineStyle - Not Implemented\n"));
aLineStyle = mLineStyle;
return NS_OK;
}
@ -881,6 +882,10 @@ NS_IMETHODIMP nsRenderingContextPh :: DestroyDrawingSurface(nsDrawingSurface aDS
NS_IMETHODIMP nsRenderingContextPh :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawLine (%ld,%ld,%ld,%ld)\n", aX0, aY0, aX1, aY1 ));
if( nsLineStyle_kNone == mLineStyle )
return NS_OK;
nscoord x0,y0,x1,y1;
x0 = aX0;
@ -894,6 +899,7 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawLine(nscoord aX0, nscoord aY0, nscoord
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawLine (%ld,%ld,%ld,%ld)\n", x0, y0, x1, y1 ));
SELECT(mSurface);
SetPhLineStyle();
PgDrawILine( x0, y0, x1, y1 );
return NS_OK;
@ -904,6 +910,9 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawPolyline(const nsPoint aPoints[], PRIn
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("untested nsRenderingContextPh::DrawPolyLine\n"));
if( nsLineStyle_kNone == mLineStyle )
return NS_OK;
PhPoint_t *pts;
if(( pts = new PhPoint_t [aNumPoints] ) != NULL )
@ -922,6 +931,7 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawPolyline(const nsPoint aPoints[], PRIn
}
SELECT(mSurface);
SetPhLineStyle();
PgDrawPolygon( pts, aNumPoints, &pos, Pg_DRAW_STROKE );
delete [] pts;
@ -1744,3 +1754,27 @@ rid = gc->rid;
// PgSetMultiClip( 0, NULL );
}
void nsRenderingContextPh::SetPhLineStyle()
{
switch( mLineStyle )
{
case nsLineStyle_kSolid:
PgSetStrokeDash( nsnull, 0, 0x10000 );
break;
case nsLineStyle_kDashed:
PgSetStrokeDash( "\10\4", 2, 0x10000 );
break;
case nsLineStyle_kDotted:
PgSetStrokeDash( "\1", 1, 0x10000 );
break;
case nsLineStyle_kNone:
default:
break;
}
}

View File

@ -175,12 +175,14 @@ private:
NS_IMETHOD CommonInit();
void RestoreGC();
void ApplyClipping( PhGC_t *);
void SetPhLineStyle();
protected:
PhGC_t *mGC;
PhGC_t *mholdGC;
PhGC_t *mOldGC;
nscolor mCurrentColor;
nsLineStyle mLineStyle;
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
nsIFontMetrics *mFontMetrics;
nsDrawingSurfacePh *mOffscreenSurface;
@ -198,12 +200,7 @@ protected:
//state management
GraphicsState *mStates;
nsVoidArray *mStateCache;
nscolor mCurrBrushColor;
nsIFontMetrics *mCurrFontMetrics;
nscolor mCurrPenColor;
PRUint8 *mGammaTable;
nscolor mCurrTextColor;
nsLineStyle mCurrLineStyle;
static PhGC_t *mPtGC;