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

📄 asix_mn.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
	{
//		bmp_width = LOWORD(menu);
//		bmp_height = HIWORD(menu);
		// longn_qi 2001/11/15 revised
		//switchonetotwo(caption, p_str->x+p_str->width/2-bmp_width/2, 
		//	p_str->y+p_str->height/2-bmp_height/2, bmp_width, bmp_height);
//		DrawMonoImage(pGC, caption, p_str->x+p_str->width/2-bmp_width/2, p_str->y+p_str->height/2-bmp_height/2, bmp_width, bmp_height, ColorTheme.form_text, ColorTheme.form_client);//by zl 2002.3.20
//		DrawMonoImage(pGC, caption, p_str->x + (p_str->width - bmp_width)/2, p_str->y + (p_str->height - bmp_height)/2, 
//		bmp_width, bmp_height, ColorTheme.form_frontcolor, ColorTheme.form_client);
		{
			U32	hbmp;
			U32	trColor;
			U16 x, y;

			hbmp = LoadBitmap( caption, NULL );
			if( hbmp != 0 )
			{
				x = p_str->x + (p_str->width - ((BITMAP *)hbmp)->info.width)/2;
				y = p_str->y + (p_str->height - ((BITMAP *)hbmp)->info.height)/2;
				if( style & MNS_TRANSPARENT )
				{
					SetBkFillMode( pGC, MAKELONG( GPC_REPLACE_STYLE, GPC_TRANSPARENT_STYLE ) );
					#ifndef COLORINDEX_GARFILED		//add COLORINDEX_GARFILED by DSA 2004.09.20
					trColor = ((BITMAP *)hbmp)->palette[0];
					#else
					trColor = 0x0000;
					#endif
					DisplayBMPEx( pGC, x, y, hbmp, GPC_TRANSPARENT_STYLE, trColor );
				}
				else
					DisplayBMP( pGC, x, y, hbmp );
				FreeBitmap( hbmp );
			}
		}
	};
		
	PenIrptEnable(  );
	*ctrl_str = (void *)p_str;
	asix_mn_memdbgprintf( "### Create Menu Successfully ###" );
	return ASIX_OK;	
} 



/***************************************************************************/
/*注销**********************************************************************/
extern STATUS	menu_destroy(void *ctrl_str)
{
	struct MENU_STRUCTURE *		p_str;

	p_str = ( struct MENU_STRUCTURE * )ctrl_str;
	if ( p_str == NULL || p_str -> windowid == 0)  	return ASIX_ERROR;
	
	PenIrptDisable(  );	
	asix_mn_memdbgprintf( "### Destroy Menu ###" );
	if ( p_str->pop_status == POP_SHOW )	menu_hide( p_str );	
	ActiveAreaDisable( (p_str->menu_start).icon_id);
	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( "### Destroy Menu Successfully ###" );
	return   	ASIX_OK;
}



/******************************************************************************/
/*消息翻译**********************************************************************/
extern STATUS	menu_msgtrans(void *ctrl_str, U16 msg_type, U32 areaid,
		 U16 *data, U32 size, PMSG trans_msg)
{
	struct MENU_STRUCTURE *		p_str = (struct MENU_STRUCTURE *)ctrl_str;
	U8							i;

	if ( msg_type != IRPT_ICON && msg_type != ASIX_KEY )	return  ASIX_NO_MSG;// if the msg is not IRPT_ICON, it must not for me!
	if ( p_str == NULL || p_str->windowid == 0) 	return ASIX_ERROR;
//	if ( data == NULL)		return	ASIX_ERROR;
	
	if ( msg_type == IRPT_ICON )
	{
		p_str->item_selected = SELECTED_NONE;
		
		if ( (areaid == (p_str->menu_start).icon_id) && 
			(ICON_ENABLE == (p_str->menu_start).icon_status) )
		{	
			p_str->item_selected = SELECTED_START;
			trans_msg->wparam = SELECTED_START;
			goto trans_type;
		}
		if ( (areaid == (p_str->menu_mask).icon_id) && 
			(ICON_ENABLE == (p_str->menu_mask).icon_status) )
		{	
			p_str->item_selected = SELECTED_MASK;
			trans_msg->wparam = SELECTED_MASK;
			goto trans_type;
		}
		if ( (areaid == (p_str->menu_up).icon_id) && 
			(ICON_ENABLE == (p_str->menu_up).icon_status) )
		{	
			p_str->item_selected = SELECTED_UP;
			trans_msg->wparam = SELECTED_UP;
			goto trans_type;
		}
		if ( (areaid == (p_str->menu_down).icon_id) && 
			(ICON_ENABLE == (p_str->menu_down).icon_status) )
		{	
			p_str->item_selected = SELECTED_DOWN;
			trans_msg->wparam = SELECTED_DOWN;
			goto trans_type;
		}
				
		if ( (p_str->total_line) > ITEMDISPLAY_MAX )//if ( (p_str->total_line) > 5 ) //by zl 2002.3.20
		{
			for ( i = 0; i < ITEMDISPLAY_MAX; i++ )//for ( i=0; i<5; i++ )//by zl 2002.3.20
			{
				if ( (areaid == (p_str->menu_icon[i]).icon_id) 
					&& (ICON_ENABLE == (p_str->menu_icon[i]).icon_status) )
				{
					p_str->item_selected = i;
					break;
				}
			}
		}
		else 
		{
			for ( i = 0; i < p_str->total_line; i++ )
			{
				if ( (areaid == (p_str->menu_icon[i]).icon_id)
					&& (ICON_ENABLE == (p_str->menu_icon[i]).icon_status) )
				{
					p_str->item_selected = i;
					break;
				}	
			}	
		}
		if ( (i == p_str->total_line) || (i == ITEMDISPLAY_MAX) )
			return ASIX_NO_MSG;
		trans_msg->wparam = p_str->item_selected;
	}
	else if( msg_type == ASIX_KEY )
	{
		if ( p_str->windowid != areaid )
			return ASIX_NO_MSG;
	}
	
trans_type:
	switch( msg_type )
	{
		case ASIX_ICON:
			{
//				switch ( *data )
				switch ( size )
				{
					case PPSM_ICON_TOUCH:
						trans_msg->message = WM_PENDOWN;
						break;
					case PPSM_ICON_PEN_UP:
						trans_msg->message = WM_PENUP;
						break;
					case PPSM_ICON_DRAG:
						trans_msg->message = WM_PENDRAG;
						break;
					case PPSM_ICON_DRAG_UP: 
						trans_msg->message = WM_PENDRAGUP;
						break;
					default:
						return		ASIX_ERROR;
				}

				trans_msg->messageType = ASIX_MESSAGE;
				trans_msg->lparam = p_str->windowid;
				trans_msg->data = (void *)p_str;
			}
			break;
		case ASIX_KEY:
		    trans_msg->messageType = ASIX_MESSAGE;
			trans_msg->message = WM_KEYUP;
			trans_msg->lparam = p_str->windowid;
			trans_msg->wparam = size + ASIX_CONTROL_KEY_CODE_BEGIN;
			trans_msg->data = (void *)p_str;
			break;
		default:
		 	return ASIX_NO_MSG;
	}
	
	return	ASIX_OK;
}



/****************************************************************************/
/*消息处理********************************************************************/
STATUS menu_msgproc( U32 win_id, U16 message, U32 lparam, void *data, U16 wparam, void *reserved)
{	
	//U16 c=0;
	//U16		j=0;
	U16		i = 0;
	struct MENU_STRUCTURE * p_str = (struct MENU_STRUCTURE *)data;
	struct MENU_ITEM * p_input;
	MSG		menu_msg;
	char *	dispbuf;
	U32		pGC;
	ASIX_WINDOW		*wndptr;
		
	wndptr = (ASIX_WINDOW *)win_id;
	//It is not for me, Just go away!
	if( wndptr == NULL )
		return ASIX_ERROR;
	
	if( wndptr->wndclass == NULL || wndptr->wndclass->wndclass_id != WNDCLASS_MENU )
		return ASIX_ERROR;

	p_str = (struct MENU_STRUCTURE *)wndptr->ctrl_str;
	if ( (p_str == NULL) || (p_str->windowid == 0) )	return ASIX_ERROR;
//	if ( p_str->classid != (U32)WNDCLASS_MENU )		return ASIX_OK;//it is not for me. By Lingming 2001/11/27
//	if ( lparam != p_str->windowid )	return ASIX_ERROR;
	
	p_input = p_str->menu_item;

	pGC = GetGC( );

	PenIrptDisable(  );
	
	switch( message )
	{
		case WM_KEYDOWN:
		case WM_KEYUP:
		    menu_msg.messageType = ASIX_MESSAGE;
			menu_msg.lparam = p_str->windowid;
			menu_msg.data = (void *)p_str;
			switch( wparam )
			{
				case ASIX_KEY_OK:
					{
						if( p_str->pop_status == POP_SHOW )
						{
						}
						else
						{
							ActiveListPush(  );
							menu_show( p_str );
						}
					}
					break;
				case ASIX_KEY_CANCEL:
					{
						menu_hide( p_str );
						ActiveListPop(  );
					}
					break;
				case ASIX_KEY_UP:
					break;
				case ASIX_KEY_DOWN:
					break;
			}
			break;
	}
	switch ( wparam )
	{
		case SELECTED_START:
			if ( (p_str->menu_start).icon_status != ICON_ENABLE )	goto error_end;
			switch ( message )
			{
				case WM_PENDOWN:
					SetFocus( p_str->windowid );
				case WM_PENDRAG:
				case WM_PENDRAGUP:
//					InvRec( pGC, p_str->x, p_str->y, p_str->width, p_str->height );//by zl 2002.3.20
				/*by zl 2002/4/4*/
//					InvRec( pGC, p_str->x + 1, p_str->y + 1, p_str->width - 2, p_str->height - 2 );
//					SetDotWidth( pGC, 2, NULL);
					DrawHorz( pGC, ColorTheme.obj3D_shadow, p_str->x, p_str->y + (((GC*)pGC)->dotwidth - 1) / 2, p_str->width, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
					DrawVert( pGC, ColorTheme.obj3D_shadow, p_str->x + (((GC*)pGC)->dotwidth - 1) / 2, p_str->y + ((GC*)pGC)->dotwidth, p_str->height - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
					DrawHorz( pGC, ColorTheme.obj3D_highlight, p_str->x + ((GC*)pGC)->dotwidth, p_str->y + p_str->height - ((GC*)pGC)->dotwidth / 2 - 1, p_str->width - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
					DrawVert( pGC, ColorTheme.obj3D_highlight, p_str->x + p_str->width - ((GC*)pGC)->dotwidth / 2 - 1, p_str->y + ((GC*)pGC)->dotwidth, p_str->height - 2 * ((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);
				break;
					
				case WM_PENUP:
					ActiveListPush(  );
					if (menu_show( p_str ) != ASIX_OK)
					{
	//					InvRec( pGC, p_str->x, p_str->y, p_str->width, p_str->height );//by zl 2002.3.20
						/*by zl 2002/4/4*/
//						InvRec( pGC, p_str->x + 1, p_str->y + 1, p_str->width - 2, p_str->height - 2 );
//						SetDotWidth( pGC, 2, NULL);
						DrawHorz( pGC, ColorTheme.obj3D_highlight, p_str->x, p_str->y + (((GC*)pGC)->dotwidth - 1) / 2, p_str->width - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
						DrawVert( pGC, ColorTheme.obj3D_highlight, p_str->x + (((GC*)pGC)->dotwidth - 1) / 2, p_str->y + ((GC*)pGC)->dotwidth, p_str->height - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
						DrawHorz( pGC, ColorTheme.obj3D_shadow, p_str->x + ((GC*)pGC)->dotwidth, p_str->y +p_str-> height - ((GC*)pGC)->dotwidth / 2 - 1, p_str->width - ((GC*)pGC)->dotwidth, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
						DrawVert( pGC, ColorTheme.obj3D_shadow, p_str->x + p_str->width - ((GC*)pGC)->dotwidth / 2 - 1, p_str->y, p_str->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);
						ActiveListPop(  );
						PenIrptEnable(  );
						return ASIX_ERROR;
					}
					break;
					
				default:
					break;
			}
			break;
		
		case SELECTED_MASK:
			if ( (p_str->menu_mask).icon_status != ICON_ENABLE )
				goto error_end;

⌨️ 快捷键说明

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