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

📄 asix_mn.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
								#else
								DisplayBMP( pGC, x, y, hbmp );
								#endif
								FreeBitmap( hbmp );
							}
						}
//						DrawLine( pGC, GPC_BLACK, p_str->pop_x, p_str->pop_y+ITEM_0+5*ITEM_1, p_str->pop_x+p_str->pop_width, p_str->pop_y+ITEM_0+5*ITEM_1, GPC_SOLID_LINE, GPC_REPLACE_STYLE );		//by zl 2002.3.20
						DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x + 2, p_str->pop_y + ITEM_0 + ITEMDISPLAY_MAX * ITEM_1 + 1, p_str->pop_width - 4, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
					}
					
					p_input = p_str->menu_item + p_str->offset;
//					if ((dispbuf = (char *)Lmalloc( ITEMTEXT_MAX + 1)) == NULL)	return ASIX_ERROR;//by zl 2002.3.28
					if ((dispbuf = (char *)Lmalloc( ITEMTEXT_MAX + 1 )) == NULL)//dispbuf = (char *)Lmalloc( 11 );//by zl 2002/4/4
					{
						ActiveListPop(  );
						PenIrptEnable(  );
						return ASIX_ERROR;
					}
					for ( i = 0; i < ITEMDISPLAY_MAX; i++ )//for ( i=0; i<5; i++ )//by zl 2002.3.20
					{
/*						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.20

						// 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, ITEMTEXT_MAX, dispbuf );//menu_cutstring( p_input->item_text, 10, dispbuf );//by zl 2002.3.20
						if ( p_input->item_underline == UNDERLINE )
//							DrawLine( pGC, GPC_BLACK, p_str->pop_x, p_str->pop_y+(i+1)*ITEM_1+ITEM_0, p_str->pop_x+p_str->pop_width, p_str->pop_y+ITEM_1*(i+1)+ITEM_0, GPC_SOLID_LINE, GPC_REPLACE_STYLE);//by zl 2002/3/20
							DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x + 2, p_str->pop_y + (i + 1)*ITEM_1 + ITEM_0 + 1, p_str->pop_width - 4, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
						if ( p_input->item_status == ICON_ENABLE )
							//Disp16String( dispbuf, p_str->pop_x+MARGIN, (p_str->pop_y)
							//+ITEM_0+ITEM_1*i+2 );
//							TextOut( pGC, dispbuf, p_str->pop_x+MARGIN, (p_str->pop_y)+ITEM_0+ITEM_1*i+2, HZK_16X16_FONT, ColorTheme.form_text, GPC_REPLACE_STYLE);//GPC_OR_STYLE);//by zl 2002.3.20
							TextOut( pGC, dispbuf, p_str->pop_x + MARGIN + 1, p_str->pop_y + i * ITEM_1 + ITEM_0 + ITEMTEXT_UP_FROM + 1, HZK_16X16_FONT, ColorTheme.form_text, GPC_REPLACE_STYLE);//GPC_OR_STYLE);
						else
							//Disp16StringGrey( GPC_DARKGREY, dispbuf, p_str->pop_x+MARGIN, 
							//(p_str->pop_y)+ITEM_0+ITEM_1*i+2 );
//							TextOut( pGC, dispbuf, p_str->pop_x+MARGIN, (p_str->pop_y)+ITEM_0+ITEM_1*i+2, HZK_16X16_FONT, ColorTheme.form_disablecolor, GPC_REPLACE_STYLE);//GPC_OR_STYLE);
							TextOut( pGC, dispbuf, p_str->pop_x + MARGIN + 1, p_str->pop_y + i * ITEM_1 + ITEM_0 + ITEMTEXT_UP_FROM + 1, HZK_16X16_FONT, ColorTheme.form_disablecolor, GPC_REPLACE_STYLE);//GPC_OR_STYLE);
						(p_str->menu_icon[i]).icon_status = p_input->item_status;
						p_input++;
//						Lfree( (void *)dispbuf );//by zl 2002.3.20

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

					}
					Lfree( (void *)dispbuf );//by zl 2002.3.20
					break;
					
				case WM_PENDOWN:
				case WM_PENDRAG:
				case WM_PENDRAGUP:
//					InvRec( pGC, p_str->pop_x, p_str->pop_y+5*ITEM_1+ITEM_0, p_str->pop_width, ITEM_0);//by zl 2002.3.20
					InvRec( pGC, p_str->pop_x + 2, p_str->pop_y + 5 * ITEM_1 + ITEM_0 + 1, p_str->pop_width - 4, ITEM_0 );
					break;
					
				default:
					break;
			}
			break;
			
		case 0:
		case 1:
		case 2: 
		case 3:
		case 4:
			i = wparam;
			if ( (p_str->menu_icon[i]).icon_status != ICON_ENABLE )
				goto error_end;
			switch ( message )
			{
				case WM_PENUP:
					menu_hide( p_str );
//					InvRec( pGC, p_str->x , p_str->y, p_str->width, p_str->height);//by zl 2002.3.30
//					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(  );
					memset( (void *)&menu_msg, 0x0, sizeof(MSG) );
					menu_msg.messageType = ASIX_MESSAGE;
					menu_msg.message = WM_COMMAND;
					menu_msg.lparam = p_str->windowid;
					menu_msg.data = NULL;
					menu_msg.wparam = p_str->offset+i;
					AdvSendMessage( GetCurTask()->id, (P_MESSAGE)&menu_msg, NO_SWAP_TASK );
					break;
					
				case WM_PENDOWN:
				case WM_PENDRAG:
				case WM_PENDRAGUP:
					if (p_str->total_line > 5)
//						InvRec( pGC, p_str->pop_x, p_str->pop_y+i*ITEM_1+ITEM_0, p_str->pop_width, ITEM_1 );// by zl 2002.3.20
						InvRec( pGC, p_str->pop_x + 2, p_str->pop_y + i * ITEM_1 + ITEM_0 + 2, p_str->pop_width - 4, ITEM_1 );
					else 
//						InvRec( pGC, p_str->pop_x, p_str->pop_y+i*ITEM_1, p_str->pop_width, ITEM_1 );//by zl 2002.3.20
						InvRec( pGC, p_str->pop_x + 2, p_str->pop_y + i * ITEM_1 + 2, p_str->pop_width - 4, ITEM_1 );
					break;
					
				default:
					break;
			}
			break;
			
		default:
			break;	
	}
	
	PenIrptEnable( );
	
	return ASIX_OK;
error_end:
	PenIrptEnable(  );
	return ASIX_ERROR;
}



STATUS mn_repaint(void *ctrl_str, U32 lparam)
{
	ASIX_WINDOW				*wndptr;
	struct MENU_STRUCTURE  	*ctrlptr;
//	U16						bmp_width=0,bmp_height=0;
	U32		pGC;
	U16		x;
	U16		y;
	U16		width;
	U16		height;

	if (ctrl_str == NULL || *((U32 *)ctrl_str) != WNDCLASS_MENU ) return ASIX_ERROR;
	
	pGC= GetGC( );

	ctrlptr = (struct MENU_STRUCTURE *)ctrl_str;
	wndptr = (ASIX_WINDOW *)(ctrlptr->windowid);
	
	x = ctrlptr->x;
	y = ctrlptr->y;
	width = ctrlptr->width;
	height = ctrlptr->height;
	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);
//	if ( wndptr->hmenu == 0 )
	if ( wndptr->style & MNS_TEXT )
	{
		char	*dispbuf;

		/*by zl 2002.4.4*/
		if ((dispbuf = (char *)Lmalloc( (width - 2*MARGIN )/ENGLISH_CHAR_WIDTH )) == NULL)
			return ASIX_ERROR;
		menu_cutstring( wndptr->caption, (U8)((width - 2*MARGIN )/ENGLISH_CHAR_WIDTH), dispbuf );
		Disp16String(dispbuf, x + MARGIN, y + 3);
		Lfree( dispbuf );
	}
	else
	{
		//bmp_width = LOWORD(wndptr->hmenu);
		//bmp_height = HIWORD(wndptr->hmenu);
		// longn_qi 2001/11/15 revised
		//switchonetotwo(wndptr->caption, ctrlptr->x+ctrlptr->width/2-bmp_width/2, 
		//ctrlptr->y+ctrlptr->height/2-bmp_height/2, bmp_width, bmp_height);
//		DrawMonoImage(pGC, wndptr->caption, ctrlptr->x+ctrlptr->width/2-bmp_width/2,
//			ctrlptr->y+ctrlptr->height/2-bmp_height/2, bmp_width, bmp_height, ColorTheme.form_text, ColorTheme.form_client);
		{
			U32	hbmp;
			U32	trColor;
			//U32 palette[2];
			
			//palette[0] = ColorTheme.obj3D;
			//palette[1] = ColorTheme.obj3D_text;

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



/*********************************************/
/*截取字符串*************************************/
static 	STATUS  menu_cutstring( char * string_input, U8 n, char * dispbuf )
//by zl 2002.3.28
{
	char *  p_char;
	U8 		i = 0;
	
//	memset( dispbuf, 0x0, n+1 ); // by zl 2002.3.13
	memset( dispbuf, 0x0, n );
	p_char = string_input;
	if ( strlen(string_input) > n )
	{
		for ( i = 0; i < n; i++ )
		{
/*			switch ( gpcCheckFontByte(p_char) )
			{
				case 1:
					if ( i < n - 2 )			dispbuf[i] = *p_char;
					break;
				case 2:
					if ( i + 1 < n - 2 )
					{
						dispbuf[i++] = *p_char;
						p_char++;
						dispbuf[i] = *p_char;
					}
					else dispbuf[i] = '.';
					break;
				default:
					break;
			}
*/		
			if ( *p_char >= 0x20 && *p_char<=0x7e )
			{
				if ( i < n - 2 )
					dispbuf[i] = *p_char;
			}
			else
			{
				if ( i + 1 < n - 2 )
				{
					dispbuf[i++] = *p_char;
					p_char++;
					dispbuf[i] = *p_char;
				}
				else dispbuf[i] = '.';
			}
			p_char++;
		}
		dispbuf[n-2] = '.';
		dispbuf[n-1] = '.';
		dispbuf[n] = '\0';
/*
		for ( i = 0; i < n; i++ )
		{
			dispbuf[i] = *p_char;
			p_char++; 	
		}
		dispbuf[n-2] = '.';
		dispbuf[n-1] = '.';
		dispbuf[n] = '\0';
*/
	}
	else 
	{
		for ( i = 0; i<strlen(string_input); i++ )
		{
			dispbuf[i] = *p_char;
			p_char++;	
		}
		dispbuf[i] = '\0';
	}
	return ASIX_OK;
}

/*
{
	char * p_char;
	U8 		i=0;
	
	memset( dispbuf, 0x0, n );//memset( dispbuf, 0x0, n+1 );//by zl 2002.3.20
	p_char = string_input;
	if ( strlen(string_input) > n )
	{
		for ( i = 0; i < n; i++ )
		{
			dispbuf[i] = *p_char;
			p_char++; 	
		}
		dispbuf[ITEMTEXT_MAX - 2] = '.';//dispbuf[8] = '.';by zl 2002.3.20
		dispbuf[ITEMTEXT_MAX - 1] = '.';//dispbuf[9] = '.';//by zl 2002.3.20
		dispbuf[ITEMTEXT_MAX] =

⌨️ 快捷键说明

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