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

📄 asix_mn.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
		if ( p_input->item_underline == UNDERLINE )
		{
//			DrawLine( pGC, GPC_BLACK, p_str->pop_x, p_str->pop_y+(i+1)*ITEM_1+item, p_str->pop_x+p_str->pop_width, p_str->pop_y+ITEM_1*(i+1)+item, 0, GPC_REPLACE_STYLE);// by zl 2002.3.19
			DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x + 2, p_str->pop_y + (i + 1)*ITEM_1 + item + 1, p_str->pop_width - 4, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
		}
		
/*		if ( strlen( p_input->item_text ) > 10 )
		{
			(p_input->item_text[8]) = '.';
			(p_input->item_text[9]) = '.';
			(p_input->item_text[10])= '\0';
		}
*/
//		dispbuf = (char *)Lmalloc( 11 );// by zl 2002.3.19
//		dispbuf = (char *)Lmalloc( ITEMTEXT_MAX ); //move up by zl 2002.3.19

		// longn_qi 2002/01/25 for monitor memory leak
		asix_mn_memdbgprintf( "asix_mn appeal mem for menu display buffer" );

//		menu_cutstring( p_input->item_text, 10, dispbuf );//by zl 2002.3.19
		menu_cutstring( p_input->item_text, ITEMTEXT_MAX, dispbuf );
		if ( p_input->item_status == ICON_ENABLE)
			//Disp16String( dispbuf, p_str->pop_x+MARGIN, p_str->pop_y+i*ITEM_1+item+2);
//			TextOut(pGC, dispbuf, p_str->pop_x+MARGIN, p_str->pop_y+i*ITEM_1+item+2, HZK_16X16_FONT, ColorTheme.form_text, GPC_REPLACE_STYLE);//by zl 2002.3.19
			TextOut(pGC, dispbuf, p_str->pop_x + 2 + MARGIN, p_str->pop_y + 2 + i * ITEM_1 + item + ITEMTEXT_UP_FROM, 
			HZK_16X16_FONT, ColorTheme.form_text, GPC_REPLACE_STYLE);
		else 
			//Disp16StringGrey(GPC_DARKGREY, dispbuf, p_str->pop_x+MARGIN, p_str->pop_y+i*ITEM_1+item+2); 	
//			TextOut(pGC, dispbuf, p_str->pop_x+MARGIN, p_str->pop_y+i*ITEM_1+item+2, HZK_16X16_FONT, ColorTheme.form_disablecolor, GPC_REPLACE_STYLE);//by zl 2002.3.19
			TextOut(pGC, dispbuf, p_str->pop_x + 2 + MARGIN, p_str->pop_y + 2 + i * ITEM_1 + item + ITEMTEXT_UP_FROM, 
			HZK_16X16_FONT, ColorTheme.form_disablecolor, GPC_REPLACE_STYLE);
			
//		Lfree( (void *)dispbuf );//move down by zl 2002.3.19

		// longn_qi 2002/01/25 for monitor memory leak
		asix_mn_memdbgprintf( "asix_mn free mem of menu display buffer" );
		
		p_input++;
		  	
	}
	Lfree( (void *)dispbuf );	
	
	//ClearRec(GPC_LIGHTGREY,p_str->pop_x+MARGIN,p_str->pop_y+item+2, p_str->pop_width-MARGIN, i*ITEM_1, GPC_OR_STYLE);
	
	return ASIX_OK;
}



