📄 txtwindw.cpp
字号:
stringCopy(m_pURL, pNewURL, newURLstrlen); return TRUE;}void TextWindow::clearURL(){ if(m_pURL) { delete [] m_pURL; m_pURL = NULL; } m_ulLenURLbuf = 0L; m_ulTargetOfURL = URL_TARGET_INVALID;}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setScrollRate(LONG32 sr)//// Purpose:// Sets the rate, in pixels per second, that the text will move vertically// within the window. sr can be positive or negative; if positive, the text// moves toward the top of the screen. Affects motion of all text,// including text that has already been received from the stream.//// Returns:// returns TRUE upon success, FALSE if (sr < MIN_SCROLLRATE) or if// (sr > MAX_SCROLLRATE)://BOOL TextWindowBase::setScrollRate(LONG32 sr){ if(sr>=MIN_SCROLLRATE && sr<=MAX_SCROLLRATE) { m_scrollRate = sr; } else { sr = SCROLLRATE_UNSPECIFIED; } return (sr == m_scrollRate);}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setScrollRate(_CHAR* pBuf, ULONG32 bufLen)//// Purpose:// Sets the rate, in pixels per second, that the text will move vertically// within the window based on the conversion of the contents of buf into// a LONG32 value. This value can be positive or negative; if positive,// the text moves toward the top of the screen. Affects motion of all text,// including text that has already been received from the stream.//// Returns:// returns TRUE upon success, FALSE if the converted value from buf is// less than MIN_SCROLLRATE or if it is greater than MAX_SCROLLRATE, or // if buf is otherwise invalid://BOOL TextWindowBase::setScrollRate(_CHAR* pBuf, ULONG32 bufLen){ BOOL didErrorOccur = FALSE; LONG32 tmpScrollRate = string_to_LONG32(pBuf, didErrorOccur); if(didErrorOccur) { m_scrollRate = SCROLLRATE_UNSPECIFIED; } else { didErrorOccur = setScrollRate(tmpScrollRate); } return (!didErrorOccur);}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setCrawlRate(LONG32 cr)//// Purpose:// Sets the rate, in pixels per second, that the text will move horizontally// within the window. "cr" can be positive or negative; if positive, the// text moves toward the left of the screen. Affects motion of all text,// including text that has already been received from the stream.//// Returns:// returns TRUE upon success, FALSE if (sr < MIN_CRAWLRATE) or if// (sr > MAX_CRAWLRATE)://BOOL TextWindowBase::setCrawlRate(LONG32 cr){ if(cr>=MIN_CRAWLRATE && cr<=MAX_CRAWLRATE) { m_crawlRate = cr; } return (cr == m_crawlRate);}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setCrawlRate(_CHAR* pBuf, ULONG32 bufLen)//// Purpose:// Sets the rate, in pixels per second, that the text will move horizontally// within the window based on the conversion of the contents of buf into// a LONG32 value. This value can be positive or negative; if positive,// the text moves toward the left of the screen. Affects motion of all// text, including text that has already been received from the stream.//// Returns:// returns TRUE upon success, FALSE if the converted value from buf is// less than MIN_SCROLLRATE or if it is greater than MAX_SCROLLRATE, or // if buf is otherwise invalid://BOOL TextWindowBase::setCrawlRate(_CHAR* pBuf, ULONG32 bufLen){ BOOL didErrorOccur = FALSE; LONG32 tmpCrawlRate = string_to_LONG32(pBuf, didErrorOccur); if(didErrorOccur) { m_crawlRate = CRAWLRATE_UNSPECIFIED; } else { didErrorOccur = setCrawlRate(tmpCrawlRate); } return (!didErrorOccur);}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setBackgroundColor// (// _CHAR* pColorName,// ULONG32 colorNameLen// )//// Purpose:// Sets the background color of the window from the value in // pColorName, which can contain any of the following color names:// black, brown, green, cyan, darkblue, purple, teal, gray, red,// lightgreen, yellow, blue, magenta, lightblue, and white.// or, alternatively, any color of the form: #RRGGBB where RR, GG, and BB// are hex values from 0x00 to 0xFF representing the Red, Green, and Blue// components of the color. These values can be different lengths (from// one to six) as follows: #B, #BB, #GBB, #GGBB, #RGGBB, and #RRGGBB, for// example, #7CF means a Red compolnent of 0x00, a Green component of// 0x07, and a Blue component of 0xCF.//// Returns:// returns FALSE if pColorName contains an unrecognized color or hex value://BOOL TextWindowBase::setBackgroundColor( _CHAR* pColorName, ULONG32 colorNameLen){ //first look for red, black, ...etc: if(!convertColorNameToCOLORTYPE(pColorName, colorNameLen, m_backgroundColor)) { //That failed, so look for value of type #RRGGBB: return (setBackgroundColorFromHexValString( pColorName, colorNameLen) ); } return TRUE;}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setBackgroundColorFromHexValString// (// _CHAR* pColorName,// ULONG32 colorNameLen// )//// Purpose:// Sets the background color of the window from the value in // pColorName, which can contain any color of the form: #RRGGBB where RR,GG,// and BB are hex values from 0x00 to 0xFF representing the Red, Green, and// Blue components of the color. These values can be different lengths// (from one to six) as follows: #B, #BB, #GBB, #GGBB, #RGGBB, and #RRGGBB,// for example, #7CF means a Red compolnent of 0x00, a Green component of// 0x07, and a Blue component of 0xCF.//// Returns:// returns FALSE if pColorName contains an invalid hex value://BOOL TextWindowBase::setBackgroundColorFromHexValString( _CHAR* pColorHexVal, ULONG32 colorHexValLen){ return (convertColorValStringToCOLORTYPE( pColorHexVal, colorHexValLen, m_backgroundColor) );}// Sets the background opacity. Returns TRUE if ulOpacity <= 255,// FALSE otherwise. 255 = fully opaque, 0 = fully transparent.// 255 is the default background opacity value.BOOL TextWindowBase::setBackgroundOpacity(UINT32 ulOpacity){ BOOL bRet = FALSE; if (ulOpacity <= 255) { m_ulBackgroundOpacity = ulOpacity; bRet = TRUE; } return bRet;}// Sets the media opacity. Returns TRUE if ulOpacity <= 255,// FALSE otherwise. 255 = fully opaque, 0 = fully transparent.// 255 is the default media opacity value.BOOL TextWindowBase::setMediaOpacity(UINT32 ulOpacity){ BOOL bRet = FALSE; if (ulOpacity <= 255) { m_ulMediaOpacity = ulOpacity; bRet = TRUE; } return bRet;}BOOL TextWindowBase::setChromaKey(UINT32 ulColor){ BOOL bRet = TRUE; m_ulChromaKey = ulColor & 0x00FFFFFF; m_bIsChromaKeySet = TRUE; return bRet;}BOOL TextWindowBase::setChromaKeyTolerance(UINT32 ulTol){ BOOL bRet = TRUE; m_ulChromaKeyTolerance = ulTol & 0x00FFFFFF; return bRet;}BOOL TextWindowBase::setChromaKeyOpacity(UINT32 ulOpacity){ BOOL bRet = FALSE; if (ulOpacity <= 255) { m_ulChromaKeyOpacity = ulOpacity; bRet = TRUE; } return bRet;}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setLinkColor// (// _CHAR* pColorName,// ULONG32 colorNameLen// )//// Purpose:// Sets the color of hyperlinked text from the value in // pColorName, which can contain any color of the form: #RRGGBB where RR,GG,// and BB are hex values from 0x00 to 0xFF representing the Red, Green, and// Blue components of the color. These values can be different lengths// (from one to six) as follows: #B, #BB, #GBB, #GGBB, #RGGBB, and #RRGGBB,// for example, #7CF means a Red compolnent of 0x00, a Green component of// 0x07, and a Blue component of 0xCF.//// Returns:// returns FALSE if pColorName contains an unrecognized color or hex value://BOOL TextWindowBase::setLinkColor(_CHAR* pColorName, ULONG32 colorNameLen){ //first look for red, black, ...etc: if(!convertColorNameToCOLORTYPE(pColorName, colorNameLen, m_linkColor)) { //That failed, so look for value of type #RRGGBB: return (convertColorValStringToCOLORTYPE( pColorName, colorNameLen, m_linkColor) ); } return TRUE;}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setHeight(_CHAR* pBuf, ULONG32 bufLen)//// Purpose:// Sets the height, in pixels, of the window before it is created.// The contents of buf can be a number, like "144".// //as of 1997/06/02, it can NO LONGER be a percentage, like "56%".//// Returns:// returns FALSE, with the height set to DEFAULT_WINDOWWIDTH, if pBuf// converts to an invalid ULONG32 value, or if it is out of bounds;// //as of 1997/06/02, it can NO LONGER be a percentage, like "56%", so:// if pBuf contains a value, in "Y%" form, the % is ignored, so 56% would// cause a return value of 56 (pixels).//BOOL TextWindowBase::setHeight(_CHAR* pBuf, ULONG32 bufLen){ BOOL didErrorOccur = FALSE; BOOL doPercentOfParentWindowHt = FALSE; if(bufLen > 1) { if(pBuf[bufLen-1] == '%') { doPercentOfParentWindowHt = TRUE; pBuf[bufLen-1]='\0'; } } m_height = string_to_ULONG32(pBuf, didErrorOccur); if(didErrorOccur) { m_height = DEFAULT_WINDOWHEIGHT; return FALSE; } return (!didErrorOccur);}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindowBase::setWidth(_CHAR* pBuf, ULONG32 bufLen)//// Purpose:// Sets the width, in pixels, of the window before it is created.// The contents of buf can be a number, like "144"// //as of 1997/06/02, it can NO LONGER be a percentage, like "56%".//// Returns:// returns FALSE, with width set to DEFAULT_WINDOWWIDTH, if pBuf converts// to an invalid ULONG32 value or if it is out of bounds;// //as of 1997/06/02, it can NO LONGER be a percentage, like "56%", so:// if pBuf contains a value, in "X%" form, the % is ignored, so 56% would// cause a return value of 56 (pixels).//BOOL TextWindowBase::setWidth(_CHAR* pBuf, ULONG32 bufLen){ /* Can only be set from within <WINDOW > header tag, * before window is created: */ BOOL didErrorOccur = FALSE; BOOL doPercentOfParentWindowWidth = FALSE; if(bufLen > 1) { if(pBuf[bufLen-1] == '%') { doPercentOfParentWindowWidth = TRUE; pBuf[bufLen-1]='\0'; } } m_width = string_to_ULONG32(pBuf, didErrorOccur); if(didErrorOccur) { m_width = DEFAULT_WINDOWWIDTH; return FALSE; } return (!didErrorOccur);}// /Added the following two methods to handle in-line SMIL plain-text data// URLs which don't have an intrinsic width/height but rely on the SMIL// layout to provide them with w,h (PR 59951 and others):HX_RESULTTextWindowBase::overrideDefaultWindowWidth(LONG32 ulNewWindowWidth){ HX_RESULT hxrslt = HXR_OK; if (ulNewWindowWidth <= 0) { hxrslt = HXR_INVALID_PARAMETER; } else { m_width = ulNewWindowWidth; } return hxrslt;}HX_RESULTTextWindowBase::overrideDefaultWindowHeight(LONG32 ulNewWindowHeight){ HX_RESULT hxrslt = HXR_OK; if (ulNewWindowHeight <= 0) { hxrslt = HXR_INVALID_PARAMETER; } else { m_height = ulNewWindowHeight; } return hxrslt;}//Added the following function so author can// specify whether or not hyperlinks get underlined automatically:BOOL TextWindowBase::setUnderlineHyperlinks(_CHAR* pBuf, ULONG32 bufLen){ //Can only be set from within <WINDOW > header tag, // before window is created: BOOL didErrorOccur = FALSE; m_bUnderlineHyperlinks = string_to_BOOL(pBuf, bufLen, didErrorOccur); if(didErrorOccur) { m_bUnderlineHyperlinks = DEFAULT_DO_UNDERLINE_HYPERLINKS; } return (!didErrorOccur);}//Added the following function so author can// specify the content version of the rt file:BOOL TextWindowBase::setContentVersion(_CHAR* pBuf, ULONG32 bufLen){ //Can only be set in the header: BOOL didErrorOccur = FALSE; double fVersion = string_to_double(pBuf, didErrorOccur, m_ulContentMajorVersion, m_ulContentMinorVersion); if(didErrorOccur) { m_ulContentMajorVersion = 0L; m_ulContentMinorVersion = 0L; } return (!didErrorOccur);}//Added the following function so author can// specify whether or not wordwrap is performed:BOOL TextWindowBase::setWordwrap(_CHAR* pBuf, ULONG32 bufLen){ //Can only be set from within <WINDOW > header tag, // before window is created: BOOL didErrorOccur = FALSE; m_bUseWordwrap = string_to_BOOL(pBuf, bufLen, didErrorOccur); if(didErrorOccur) { m_bUseWordwrap = DEFAULT_USE_WORDWRAP; } return (!didErrorOccur);}//Added the following function to keep track of live src:BOOL TextWindowBase::setIsLiveSource(_CHAR* pBuf, ULONG32 bufLen){ //Can only be set from within <WINDOW > header tag, // before window is created: BOOL didErrorOccur = FALSE; m_bIsLiveSource = string_to_BOOL(pBuf, bufLen, didErrorOccur); if(didErrorOccur) { m_bIsLiveSource = DEFAULT_IS_LIVE_SOURCE; } return (!didErrorOccur);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -