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

📄 txtattrb.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: txtattrb.cpp,v 1.1.2.1 2004/07/09 01:50:20 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** *//////////////////////////////////////////////////////////////////////////////////  TXTATTRB.CPP////  TextAttributes class implementation.////	A class TextAttributes object holds the text to	be rendered's//	attributes like font color, weight, size, italicized or not,//	...etc.////  TextAttribStack class implementaion:////	A class TextAttribStack[BOOL|ULONG32] object is a stack of type//	[BOOL|ULONG32] that always maintains its default value on the bottom//	of the stack; if a pop() is done when there is only this default//	value on the stack, the stack top is not reduced and the default//	value is returned.  For example, "<B>text</B>text2</B>text3" would//	push the first bold tag so that "text1" is bold, would then pop//	the bold tag so that "text2" is not bold (default is not bold,//	on bottom of stack) and then would try to pop again but this would//	have no effect, leaving the default on the bottom of the stack.////  TextAttributeStacks class implementaion:////	A class TextAttributeStacks object is an array of TextAttrbStack//	objects that keep track of changes in attributes so that when the//	scope of a change ends (and that change is "popped" from the stack),//	the previous value for that attribute can be obtained and used for//	the next block of text.//#include <memory.h> //for memcpy().#include <stdlib.h>#include <string.h>#include <limits.h> //for ULONG_MAX.#include "hxtypes.h"#include "rt_types.h" //for _CHAR, RED_GREEN_OR_BLUE, COLORTYPE#include "rt_string.h"#include "atotime.h"#include "parsing.h" //For convertToUpperCase().#include "fontdefs.h"  //(broke defs out of txtattrb.h)#include "hxstack.h"#include "hxslist.h" //for base class CHXSimpleList.#include "txtattrb.h" //for base class TextAttributes.#include "txtcntnr.h"#include "textprsr.h" /*for ..._CONTENT_VERSION_... defines */#ifdef _WINDOWS#ifdef _WIN16#include <windows.h>#endif /* _WIN16 */#endif /* _WINDOWS */#include "hxslist.h"#include "textline.h"#include "txtwindw.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE		static char HX_THIS_FILE[] = __FILE__;#endif#ifdef _CARBON#pragma old_argmatch on#endifvoid TextAttributes::init(){    /*resets to default vals, sets dynamically-allocated buffers to NULL*/    m_textColor = DEFAULT_TEXT_COLOR;    m_textBackgroundColor = DEFAULT_TEXT_BGCOLOR;    m_tickerUpperColor = DEFAULT_TICKER_UPPERCOLOR;    m_tickerLowerColor = DEFAULT_TICKER_LOWERCOLOR;    m_fontFaceIndex = DEFAULT_FONT_FACE_INDX;    //Added this line to handle charsets:    m_fontCharset = CHARSET__default;    m_fontPointSize = DEFAULT_FONT_PTSIZE;    m_isBold = m_isItalicized = m_isUnderlined = m_isStruckOut = FALSE;    m_isCentered = m_bIsPreFormatted = FALSE;    m_numNewlinesAtStart = 0L;    m_isFakeNewLine = FALSE;//new var for crawlrate "lines"    m_isWordWrapNewLine = FALSE;//new var.    m_breakSpacingX = m_breakSpacingY = 0L;    m_isTickerUpperText = TRUE;    m_blinkRate = DEFAULT_BLINKRATE;    m_isLit = TRUE;    m_pHrefBuf = NULL;    m_hrefBufLen = 0L;    m_ulTargetOfURL = URL_TARGET_INVALID;    m_beginTime = m_endTime = m_lastKnownTime = TIME_INVALID;    m_ulMostRecentTimeTagEndTime = (ULONG32)ULONG_MAX;    m_lastKnownX = m_lastKnownY = 0L;    m_xAtTimeZeroUpperLeftCorner = m_yAtTimeZeroUpperLeftCorner = 0L;    m_xUpperLeftCorner = m_yUpperLeftCorner = m_xExtent = m_yExtent = 0L;    //added this for indenting text in lists and as requested:    m_lineIndentAmtInPixels = 0;    //This is needed for knowing which to put first in the packet header,    // the <font color=...> tag or the <a...> tag:    m_ulNumLinkColorOverrides = 0L;}	void TextAttributes::clear_URL(){    if(m_pHrefBuf)    {	delete [] m_pHrefBuf;	m_pHrefBuf = NULL;    }    m_hrefBufLen=0L;    m_ulTargetOfURL = URL_TARGET_INVALID;}void TextAttributes::setFontFace(ULONG32 ulFntFcIndx)	{    m_fontFaceIndex = ulFntFcIndx;}void TextAttributes::setFontFace(_CHAR* pFntFc, ULONG32 len,	ULONG32 ulMajorContentVersion, ULONG32 ulMinorContentVersion)	{    m_fontFaceIndex = getFontFaceIndexFromString(pFntFc, len,	    ulMajorContentVersion, ulMinorContentVersion);}//added this function which converts a predefined // string into a font index (returning default index if string unrecognized):ULONG32 getFontFaceIndexFromString(_CHAR* pFntFc, ULONG32 len,	ULONG32 ulMajorContentVersion, ULONG32 ulMinorContentVersion){    if(!pFntFc  ||  !len)    {	return DEFAULT_FONT_FACE_INDX;    }    BOOL bActiveContentVersionIncludesKorean = FALSE;    //XXXEH: docs need updating: version="1.4" or higher must    // be set in the <window> tag of the rt file in order for    // Korean to be rendered:    if(ulMajorContentVersion >	REAL_TEXT_KOREAN_FONT_HANDLING_CONTENT_MAJOR_VERSION	||	(ulMajorContentVersion ==	REAL_TEXT_KOREAN_FONT_HANDLING_CONTENT_MAJOR_VERSION	&&	ulMinorContentVersion >=	REAL_TEXT_KOREAN_FONT_HANDLING_CONTENT_MINOR_VERSION)	)    {	bActiveContentVersionIncludesKorean = TRUE;    }    convertToUpperCase(pFntFc, len);    if(!stringCompare(	    TIMES_FONT_FACE_STR, TIMES_FONT_FACE_STRLEN,	    pFntFc, len)  ||	    !stringCompare(	    TIMES_FONT_FACE_STR2, TIMES_FONT_FACE_STR2LEN,	    pFntFc, len)  )    {	return(TIMES_FONT_FACE_INDX);    }    else if(!stringCompare(	    COURIERTT_FONT_FACE_STR, COURIERTT_FONT_FACE_STRLEN,	    pFntFc, len)  ||	    !stringCompare(	    COURIERTT_FONT_FACE_STR2, COURIERTT_FONT_FACE_STR2LEN,	    pFntFc, len)  )    {	return(COURIERTT_FONT_FACE_INDX);    }    else if(!stringCompare(	    SYSTEM_FONT_FACE_STR, SYSTEM_FONT_FACE_STRLEN,	    pFntFc, len)  ||	    !stringCompare(	    GENEVA_FONT_FACE_STR, GENEVA_FONT_FACE_STRLEN,	    pFntFc, len)  )    {	return(SYSTEM_FONT_FACE_INDX);    }    else if(!stringCompare(	    ARIAL_FONT_FACE_STR, ARIAL_FONT_FACE_STRLEN,	    pFntFc, len)  )    {	return(ARIAL_FONT_FACE_INDX);    }    else if(!stringCompare(	    HELVETICA_FONT_FACE_STR, HELVETICA_FONT_FACE_STRLEN,	    pFntFc, len)  )    {	return(HELVETICA_FONT_FACE_INDX);    }    else if(!stringCompare(	    ARIAL_BLACK_FONT_FACE_STR, ARIAL_BLACK_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return(ARIAL_BLACK_FONT_FACE_INDX);    }    else if(!stringCompare(	    ARIAL_NARROW_FONT_FACE_STR, ARIAL_NARROW_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return(ARIAL_NARROW_FONT_FACE_INDX);    }    else if(!stringCompare(	    ARIAL_ROUNDED_MT_BOLD_FONT_FACE_STR,	    ARIAL_ROUNDED_MT_BOLD_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return(ARIAL_ROUNDED_MT_BOLD_FONT_FACE_INDX);    }    else if(!stringCompare(	    ALGERIAN_FONT_FACE_STR,	    ALGERIAN_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return ALGERIAN_FONT_FACE_INDX;    }    else if(!stringCompare(	    BOOK_ANTIQUA_FONT_FACE_STR,	    BOOK_ANTIQUA_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return BOOK_ANTIQUA_FONT_FACE_INDX;    }    else if(!stringCompare(	    BOOKMAN_OLD_STYLE_FONT_FACE_STR,	    BOOKMAN_OLD_STYLE_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return BOOKMAN_OLD_STYLE_FONT_FACE_INDX;    }    else if(!stringCompare(	    BRAGGADOCIO_FONT_FACE_STR,	    BRAGGADOCIO_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return BRAGGADOCIO_FONT_FACE_INDX;    }    else if(!stringCompare(	    BRITANNIC_BOLD_FONT_FACE_STR,	    BRITANNIC_BOLD_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return BRITANNIC_BOLD_FONT_FACE_INDX;    }    else if(!stringCompare(	    BRUSH_SCRIPT_FONT_FACE_STR,	    BRUSH_SCRIPT_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return BRUSH_SCRIPT_FONT_FACE_INDX;    }    else if(!stringCompare(	    CENTURY_GOTHIC_FONT_FACE_STR,	    CENTURY_GOTHIC_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return CENTURY_GOTHIC_FONT_FACE_INDX;    }    else if(!stringCompare(	    CENTURY_SCHOOLBOOK_FONT_FACE_STR,	    CENTURY_SCHOOLBOOK_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return CENTURY_SCHOOLBOOK_FONT_FACE_INDX;    }    else if(!stringCompare(	    COLONNA_MT_FONT_FACE_STR,	    COLONNA_MT_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return COLONNA_MT_FONT_FACE_INDX;    }    else if(!stringCompare(	    COMIC_SANS_MS_FONT_FACE_STR,	    COMIC_SANS_MS_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return COMIC_SANS_MS_FONT_FACE_INDX;    }    else if(!stringCompare(	    DESDEMONA_FONT_FACE_STR,	    DESDEMONA_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return DESDEMONA_FONT_FACE_INDX;    }    else if(!stringCompare(	    FOOTLIGHT_MT_LIGHT_FONT_FACE_STR,	    FOOTLIGHT_MT_LIGHT_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return FOOTLIGHT_MT_LIGHT_FONT_FACE_INDX;    }    else if(!stringCompare(	    GARAMOND_FONT_FACE_STR,	    GARAMOND_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return GARAMOND_FONT_FACE_INDX;    }    else if(!stringCompare(	    HAETTENSCHWEILER_FONT_FACE_STR,	    HAETTENSCHWEILER_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return HAETTENSCHWEILER_FONT_FACE_INDX;    }    else if(!stringCompare(	    IMPACT_FONT_FACE_STR,	    IMPACT_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return IMPACT_FONT_FACE_INDX;    }    else if(!stringCompare(	    KINO_MT_FONT_FACE_STR,	    KINO_MT_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return KINO_MT_FONT_FACE_INDX;    }    else if(!stringCompare(	    MATURA_MT_SCRIPT_CAPITALS_FONT_FACE_STR,	    MATURA_MT_SCRIPT_CAPITALS_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return MATURA_MT_SCRIPT_CAPITALS_FONT_FACE_INDX;    }    else if(!stringCompare(	    MODERN_FONT_FACE_STR,	    MODERN_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return MODERN_FONT_FACE_INDX;    }    else if(!stringCompare(	    MS_DIALOG_FONT_FACE_STR,	    MS_DIALOG_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return MS_DIALOG_FONT_FACE_INDX;    }    else if(!stringCompare(	    MS_DIALOG_LIGHT_FONT_FACE_STR,	    MS_DIALOG_LIGHT_FONT_FACE_STRLEN,	    pFntFc, len) )    {	return MS_DIALOG_LIGHT_FONT_FACE_INDX;    }    else if(!stringCompare(

⌨️ 快捷键说明

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