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

📄 atbwapaui.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
 
*******************************************************************************/

T_WAP_RES ATB_wap_options_menu_select(T_WAP_VIEW *View)
{
#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_options_menu_select");
#endif

	ATB_wap_card_key_event(View, WAP_KEY_SELECT);
	
	return WAP_OK;
}


/*******************************************************************************

 $Function:    	ATB_wap_buffer_add_element

 $Description:	Add a new element to the element chain
 
 $Returns:		Pointer to the element

 $Arguments:	View - 	the current view
 				type - the type of element (text, fieldset, image)
 
*******************************************************************************/

T_WAP_ELEMENT * ATB_wap_buffer_add_element(T_WAP_VIEW *View, WAP_ELEMENT_TYPE type)
{
	T_WAP_ELEMENT	*Element;
	T_WAP_ELEMENT	*ElementIndex;
	static USHORT	elementCount = 0;

#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_buffer_add_element");
#endif

	if (!View)
		return;

	/* Create the element */
	
	Element = (T_WAP_ELEMENT *)AUI_wap_memory_alloc(sizeof(T_WAP_ELEMENT));

	/* If it's the first element in the chain, it forms the element chain header */
	
	if (View->NewElementHeader == NULL)
	{
		View->NewElementHeader = Element;
		elementCount = 0;
	}

	/* Otherwise, find its place in the chain and add it */
	
	else
	{
		ElementIndex = View->NewElementHeader;
		while(ElementIndex->NextElement !=NULL)
			ElementIndex = ElementIndex->NextElement;
		ElementIndex->NextElement = Element;
	}
	
	Element->type		= type;
	Element->NextElement = NULL;

	elementCount++;

	return Element;
}


/*******************************************************************************

 $Function:    	ATB_wap_buffer_display

 $Description:	Displays the card from the buffer
 
 $Returns:		None.

 $Arguments:	View - the current view
 
*******************************************************************************/

void ATB_wap_buffer_display(T_WAP_VIEW *View)
{
	T_WAP_ELEMENT				*Element		= View->ElementHeader;
	USHORT						elementCount	= 0;		/* No. of element */
	SHORT						titleX;						/* Position of title to centre it */
	SHORT						titleWidth;					/* Width of the title in pixels */
	double						doubleTemp;					/* Temporary double value */
	SHORT						scrollBarSize;				/* Size of scroll bar in pixels */
	SHORT						scrollBarPos;				/* Y position of top of scroll bar */
	SHORT						lineX;						/* First X position of line */
	SHORT						lineY;						/* First Y position of line */
	USHORT						*temp;						/* Temporary storage for text strings */
	UBYTE						scrollIndex;				/* For drawing scrollbar */
	USHORT						titleLen;					/* Length of title */
	
#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_buffer_display");
#endif

	/* Display the title of the card, centred, over the line */

	temp = (USHORT *)AUI_wap_memory_alloc((CARD_TITLE_MAX_LEN+1)*sizeof(USHORT));
	
	if (ATB_wap_status_get(View, ATB_WAP_DOWNLOADING))	
	{
		/* Card is downloading */
		titleLen = AUI_wap_stringID(temp, CARD_TITLE_MAX_LEN, WAP_STRING_DOWNLOADING);
	}
	else if (ATB_wap_status_get(View, ATB_WAP_CARD_READING))
	{
		/* Card is updating */
		titleLen = AUI_wap_stringID(temp, CARD_TITLE_MAX_LEN, WAP_STRING_UPDATING);
	}
	else
	{
		/* Normal card title */
		titleLen = ATB_uc_text_copy(temp, View->Title, CARD_TITLE_MAX_LEN);
	}

	titleWidth = ATB_uc_text_width(temp, titleLen);		/* Width of the title */
	titleX = (WAP_TOTAL_WIDTH - titleWidth)/2;			/* Position of title to centre it */
	dspl_TextOut(titleX,0,DSPL_TXTATTR_SIGNED_COORDS | DSPL_TXTATTR_UNICODE, (char *)temp);
	
	AUI_wap_memory_free((UBYTE *)temp, (CARD_TITLE_MAX_LEN+1)*sizeof(USHORT));

	/* Horizontal scroll bar and top line */
		
	dspl_DrawLine(titleX-2, WAP_TOP_BORDER/2, 0, WAP_TOP_BORDER/2);	  /* Line to left of title */
	dspl_DrawLine(WAP_TOTAL_WIDTH-titleX+1, WAP_TOP_BORDER/2,
		WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH, WAP_TOP_BORDER/2);		/* Line to right of title */

	if (View->cardWidth>WAP_SCREEN_WIDTH)
	{
		doubleTemp = WAP_HSCROLLBAR_WIDTH*(double)WAP_SCREEN_WIDTH/(double)View->cardWidth;
		scrollBarSize = (SHORT)(doubleTemp+0.5);			/* Round to nearest int */
		if (scrollBarSize>WAP_HSCROLLBAR_WIDTH)
			scrollBarSize = WAP_HSCROLLBAR_WIDTH;

		doubleTemp = WAP_HSCROLLBAR_WIDTH*(double)View->cardXPosition/(double)View->cardWidth;
		scrollBarPos = (SHORT)(doubleTemp+0.5);				/* Round to nearest int */
		
		for (scrollIndex=0; scrollIndex<scrollBarSize; scrollIndex++)
		{
			dspl_DrawLine(scrollBarPos+scrollIndex, 0,
				scrollBarPos+scrollIndex, WAP_TOP_BORDER/2);
		}

		if (WAP_HSCROLLBAR_WIDTH<(titleX-1))
			dspl_DrawLine( WAP_HSCROLLBAR_WIDTH, 0, WAP_HSCROLLBAR_WIDTH, WAP_TOP_BORDER/2);
	}
	
	/* Display the elements of the card one by one */
	
	while (Element!=NULL)
	{
		switch(Element->type)
		{
			case WAP_TEXT:
				/* Text Element */
				ATB_wap_buffer_text_draw((T_WAP_MMI_SEND_TEXT_IND *)Element->data);
				break;

			case WAP_TABLE:
				/* Table/Fieldset element */
				ATB_wap_buffer_table_draw((T_WAP_MMI_SEND_TABLE_IND *)Element->data);
				break;
			
			case WAP_IMAGE:
				/* Image element */
				if (View->Status & WAP_STATUS_SCALEIMAGES)
					ATB_wap_buffer_image_scale((T_WAP_MMI_SEND_IMAGE_IND *)Element->data);
				else
					ATB_wap_buffer_image_display((T_WAP_MMI_SEND_IMAGE_IND *)Element->data);
				break;
		}
		elementCount++;
		Element = Element->NextElement;		/* Find the next element */
	}

	/* Vertical scroll bar and right frame */

	scrollBarSize = WAP_SCREEN_HEIGHT*WAP_SCREEN_HEIGHT/View->cardHeight;
	if (scrollBarSize>WAP_SCREEN_HEIGHT)
		scrollBarSize = WAP_SCREEN_HEIGHT;

	scrollBarPos = WAP_SCREEN_HEIGHT*View->cardYPosition/View->cardHeight;

	dspl_DrawLine(WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH, WAP_TOP_BORDER/2,
		WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH, WAP_SCREEN_BOTTOM);			/* Line to top of bar */

	for (scrollIndex=1; scrollIndex<WAP_VSCROLLBAR_WIDTH; scrollIndex++)
	{
		dspl_DrawLine(WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH+scrollIndex, scrollBarPos+WAP_TOP_BORDER,
			WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH+scrollIndex, scrollBarPos+WAP_TOP_BORDER+scrollBarSize);
	}

	return;
}


/*******************************************************************************

 $Function:    	ATB_wap_buffer_text_draw

 $Description:	Draws text
 
 $Returns:		None.

 $Arguments:	parameter	- the send text event
 
*******************************************************************************/

