📄 txtwindw.cpp
字号:
tokenNameBufLen, "HEIGHT", 6)) { setHeight(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } break; case 'L': if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "LOOP", 4)) { if(!setLoop(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen)) { /* Invalid value, so restore to unspecified so that * proper defaulting can occur based on window * type: */ loop(DOLOOP_UNSPECIFIED); } } //Added the following case so author can // specify what color will be of hyperlinked text (i.e., text // inside an <A ..>..</A> tag): else if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "LINK", 4)) { setLinkColor(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } else if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "LIVE", 4)) { setIsLiveSource(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } break; case 'S': if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "SCROLLTYPE", 10)) {#if defined(SHOW_CODE_CHANGE_MESSAGES)#pragma message("EH- in "__FILE__", finish the SCROLLTYPE handling")#endif/// setScrollType(&pHeaderTagBuf[tokenValueStartIndex]); } else if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "SCROLLRATE", 10)) { setScrollRate(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } break; case 'T': if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "TYPE", 4)) { setType(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } break; //Added the following case so author can // specify whether or not hyperlinks get underlined automatically: case 'U': if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "UNDERLINE_HYPERLINKS", 20)) { setUnderlineHyperlinks(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } break; //Added the following case so author can // specify whether or not hyperlinks get underlined automatically: case 'V': if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "VERSION", 7)) { setContentVersion(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } break; case 'W': if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "WIDTH", 5)) { setWidth(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } //Added the following case so author can // specify whether or not wordwrap is performed: else if(!stringCompare( &pHeaderTagBuf[tokenNameStartIndex], tokenNameBufLen, "WORDWRAP", 8)) { setWordwrap(&pHeaderTagBuf[tokenValueStartIndex], tokenValueBufLen); } break; default: break; } //end switch(). //Restore the chars that were set temporarily to '\0': pHeaderTagBuf[tokenNameEndIndex] = tempCharName; pHeaderTagBuf[tokenValueEndIndex] = tempCharVal; //Set startIndex to find next token: tokenNameStartIndex = tokenNameEndIndex = tokenValueEndIndex; } while(tokenValueEndIndex < headerTagBufLen); // /If the content version is not high enough (i.e., 1.6 or greater), // then we need to behave as we used to which is to treat "transparent" // as BAD_RGB_COLOR: if (TRANSPARENT_COLOR == m_backgroundColor && ((getMajorContentVersion() < REAL_TEXT_TRANSPARENT_BGCOLOR_MAJOR_VERSION) || (getMajorContentVersion() == REAL_TEXT_TRANSPARENT_BGCOLOR_MAJOR_VERSION && getMinorContentVersion() < REAL_TEXT_TRANSPARENT_BGCOLOR_MINOR_VERSION)) ) { // /It's "transparent" but not high enough content version #: m_backgroundColor = BAD_RGB_COLOR; } //For each of *this's variables that are <variable>_UNSPECIFIED, set them // to the appropriate default values based on this->m_type: if(TYPE_UNSPECIFIED == m_type) { m_type = TYPE_GENERIC; } switch(m_type) { case TYPE_SCROLLINGNEWS: if(SCROLLTYPE_UNSPECIFIED == m_scrollType) { m_scrollType = DEFAULT_SCROLLTYPE_SCROLLINGNEWS; if(SCROLLRATE_UNSPECIFIED == m_scrollRate) m_scrollRate = DEFAULT_SCROLLRATE_SCROLLINGNEWS; if(CRAWLRATE_UNSPECIFIED == m_crawlRate) m_crawlRate = DEFAULT_CRAWLRATE_SCROLLINGNEWS; } else//scrolltype was specified so default to appropriate // scrollrate & crawlrate if they are not already specified: { if(SCROLLRATE_UNSPECIFIED == m_scrollRate) m_scrollRate=(m_scrollType & SCROLLTYPE_SETRATE != 0? DEFAULT_SCROLLRATE_SCROLLINGNEWS:0); if(CRAWLRATE_UNSPECIFIED == m_crawlRate) m_crawlRate =(m_scrollType & SCROLLTYPE_SETRATE != 0? DEFAULT_CRAWLRATE_SCROLLINGNEWS:0); } if(DOLOOP_UNSPECIFIED == m_loop) { m_loop = DEFAULT_DOLOOP_SCROLLINGNEWS; } if(BGCOLOR_RGB_UNSPECIFIED == m_backgroundColor) { m_backgroundColor = DEFAULT_BGCOLOR_RGB_SCROLLINGNEWS; } if(WINDOW_DIMENSION_UNSPECIFIED == m_width) { m_width = DEFAULT_WINDOWWIDTH_SCROLLINGNEWS; } if(WINDOW_DIMENSION_UNSPECIFIED == m_height) { m_height = DEFAULT_WINDOWHEIGHT_SCROLLINGNEWS; } break; case TYPE_TICKERTAPE:#if(DEFAULT_SCROLLRATE_TICKERTAPE)#error: "Tickertape doesn't work with non-zero scroll rate."#else m_scrollRate = DEFAULT_SCROLLRATE_TICKERTAPE;#endif if(SCROLLTYPE_UNSPECIFIED == m_scrollType) { m_scrollType = DEFAULT_SCROLLTYPE_TICKERTAPE; if(CRAWLRATE_UNSPECIFIED == m_crawlRate) m_crawlRate = DEFAULT_CRAWLRATE_TICKERTAPE; } else//scrolltype was specified so default to appropriate // crawlrate if it is not already specified: { if(CRAWLRATE_UNSPECIFIED == m_crawlRate) { m_crawlRate = (m_scrollType & SCROLLTYPE_SETRATE != 0? DEFAULT_CRAWLRATE_TICKERTAPE:0); } } if(DOLOOP_UNSPECIFIED == m_loop) { m_loop = DEFAULT_DOLOOP_TICKERTAPE; } if(BGCOLOR_RGB_UNSPECIFIED == m_backgroundColor) { m_backgroundColor = DEFAULT_BGCOLOR_RGB_TICKERTAPE; } if(WINDOW_DIMENSION_UNSPECIFIED == m_width) { m_width = DEFAULT_WINDOWWIDTH_TICKERTAPE; } if(WINDOW_DIMENSION_UNSPECIFIED == m_height) { m_height = DEFAULT_WINDOWHEIGHT_TICKERTAPE; } break; case TYPE_TELEPROMPTER:#if(DEFAULT_CRAWLRATE_TELEPROMPTER || DEFAULT_DOLOOP_TELEPROMPTER)#error: "Teleprompter doesn't work with non-zero scroll or crawl rate or with LOOP set to TRUE."#else m_crawlRate = DEFAULT_CRAWLRATE_TELEPROMPTER; m_scrollRate = DEFAULT_SCROLLRATE_TELEPROMPTER; m_loop = DEFAULT_DOLOOP_TELEPROMPTER;#endif if(SCROLLTYPE_UNSPECIFIED == m_scrollType) { m_scrollType = DEFAULT_SCROLLTYPE_TELEPROMPTER; } if(BGCOLOR_RGB_UNSPECIFIED == m_backgroundColor) { m_backgroundColor = DEFAULT_BGCOLOR_RGB_TELEPROMPTER; } if(WINDOW_DIMENSION_UNSPECIFIED == m_width) { m_width = DEFAULT_WINDOWWIDTH_TELEPROMPTER; } if(WINDOW_DIMENSION_UNSPECIFIED == m_height) { m_height = DEFAULT_WINDOWHEIGHT_TELEPROMPTER; } break; case TYPE_MARQUEE:#if(DEFAULT_SCROLLRATE_MARQUEE)#error: "Marquee doesn't work with non-zero scroll rate."#else m_scrollRate = DEFAULT_SCROLLRATE_MARQUEE;#endif if(SCROLLTYPE_UNSPECIFIED == m_scrollType) { m_scrollType = DEFAULT_SCROLLTYPE_MARQUEE; if(CRAWLRATE_UNSPECIFIED == m_crawlRate) m_crawlRate = DEFAULT_CRAWLRATE_MARQUEE; } else//scrolltype was specified so default to appropriate // crawlrate if it is not already specified: { if(CRAWLRATE_UNSPECIFIED == m_crawlRate) { m_crawlRate = (m_scrollType & SCROLLTYPE_SETRATE != 0? DEFAULT_CRAWLRATE_MARQUEE:0); } } if(DOLOOP_UNSPECIFIED == m_loop) { m_loop = DEFAULT_DOLOOP_MARQUEE; } if(BGCOLOR_RGB_UNSPECIFIED == m_backgroundColor) { m_backgroundColor = DEFAULT_BGCOLOR_RGB_MARQUEE; } if(WINDOW_DIMENSION_UNSPECIFIED == m_width) { m_width = DEFAULT_WINDOWWIDTH_MARQUEE; } if(WINDOW_DIMENSION_UNSPECIFIED == m_height) { m_height = DEFAULT_WINDOWHEIGHT_MARQUEE; } break; case TYPE_GENERIC: //fall through and do default code, below: default: { if(SCROLLTYPE_UNSPECIFIED == m_scrollType) { m_scrollType = DEFAULT_SCROLLTYPE_GENERIC; if(SCROLLRATE_UNSPECIFIED == m_scrollRate) { m_scrollRate = DEFAULT_SCROLLRATE_GENERIC; } if(CRAWLRATE_UNSPECIFIED == m_crawlRate) { m_crawlRate = DEFAULT_CRAWLRATE_GENERIC; } } else//scrolltype was specified so default to appropriate // scrollrate & crawlrate if they are not already specified: { if(SCROLLRATE_UNSPECIFIED == m_scrollRate) { m_scrollRate = (m_scrollType & SCROLLTYPE_SETRATE != 0? DEFAULT_SCROLLRATE_GENERIC:0); } if(CRAWLRATE_UNSPECIFIED == m_crawlRate) { m_crawlRate = (m_scrollType & SCROLLTYPE_SETRATE != 0? DEFAULT_CRAWLRATE_GENERIC:0); } } if(DOLOOP_UNSPECIFIED == m_loop) { m_loop = DEFAULT_DOLOOP_GENERIC; } if(BGCOLOR_RGB_UNSPECIFIED == m_backgroundColor) { m_backgroundColor = DEFAULT_BGCOLOR_RGB_GENERIC; } if(WINDOW_DIMENSION_UNSPECIFIED == m_width) { m_width = DEFAULT_WINDOWWIDTH_GENERIC; } if(WINDOW_DIMENSION_UNSPECIFIED == m_height) { m_height = DEFAULT_WINDOWHEIGHT_GENERIC; } } break; //end "default:". } //end "switch(m_type)". if(m_scrollRate < MIN_SCROLLRATE) { m_scrollRate = MIN_SCROLLRATE; } if(m_scrollRate > MAX_SCROLLRATE) { m_scrollRate = MAX_SCROLLRATE; } if(m_crawlRate < MIN_CRAWLRATE) { m_crawlRate = MIN_CRAWLRATE; } if(m_crawlRate > MAX_CRAWLRATE) { m_crawlRate = MAX_CRAWLRATE; } if(m_width < MIN_WINDOWWIDTH) { m_width = MIN_WINDOWWIDTH; } if(m_height < MIN_WINDOWHEIGHT) { m_height = MIN_WINDOWHEIGHT; } return TRUE;}/////////////////////////////////////////////////////////////////////////////// Method:// TextWindow::insertAtEndOfList(TextContainer* pTC)//// Purpose:// inserts the TextContainer* object into *this::TextContainerList. The// TextContianer::TextAttributes members of pTC are assumed to already be// set before this function is called. The "location" of the text in pTC// gets set herein based on m_type and scroll and crawl attributes// of *this. The x and y extents of pTC's text are determined in this// function based on pTC's font.//// Returns:// returns FALSE if pTC is NULL or if some other error occurred.//BOOL TextWindow::insertAtEndOfList(TextContainer* pTC, BOOL bCalledFromRendererCode, BOOL bDealingWithTabCharWithPre){ TextContainer* pTC_prev; LONG32 prev_x, prev_y, prev_xExtent, prev_yExtent; if(!pTC) { return FALSE; } if(!pTC->getBuffer() || pTC->getTextLengthPlus1()<=1) { return FALSE; //there's nothing to insert. } LONG32 xExtentInPixels; ULONG32 ulTimeOfEncoderStartup = getTimeAtStartup(); ULONG32 ulLiveXOffset = (isLiveSource() && !bCalledFromRendererCode)? //NOTE: the casting to double here is ONLY to avoid // overflow and does not need special floating-point // consideration for fixed-point code conversion, // i.e., precision does not need to be maintainted: (ULONG32(((double)m_crawlRate* (double)ulTimeOfEncoderStartup)/1000.0)): 2L; //Use 2 to pull text away from edge a bit. ULONG32 ulLiveYOffset = (isLiveSource() && !bCalledFromRendererCode)? //NOTE: the casting to double here is ONLY to avoid // overflow and does not need special floating-point // consideration for fixed-point code conversion, // i.e., precision does not need to be maintainted: (ULONG32(((double)m_scrollRate* (double)ulTimeOfEncoderStartup)/1000.0)): 0L; xExtentInPixels = GetStringWidthInPixels(//this functn is in fontinfo.cpp pTC->getBuffer(), pTC->getTextLengthPlus1()-1, pTC->getFontFace(), pTC->getFontPointSize(), pTC->isBold(), pTC->isItalicized(), pTC->getFontCharset()); if(xExtentInPixels < 0) { xExtentInPixels = -xExtentInPixels; //XXXEH- an error occurred in GetStringWidthInPixels(); handle it!! } else if(0 == xExtentInPixels) { //XXXEH- an error occurred in GetStringWidthInPixels(); handle it // better than the following kludge: xExtentInPixels = (pTC->getFontPointSize()/2) * (pTC->getTextLengthPlus1()-1); } pTC->setXExtent(xExtentInPixels); pTC->setYExtent(pTC->getFontPointSize()); //added the following to handle word wrap; // word wrap can only happen between two T.C.s where the first // ends with a space or the second begins with one: BOOL bPrevEndedWithSpaceChar=FALSE; //Is DBCS Acts same as BeginsWithSpaceChar as far as wordwrap goes, since // typically no spaces separate DBCS "words": BOOL bCurBeginsWithSpaceCharOrCharIsDBCSorUNICODE=FALSE; _CHAR* pTmpBufCopy = pTC->getBuffer(); if(' '==pTmpBufCopy[0])//(Valid buf & bufsize check was done above.) { bCurBeginsWithSpaceCharOrCharIsDBCSorUNICODE=TRUE; } if (pTC->getFontCharset() & HX_DBCS_CHARSET || pTC->getFontCharset() & HX_UNICODE_CHARSET) { bCurBeginsWithSpaceCharOrCharIsDBCSorUNICODE = TRUE; } pTC_prev = end(); ULONG32 newLines = pTC->getNumNewlinesAtStart(); ULONG32 ulNumNewlinesStatedInPacketHeader = GetNumNewlinesStatedInPacketHeader(); if(bCalledFromRendererCode) //Should never be called in file format since // this is just to deal with the arrival of a packet in the renderer // that has <POS ... NEWLINES=n/> in it: { if(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -