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

📄 gletext.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright (C) AU-System AB, 2000.
 * All rights reserved.
 *
 * This software is covered by the license agreement between
 * the end user and AU-System AB, and may be used and copied
 * only in accordance with the terms of the said agreement.
 *
 * AU-System AB does not assume any responsibility or 
 * liability for any errors or inaccuracies in this 
 * software, or any consequential, incidental or indirect 
 * damage arising out of the use of the Generic Layout Engine 
 * software.
 */

#include "gledef.h"
#include "engine.h"
#include "gletext.h"
#include "aapigle.h"
#include "tapimmi.h"
#include "capimmi.h"
#include "ansilibs.h"

VOID* WIPAlloc(UINT32 size);
VOID WIPFree( VOID* memory );

#ifdef SUPPORT_KEY_NAVIGATION 
	BOOL GleTextIsMarkable(GleViewType* viewP, const GleText* self) {
		BOOL onScreen = FALSE;
		UINT16 k = 0;
		if(!self->isLink)
			return FALSE;
		for (k=0; (k<self->nRows) && !onScreen; k++) {
			if (self->rowInfo[k].bounds.topLeft.y >= viewP->vertOffset) 
				if ((self->rowInfo[k].bounds.topLeft.y + self->rowInfo[k].bounds.extent.y) < (viewP->vertOffset + viewP->height)) 
					onScreen=TRUE;
			}
		return onScreen;
	}
#endif

VOID GleTextDraw(GleViewType* viewP, const GleText* self){
	const BYTE* p;
	UINT16	k;
	BOOL isInverted;
	GleRectangleType textBounds;
	/* いif (self->myTable)
		;	horisOffset = self->myTable->horisOffset;*/ /*myTableAtrPtr->horisOffset;*/ 

	isInverted = (viewP->markedGleElement == (GleElement*)self);	
	
	

	memmove(&textBounds, &self->rowInfo[0].bounds, sizeof(GleRectangleType));
	/* textBounds.topLeft.x += viewP->viewBounds.topLeft.x */
	textBounds.topLeft.x += - viewP->horizOffset;

	/* textBounds.topLeft.y += viewP->viewBounds.topLeft.y */;	
	textBounds.topLeft.y += -viewP->vertOffset ;	

	GLEa_textDraw(viewP->viewId, self->text, self->rowInfo[0].nChars, isInverted, (GleRectangleType*)&textBounds, self->firstRowDeltaY, self->format, self->isLink);
	/*%
	p += self->rowInfo[0].nChars;
	while (*p==0x20)
		p++;*/
	/* */
	p = ((BYTE*)self->text) + self->rowInfo[0].nBytes;
	/* */


	if (self->nRows > 1)
		{ 
		for (k=1 ; k<self->nRows-1 ; k ++)
			{
			memmove(&textBounds, &self->rowInfo[k].bounds, sizeof(GleRectangleType) );
			
			/* textBounds.topLeft.x += viewP->viewBounds.topLeft.x; */
			textBounds.topLeft.x += - viewP->horizOffset;
			
			/* textBounds.topLeft.y += viewP->viewBounds.topLeft.y; */				
			textBounds.topLeft.y +=  - viewP->vertOffset;	
			GLEa_textDraw(viewP->viewId, (GLE_STRING)p, self->rowInfo[k].nChars, isInverted, (GleRectangleType*)&textBounds, 0, self->format, self->isLink);			
			/*%
			p += self->rowInfo[k].nChars;
			while (*p==0x20)
				p++;*/
			/* */
			p += self->rowInfo[k].nBytes;
			/* */
			}
		memmove(&textBounds, &self->rowInfo[k].bounds, sizeof(GleRectangleType) );
		/* textBounds.topLeft.x += viewP->viewBounds.topLeft.x; */
		textBounds.topLeft.x += - viewP->horizOffset;

		/* textBounds.topLeft.y += viewP->viewBounds.topLeft.y; */
		textBounds.topLeft.y += -viewP->vertOffset;	
		GLEa_textDraw(viewP->viewId, (GLE_STRING)p, self->rowInfo[k].nChars, isInverted, (GleRectangleType*)&textBounds, self->lastRowDeltaY, self->format, self->isLink);
		}
	}
	
VOID GleTextGetAcsentAndDescender(const GleText* self, INT16* ascentMax, INT16* descenderMax) {
	*ascentMax = self->ascent;
	*descenderMax = GLEa_textFontLineHeight(self->format, self->isLink) - self->ascent;
	}


