From: <sil...@li...> - 2004-10-27 14:32:45
|
Update of /cvsroot/silgraphite/silgraphite/contrib/fwviews In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11188/contrib/fwviews Modified Files: Tag: v2api GrTxtSrc.cpp GrTxtSrc.h Log Message: Synchronized with FW changelist #12044: began ITextSource rework Index: GrTxtSrc.cpp =================================================================== RCS file: /cvsroot/silgraphite/silgraphite/contrib/fwviews/GrTxtSrc.cpp,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -d -r1.5 -r1.5.2.1 --- GrTxtSrc.cpp 6 Oct 2004 18:28:30 -0000 1.5 +++ GrTxtSrc.cpp 27 Oct 2004 14:31:59 -0000 1.5.2.1 @@ -28,27 +28,33 @@ //:>******************************************************************************************** //:>******************************************************************************************** -//:> Methods +//:> Methods: old interface //:>******************************************************************************************** /*---------------------------------------------------------------------------------------------- Constructors. ----------------------------------------------------------------------------------------------*/ -GrSimpleTextSource::GrSimpleTextSource(OLECHAR * pszText, GrCharProps & chrp, - OLECHAR * prgchFontVar, int ichFontVar) +GrSimpleTextSource::GrSimpleTextSource(gr::utf16 * pszText, + gr::utf16 * szFaceName, int ichFaceName, int pointSize, bool fBold, bool fItalic, bool fRtl) + //gr::utf16 * prgchFontVar, int ichFontVar) { - Assert(ichFontVar < isizeof(m_rgchFontVar)); + //Assert(ichFontVar < isizeof(m_rgchFontVar)); m_cref = 1; // COM-like behavior m_cchLength = wcslen(pszText); - m_prgchText = NewObj OLECHAR[m_cchLength + 1]; - memcpy(m_prgchText, pszText, isizeof(OLECHAR) * m_cchLength); + m_prgchText = NewObj gr::utf16[m_cchLength + 1]; + memcpy(m_prgchText, pszText, isizeof(gr::utf16) * m_cchLength); m_prgchText[m_cchLength] = 0; // zero-terminate - memcpy(&m_chrp, &chrp, isizeof(GrCharProps)); - memset(m_rgchFontVar, 0, isizeof(m_rgchFontVar)); - memcpy(m_rgchFontVar, prgchFontVar, min(ichFontVar, isizeof(m_rgchFontVar))); + wcscpy(m_szFaceName, szFaceName); + m_pointSize = pointSize; + m_fBold = fBold; + m_fItalic = fItalic; + m_fRtl = fRtl; + + //memset(m_rgchFontVar, 0, isizeof(m_rgchFontVar)); + //memcpy(m_rgchFontVar, prgchFontVar, min(ichFontVar, isizeof(m_rgchFontVar))); } @@ -86,7 +92,17 @@ ChkGrArgPtrN(pichLim); ChkGrArgPtrN(pichMin); - memcpy(pchrp, &m_chrp, isizeof(GrCharProps)); + wcscpy(pchrp->szFaceName, m_szFaceName); + pchrp->dympHeight = m_pointSize * 1000; + pchrp->ttvBold = (byte)((m_fBold) ? kttvOn : kttvOff); + pchrp->ttvItalic = (byte)((m_fItalic) ? kttvOn : kttvOff); + pchrp->fWsRtl = m_fRtl; + + pchrp->dympOffset = 0; // vertical offset + pchrp->ssv = kssvOff; // superscript + pchrp->clrFore = 0; + pchrp->clrBack = 0; // transparent + *pichMin = 0; *pichLim = m_cchLength; return kresOk; @@ -123,24 +139,95 @@ should be in effect for the given character. Also return the range of characters for which these variations are in effect; for this implementation that is the entire string. + This is simple implementaton of text-source does not support features. ----------------------------------------------------------------------------------------------*/ GrResult GrSimpleTextSource::GetFontVariations(int ich, - OLECHAR * prgchFontVar, int ichMax, int * pich, + OLECHAR * prgchFontVar, int ichMax, int * pcch, int * pichMin, int * pichLim) { ChkGrArgPtr(pichMin); ChkGrArgPtr(pichLim); ChkGrArrayArg(prgchFontVar, ichMax); - *pich = isizeof(m_rgchFontVar); - if (ichMax < *pich) - return kresFalse; - - memcpy(prgchFontVar, m_rgchFontVar, isizeof(m_rgchFontVar)); + //*pich = isizeof(m_rgchFontVar); + //if (ichMax < *pich) + // return kresFalse; + //memcpy(prgchFontVar, m_rgchFontVar, isizeof(m_rgchFontVar)); + *pcch = 0; *pichMin = 0; *pichLim = m_cchLength; return kresOk; } +//:>******************************************************************************************** +//:> Methods: new interface +//:>******************************************************************************************** + +/*---------------------------------------------------------------------------------------------- + Fill in the buffer with the font face name at the given character position. + Return the number of characters needed, whether or not there is room. +----------------------------------------------------------------------------------------------*/ +GrResult GrSimpleTextSource::getFaceName(int ich, unsigned int cchMax, + gr::utf16 * prgchFaceName, unsigned int * pcchLen) +{ + *pcchLen = wcslen(m_szFaceName); + if (*pcchLen >= cchMax) + return kresFail; // insufficient room in the buffer + + wcscpy(prgchFaceName, m_szFaceName); // includes zero-terminator + return kresOk; +} + +/*---------------------------------------------------------------------------------------------- + Return the size of the text, in points. +----------------------------------------------------------------------------------------------*/ +float GrSimpleTextSource::getFontSize(int ich) +{ + return (float)m_pointSize; +} + +/*---------------------------------------------------------------------------------------------- + Return true if the text is bold. +----------------------------------------------------------------------------------------------*/ +bool GrSimpleTextSource::getBold(int ich) +{ + return m_fBold; +} + +/*---------------------------------------------------------------------------------------------- + Return true if the text is italic. +----------------------------------------------------------------------------------------------*/ +bool GrSimpleTextSource::getItalic(int ich) +{ + return m_fItalic; +} + +/*---------------------------------------------------------------------------------------------- + Return true if the text uses a right-to-left writing system. +----------------------------------------------------------------------------------------------*/ +bool GrSimpleTextSource::getRightToLeft(int ich) +{ + return m_fRtl; +} + +/*---------------------------------------------------------------------------------------------- + Return the depth of embedding of the writing system. +----------------------------------------------------------------------------------------------*/ +unsigned int GrSimpleTextSource::getDirectionDepth(int ich) +{ + if (m_fRtl) + return 1; + else; + return 0; +} + +/*---------------------------------------------------------------------------------------------- + Return the vertical offset of the text. This simple implementation provides no + vertical offset. +----------------------------------------------------------------------------------------------*/ +float GrSimpleTextSource::getVerticalOffset(int ich) +{ + return 0; +} Index: GrTxtSrc.h =================================================================== RCS file: /cvsroot/silgraphite/silgraphite/contrib/fwviews/GrTxtSrc.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- GrTxtSrc.h 6 Oct 2004 18:28:30 -0000 1.4 +++ GrTxtSrc.h 27 Oct 2004 14:31:59 -0000 1.4.2.1 @@ -26,8 +26,10 @@ { public: // Constructor: - GrSimpleTextSource(OLECHAR * pszText, GrCharProps & chrp, - OLECHAR * prgchFontVar, int ichFontVar); + GrSimpleTextSource(gr::utf16 * pszText, + gr::utf16 * szFaceName, int ichFaceName, int pointSize, + bool fBold, bool fItalic, bool fRtl); + //gr::utf16 * prgchFontVar, int ichFontVar); ~GrSimpleTextSource(); virtual long IncRefCount(void) @@ -51,7 +53,7 @@ virtual GrResult GetParaProps(int ich, LgParaRenderProps * pchrp, int * pichMin, int * pichLim); virtual GrResult GetFontVariations(int ich, - OLECHAR * prgchFontVar, int ichMax, int * pich, + OLECHAR * prgchFontVar, int ichMax, int * pcch, int * pichMin, int * pichLim); // virtual GrResult GetCharStringProp(int ich, int id, // OLECHAR * prgch, int ichMax, int * pich, @@ -72,12 +74,52 @@ { } + // ------------------------------------------------------------------------------- + // New interface: + virtual GrResult getFaceName(int ich, unsigned int cchMax, + gr::utf16 * prgchFaceName, unsigned int * pcchLen); + virtual float getFontSize(int ich); + virtual bool getBold(int ich); + virtual bool getItalic(int ich); + virtual bool getRightToLeft(int ich); + virtual unsigned int getDirectionDepth(int ich); + virtual float getVerticalOffset(int ich); + + virtual void getRunRange(int ich, int * pichMin, int * pichLim) + { + *pichMin = 0; + *pichLim = m_cchLength; + } + virtual GrResult getFontFeatures(int ich, int cMax, + FeatureSetting * prgfset, int * pcfset) + { + *pcfset = 0; // no features in this simple implementation + return kresOk; + } + virtual bool sameSegment(int ich1, int ich2) + { + return true; + } + + // Temporary--eventually these properties will be of interest only to SegmentPainter. + virtual void getColors(int ich, int * pclrFore, int * pclrBack) + { + *pclrFore = kclrBlack; + *pclrBack = kclrTransparent; + } + protected: long m_cref; - OLECHAR * m_prgchText; + gr::utf16 * m_prgchText; int m_cchLength; - OLECHAR m_rgchFontVar[64]; - GrCharProps m_chrp; + //gr::utf16 m_rgchFontVar[64]; + + gr::utf16 m_szFaceName[32]; + int m_pointSize; + bool m_fBold; + bool m_fItalic; + bool m_fRtl; + bool m_directionDepth; }; |