static void ATB_wap_buffer_text_draw(T_WAP_MMI_SEND_TEXT_IND *parameter)
{
	USHORT	*temp;			/* Temporary string storage */
	SHORT	elementX;		/* X position of element on-screen */
	SHORT	elementY;		/* Y position of element on-screen */
	USHORT	textWidth;		/* Width of text to draw */
	USHORT textLength;		/* Length of text */
	
	textWidth = parameter->pWidth;
	if ((textWidth + parameter->pX)>WAP_SCREEN_WIDTH)		/* if text goes off the screen, */
		textWidth = WAP_SCREEN_WIDTH-parameter->pX;			/* cut it down to size */

	elementX = (USHORT)parameter->pX+WAP_LEFT_BORDER;		/* Absolute position of text */
	elementY = (USHORT)parameter->pY+WAP_TOP_BORDER;		/* on screen */

	/* Draw special text features */
	
	switch(parameter->type)
	{
		case WAP_TEXT_OPTION:
			/* An options menu item - draw checkbox */
			dspl_DrawRect(elementX,
				elementY+WAP_CHECKBOX_TOP, \
				elementX+WAP_CHECKBOX_WIDTH-1, \
				elementY+WAP_CHECKBOX_TOP+WAP_CHECKBOX_HEIGHT-1);

			/* Draw check if item is selected */
			
			if (parameter->selected)
			{
				dspl_DrawRect(elementX+WAP_CHECKBOX_INDENT, \
					elementY+WAP_CHECKBOX_TOP+WAP_CHECKBOX_INDENT, \
					elementX+WAP_CHECKBOX_WIDTH-1-WAP_CHECKBOX_INDENT, \
					elementY+WAP_CHECKBOX_TOP+WAP_CHECKBOX_HEIGHT-1-WAP_CHECKBOX_INDENT);
			}

			/* Shift text to right to make space for checkbox */
			
			elementX += (WAP_CHECKBOX_WIDTH+WAP_CHECKBOX_RIGHT);				
			textWidth -= (WAP_CHECKBOX_WIDTH+WAP_CHECKBOX_RIGHT);
			break;
		
		case WAP_TEXT_OPTIONGROUP:
			/* Option group titles are currently not distinguished from normal text */
			break;
	}

	/* Convert text to MMI unicode and crop it to fit the width */
	
	temp = (USHORT *)AUI_wap_memory_alloc((parameter->text_length+1)*sizeof(USHORT));
	
	ATB_uc_text_copy(temp, parameter->Text, (USHORT)parameter->text_length);
	ATB_uc_text_convert(temp, (USHORT)parameter->text_length);
	
	textLength = ATB_uc_text_crop(temp, parameter->text_length, textWidth);

	/* Draw text, inverted or not inverted */
	
	if (!parameter->invert)
		dspl_TextOut((USHORT)elementX,(USHORT)elementY,DSPL_TXTATTR_SIGNED_COORDS | DSPL_TXTATTR_UNICODE,(char*)temp);
	else
		dspl_TextOut((USHORT)elementX,(USHORT)elementY,DSPL_TXTATTR_INVERS | DSPL_TXTATTR_SIGNED_COORDS | DSPL_TXTATTR_UNICODE, (char*)temp);

	AUI_wap_memory_free((UBYTE *)temp, (parameter->text_length+1)*sizeof(USHORT));
	
	return;
}
				

/*******************************************************************************

 $Function:    	ATB_wap_buffer_table_draw

 $Description:	Draws a table, or a fieldset
 
 $Returns:		None.

 $Arguments:	parameter	- the send table event
 
*******************************************************************************/

