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

📄 gletext.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:
		if ((self->rowInfo[0].bounds.extent.y - self->ascent)> *descenderMax)
			*descenderMax = self->rowInfo[0].bounds.extent.y - self->ascent;

		/*p = self->text;*/
		self->rowInfo[0].bounds.extent.x=GLEa_textFontWidth(self->text,self->rowInfo[0].nChars, self->format, self->isLink);
		self->rowInfo[0].bounds.extent.y=*descenderMax + *ascentMax;
		self->rowInfo[0].bounds.topLeft.x = *xSum;	
		*xSum+=self->rowInfo[0].bounds.extent.x;			
		}
		
	else /* all characters fit on one row...*/
		{
		if(*xSum)
			*xSum += gle_horizontalSpaceBetweenElements;
		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;

		
		/*p = self->text;*/
		self->rowInfo[0].bounds.extent.x=GLEa_textFontWidth(self->text,self->rowInfo[0].nChars, self->format, self->isLink);
		self->rowInfo[0].bounds.extent.y=*descenderMax + *ascentMax;
		self->rowInfo[0].bounds.topLeft.x = *xSum;	
		*xSum+=self->rowInfo[0].bounds.extent.x;
		if (*xSum > *columnWidth)
			*xSum = *columnWidth;
		}
	
	if (multipleRows)
		{
		switch (*myAlign) 
			{
			case ALIGN_CENTER:
				xOffSet = *columnLeftX + *columnWidth/2;
				self->rowInfo[0].bounds.topLeft.x += xOffSet-*xSum/2;
				break;
			case ALIGN_RIGHT:	
				xOffSet=*columnLeftX+*columnWidth;
				self->rowInfo[0].bounds.topLeft.x += xOffSet-*xSum;		
				break;
			default:
				xOffSet=*columnLeftX;
				self->rowInfo[0].bounds.topLeft.x += xOffSet;
				break;
			}
		}
	textNbrBytes = GLEa_sizeofNchars(self->text,textNbrChars);
	/*%
	p += nbrChars;*/
	/* */
	p += self->rowInfo[0].nBytes;
	/* */
	rowInfoChunkSize=sizeof(GleTextRowInfoType);
	
	/*%
	while(*p)*/
	while((p - ((BYTE*)self->text))!=textNbrBytes)/*Equal to while(*p), in ASCII*/
		{
		rowInfoChunkSize += sizeof(GleTextRowInfoType);	
		tempRowInfoPtr = (VOID*)WIPAlloc(rowInfoChunkSize);

		memmove(tempRowInfoPtr,self->rowInfo,rowInfoChunkSize - sizeof(GleTextRowInfoType));
		WIPFree(self->rowInfo);
		self->rowInfo=tempRowInfoPtr;
		
		self->nRows++;
		/*"*/
		/* nbrChars=GLEa_textFontLineWidth(p,22, self->format, self->isLink); */

		 
		/*"*/
		nbrChars=GLEa_textFontWordWrap((GLE_STRING)p,self->columnWidth, self->format, self->isLink);
		self->rowInfo[self->nRows-1].nChars = GLEa_strNbrCharsWithoutEndingSpaces((GLE_STRING)p,nbrChars);
		self->rowInfo[self->nRows-1].nBytes = GLEa_sizeofNchars((GLE_STRING)p,nbrChars);

		self->rowInfo[self->nRows-1].bounds.extent.x = GLEa_textFontWidth((GLE_STRING)p,self->rowInfo[self->nRows-1].nChars, self->format, self->isLink);
		self->rowInfo[self->nRows-1].bounds.extent.y = rowHeight;
		
		switch (*myAlign) 
			{
			case ALIGN_CENTER:
				self->rowInfo[self->nRows-1].bounds.topLeft.x = xOffSet-self->rowInfo[self->nRows-1].bounds.extent.x/2;
				break;
			case ALIGN_RIGHT:	
				self->rowInfo[self->nRows-1].bounds.topLeft.x = xOffSet-self->rowInfo[self->nRows-1].bounds.extent.x;
				break;
			default:
				self->rowInfo[self->nRows-1].bounds.topLeft.x = xOffSet;
				break;
			}
		self->rowInfo[self->nRows-1].bounds.topLeft.y = *ySum + *ascentMax + *descenderMax + (self->nRows-2)*rowHeight;
		/*%
		p += nbrChars;*/
		/* */
		p += self->rowInfo[self->nRows-1].nBytes;
		/* */
		((GleViewType*)viewP)->xSumMaxForFieldSet = max(((GleViewType*)viewP)->xSumMaxForFieldSet, self->rowInfo[self->nRows-1].bounds.extent.x);
		}
	if (multipleRows) 
		{
		self->rowInfo[self->nRows-1].bounds.extent.y = rowHeight;
		self->firstRowDeltaY=*ascentMax - self->ascent;
		self->rowInfo[0].bounds.topLeft.y=*ySum;
		
		self->totalTextHeight= *descenderMax+(self->nRows-2)*rowHeight;
		}
	else
		self->rowInfo[self->nRows-1].bounds.extent.y = textFontLineHeight;
	*gleType = self->type;

	self->chunkSize = oldChunkSize + (self->nRows - oldNRows)*sizeof(GleTextRowInfoType);

	return (!multipleRows);
	}

