From: <sil...@li...> - 2003-01-31 00:23:17
|
Update of /cvsroot/silgraphite/silgraphite/c/src In directory sc8-pr-cvs1:/tmp/cvs-serv7241/c/src Added Files: graphitepriv.h greng.cpp grgfx.cpp grseg.cpp grtxt.cpp Log Message: add c wraper --- NEW FILE: graphitepriv.h --- /************************************************************** Copyright (C) 1999, 2001 SIL International. All rights reserved. Distributable under the terms of either the Common Public License or the GNU Lesser General Public License, as specified in the LICENSING.txt file. File: graphitepriv.h Description: header file to help C interface wrapper Author: Frank Yung-Fong Tang <ft...@ne...> *************************************************************/ #ifndef graphitepriv_h__ #define graphitepriv_h__ #define GRRES_C_TO_CPP(res) ((GrResult)(res)) #define GRRES_CPP_TO_C(result) ((grres)(result)) #define GRENG_C_TO_CPP(eng) ((GrEngine*)(eng)) #define GRENG_CPP_TO_C(engine) ((greng)(engine)) #define GRSEG_C_TO_CPP(seg) ((GrSegment*)(seg)) #define GRSEG_CPP_TO_C(segment) ((grseg)(segment)) #define GRSEGP_C_TO_CPP(segp) ((GrSegment**)(segp)) #define GRGFX_C_TO_CPP(gfx) ((IGrGraphics*)(gfx)) #define GRGFX_CPP_TO_C(graphics) ((grgfx)(graphics)) #define GRTXT_C_TO_CPP(txt) ((IGrTextSource*)(txt)) #define GRTXT_CPP_TO_C(txtsrc) ((grtxt)(txtsrc)) #define GRTXTP_CPP_TO_C(txtsrcp) ((grtxt*)(txtsrcp)) #endif /* graphitepriv_h__ */ --- NEW FILE: greng.cpp --- /************************************************************** Copyright (C) 1999, 2001 SIL International. All rights reserved. Distributable under the terms of either the Common Public License or the GNU Lesser General Public License, as specified in the LICENSING.txt file. File: greng.cpp Description: Wrapper file for greng C interface Author: Frank Yung-Fong Tang <ft...@ne...> *************************************************************/ #include "main.h" #include "graphite.h" #include "graphitepriv.h" #include "GrEngine.h" class GrSegment; // forward declaration greng grengNew() { return GRENG_CPP_TO_C( new GrEngine() ); } void grengDone(greng aEng) { delete GRENG_C_TO_CPP(aEng); } grres grengFontIsValid(greng aEng, OLECHAR * prgchwErrMsg, int cchMaxErrMsg) { return GRRES_CPP_TO_C( GRENG_C_TO_CPP(aEng)->FontIsValid(prgchwErrMsg, cchMaxErrMsg) ); } grres grengGetSegDatMaxLength(greng aEng, int * pcb) { return GRRES_CPP_TO_C( GRENG_C_TO_CPP(aEng)->get_SegDatMaxLength(pcb) ); } grres grengFindBreakPoint(greng aEng, grgfx pgg, grtxt pgts, int ichMin, int ichLim, int ichLimBacktrack, bool fNeedFinalBreak, bool fStartLine, int dxMaxWidth, LgLineBreak lbPref, LgLineBreak lbMax, LgTrailingWsHandling twsh, bool fParaRtoL, grseg * ppsegRet, int * pdichwLimSeg, int * pdxWidth, LgEndSegmentType * pest, int cbPrev, byte * pbPrevSegDat, int cbNextMax, byte * pbNextSegDat, int * pcbNextSegDat, int * pdichwContext, OLECHAR * prgchwErrMsg, int cchMaxErrMsg) { return GRRES_CPP_TO_C( GRENG_C_TO_CPP(aEng)->FindBreakPoint( GRGFX_C_TO_CPP(pgg), GRTXT_C_TO_CPP(pgts), ichMin, ichLim, ichLimBacktrack, fNeedFinalBreak, fStartLine, dxMaxWidth, lbPref, lbMax, twsh, fParaRtoL, GRSEGP_C_TO_CPP(ppsegRet), pdichwLimSeg, pdxWidth, pest, cbPrev, pbPrevSegDat, cbNextMax, pbNextSegDat, pcbNextSegDat, pdichwContext, prgchwErrMsg, cchMaxErrMsg ) ); } grres grengGetScriptDirection(greng aEng, int * pgrfsdc, OLECHAR * prgchwErrMsg, int cchMaxErrMsg) { return GRRES_CPP_TO_C( GRENG_C_TO_CPP(aEng)->get_ScriptDirection(pgrfsdc, prgchwErrMsg, cchMaxErrMsg) ); } grres grengInterpretChrp(greng aEng, LgCharRenderProps * pchrp) { return GRRES_CPP_TO_C( GRENG_C_TO_CPP(aEng)->InterpretChrp(pchrp) ); } grres grengIsGraphiteFont(greng aEng, grgfx pgg) { return GRRES_CPP_TO_C( GRENG_C_TO_CPP(aEng)->IsGraphiteFont( GRGFX_C_TO_CPP(pgg)) ); } int grengGetFontEmUnits(greng aEng ) { return GRENG_C_TO_CPP(aEng)->GetFontEmUnits(); } int grengGetExtraAscent(greng aEng ) { return GRENG_C_TO_CPP(aEng)->ExtraAscent(); } int grengGetExtraDescent(greng aEng ) { return GRENG_C_TO_CPP(aEng)->ExtraDescent(); } --- NEW FILE: grgfx.cpp --- /************************************************************** Copyright (C) 1999, 2001 SIL International. All rights reserved. Distributable under the terms of either the Common Public License or the GNU Lesser General Public License, as specified in the LICENSING.txt file. File: graphite.h Description: Wrapper file for grgfx C interface Author: Frank Yung-Fong Tang <ft...@ne...> *************************************************************/ #include "main.h" #include "IGrGraphics.h" #include "graphite.h" #include "graphitepriv.h" class cwGrGraphics : public IGrGraphics { public: cwGrGraphics(grgfx_funcs aFuncs, grgfx_data aData) : mFuncs(aFuncs) , mData(aData) { InitData(); }; virtual ~cwGrGraphics() { ReleaseData(); }; void InitData() { (*(mFuncs->mInitData))(mFuncs, mData); } void ReleaseData() { (*(mFuncs->mReleaseData))(mFuncs, mData); }; GrResult InvertRect(int twLeft, int twTop, int twRight, int twBottom) { return GRRES_C_TO_CPP((*(mFuncs->mInvertRect)) (mFuncs, mData, twLeft, twTop, twRight, twBottom)); }; GrResult DrawTextExt(int x, int y, int cch, const OLECHAR __RPC_FAR * prgchw, UINT uOptions, const RECT __RPC_FAR * pRect, int __RPC_FAR * prgdx) { return GRRES_C_TO_CPP((*(mFuncs->mDrawTextExt)) (mFuncs, mData, x, y, cch, prgchw, uOptions, pRect, prgdx)); }; GrResult GetFontEmSquare(int * pxyFontEmSquare) { return GRRES_C_TO_CPP((*(mFuncs->mGetFontEmSquare)) (mFuncs, mData, pxyFontEmSquare )); }; GrResult GetGlyphMetrics(int chw, int * psBoundingWidth, int * pyBoundingHeight, int * pxBoundingX, int * pyBoundingY, int * pxAdvanceX, int * pyAdvanceY) { return GRRES_C_TO_CPP((*(mFuncs->mGetGlyphMetrics)) (mFuncs, mData, chw, psBoundingWidth, pyBoundingHeight, pxBoundingX, pyBoundingY, pxAdvanceX, pyAdvanceY)); }; GrResult GetFontData(int nTableId, int * pcbTableSz, byte * prgb, int cbMax) { return GRRES_C_TO_CPP((*(mFuncs->mGetFontData)) (mFuncs, mData, nTableId, pcbTableSz, prgb, cbMax)); }; GrResult XYFromGlyphPoint(int chw, int nPoint, int * pxRet, int * pyRet) { return GRRES_C_TO_CPP((*(mFuncs->mXYFromGlyphPoint)) (mFuncs, mData, chw, nPoint, pxRet, pyRet)); }; GrResult get_FontAscent(int* pdy) { return GRRES_C_TO_CPP((*(mFuncs->mGetFontAscent)) (mFuncs, mData, pdy)); }; GrResult get_FontDescent(int* pdy) { return GRRES_C_TO_CPP((*(mFuncs->mGetFontDescent)) (mFuncs, mData, pdy)); }; GrResult get_YUnitsPerInch(int * pyInch) { return GRRES_C_TO_CPP((*(mFuncs->mGetYUnitsPerInch)) (mFuncs, mData, pyInch)); }; GrResult SetupGraphics(LgCharRenderProps * pchrp) { return GRRES_C_TO_CPP((*(mFuncs->mSetupGraphics)) (mFuncs, mData, pchrp)); }; private: grgfx_funcs mFuncs; grgfx_data mData; }; grgfx grgfxNew(grgfx_funcs aFuns, grgfx_data aData) { return GRGFX_CPP_TO_C( new cwGrGraphics(aFuns, aData) ); } void grgfxDone(grgfx aGra) { delete GRGFX_C_TO_CPP(aGra); } --- NEW FILE: grseg.cpp --- /************************************************************** Copyright (C) 1999, 2001 SIL International. All rights reserved. Distributable under the terms of either the Common Public License or the GNU Lesser General Public License, as specified in the LICENSING.txt file. File: graphite.h Description: Wrapper file for grseg C interface Author: Frank Yung-Fong Tang <ft...@ne...> *************************************************************/ #include "main.h" #include "GrSegment.h" #include "graphite.h" #include "graphitepriv.h" void grsegDone(grseg aSeg) { delete GRSEG_C_TO_CPP(aSeg); } grres grsegDrawText(grseg aSeg, int ichwBase, grgfx pgg, RECT rcSrc, RECT rcDst, int * pdxdWidth) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->DrawText( ichwBase, GRGFX_C_TO_CPP(pgg), rcSrc, rcDst, pdxdWidth)); } grres grsegRecompute(grseg aSeg, int ichwBase, grgfx pgg) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->Recompute( ichwBase, GRGFX_C_TO_CPP(pgg))); } #define IMPL_GRSEG_INT_GETTER(a) \ grres grsegGet ##a (grseg aSeg, int ichwBase, grgfx pgg, int * pxs) \ { \ return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_ ##a ( ichwBase, \ GRGFX_C_TO_CPP(pgg), pxs)); \ } IMPL_GRSEG_INT_GETTER(Width) IMPL_GRSEG_INT_GETTER(RightOverhang) IMPL_GRSEG_INT_GETTER(LeftOverhang) IMPL_GRSEG_INT_GETTER(Height) IMPL_GRSEG_INT_GETTER(Ascent) IMPL_GRSEG_INT_GETTER(AscentOverhang) IMPL_GRSEG_INT_GETTER(DescentOverhang) grres grsegExtent(grseg aSeg, int ichwBase, grgfx pgg, int * pdxsWidth, int * pdysHt) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->Extent( ichwBase, GRGFX_C_TO_CPP(pgg), pdxsWidth, pdysHt)); } grres grsegBoundingRect(grseg aSeg, int ichwBase, grgfx pgg, RECT rcSrc, RECT rcDst, RECT * prcBounds) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->BoundingRect( ichwBase, GRGFX_C_TO_CPP(pgg), rcSrc, rcDst, prcBounds)); } grres grsegGetActualWidth(grseg aSeg, int ichwBase, grgfx pgg, RECT rcSrc, RECT rcDst, int * pdxdWidth) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->GetActualWidth( ichwBase, GRGFX_C_TO_CPP(pgg), rcSrc, rcDst, pdxdWidth)); } grres grsegGetRightToLeft(grseg aSeg, int ichwBase, bool * pfResult) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_RightToLeft( ichwBase, pfResult)); } grres grsegGetDirectionDepth(grseg aSeg, int ichwBase, int * pnDepth, bool * pfWeak) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_DirectionDepth( ichwBase, pnDepth, pfWeak)); } grres grsegSetDirectionDepth(grseg aSeg, int ichwBase, int nNewDepth) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->SetDirectionDepth( ichwBase, nNewDepth)); } grres grsegGetWritingSystem(grseg aSeg, int ichwBase, int * penc, int * pws) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_WritingSystem( ichwBase, penc, pws)); } grres grsegGetLim(grseg aSeg, int ichwBase, int * pdichw) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_Lim( ichwBase, pdichw)); } grres grsegGetLimInterest(grseg aSeg, int ichwBase, int * pdichw) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_LimInterest( ichwBase, pdichw)); } grres grsegPutEndLine(grseg aSeg, int ichwBase, grgfx pgg, bool fNewVal) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->put_EndLine( ichwBase, GRGFX_C_TO_CPP(pgg), fNewVal)); } grres grsegPutStartLine(grseg aSeg, int ichwBase, grgfx pgg, bool fNewVal) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->put_StartLine( ichwBase, GRGFX_C_TO_CPP(pgg), fNewVal)); } grres grsegGetStartBreakWeight(grseg aSeg, int ichwBase, grgfx pgg, LgLineBreak * plb) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_StartBreakWeight(ichwBase, GRGFX_C_TO_CPP(pgg), plb)); } grres grsegGetEndBreakWeight(grseg aSeg, int ichwBase, grgfx pgg, LgLineBreak * plb) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_EndBreakWeight(ichwBase, GRGFX_C_TO_CPP(pgg), plb)); } grres grsegGetStretch(grseg aSeg, int ichwBase, int * pxs) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->get_Stretch( ichwBase, pxs)); } grres grsegPutStretch(grseg aSeg, int ichwBase, int xs) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->put_Stretch( ichwBase, xs)); } grres grsegIsValidInsertionPoint(grseg aSeg, int ichwBase, grgfx pgg, int ichwIP, LgIpValidResult * pipvr) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->IsValidInsertionPoint( ichwBase, GRGFX_C_TO_CPP(pgg), ichwIP, pipvr)); } grres grsegDoBoundariesCoincide(grseg aSeg, int ichwBase, grgfx pgg, bool fBoundaryEnd, bool fBoundaryRight, bool * pfResult) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->DoBoundariesCoincide(ichwBase, GRGFX_C_TO_CPP(pgg), fBoundaryEnd, fBoundaryRight, pfResult)); } grres grsegDrawInsertionPoint(grseg aSeg, int ichwBase, grgfx pgg, RECT rcSrc, RECT rcDst, int ichwIP, bool fAssocPrev, bool bOn, LgIPDrawMode dm) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->DrawInsertionPoint(ichwBase, GRGFX_C_TO_CPP(pgg), rcSrc, rcDst, ichwIP, fAssocPrev, bOn, dm)); } grres grsegPositionsOfIP(grseg aSeg, int ichwBase, grgfx pgg, RECT rs, RECT rd, int ichwIP, bool fAssocPrev, LgIPDrawMode dm, RECT * prdPrimary, RECT * prdSecondary, bool * pfPrimaryHere, bool * pfSecHere) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->PositionsOfIP(ichwBase, GRGFX_C_TO_CPP(pgg), rs, rd, ichwIP, fAssocPrev, dm, prdPrimary, prdSecondary, pfPrimaryHere, pfSecHere)); } grres grsegDrawRange(grseg aSeg, int ichwBase, grgfx pgg, RECT rs, RECT rd, int ichwMin, int ichwLim, int ydTop, int ydBottom, bool bOn) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->DrawRange(ichwBase, GRGFX_C_TO_CPP(pgg), rs, rd, ichwMin, ichwLim, ydTop, ydBottom, bOn)); } grres grsegPositionOfRange(grseg aSeg, int ichwBase, grgfx pgg, RECT rs, RECT rd, int ichwMin, int ichwLim, int ydTop, int ydBottom, RECT * prsBounds, bool * pfAnythingToDraw) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->PositionOfRange(ichwBase, GRGFX_C_TO_CPP(pgg), rs, rd, ichwMin, ichwLim, ydTop, ydBottom, prsBounds, pfAnythingToDraw)); } grres grsegPointToChar(grseg aSeg, int ichwBase, grgfx pgg, RECT rs, RECT rd, POINT zptdClickPosition, int * pichw, bool * pfAssocPrev) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->PointToChar(ichwBase, GRGFX_C_TO_CPP(pgg), rs, rd, zptdClickPosition, pichw, pfAssocPrev)); } grres grsegArrowKeyPosition(grseg aSeg, int ichwBase, grgfx pgg, int * pichwIP, bool * pfAssocPrev, bool fRight, bool fMovingIn, bool * pfResult) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->ArrowKeyPosition(ichwBase, GRGFX_C_TO_CPP(pgg), pichwIP, pfAssocPrev, fRight, fMovingIn, pfResult)); } grres grsegExtendSelectionPosition(grseg aSeg, int ichwBase, grgfx pgg, int * pichw, bool fAssocPrevMatch, bool fAssocPrevNeeded, int ichAnchor, bool fRight, bool fMovingIn, bool* pfRet) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->ExtendSelectionPosition( ichwBase, GRGFX_C_TO_CPP(pgg), pichw, fAssocPrevMatch, fAssocPrevNeeded, ichAnchor, fRight, fMovingIn, pfRet)); } grres grsegGetCharPlacement(grseg aSeg, int ichwBase, grgfx pgg, int ichwMin, int ichwLim, RECT rs, RECT rd, bool fSkipSpace, int crgMax, int * pcxd, int * prgxdLefts, int * prgxdRights, int * prgydTops) { return GRRES_CPP_TO_C( GRSEG_C_TO_CPP(aSeg)->GetCharPlacement( ichwBase, GRGFX_C_TO_CPP(pgg), ichwMin, ichwLim, rs, rd, fSkipSpace, crgMax, pcxd, prgxdLefts, prgxdRights, prgydTops)); } --- NEW FILE: grtxt.cpp --- /************************************************************** Copyright (C) 1999, 2001 SIL International. All rights reserved. Distributable under the terms of either the Common Public License or the GNU Lesser General Public License, as specified in the LICENSING.txt file. File: grtxt.cpp Description: Wrapper file for grtxt C interface Author: Frank Yung-Fong Tang <ft...@ne...> *************************************************************/ #include "main.h" #include "IGrTextSource.h" #include "graphite.h" #include "graphitepriv.h" /* Functions for grtxt */ class cwTextSource : public IGrTextSource { public: cwTextSource(grtxt_funcs aFuncs, grtxt_data aData) : mFuncs(aFuncs) , mData(aData) { InitData(); }; virtual ~cwTextSource() { ReleaseData(); }; void InitData() { (*(mFuncs->mInitData))(mFuncs, mData); } void ReleaseData() { (*(mFuncs->mReleaseData))(mFuncs, mData); }; GrResult Fetch(int ichMin, int ichLim, OLECHAR * prgchBuf) { return GRRES_C_TO_CPP((*(mFuncs->mFetch)) (mFuncs, mData, ichMin, ichLim, prgchBuf)); }; GrResult get_Length(int* pcch) { return GRRES_C_TO_CPP((*(mFuncs->mGetLength)) (mFuncs, mData, pcch)); }; GrResult GetCharProps( int ich, LgCharRenderProps * pchrp, int * pichMin, int * pichLim) { return GRRES_C_TO_CPP((*(mFuncs->mGetCharProps)) (mFuncs, mData, ich, pchrp, pichMin, pichLim)); }; GrResult GetParaProps( int ich, LgParaRenderProps * pchrp, int * pichMin, int * pichLim) { return GRRES_C_TO_CPP((*(mFuncs->mGetParaProps)) (mFuncs, mData, ich, pchrp, pichMin, pichLim)); }; GrResult GetFontVariations( int ich, OLECHAR * prgchFontVar, int ichMax, int * pich, int * pichMin, int * pichLim) { return GRRES_C_TO_CPP((*(mFuncs->mGetFontVariations)) (mFuncs, mData, ich, prgchFontVar, ichMax, pich, pichMin, pichLim)); }; void TextSrcObject( IGrTextSource** ppgts) { (*(mFuncs->mTextSrcObject)) (mFuncs, mData, GRTXTP_CPP_TO_C(ppgts)); }; void DeleteTextSrcPtr() { (*(mFuncs->mDeleteTextSrcPtr))(mFuncs, mData); }; private: grtxt_funcs mFuncs; grtxt_data mData; }; grtxt grtxtNew(grtxt_funcs aFuns, grtxt_data aData) { return GRTXT_CPP_TO_C( new cwTextSource(aFuns, aData) ); } void grtxtDone(grtxt aTxt) { delete GRTXT_C_TO_CPP(aTxt); } |