static void ATB_wap_buffer_table_draw(T_WAP_MMI_SEND_TABLE_IND *parameter)
{
	SHORT	elementX	= parameter->pX+WAP_LEFT_BORDER;			/* Left edge position of table/fieldset */
	SHORT	elementY	= parameter->pY+WAP_TOP_BORDER;				/* Top edge position of table/fieldset */
	SHORT	top			= elementY+WAP_CHAR_HEIGHT/2;				/* Top of fieldset */
	SHORT	bottom		= elementY+parameter->pHeight-1; 			/* Bottom of table/fieldset */
	SHORT	right		= elementX+parameter->pWidth-1;				/* Right side of table/fieldset */
	SHORT	lineX;													/* X position of column line */
	SHORT	lineY;													/* Y position of row line */
	USHORT	*temp;													/* Temp storage for title. */
	USHORT	titleWidth;												/* Width of the title in pixels */
	USHORT titleLength;												/* Length of title */
	USHORT	index;													/* Index for columns and rows */
	
#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_buffer_table_draw");
	TRACE_EVENT_P4( "Fieldset/table pX, pY, pWidth, pHeight: %d, %d, %d, %d",
		parameter->pX, parameter->pY, parameter->pWidth, parameter->pHeight);
#endif

	/* Convert title to MMI Unicode */

	temp = (USHORT *)AUI_wap_memory_alloc((parameter->title_length+1)*sizeof(USHORT));
	titleLength = parameter->title_length;
	ATB_uc_text_copy(temp, parameter->Title, titleLength);
	ATB_uc_text_convert(temp, titleLength);

	/* Crop title if it overshoots screen */

	if ((parameter->pX+gle_fieldset_spaceLeft+ATB_uc_text_width(temp, titleLength)) > WAP_SCREEN_WIDTH)
	{
		titleLength = ATB_uc_text_crop(temp, titleLength, WAP_SCREEN_WIDTH-parameter->pX-gle_fieldset_spaceLeft);
	}
	
	/* Crop title if it overshoots edge of fieldset */
	
	if ((gle_fieldset_spaceLeft+ATB_uc_text_width(temp, titleLength)+gle_fieldset_spaceRight) > parameter->pWidth)
	{
		titleLength = ATB_uc_text_crop(temp, titleLength, parameter->pWidth-gle_fieldset_spaceLeft-gle_fieldset_spaceRight);
	}
	
	titleWidth = ATB_uc_text_width(temp, titleLength);	/* Width of the title */

	/* Display title if it's onscreen */

	if (parameter->pY >= 0 && parameter->pY < WAP_TEXT_LOWEST)	
	{
		dspl_TextOut(elementX+gle_fieldset_spaceLeft, elementY, DSPL_TXTATTR_SIGNED_COORDS | DSPL_TXTATTR_UNICODE, (char *)temp);	
	}
	AUI_wap_memory_free((UBYTE *)temp, (parameter->title_length+1)*sizeof(USHORT));
	
	/* Horizontal lines */

	lineY = elementY+gle_cell_vBefore;
	ATB_wap_buffer_line_draw(elementX, bottom, right, bottom);	/* Bottom line of table */

	if (parameter->rows_length > 0)
		ATB_wap_buffer_line_draw(elementX, lineY, right, lineY);	/* Line under title */
	else
	{
		ATB_wap_buffer_line_draw(elementX+gle_fieldset_spaceLeft-2, top, elementX, top);     /* Line to left of title */
		ATB_wap_buffer_line_draw(elementX+gle_fieldset_spaceLeft+titleWidth+2, top, right, top);   /* right */
	}

	/* Row lines */
	
	if (parameter->rows_length > 1)
	{
		for (index=0; index<(parameter->rows_length-1); index++)
		{
			lineY += parameter->RowHeight[index]+gle_cell_spaceToBorder;
			ATB_wap_buffer_line_draw(elementX, lineY, right, lineY);
			lineY += gle_cell_borderExtent+gle_cell_spaceToBorder;
		}
	}
	
	/* Vertical lines */

	lineX = elementX+gle_cell_hBefore;
	
	if (parameter->rows_length == 0)
		lineY = top;												/* For fieldset */
	else
		lineY = elementY+gle_cell_vBefore;							/* For table */

	ATB_wap_buffer_line_draw(elementX, lineY, elementX, bottom);	/* Left hand line */

	/* Column lines */
	
	if (parameter->cols_length > 1)
	{
		for (index=0; index<(parameter->cols_length-1); index++)
		{
			lineX += parameter->ColWidth[index]+gle_cell_spaceToBorder;
			ATB_wap_buffer_line_draw(lineX, lineY, lineX, bottom);
			lineX += gle_cell_borderExtent+gle_cell_spaceToBorder;
		}
	}
	ATB_wap_buffer_line_draw(right, lineY, right, bottom);			/* Right hand line */
		
	return;
}


/*******************************************************************************

 $Function:    	ATB_wap_buffer_line_draw

 $Description:	Draws a line, making sure it fits on-screen
 
 $Returns:		None.

 $Arguments:	x1,y1 - Coordinates of the start of the line
 				x2,y2 - Coordinates of the end of the line
 
*******************************************************************************/

static void ATB_wap_buffer_line_draw(SHORT x1, SHORT y1, SHORT x2, SHORT y2)
{
	SHORT deltaX1;
	SHORT deltaY1;
	SHORT deltaX2;
	SHORT deltaY2;
	double m;
	
	ATB_wap_buffer_onscreen(x1,y1, &deltaX1, &deltaY1);
	ATB_wap_buffer_onscreen(x2,y2, &deltaX2, &deltaY2);
	
	if (x2==x1)
	{
		if (deltaX1)
			return;
		y1+=deltaY1;
		y2+=deltaY2;
	}
	else if (y2==y1)
	{
		if (deltaY1)
			return;
		x1+=deltaX1;
		x2+=deltaX2;
	}
	else
	{
		m = (y2-y1)/(x2-x1);	
		if (deltaX1 || deltaY1)
		{
			x1 += deltaX1;
			y1 += m*deltaX1;
			if (!ATB_wap_buffer_onscreen(x1,y1,&deltaX1,&deltaY1))
				return;
		}
		if (deltaX2 || deltaY2)
		{
			x2 += deltaX2;
			y2 += m*deltaX2;
			if (!ATB_wap_buffer_onscreen(x2,y2,&deltaX2,&deltaY2))
				return;
		}
	}

⌨️ 快捷键说明

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