VOID GleTextRenderY(GleText* self, INT16* xOffSet, INT16* ySum, INT16* ascentMax) {
	self->rowInfo[0].bounds.topLeft.y = *ySum-self->ascent + *ascentMax;
	self->rowInfo[0].bounds.topLeft.x += *xOffSet;
	}
	
VOID GleTextLastRowRenderY(GleText* self, INT16 *xSum, INT8 *myAlign, INT16 *ascentMax, INT16 *descenderMax) {	
	INT16 xOffSet;

	if (self->ascent > *ascentMax)
		*ascentMax = self->ascent;
	if ((self->rowInfo[self->nRows-1].bounds.extent.y - self->ascent) > *descenderMax)	
		*descenderMax = self->rowInfo[self->nRows-1].bounds.extent.y - self->ascent;
	self->lastRowDeltaY = *ascentMax - self->ascent;

	switch (*myAlign) 
		{
		case ALIGN_CENTER:
			xOffSet=self->columnLeftX+(self->columnWidth-*xSum)/2;
			break;
		case ALIGN_RIGHT:	
			xOffSet=self->columnLeftX+(self->columnWidth-*xSum);
			break;
		default:
			xOffSet=self->columnLeftX;
			break;
		}
	
	self->rowInfo[self->nRows-1].bounds.extent.y = *descenderMax + *ascentMax;
	self->rowInfo[self->nRows-1].bounds.topLeft.x=xOffSet; 
	}

#ifdef SUPPORT_PEN_NAVIGATION
	BOOL GleTextContains(GleViewType* viewP, const GleText *self, GlePointType point)
		{
		BOOL result = FALSE;
		GleRectangleType r;
		GleRectangleType intersectionR;
		INT16 horisOffset = 0;
		UINT16 k;
		if (self->isLink) {
			GleRctSetRectangle(&r, horisOffset + viewP->horizOffset, viewP->vertOffset, viewP->width, viewP->height);
			for (k=0 ; k<self->nRows ; k ++)
				{
				GleRctGetIntersection(&r,&(self->rowInfo[k].bounds), &intersectionR);	
				result = GleRctPtInRectangle( point.x + horisOffset + viewP->horizOffset, point.y + viewP->vertOffset, &intersectionR);
				if (result)
					break;
				}
			}
		return (result);
		}	
#endif
	 
VOID GleTextSelected(GleViewType* viewP, const GleText* self) {
	if(!viewP->mMIa_wait)
		{
		if(self->image)
			CALL_GWC_API(MMIc_imageSelected(viewP->viewId, self->textId));
		else			
			CALL_GWC_API(MMIc_textSelected(viewP->viewId,self->textId));
		GLEa_playSoundClick();	
		}
	}	
VOID GleTextDestruct(GleText* self){
	WIPFree(self->rowInfo);
	WIPFree(self->text);
	WIPFree(self->linkTitle);
	if(self->image) {
		GleImageDestruct(self->image);
		}
	WIPFree(self);
	}

GleElement *GleTextConstruct(UINT8 viewId, UINT8 textId, const WCHAR *text, BOOL isLink, const WCHAR *linkTitle, INT8 format, GleImage* image){
	GleText *self;
	UINT16 n1;
	UINT16 n2;
	INT16 nullChar = 0;
	if(text)
		n1 = GLEa_sizeofString(text);
	else
		n1 = GLEa_sizeofString((WCHAR*)&nullChar);
		
	if(linkTitle)
		n2 = GLEa_sizeofString(linkTitle);
	else
		n2 = GLEa_sizeofString((WCHAR*)&nullChar);

	self = (GleText*)WIPAlloc(sizeof(GleText));
	self->text = WIPAlloc(n1);
	self->linkTitle = WIPAlloc(n2);
	self->rowInfo = (struct GleTextRowInfoNode *)WIPAlloc(sizeof(GleTextRowInfoType));
		
	self->type=Text;
	self->chunkSize = sizeof(GleText) + sizeof(GleTextRowInfoType) + n1 + n2;
	self->viewId = viewId;
	self->image = image;
	self->textId = textId;
	self->isLink = isLink;
	self->format = format;
	self->Draw=&GleTextDraw;  
	self->RenderX=&GleTextRenderX;
	self->RenderY=&GleTextRenderY;
	self->Destruct=&GleTextDestruct;
	#ifdef SUPPORT_KEY_NAVIGATION
		self->IsMarkable=&GleTextIsMarkable;
	#endif
	#ifdef SUPPORT_PEN_NAVIGATION
		self->Contains=&GleTextContains;
	#endif
	self->Selected=&GleTextSelected;	
	self->nRows = 1;

	if (text)	
		GLEa_strcpyWchar2Gle(self->text, text);
	else 
		GLEa_strcpyWchar2Gle(self->text, (WCHAR*)&nullChar);

	
	if(linkTitle && isLink) 
		GLEa_strcpyWchar2Gle(self->linkTitle, linkTitle);		
	else 
		GLEa_strcpyWchar2Gle(self->linkTitle, (WCHAR*)&nullChar);
		
	self->ascent = GLEa_textFontAscent(self->format, self->isLink);
	self->rowInfo[0].bounds.extent.y = GLEa_textFontLineHeight(self->format, self->isLink);
	self->firstRowDeltaY = 0;
	self->totalTextHeight = self->rowInfo[0].bounds.extent.y;
	
	return (GleElement*)self;
	}

⌨️ 快捷键说明

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