⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 txtwindw.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}HX_RESULTTextWindowBase::setDefaultFontFaceString(const char* pszFace){    HX_RESULT hxrslt = HXR_FAILED;    if (pszFace)    {	if (m_pDefaultFontFaceString)	{	    delete [] m_pDefaultFontFaceString;	    m_pDefaultFontFaceString = NULL;	}	INT32 lLen = strlen(pszFace);	if (lLen > 0)	{	    m_pDefaultFontFaceString = new char[lLen + 1];	    if (m_pDefaultFontFaceString)	    {		strcpy(m_pDefaultFontFaceString, pszFace); /* Flawfinder: ignore */	    }	}	// /else leave it NULL.    }    return hxrslt;}HX_RESULTTextWindowBase::setDefaultCharsetString(const char* pszCharset){    HX_RESULT hxrslt = HXR_FAILED;    if (pszCharset)    {	if (m_pDefaultCharsetString)	{	    delete [] m_pDefaultCharsetString;	    m_pDefaultCharsetString = NULL;	}	INT32 lLen = strlen(pszCharset);	if (lLen > 0)	{	    m_pDefaultCharsetString = new char[lLen + 1];	    if (m_pDefaultCharsetString)	    {		// /Allow it to be case-insensitive by converting to lower-case		const char* pszChSet = pszCharset;		char* pszDefChSet = m_pDefaultCharsetString;		for (INT32 lI = 0; lI<lLen; lI++, pszChSet++, pszDefChSet++)		{		    if (*pszChSet>='A'  &&  *pszChSet<='Z')		    {			*pszDefChSet = *pszChSet-'A'+'a';		    }		    else		    {			*pszDefChSet = *pszChSet;		    }		}		*pszDefChSet = '\0'; // /NULL terminate it.	    }	}	// /else leave it NULL.    }    return hxrslt;}HX_RESULTTextWindowBase::getCharsetULONG32(const char* pszCharset,				      UINT16 uiMaxLevelSupported,				      ULONG32& ulCharset /*OUT*/){    HX_RESULT hxrslt = HXR_OK;    if (!pszCharset)    {	hxrslt = HXR_INVALID_PARAMETER;    }    else    {	TextParser* pTP = new TextParser((TextWindow*)this);	if (pTP)	{	    hxrslt = pTP->convertCharsetNameToCharsetULONG32(pszCharset,		    strlen(pszCharset), uiMaxLevelSupported,		    ulCharset);	}	else	{	    hxrslt = HXR_OUTOFMEMORY;	}	HX_DELETE(pTP);    }    return hxrslt;}HX_RESULTTextWindowBase::setUserPrefRelativeTextSizing(ULONG32 ulTextSizeScaleFactor){    m_bUserTextSizingPrefIsSet = TRUE;    m_bUserPrefSizeIsRelative = TRUE;    m_ulUserPrefTextSizeOrScaleFactorPct = ulTextSizeScaleFactor;    m_ulDefaultPointSize = (ULONG32)((float)( (double)((float)(m_ulDefaultPointSize)) *	    ((double)((float)(m_ulUserPrefTextSizeOrScaleFactorPct)) / 100.0) ));    return HXR_OK;}HX_RESULTTextWindowBase::setUserPrefAbsoluteTextSizing(ULONG32 ulTextPointSize){    m_bUserTextSizingPrefIsSet = TRUE;    m_bUserPrefSizeIsRelative = FALSE;    m_ulDefaultPointSize = m_ulUserPrefTextSizeOrScaleFactorPct =	    ulTextPointSize;    m_bUserTextSizingPrefIsSet = TRUE;    return HXR_OK;}// /XXXEH- check if is within reasonable bounds before setting:// /Returns HXR_OK if and only if it does set the base text point// size to the requested value:HX_RESULTTextWindowBase::setDefaultPtSize(ULONG32 ulPtSz){    HX_RESULT hxrslt = HXR_OK;    if (!m_bUserTextSizingPrefIsSet)    {	m_ulDefaultPointSize = ulPtSz;    }    else if (m_bUserPrefSizeIsRelative)    {	double dPtSz = (double)((float)ulPtSz);	double dUserPrefTextSizeOrScaleFactorPct =		(double)((float)m_ulUserPrefTextSizeOrScaleFactorPct);	// /If relative, then m_ulUserPrefTextSize is a scaling factor:	m_ulDefaultPointSize = (ULONG32)((float)(		dPtSz * (dUserPrefTextSizeOrScaleFactorPct / 100.0) ));    }    else // /user pref is absolute, so we can't change it:    {	hxrslt = HXR_FAILED;    }    return hxrslt;}// /Scales the default font size by the given scale factor.// Returns HXR_OK if and only if it set the default text point// size to the requested value:HX_RESULTTextWindowBase::scaleDefaultPtSize(double dScaleFactor){    HX_RESULT hxrslt = HXR_OK;    if (!m_bUserTextSizingPrefIsSet)    {	m_ulDefaultPointSize = (ULONG32)((float)(	    (double)((float)(m_ulDefaultPointSize)) * dScaleFactor) );    }    else if (m_bUserPrefSizeIsRelative)    {	double dDefaultPointSize = (double)((float)m_ulDefaultPointSize);	double dUserPrefTextSizeOrScaleFactorPct =		(double)((float)m_ulUserPrefTextSizeOrScaleFactorPct);	// /If relative, then m_ulUserPrefTextSize is a scaling factor:	m_ulDefaultPointSize = (ULONG32)((float)( dDefaultPointSize *		(dUserPrefTextSizeOrScaleFactorPct / 100.0) *		dScaleFactor));  // /e.g., 16pt * "larger" * 1.20 = 23pt    }    else // /user pref is absolute, so we can't change it:    {	hxrslt = HXR_FAILED;    }    return hxrslt;}// /Sets default bold-ness (of plain text):voidTextWindowBase::setDefaultFontWeight(UINT32 ulWeight){    // /Make it 100, 200, ..., 900 only:    if (ulWeight < 100)    {	ulWeight = 100;    }    else    {	ulWeight %= 1000;	ulWeight = (ulWeight+50) / 100; // /Add 50 to round up >= x.50	ulWeight *= 100;    }    m_ulDefaultFontWeight = ulWeight;}/////////////////////////////////////////////////////////////////////////////// Method://  TextWindowBase::setLoop(_CHAR* pBuf, ULONG32 bufLen)//// Purpose://  Sets the m_loop member to TRUE or FALSE, depending on the conversion //  of the value in buf.  For example, if buf contains "FALSE", this function//  will set m_loop to FALSE, meaning that the text that the window displays//  will not loop back and restart displaying prior text when it has all//  scrolled or crawled out of the window's client area.  If "TRUE" is sent,//  then this window has the loop property and old text will loop back and //  be redisplayed when the stream stops sending new text.//// Returns://  returns FALSE, with m_loop set to DEFAULT_DOLOOP, if buf converts to//  an invalid BOOL value://BOOL TextWindowBase::setLoop(_CHAR* pBuf, ULONG32 bufLen){	    BOOL didErrorOccur = FALSE;    m_loop = string_to_BOOL(pBuf, bufLen, didErrorOccur);		    if(didErrorOccur)    {	m_loop = DEFAULT_DOLOOP;    }    return (!didErrorOccur);}/////////////////////////////////////////////////////////////////////////////// Method://  TextWindowBase::SetExtraSpacesHandling(_CHAR* pBuf, ULONG32 bufLen)//BOOL TextWindowBase::SetExtraSpacesHandling(_CHAR* pBuf, ULONG32 bufLen){    BOOL didErrorOccur = FALSE;        m_bDontIgnoreExtraSpaces =	    string_to_BOOL(pBuf, bufLen, didErrorOccur);    if(didErrorOccur)    {	m_bDontIgnoreExtraSpaces = DEFAULT_DONT_IGNORE_EXTRA_SPACES;    }    return (!didErrorOccur);}/////////////////////////////////////////////////////////////////////////////// Method://  TextWindowBase::setType(_CHAR* pBuf, ULONG32 bufLen)//// Purpose://  Sets the window's type, which has particular rendering characteristics//  and default sizes .etc associated with it.//  buf can contain one of the following://   - "GENERIC" which is a 320x180 window with no text motion.//   - "TICKERTAPE" which creates a marquee-type window where all text//  	is displayed on the same line and moves to the left at a set rate,//	and loops, by default.  Is different from "MARQUEE" because it//	has "upper" and "lower" text items instead of centering all text//	vertically.//   - "SCROLLINGNEWS" which creates a window where text scrolls toward//  	the top of the screen, with no looping, by default.//   - "TELEPROMPTER" which creates a window with no set scrollrate but, when//	a new item of text arrives, it scrolls the currently-displayed text//	upward to make room for the new text.//   - "MARQUEE" which creates a marquee-type window where all text//  	is displayed on the same line and moves to the left at a set rate,//	and loops, by default.  Is different from "TICKERTAPE" because it//	centers all text vertically instead of having "upper" and "lower"//	text items.//// Returns://  returns FALSE, with m_type set to DEFAULT_TYPE, if buf converts to//  an invalid type value://BOOL TextWindowBase::setType(_CHAR* pBuf, ULONG32 bufLen){   /*  Can only be set from within <WINDOW > header tag,     *  before window is created: */    if(!pBuf  ||  !bufLen)    {	m_type = DEFAULT_TYPE;    }    else    {	_CHAR tmpChar = '\0';	if(pBuf[0] == '\"') //get "rid" of starting quote char:	{	    pBuf++;	    bufLen--;	}	if(pBuf[bufLen-1] == '\"')  //get rid of ending quote char:	{	    tmpChar = '\"';	    pBuf[bufLen-1] = '\0';	    bufLen--;	}	convertToUpperCase(pBuf, bufLen);		if(!stringCompare(pBuf, bufLen, "TICKERTAPE", 10))	{	    m_type = TYPE_TICKERTAPE;	}	else if(!stringCompare(pBuf, bufLen, "SCROLLINGNEWS", 13)  ||		//(keep this for legacy reasons:)		!stringCompare(pBuf, bufLen, "MISCELLANEOUSNEWS", 17) ) 	{	    m_type = TYPE_SCROLLINGNEWS;	}	else if(!stringCompare(pBuf, bufLen, "TELEPROMPTER", 12)  ||		!stringCompare(pBuf, bufLen, "AUTOSCROLL", 10) )	{	    m_type = TYPE_TELEPROMPTER;	}	else if(!stringCompare(pBuf, bufLen, "MARQUEE", 7))	{	    m_type = TYPE_MARQUEE;	}	else	{	    m_type = DEFAULT_TYPE;	}		if(tmpChar == '\"')	{   //restore the ending quote char:	    bufLen++;	    pBuf[bufLen-1] = tmpChar;	}    }    return (DEFAULT_TYPE != m_type); //Error occurred if m_type==DEFAULT_TYPE}/////////////////////////////////////////////////////////////////////////////// Method://  TextWindowBase::setDebugFlags(_CHAR* pBuf, BOOL& didErrorOccur)//// Purpose://  Converts a _CHAR* buffer into m_ulDebugFlags (a ULONG32 value).  pBuf can//  contain a base-10 number, like 65537, or a hex number that starts with//  "0x", like 0x00010001 (which equals 65537).//// Returns://  returns FALSE if fails for any reason.//#if defined(_DEBUG)BOOL TextWindowBase::setDebugFlags(_CHAR* pBuf, ULONG32 bufLen){   /*  Can only be set from within <WINDOW > header tag,     *  before window is created: */    BOOL didErrorOccur = FALSE;    BOOL bIsHex = FALSE;    m_ulDebugFlags = 0L;    if(bufLen > 2)    {	if(pBuf[0] == '0'  &&  (pBuf[1] == 'X'  ||  pBuf[1] == 'x'))	{	    bIsHex = TRUE;	    pBuf = &pBuf[2];	    bufLen -= 2;	    _CHAR* pTmp = pBuf;	    if(!pTmp)	    {		return FALSE;	    }	    do	    {		_CHAR tmpCh = *pTmp;		if(tmpCh >= '0'  &&  tmpCh <='9')		{		    m_ulDebugFlags<<=4;		    m_ulDebugFlags += tmpCh-'0';		}		else if(tmpCh >= 'A'  &&  tmpCh <='F')		{		    m_ulDebugFlags<<=4;		    m_ulDebugFlags += tmpCh-'A' + 0xAL;		}		else if(tmpCh >= 'a'  &&  tmpCh <='f')		{		    m_ulDebugFlags<<=4;		    m_ulDebugFlags += tmpCh-'a' + 0xAL;		}	    } while(*(++pTmp));	    return TRUE;	}    }    m_ulDebugFlags = string_to_ULONG32(pBuf, didErrorOccur);    if(didErrorOccur)    {	return FALSE;    }    return (!didErrorOccur);}#endif/////////////////////////////////////////////////////////////////////////////// Method://  TextWindowBase::string_to_ULONG32(_CHAR* pBuf, BOOL& didErrorOccur)//// Purpose://  Converts a _CHAR* buffer into a ULONG32 value.	//// Returns://  returns the ULONG32 value as converted from buf.  //  The referenced value, didErrorOccur, is set to FALSE, and the returned//  value is set to 0L, if an error occurred.//ULONG32 TextWindowBase::string_to_ULONG32(_CHAR* pBuf, BOOL& didErrorOccur){    return(ULONG32)(string_to_LONG32(pBuf, didErrorOccur));}/////////////////////////////////////////////////////////////////////////////// Method://  TextWindowBase::string_to_LONG32(_CHAR* pBuf, BOOL& didErrorOccur)//// Purpose://  Converts a _CHAR* buffer into a LONG32 value.	//// Returns://  returns the LONG32 value as converted from buf.  //  The referenced value, didErrorOccur, is set to FALSE, and the returned//  value is set to 0L, if an error occurred.//LONG32 TextWindowBase::string_to_LONG32(_CHAR* pBuf, BOOL& didErrorOccur){    didErrorOccur = FALSE;    if(pBuf)    {	ULONG32 bufLen = strlen(pBuf);	LONG32 tmp = 0L;	BOOL bStartQuoteWasFound = FALSE;	BOOL bEndQuoteWasFound = FALSE;	//This function is in parsing.cpp|h:	if(lookForStartAndEndQuotesOfString(pBuf, bufLen,		bStartQuoteWasFound, bEndQuoteWasFound))	{	    if(bEndQuoteWasFound)	    {		pBuf[bufLen-1] = '\0';		bufLen--;	    }	    if(bStartQuoteWasFound)	    {		pBuf++;		bufLen--;	    }	    	    HX_ASSERT(strlen(pBuf) == bufLen);	}#if defined(_CHARsizeInBytesIs1)	tmp = atol(pBuf);#else	tmp = _wtol(pBuf);#endif	    	if(bEndQuoteWasFound)	{	    //restore the ending char:	    bufLen++;	    pBuf[bufLen-1] = '\"';	}	return (tmp);    }    didErrorOccur = TRUE;    return 0L;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -