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

📄 gleoptn.c

📁 是一个手机功能的模拟程序
💻 C
字号:
/*
 * 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 "gleoptn.h"
	#include "gleselct.h"
	#include "aapigle.h"
	#include "capimmi.h"
	#include "ansilibs.h"
	
	VOID* WIPAlloc(UINT32 size);
	VOID WIPFree( VOID* memory );

	extern GleRectangleType gTotalScreen;
	extern GleSelect *gGleSingleSelect;
	
	BOOL GleCloseOptionGroupRenderX(GleCloseOptionGroup* self, INT16  *xSum, INT16 *ySum, INT16 *ascentMax, INT16 *descenderMax, GleElementType *gleType, UINT16 *currentFontLineHeight, INT8 *myAlign, BOOL *myWrap, INT16 *columnLeftX, INT16 *columnWidth) {
		#ifdef SHOW_OPTIONS_IN_CONTENT
			*gleType = self->type;
			*columnLeftX -= gle_optiongroup_tab;
			*columnWidth += gle_optiongroup_tab;	
			return (TRUE);	
		#else
			*gleType = self->type;
			return (TRUE);	
		#endif
		}	
	
	GleElement *GleCloseOptionGroupConstruct(VOID) {
		GleCloseOptionGroup *self;
		UINT32 chunkSize;
	
		chunkSize = sizeof(GleCloseOptionGroup);
		self = (GleCloseOptionGroup*)WIPAlloc(chunkSize);

		self->chunkSize = chunkSize;
		self->type=CloseOptionGroup;
	
		#ifdef SUPPORT_PEN_NAVIGATION
			self->Contains=&GleElementContains;
		#endif
		self->Draw=&GleElementDraw;
		self->RenderX=&GleCloseOptionGroupRenderX;
		self->RenderY=&GleElementRenderY;
		self->Destruct=&GleElementDestruct;
		#ifdef SUPPORT_KEY_NAVIGATION
			self->IsMarkable=&GleElementIsMarkable;
		#endif
		self->Selected=&GleElementSelected;
		return (GleElement*)self;
		}
	
	
	
	#ifdef SUPPORT_PEN_NAVIGATION
	BOOL GleOptionContains(GleViewType* viewP, const GleOption *self, GlePointType point){
		#ifdef SHOW_OPTIONS_IN_CONTENT
			GleRectangleType r;
			GleRectangleType intersectionR;
		
			GleRctSetRectangle(&r,viewP->horizOffset, viewP->vertOffset, viewP->width, viewP->height);
			GleRctGetIntersection(&r,(GleRectanglePtr)&self->bounds, &intersectionR);
			return( GleRctPtInRectangle( point.x + viewP->horizOffset, point.y + viewP->vertOffset, &intersectionR));
		#else
			return(FALSE);
		#endif
		}	
	#endif
	
	VOID GleOptionSelected(GleViewType* viewP, GleOption* self) {
		#ifdef SHOW_OPTIONS_IN_CONTENT
			if(!viewP->mMIa_wait) {	
				GleSelect *singleSelect = self->singleSelect;
				GleOption *singleSelectedOptionBefore;
				GLEa_playSoundClick();	
				if (singleSelect) {	/* Radiobutton	*/
					singleSelectedOptionBefore = ((GleSelect *)(self->singleSelect))->singleSelectedOption;		
					CALL_GWC_API(MMIc_optionSelected(self->viewId, self->optionId));
													   	
					/* Only graphic reset of previous option is needed*/
					((GleSelect *)(self->singleSelect))->singleSelectedOption = self;

					if(GLEa_drawCardRequest(viewP->viewId, viewP->horizOffset, viewP->horizontalSize, viewP->vertOffset, viewP->verticalSize)) {
					self->Draw(viewP, self);
						GLEa_drawCardCompleted(viewP->viewId);
						}

					if(GLEa_drawCardRequest(viewP->viewId, viewP->horizOffset, viewP->horizontalSize, viewP->vertOffset, viewP->verticalSize)) {
						if(singleSelectedOptionBefore)
							singleSelectedOptionBefore->Draw(viewP, singleSelectedOptionBefore);
							GLEa_drawCardCompleted(viewP->viewId);
							}
					}
				else if (!singleSelect) {	/* Checkbox*/
					CALL_GWC_API(MMIc_optionSelected(self->viewId, self->optionId));	
					self->multipleSelected =! self->multipleSelected;
					if(GLEa_drawCardRequest(viewP->viewId, viewP->horizOffset, viewP->horizontalSize, viewP->vertOffset, viewP->verticalSize)) {
						self->Draw(viewP, self);
						GLEa_drawCardCompleted(viewP->viewId);
						}
					}
				}
		#endif
		}	
	
	#ifdef SUPPORT_KEY_NAVIGATION 
		BOOL GleOptionIsMarkable(GleViewType* viewP, const GleOption* self) {
			#ifdef SHOW_OPTIONS_IN_CONTENT
				BOOL onScreen = FALSE;
				if (self->bounds.topLeft.y >= viewP->vertOffset) 
					if ((self->bounds.topLeft.y + self->bounds.extent.y) < (viewP->vertOffset + viewP->height)) 
						onScreen=TRUE;
				return onScreen;
			#else
				return FALSE;
			#endif
			}
	#endif
	VOID GleOptionDraw(GleViewType* viewP, const GleOption* self){
		#ifdef SHOW_OPTIONS_IN_CONTENT
			GleRectangleType selectBounds;
			BOOL isInverted;
		
			isInverted = (viewP->markedGleElement == (GleElement*)self);	
			/*GLEa_fontSetTextStyle(0, FALSE);*/
		
			/*memmove(&selectBounds, &self->bounds, sizeof(GleRectangleType) );
			selectBounds.topLeft.x += GLE_SCREENTOPLEFTX   - gHorizOffset;
			selectBounds.topLeft.y +=  GLE_SCREENTOPLEFTY - gVertOffset  ;	*/

			selectBounds.topLeft.x = self->bounds.topLeft.x - viewP->horizOffset;			
			selectBounds.topLeft.y = self->bounds.topLeft.y - viewP->vertOffset;
			selectBounds.extent.x = self->bounds.extent.x;
			selectBounds.extent.y = self->bounds.extent.y;
		
			if(self->singleSelect)	
				GLEa_optionDraw(viewP->viewId, self->label, FALSE, isInverted, ((GleOption*)((GleSelect *)self->singleSelect)->singleSelectedOption == self), (GleRectangleType*)&selectBounds);
			else
				GLEa_optionDraw(viewP->viewId, self->label, TRUE, isInverted, self->multipleSelected, (GleRectangleType*)&selectBounds);
		#endif
		}
		
	BOOL GleOptionRenderX(GleOption* self, INT16  *xSum, INT16 *ySum, INT16 *ascentMax, INT16 *descenderMax, GleElementType *gleType, UINT16 *currentFontLineHeight, INT8 *myAlign, BOOL *myWrap, INT16 *columnLeftX, INT16 *columnWidth){
		#ifdef SHOW_OPTIONS_IN_CONTENT
			GLEa_optionSize(self->label, (self->singleSelect==0), *columnWidth, &self->bounds.extent.x, &self->bounds.extent.y, &self->ascent);
			self->bounds.topLeft.x = *columnLeftX;
			self->bounds.topLeft.y = *ySum;
			*ySum += self->bounds.extent.y;
			*gleType = self->type;
			*xSum = max(*xSum, self->bounds.extent.x + self->bounds.topLeft.x);
			return (TRUE);
		#else
			return (TRUE);
		#endif
		}
		
	VOID GleOptionDestruct(GleOption* self){
		WIPFree(self->label);
		WIPFree(self->title);
		WIPFree(self);
		}
	
	GleElement *GleOptionConstruct(UINT8 viewId, UINT8 optionId, const WCHAR *label, const WCHAR *title, BOOL isSelected) {
		GleViewType* viewP;
	    GleOption *self;
		INT32 n1;
		INT32 n2;
		INT16 nullChar = 0;
		
		viewP = GleViewSearchByViewId(viewId);
		if(label)
			n1 = GLEa_sizeofString(label);
		else
			n1 = GLEa_sizeofString((WCHAR*)&nullChar);
			
		if (title)
			n2 = GLEa_sizeofString(title);
		else
			n2 = GLEa_sizeofString((WCHAR*)&nullChar);
		
		self = (GleOption*)WIPAlloc(sizeof(GleOption));
		self->label = WIPAlloc(n1);
		self->title = WIPAlloc(n2);
			
		self->viewId = viewId;
		self->optionId = optionId;
		self->multipleSelected = isSelected;
		self->type = Option;
		self->chunkSize = sizeof(GleOption) + n1 + n2;
	

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

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

		self->singleSelect = viewP->gleSingleSelect;
		   
		if(viewP->gleSingleSelect)
			if(isSelected)
				((GleSelect *)(self->singleSelect))->singleSelectedOption = self;				
		
		#ifdef SUPPORT_PEN_NAVIGATION		
			self->Contains = &GleOptionContains;
		#endif
		self->Draw = &GleOptionDraw; 
		self->RenderX = &GleOptionRenderX;
		self->RenderY = &GleElementRenderY;
		self->Destruct = &GleOptionDestruct;
		#ifdef SUPPORT_KEY_NAVIGATION
			self->IsMarkable = &GleOptionIsMarkable;
		#endif
		self->Selected = &GleOptionSelected;
		return (GleElement*)self;
		}
	
	BOOL GleOptionGroupRenderX(GleOptionGroup* self, INT16  *xSum, INT16 *ySum, INT16 *ascentMax, INT16 *descenderMax, GleElementType *gleType, UINT16 *currentFontLineHeight, INT8 *myAlign, BOOL *myWrap, INT16 *columnLeftX, INT16 *columnWidth, VOID* viewP) {	
		#ifdef SHOW_OPTIONS_IN_CONTENT
			*columnLeftX += gle_optiongroup_tab;
			*columnWidth -= gle_optiongroup_tab;
			GLEa_optionGroupSize(self->label, *columnWidth, &self->bounds.extent.x, &self->bounds.extent.y, &self->ascent);
			self->bounds.topLeft.x = *columnLeftX;	
			self->bounds.topLeft.y = *ySum;
			*ySum += self->bounds.extent.y;
			*gleType = self->type;
			*xSum = max(*xSum, self->bounds.extent.x + self->bounds.topLeft.x);
			return (TRUE);
		#else
			return (TRUE);
		#endif
		}
	
	VOID GleOptionGroupDraw(GleViewType* viewP, const GleOptionGroup* self){
		#ifdef SHOW_OPTIONS_IN_CONTENT
			GleRectangleType optionGroupBounds;
			memmove(&optionGroupBounds, &self->bounds, sizeof(GleRectangleType) );
			optionGroupBounds.topLeft.x += - viewP->horizOffset;
			optionGroupBounds.topLeft.y += - viewP->vertOffset;				
			GLEa_optionGroupDraw(viewP->viewId, self->label, (GleRectangleType*)&optionGroupBounds);
		#endif
		}
	
	VOID GleOptionGroupDestruct(GleOptionGroup* self){
		WIPFree(self->label);
		WIPFree(self);
		}
	
	GleElement *GleOptionGroupConstruct(const WCHAR *label){
		GleOptionGroup *self;
		INT32 n1;
		INT16 nullChar = 0;

		if(label)
			n1 = GLEa_sizeofString(label);
		else
			n1 = GLEa_sizeofString((WCHAR*)&nullChar);

		self = (GleOptionGroup*)WIPAlloc(sizeof(GleOptionGroup));
		self->label = WIPAlloc(n1);
			
		self->chunkSize = sizeof(GleOptionGroup) + n1;	
		self->type=OptionGroup;
	
		if(label)
			GLEa_strcpyWchar2Gle(self->label, label);
		else
			GLEa_strcpyWchar2Gle(self->label, (WCHAR*)&nullChar);
	
		#ifdef SUPPORT_PEN_NAVIGATION
			self->Contains = &GleElementContains;
		#endif
		self->Draw = &GleOptionGroupDraw; 
		self->RenderX = &GleOptionGroupRenderX;
		self->RenderY = &GleElementRenderY;
		self->Destruct = &GleOptionGroupDestruct;
		#ifdef SUPPORT_KEY_NAVIGATION
			self->IsMarkable = &GleElementIsMarkable;
		#endif
		self->Selected = &GleElementSelected;
		return (GleElement*)self;
		}

⌨️ 快捷键说明

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