VOID GleTextMultipleRowCheck(GleText* self, INT16 *xSum, GleText** multipleRowTextPtr, INT16 *descenderMax, INT16 *columnWidth, INT16 xOffset)
	{
	INT16 textStrLen;
	INT16 nbrChars;
	BOOL wholeWordsOnFirstRow = FALSE;
	BOOL smaller;
	BOOL multipleRows;
				
	GleElement* testIfText = (GleElement*)self;
	if (testIfText->type != Text)
		{
		*multipleRowTextPtr = NULL;
		return;
		}
		
	nbrChars = GLEa_textFontWordWrap(self->text, self->columnWidth - self->rowInfo[0].bounds.topLeft.x + self->columnLeftX, self->format, self->isLink);

	if (((textStrLen = GLEa_strlen(self->text)) == nbrChars))
		wholeWordsOnFirstRow = TRUE;
	else
		{
		/*%
		wholeWordsOnFirstRow=FALSE;
		while (((p - self->text)<nbrChars) && !wholeWordsOnFirstRow)
			{
			wholeWordsOnFirstRow=(*p==0x20);
			p++;
			}*/
		/* */
		wholeWordsOnFirstRow = (nbrChars != GLEa_strNbrCharsWithoutEndingSpaces(self->text,nbrChars));
		/* */	
		}	
	smaller=(self->rowInfo[0].bounds.topLeft.x != xOffset);/*smaller=FALSE if the text is alone on this row*/
/*	multipleRows = (*(self->text+nbrChars));*/
	multipleRows = nbrChars < textStrLen;
	if (multipleRows && (wholeWordsOnFirstRow || !smaller))
		{
		if (self->totalTextHeight > (*descenderMax))
			*descenderMax = self->totalTextHeight ;
			
		*multipleRowTextPtr=self;
		*xSum = self->rowInfo[self->nRows-1].bounds.extent.x;	
		if (*xSum > *columnWidth)
			*xSum = *columnWidth;
		}
	else 
		*multipleRowTextPtr=0;
	}			   

BOOL GleTextRenderX(GleText* self, INT16  *xSum, INT16 *ySum, INT16 *ascentMax, INT16 *descenderMax, GleElementType *gleType, UINT16 *currentFontLineHeight, INT8 *myAlign, BOOL *myWrap, INT16 *columnLeftX, INT16 *columnWidth, VOID *viewP){		

	UINT16 tempXSum;
	const BYTE* p;
	INT16 nbrChars;
	BOOL multipleRows;
	UCHAR rowHeight;
	UINT16 xOffSet;
	UINT16 rowInfoChunkSize;
	VOID* tempRowInfoPtr;			
	UINT16 oldChunkSize = self->chunkSize;
	UINT16 oldNRows = self->nRows;
	BOOL wholeWordsOnFirstRow = FALSE;
	INT16 textNbrChars;
	INT16 textNbrBytes;
	INT16 textFontLineHeight = self->rowInfo[0].bounds.extent.y;
	self->firstRowDeltaY=0;

 
	#ifdef SUPPORT_NOWRAP

	if(!*myWrap) {
		if(*xSum)
			*xSum += gle_horizontalSpaceBetweenElements;

		self->nRows = 1;
		self->rowInfo[0].nChars = GLEa_strlen(self->text);
		self->rowInfo[0].bounds.topLeft.x = *xSum;	
		self->rowInfo[0].bounds.topLeft.y = *ySum;

		self->rowInfo[0].bounds.extent.x = GLEa_textFontWidth(self->text,self->rowInfo[0].nChars, self->format, self->isLink);
		*xSum += self->rowInfo[0].bounds.extent.x;
		if (self->ascent > *ascentMax)
			*ascentMax = self->ascent;
		if ((self->rowInfo[0].bounds.extent.y - self->ascent) > *descenderMax)
			*descenderMax = self->rowInfo[0].bounds.extent.y - self->ascent;
		*currentFontLineHeight = self->rowInfo[0].bounds.extent.y;
		*gleType = Text;
		self->chunkSize = oldChunkSize + (self->nRows - oldNRows)*sizeof(GleTextRowInfoType);
 		return TRUE;
		}
	#endif
	textNbrChars = GLEa_strlen(self->text);
	self->totalTextHeight=textFontLineHeight;

	tempXSum = *xSum;
	
	self->columnLeftX=*columnLeftX;
	self->columnWidth=*columnWidth;

	*currentFontLineHeight = self->rowInfo[0].bounds.extent.y;

	self->nRows=1;
	rowHeight = textFontLineHeight;
	if(*xSum){
		if((self->columnWidth-*xSum) > gle_horizontalSpaceBetweenElements)
			nbrChars=GLEa_textFontWordWrap(self->text,self->columnWidth - *xSum - gle_horizontalSpaceBetweenElements, self->format, self->isLink);
		else
			nbrChars=GLEa_textFontWordWrap(self->text,0, self->format, self->isLink);
		}
	else
		nbrChars=GLEa_textFontWordWrap(self->text,self->columnWidth - *xSum, self->format, self->isLink);
	self->rowInfo[0].nChars = GLEa_strNbrCharsWithoutEndingSpaces(self->text,nbrChars);
	self->rowInfo[0].nBytes = GLEa_sizeofNchars(self->text,nbrChars);

	p = (BYTE*)self->text;
	/*%
	multipleRows=(*(p+nbrChars));*/
	/* */
	multipleRows=(textNbrChars != nbrChars);
	/* */
	if (multipleRows)
		{
		/*%
		wholeWordsOnFirstRow=FALSE;
		while (((p - self->text)<nbrChars) && !wholeWordsOnFirstRow)
			{
			wholeWordsOnFirstRow=(*p==0x20);
			p++;
			}*/
		/* */
		wholeWordsOnFirstRow = (nbrChars != GLEa_strNbrCharsWithoutEndingSpaces(self->text,nbrChars));
		/* */	
		if (!wholeWordsOnFirstRow && *xSum)
			{
			*gleType = NoType;
			return (FALSE);
			}	

		if(*xSum)
			*xSum += gle_horizontalSpaceBetweenElements;
		if (self->ascent > *ascentMax)
			*ascentMax = self->ascent;

⌨️ 快捷键说明

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