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

📄 gleselct.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 "gleselct.h"
#include "aapigle.h"
#include "ansilibs.h"

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

extern GleSelect *gGleSingleSelect;

BOOL GleCloseSelectRenderX(GleCloseSelect* 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
		*gleType = self->type;
		return (FALSE);	
	#else
		if(!*xSum) {	
			*gleType = self->type;
			return (TRUE);
			}
		else
			return (FALSE);
	#endif
	}	

GleElement *GleCloseSelectConstruct(UINT8 viewId) {
	GleViewType* viewP;
	GleCloseSelect *self;
	UINT32 chunkSize;
	viewP = GleViewSearchByViewId(viewId);
	viewP->gleSingleSelect = 0; 
	
	chunkSize=sizeof(GleCloseSelect);
	self = (GleCloseSelect*)WIPAlloc(chunkSize);
	
	self->viewId = viewId;
	self->chunkSize=chunkSize;
	self->type=CloseSelect;
	#ifdef SUPPORT_PEN_NAVIGATION	
		self->Contains=&GleElementContains;
	#endif
	self->Draw=&GleElementDraw;  
	self->RenderX=&GleCloseSelectRenderX;
	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 GleSelectContains(GleViewType* viewP, const GleSelect *self, GlePointType point){
		#ifdef SHOW_OPTIONS_IN_CONTENT
			return FALSE;
		#else
			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));
		#endif
		}	
#endif

/* VOID GleKeyDestruct(GleText* self){
	WIPFree(self->rowInfo);
	WIPFree(self);
	}
*/
VOID GleSelectDraw(GleViewType* viewP, GleSelect* self){
	#ifndef SHOW_OPTIONS_IN_CONTENT
		BOOL isInverted;
		GleRectangleType selectBounds;
	
		isInverted = (viewP->markedGleElement == (GleElement*)self);	
		
		GLEa_selectSize(self->label, self->multiSelect, self->maxWidth, &self->bounds.extent.x, &self->bounds.extent.y, &self->ascent);
		memmove(&selectBounds, &self->bounds, sizeof(GleRectangleType) );
		/* selectBounds.topLeft.x += viewP->viewBounds.topLeft.x; */
		selectBounds.topLeft.x +=  - viewP->horizOffset;
		/* selectBounds.topLeft.y += viewP->viewBounds.topLeft.y;*/
		selectBounds.topLeft.y += - viewP->vertOffset;
			
		GLEa_selectDraw(viewP->viewId, self->label, self->multiSelect, isInverted, (GleRectangleType*)&selectBounds);
	#endif
	}
	
BOOL GleSelectRenderX(GleSelect* 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;
		return (FALSE);		
	#else		
		*gleType = self->type;
		if	(!*xSum) {
			self->maxWidth = *columnWidth;
			GLEa_selectGetLabel(self);
			GLEa_selectSize(self->label, self->multiSelect, self->maxWidth, &self->bounds.extent.x, &self->bounds.extent.y, &self->ascent);
			self->bounds.topLeft.x = *xSum;
			*xSum += self->bounds.extent.x + gle_horizontalSpaceBetweenElements;
			if (*xSum > *columnWidth)
				*xSum = *columnWidth;
			if (self->ascent > *ascentMax)
				*ascentMax = self->ascent;
			if (self->bounds.extent.y - self->ascent + gle_verticalSpaceBetweenElements > *descenderMax)
				*descenderMax = self->bounds.extent.y - self->ascent + gle_verticalSpaceBetweenElements ;
			return (TRUE);
			}
		else
			return (FALSE);	
	#endif
	
	}
	
VOID GleSelectRenderY(GleSelect* self, INT16* xOffSet, INT16* ySum, INT16* ascentMax) {
	#ifndef SHOW_OPTIONS_IN_CONTENT
		self->bounds.topLeft.y = *ySum - self->ascent + *ascentMax;
		self->bounds.topLeft.x += *xOffSet;
	#endif
	}

#ifdef SUPPORT_KEY_NAVIGATION 
	BOOL GleSelectIsMarkable(GleViewType* viewP, const GleSelect* self) {
		#ifdef SHOW_OPTIONS_IN_CONTENT
			return FALSE;
		#else
			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;
		#endif
		}
#endif

VOID GleSelectSelected(GleViewType* viewP, const GleSelect* self) {
	#ifndef SHOW_OPTIONS_IN_CONTENT
		if(!viewP->mMIa_wait) {	
			GLEa_playSoundClick();	
			GLEa_selectDialog(self);
			}
	#endif
	}	

VOID GleSelectDestruct(GleSelect* self){
	#ifndef SHOW_OPTIONS_IN_CONTENT
		WIPFree(self->title);
		WIPFree(self->label);
	#endif
	WIPFree(self);
	}

GleElement *GleSelectConstruct(UINT8 viewId, const WCHAR* title, BOOL multiSelect, INT8 tabIndex) {
	GleViewType* viewP;
	GleSelect *self;
	INT32 n1;
	INT16 nullChar = 0;

	viewP = GleViewSearchByViewId(viewId);

	if (title)	
		n1 = GLEa_sizeofString(title);
	else
		n1 = GLEa_sizeofString((WCHAR*)&nullChar);
		
	self = (GleSelect*)WIPAlloc(sizeof(GleSelect));

	#ifndef SHOW_OPTIONS_IN_CONTENT
		self->title = WIPAlloc(n1);
	#endif	

	self->type=Select;
	self->viewId = viewId;
	self->chunkSize=sizeof(GleSelect) + n1;
	self->multiSelect = multiSelect;
	self->singleSelectedOption = 0;
	if (!multiSelect) 
		viewP->gleSingleSelect = self;
	else 
		viewP->gleSingleSelect = 0;

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

		self->tabIndex = tabIndex;
		self->label = 0;
	#endif
	
	#ifdef SUPPORT_PEN_NAVIGATION
		self->Contains = &GleSelectContains;
	#endif
	self->Draw = &GleSelectDraw;  /* *(p->Draw)(); */
	self->RenderX = &GleSelectRenderX;
	self->RenderY = &GleSelectRenderY;
	self->Destruct = &GleSelectDestruct;  /* *(p->Destruct)(); */
	#ifdef SUPPORT_KEY_NAVIGATION
		self->IsMarkable = &GleSelectIsMarkable;
	#endif
	self->Selected = &GleSelectSelected;
	return (GleElement*)self;
	}

⌨️ 快捷键说明

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