/**********************************************************************/
/**计算弹出框位置********************************************************/
static STATUS menu_calculate( struct MENU_STRUCTURE * p_str )
{
	struct MENU_ITEM * p_input = p_str->menu_item;
	U8	 	i=0;
	U16		x1, x2, y1, y2;
	U16		menu_height=0, currentlen=0, maxlength=0;
	
	if ( (p_str->y <= BOTTOM_LIMIT) && (p_str->y >= TOP_LIMIT) )	return  ASIX_ERROR;
	
//	while ( (p_input->item_status != ICON_END) && (i<15) )// by zl 2002.3.19
	while ( (p_input->item_status != ICON_END) && (i < ITEM_MAX) )
	{
		switch ( i )
		{
			case	0:
			case	1:
			case	2:
			case	3:
			case	4:	
				menu_height = menu_height + ITEM_1;
				break;

			case	5:	
				menu_height = menu_height + ITEM_0 * 2;
				break;

			default:	
				break;
		}
		currentlen = (U16)strlen( p_input->item_text );
		if ( maxlength < currentlen )		maxlength = currentlen;
		p_input++;
		i++;
	}
	
//	if ( maxlength > 10 )	maxlength = 10;//by zl 2002.3.19
	if ( maxlength > ITEMTEXT_MAX )	maxlength = ITEMTEXT_MAX;
//	p_str->pop_width = maxlength*ENGLISH_CHAR_WIDTH + 2 * MARGIN;//by zl 2002.3.19
//	p_str->pop_height = menu_height;//by zl 2002.3.19
	p_str->pop_width = maxlength*ENGLISH_CHAR_WIDTH + 2 * MARGIN + 4;//here adds 4 because we sould draw obj3D_shadow and obj3D_highlight inside the menu By zl 2002.3.19
	p_str->pop_height = menu_height + 2;//here adds 2 because we sould draw obj3D_shadow and obj3D_highlight inside the menu By zl 2002.3.19
	p_str->total_line = i;

	if ( p_str->y > BOTTOM_LIMIT )
	{
		x1 = p_str->x;
		y1 = p_str->y - p_str->pop_height;
		y2 = p_str->y;//y2 = y1 + p_str->pop_height;//by zl 2002.3.19
		x2 = x1 + p_str->pop_width;
		
		if ( x2 >= ASIX_LCD_W ) //if ( x2 > ASIX_LCD_W )//by zl 2002.3.19
			x1 = x1-(x2-ASIX_LCD_W)-MARGIN;
 	}
	else 
	{
		x1 = p_str->x;
		y1 = p_str->y + p_str->height;
		y2 = y1 + p_str->pop_height;
		x2 = x1 + p_str->pop_width;
		
		if ( x2 >= ASIX_LCD_W ) //if ( x2 > ASIX_LCD_W )//by zl 2002.3.19
			x1 = x1-(x2-ASIX_LCD_W)-MARGIN;
	}

	p_str->pop_x = x1;
	p_str->pop_y = y1;

	return	ASIX_OK;	
}



/****************************************************************/
/*挂起***********************************************************/
static STATUS menu_hide( struct MENU_STRUCTURE * p_str )
{
	U8	   	i;
	U32		pGC;

	if ( p_str->pop_status == POP_HIDE ) 	return ASIX_ERROR;	
	
	pGC =GetGC( );
	
	if( ((ASIX_WINDOW *)p_str->windowid)->status & WST_CURSOR_ON )
		StartCursor( pGC );

	if ( (p_str->total_line) > ITEMDISPLAY_MAX )//if ( (p_str->total_line) > 5 ) //by zl 2002.3.19
	{
		for  ( i = 0; i < ITEMDISPLAY_MAX; i++ ) //for (i=0; i<5; i++) b yzl 2002.3.19
		{
			ActiveAreaDisable( (p_str->menu_icon[i]).icon_id );
			(p_str->menu_icon[i]).icon_id = 0;
			(p_str->menu_icon[i]).icon_status = ICON_DISABLE;
		}
//move from L376 By zl 2002.3.19
		ActiveAreaDisable( (p_str->menu_up).icon_id );
		(p_str->menu_up).icon_id = 0;
		(p_str->menu_up).icon_status = ICON_DISABLE;
   		
		ActiveAreaDisable( (p_str->menu_down).icon_id );
		(p_str->menu_down).icon_id = 0;
		(p_str->menu_down).icon_status = ICON_DISABLE;
	} 
	else
	{
		for ( i = 0; i < p_str->total_line; i++ )
		{
			ActiveAreaDisable( (p_str->menu_icon[i]).icon_id );
			(p_str->menu_icon[i]).icon_id = 0;
			(p_str->menu_icon[i]).icon_status = ICON_DISABLE;
		}
	}
/*
	if ( (p_str->total_line) > ITEMDISPLAY_MAX )//if ( (p_str->total_line) > 5 ) // by zl 2002.3.19
	{
		ActiveAreaDisable( (p_str->menu_up).icon_id );
		(p_str->menu_up).icon_id = 0;
		(p_str->menu_up).icon_status = ICON_DISABLE;
   		
		ActiveAreaDisable( (p_str->menu_down).icon_id );
		(p_str->menu_down).icon_id = 0;
		(p_str->menu_down).icon_status = ICON_DISABLE;
	}
*/
	ActiveAreaDisable( (p_str->menu_mask).icon_id );
	(p_str->menu_mask).icon_id = 0;
	(p_str->menu_mask).icon_status = ICON_DISABLE;
	
	p_str->item_selected = SELECTED_NONE;

//	PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width+2, p_str->pop_height+2, GPC_REPLACE_STYLE,0);	// by zl 2002.3.19
	PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width, p_str->pop_height, GPC_REPLACE_STYLE,0);	
		
	Lfree( ( void * )p_str->menu_coveredmap );
			
	// longn_qi 2002/01/25 for monitor memory leak
	asix_mn_memdbgprintf( "asix_mn free mem of menu_coveredmap" );

	p_str->pop_status = POP_HIDE;
	return	ASIX_OK;	
}


/*************************************************************************/
/*创建*********************************************************************/
extern STATUS	menu_create(char *caption, U32 style, U16 x, U16 y, U16 width, U16 height, 
			U32 wndid, U32 menu, void **ctrl_str,void *exdata)
{
	U8		i=0;
	struct	MENU_STRUCTURE *		p_str;
//	U32		bmp_width,bmp_height;
	U32		pGC;
	char*	dispbuf;//by zl 2002/4/4

	if ( caption == NULL || exdata == NULL )		return	ASIX_ERROR;
	if ( (y <= BOTTOM_LIMIT) && (y >= TOP_LIMIT) )		return ASIX_ERROR;
//	if( ((U16)strlen( caption )) * ENGLISH_CHAR_WIDTH + MARGIN > width )	return ASIX_ERROR;//By zl 2002.4.1
//	if ( (S16)width <= 0 || (S16)height <= 0 )	return ASIX_ERROR;	//by zl 2002/4/4
		
	PenIrptDisable(  );
	pGC = GetGC( );
	asix_mn_memdbgprintf( "### Create Menu ###" );
	p_str = (struct MENU_STRUCTURE *)Lcalloc( sizeof(struct MENU_STRUCTURE) );
	if (p_str == NULL)	
	{
		PenIrptEnable(  );
		asix_mn_memdbgprintf( "### Create Menu Error ###" );
		return ASIX_ERROR;	
	}

	// longn_qi 2002/01/25 for monitor memory leak
	asix_mn_memdbgprintf( "asix_mn appeal mem for itself" );

	p_str->x = x;
	p_str->y = y;
	p_str->width = width;
	p_str->height = height;
	p_str->classid = (U32)WNDCLASS_MENU;
	p_str->windowid = wndid;
	p_str->item_selected = SELECTED_NONE;
	p_str->pop_status = POP_HIDE;
	
	p_str->menu_item = ( struct MENU_ITEM * )exdata;

	(p_str->menu_mask).icon_status = ICON_DISABLE;
	(p_str->menu_start).icon_status = ICON_DISABLE;
	(p_str->menu_up).icon_status = ICON_DISABLE;
	(p_str->menu_down).icon_status = ICON_DISABLE;
	
//	if (ActiveAreaEnable(&((p_str->menu_start).icon_id), ICON_AREA, 0 , x, y, x + width, y + height) != PPSM_OK)	//by zl 2002.3.20
	if (ActiveAreaEnable(&((p_str->menu_start).icon_id), ICON_AREA, 0 , x, y, x + width - 1, y + height - 1, p_str->windowid) != PPSM_OK)
	{
			Lfree( (void *)p_str );

			// longn_qi 2002/01/25 for monitor memory leak
			asix_mn_memdbgprintf( "asix_mn free mem of itself" );

			PenIrptEnable(  );
			asix_mn_memdbgprintf( "### Create Menu Error ###" );
			return ASIX_ERROR;
	};
	(p_str->menu_start).icon_status = ICON_ENABLE;
	
	for ( i = 0; i < ITEMDISPLAY_MAX; i++ )	//for ( i = 0; i < 5; i++) //by zl 2002.3.20
		(p_str->menu_icon[i]).icon_status = ICON_DISABLE;
	
//	DrawRec( pGC, GPC_BLACK, x, y, (U16)(x+width), (U16)(y+height), GPC_SOLID_LINE, GPC_REPLACE_STYLE);		//by zl 2002.3.20
//	ClearRec(pGC, ColorTheme.form_backcolor, x, y, width, height, GPC_REPLACE_STYLE);//by zl 2002/4/4

	/*by zl 2002.4.4*/
	if ( ClearRec(pGC, ColorTheme.form_backcolor, x, y, width, height, GPC_REPLACE_STYLE) != GPC_ERR_OK )
	{
		Lfree( (void *)p_str );
		PenIrptEnable(  );
		asix_mn_memdbgprintf( "### Create Menu Error ###" );
		return ASIX_ERROR;
	};
		
//	DrawRec( pGC, ColorTheme.form_board, x, y, (U16)(x + width - 1), (U16)(y + height - 1), GPC_SOLID_LINE, GPC_REPLACE_STYLE);	
//	SetDotWidth( pGC, 2, NULL);
	DrawHorz( pGC, ColorTheme.obj3D_highlight, x, y + (((GC*)pGC)->dotwidth - 1) / 2, width - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	DrawVert( pGC, ColorTheme.obj3D_highlight, x + (((GC*)pGC)->dotwidth - 1) / 2, y + ((GC*)pGC)->dotwidth, height - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
	DrawHorz( pGC, ColorTheme.obj3D_shadow, x + ((GC*)pGC)->dotwidth, y + height - ((GC*)pGC)->dotwidth / 2 - 1, width - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	DrawVert( pGC, ColorTheme.obj3D_shadow, x + width - ((GC*)pGC)->dotwidth / 2 - 1, y, height - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
	ClearRec( pGC, ColorTheme.obj3D, x + ((GC*)pGC)->dotwidth, y + ((GC*)pGC)->dotwidth, width - 2 * ((GC*)pGC)->dotwidth, height - 2 * ((GC*)pGC)->dotwidth, GPC_REPLACE_STYLE);
//	SetDotWidth( pGC, 1, NULL);
	
//	if ( menu == 0 )	Disp16String(caption, (U16)(x + MARGIN), (U16)(y + 3));//by zl 2002.3.20
	if ( style & MNS_TEXT )	
	{
//		if( ((U16)strlen( caption )) * ENGLISH_CHAR_WIDTH + MARGIN <= p_str->width )

//		if( ((U16)strlen( caption )) * ENGLISH_CHAR_WIDTH + MARGIN > width )	//by zl 2002.4.1
//			;
//		else
//			Disp16String(caption, (U16)(x + MARGIN - 1), (U16)(y + (p_str->height - CHINESE_CHAR_WIDTH) / 2 - 1));
////		else
////			Disp16String(caption, (U16)(x + p_str->width - 1), (U16)(y + (p_str->height - CHINESE_CHAR_WIDTH) / 2 - 1));

		/*by zl 2002/4/4*/
		if ((S16)((p_str->width - 2*MARGIN )/ENGLISH_CHAR_WIDTH) <= 0 ) 
			;
		else
		{
			if ((dispbuf = (char *)Lmalloc( (p_str->width - 2*MARGIN )/ENGLISH_CHAR_WIDTH )) == NULL)
			{
				Lfree( (void *)p_str );//by zl 2002/4/4
				PenIrptEnable(  );//by zl 2002/4/4
				asix_mn_memdbgprintf( "### Create Menu Error ###" );
				return ASIX_ERROR;
			}
			else
			{
				menu_cutstring( caption, (U8)((p_str->width - 2*MARGIN )/ENGLISH_CHAR_WIDTH), dispbuf );
				Disp16String(dispbuf, (U16)(x + MARGIN - 1), (U16)(y + (p_str->height - CHINESE_CHAR_WIDTH) / 2 - 1));
			}
		}
	}
	else

⌨️ 快捷键说明

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