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

📄 asix_lb.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
				palette[0] = ColorTheme.form_client;
				palette[1] = ColorTheme.form_frontcolor;

				hbmp = LoadBitmap( down7x7, palette );
				if( hbmp != 0 )
				{
					//SetBMPPalette( hbmp, palette, NULL );
					//SetBkFillMode( pGC, MAKELONG( GPC_REPLACE_STYLE, GPC_TRANSPARENT_STYLE ) );
					//GetBMPPixel( pGC, 0, 0, hbmp, &trColor );
					//DisplayBMPEx( pGC, x, y, hbmp, GPC_TRANSPARENT_STYLE, trColor );
					DisplayBMP( pGC, lx, ly, hbmp );
					FreeBitmap( hbmp );
				}
			}
			break;
			
		case LBS_POPUP:
			if ( ActiveAreaEnable( &( (p_str->lbox_down).icon_id), ICON_AREA, 0,x + width - SCROLL_WIDTH - 1, 
				y, x + width - 1, y + height - 1, p_str->windowid ) != PPSM_OK )		//if ( ActiveAreaEnable( &( (p_str->lbox_down).icon_id), ICON_AREA, 0,x+width-SCROLL_WIDTH, y, x+width, y+height ) != PPSM_OK ) by zl 2002.3.13
				{
					ActiveAreaDisable( (p_str->lbox_display).icon_id );
					Lfree( ( void * )p_str );
					//PenIrptEnable(  );
					asix_lb_memdbgprintf( "### Create ListBox Error ###" );
					return ASIX_ERROR;	
				}
//			ClearRec( pGC, ColorTheme.form_backcolor, p_str->x, p_str->y, p_str->width, p_str->height, GPC_REPLACE_STYLE );			//ClearRec( pGC, GPC_WHITE, p_str->x+1, p_str->y+1, p_str->width-1, p_str->height-1, GPC_REPLACE_STYLE );	by zl 2002.3.13
			if (ClearRec( pGC, ColorTheme.form_backcolor, p_str->x, p_str->y, p_str->width, p_str->height, GPC_REPLACE_STYLE ) != GPC_ERR_OK )
			{
				ActiveAreaDisable( (p_str->lbox_display).icon_id );
				ActiveAreaDisable( (p_str->lbox_up).icon_id );
				Lfree( ( void * )p_str );
				//PenIrptEnable( );
				asix_lb_memdbgprintf( "### Create ListBox Error ###" );
				return ASIX_ERROR;	
			}
			DrawRec( pGC,  ColorTheme.form_board, x, y, x + width - 1, y + height - 1, GPC_SOLID_LINE, GPC_REPLACE_STYLE );		//DrawRec( pGC,  GPC_BLACK, x, y, x+width-SCROLL_WIDTH, y+height, GPC_SOLID_LINE, GPC_REPLACE_STYLE ); by zl 2002.3.13
			DrawVert( pGC,  ColorTheme.form_line, x + width - SCROLL_WIDTH - 1, y, height, GPC_SOLID_LINE, GPC_REPLACE_STYLE );		//DrawRec( pGC,  GPC_BLACK, x+width-SCROLL_WIDTH, y, x+width, y+height, GPC_SOLID_LINE, GPC_REPLACE_STYLE ); by zl 2002.3.13
//			switchonetotwo( down, x+width-SCROLL_WIDTH+5, y+5, 10, 10);
//			DrawMonoImage( pGC, down7x7, x + width - SCROLL_WIDTH + ARROW_LEFT_FROM - 1, y + ARROW_UP_FROM - 1, ARROW_WIDTH, ARROW_HEIGHT, ColorTheme.form_frontcolor, ColorTheme.form_backcolor);	//DrawMonoImage( pGC, down, x+width-SCROLL_WIDTH+5, y+5, 10, 10, GPC_BLACK, GPC_WHITE); by zl 2002.3.13
//			DrawMonoImage( pGC, down7x7, x + width - SCROLL_WIDTH + ARROW_LEFT_FROM - 1, y + arrow_upfrom - 1, ARROW_WIDTH, ARROW_HEIGHT, ColorTheme.form_frontcolor, ColorTheme.form_backcolor);	//by zl 2002.4.2
			{
				U32	hbmp;
				//U32	trColor;
				U16 lx = x + width - SCROLL_WIDTH + ARROW_LEFT_FROM - 1;
				U16 ly = y + arrow_upfrom - 1;
				U32 palette[2];
				
				palette[0] = ColorTheme.form_client;
				palette[1] = ColorTheme.form_frontcolor;

				hbmp = LoadBitmap( down7x7, NULL );
				if( hbmp != 0 )
				{
					//SetBMPPalette( hbmp, palette, NULL );
					//SetBkFillMode( pGC, MAKELONG( GPC_REPLACE_STYLE, GPC_TRANSPARENT_STYLE ) );
					//GetBMPPixel( pGC, 0, 0, hbmp, &trColor );
					//DisplayBMPEx( pGC, x, y, hbmp, GPC_TRANSPARENT_STYLE, trColor );
					DisplayBMP( pGC, lx, ly, hbmp );
					FreeBitmap( hbmp );
				}
			}
						
		default:
			break;
	}
	
	while ( (p_input->item_status != ICON_END) && (p_input->item_status != ICON_ENABLE) && (p_str->offset < 15) )
	{
		++p_input;
		++p_str->offset;
	}
	
	if ( p_str->offset < 15 )
	{
	//	if ((dispbuf = (char *)Lmalloc( p_str->maxlength )) == NULL)	return ASIX_ERROR;//by zl 2002.3.28
		if ((dispbuf = (char *)Lmalloc( p_str->maxlength )) == NULL)
		{
			ActiveAreaDisable( (p_str->lbox_display).icon_id );
			Lfree( ( void * )p_str );
			//PenIrptEnable(  );
			asix_lb_memdbgprintf( "### Create ListBox Error ###" );
			return ASIX_ERROR;	
		}
		
		Lbox_cutstring( p_input->item_text,  p_str->maxlength, dispbuf );	//Lbox_cutstring( p_input->item_text, 6, dispbuf );	by zl 2002.3.13
	//	Disp16String( dispbuf, x + MARGIN, y + ITEMTEXT_UP_FROM );
		strX = AlignString( dispbuf, x + MARGIN, p_str->width -SCROLL_WIDTH-MARGIN*2, GPC_ALIGN_CENTER );
		strY = y + ( p_str->height - CHINESE_CHAR_HEIGHT )/2;
		TextOut( pGC, dispbuf, strX, strY, NULL, ColorTheme.form_poptext, GPC_REPLACE_STYLE );
		Lfree( (void *)dispbuf);
	}
	
	//PenIrptEnable(  );	
	*ctrl_str = ( void * )p_str;
	asix_lb_memdbgprintf( "### Create ListBox Successfully ###" );
	return ASIX_OK;
}


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

extern STATUS	Lbox_destroy( void *ctrl_str )
{
	struct LBOX_STRUCTURE *			p_str = (struct LBOX_STRUCTURE * )ctrl_str;
	U32		pGC;

	if ( p_str == NULL ) 	return ASIX_ERROR; //check the ping by zl 2002.3.13
	
	pGC = GetGC( );

	asix_lb_memdbgprintf( "### Destroy ListBox ###" );
			
	if ( p_str->pop_status == POP_SHOW )	Lbox_hide(p_str);
	ActiveAreaDisable( (p_str->lbox_display).icon_id );
	switch ( p_str->lbox_style )
	{
		case LBS_ROLL:
			ActiveAreaDisable( (p_str->lbox_up).icon_id );
			ActiveAreaDisable( (p_str->lbox_down).icon_id );
			break;
		case LBS_POPUP:
			ActiveAreaDisable( (p_str->lbox_down).icon_id );
			break;
	}
/*	
	if (p_str->lbox_coveredmap!=NULL) {
		PutRec( pGC, p_str->lbox_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width+2,
			p_str->pop_height+2, GPC_REPLACE_STYLE, 0 );
		Lfree( (void *)p_str->lbox_coveredmap );
	}
*/	
	Lfree( (void *)p_str );

	asix_lb_memdbgprintf( "### Destroy ListBox Successfully ###" );

	return   	ASIX_OK;	
}

/********************************************************************************/
extern STATUS	Lbox_msgproc( U32 win_id, U16 message, U32 lparam, void *data, U16 wparam, void *reserved )
{
	struct LBOX_STRUCTURE *  	p_str;
	//U16						prepostion, curpostion;
	//U32						menu;
	//S8						offset;
	S16							offset;
	struct LBOX_ITEM *			p_input;
	//U8						flag=0;
	U16							oldoffset;					
	U32							pGC;
	ASIX_WINDOW		*wndptr;
	
	wndptr = (ASIX_WINDOW *)win_id;
//	if ( message != WM_PENUP && message != WM_PENDOWN && message != WM_PENDRAG 
//		&& message != WM_PENDRAGUP && message != WM_VSCROLL )
//		return		ASIX_OK;
	if( wndptr == NULL )
		return ASIX_ERROR;

	if ( wndptr->wndclass == NULL || wndptr->wndclass->wndclass_id != WNDCLASS_LIST )
		return ASIX_ERROR;

	p_str = (struct LBOX_STRUCTURE *)wndptr->ctrl_str;
	if( p_str == NULL )
		return ASIX_ERROR;

	pGC = GetGC( );
	
	p_input = p_str->lbox_item;
	
	//PenIrptDisable(  );
	
	if ( message == WM_VSCROLL )
	{
		if ( p_str->lbox_style != LBS_POPUP )	return ASIX_ERROR;	
		
		oldoffset = p_str->offset;

		switch ( wparam )
		{
			/*
			case SB_TOP:
				p_str->offset = 0;
				flag=1;
				break;			 
			case SB_BOTTOM:
				p_str->offset = p_str->total_line - 5;
				flag=1;
				break;
			*/	
			case SB_PAGEUP:
				offset = (S16)p_str->offset;
				offset = offset - ITEMDISPLAY_MAX; //offset = offset - 5; by zl 2002.3.13
				if ( offset <0 )
					offset = 0;
				p_str->offset = offset;

			/*by zl 2002.3.13*/
//				SetScrollPos( p_str->scroll_id, p_str->offset, 0, WM_VSCROLL);
				
				break;
			case SB_PAGEDOWN:
				offset = (S16)p_str->offset; // by zl 2002.3.13
				offset = offset + ITEMDISPLAY_MAX; //offset = offset - 5; by zl 2002.3.13
				if ( offset > p_str->total_line - ITEMDISPLAY_MAX) //if ( p_str->offset > p_str->total_line - 5 ) by zl 2002.3.13
					p_str->offset = p_str->total_line - ITEMDISPLAY_MAX; // p_str->offset = p_str->total_line - 5; by zl 2002.3.13
			/*by zl 2002.3.13*/
//				SetScrollPos( p_str->scroll_id, offset, 0, WM_VSCROLL);
				
				break;
			case SB_LINEUP:
				if ( (S16)p_str->offset > 0 ) //if ( p_str->offset > 0 ) by zl 2002.3.13
					p_str->offset--;
			/*by zl 2002.3.13*/
//				SetScrollPos( p_str->scroll_id, p_str->offset, 0, WM_VSCROLL);
				
				break;
			case SB_LINEDOWN:
				if ( p_str->offset < p_str->total_line - ITEMDISPLAY_MAX )  //if ( p_str->offset < p_str->total_line - 5 ) by zl 2002.3.13
					p_str->offset++;
			/*by zl 2002.3.13*/
//				SetScrollPos( p_str->scroll_id, ITEMDISPLAY_MAX - (p_str->total_line - p_str->offset - ITEMDISPLAY_MAX), 0, WM_VSCROLL);
//				SetScrollPos( p_str->scroll_id, p_str->offset , 0, WM_VSCROLL);
				
				break;
			case SB_THUMBTRACK:
				//prepostion = GetScrollPos( p_str->scroll_id,message,wparam,0 );
		 		//curpostion = oGetScrollPos( p_str->scroll_id,message,wparam,1 );
		 		//if ( curpostion > prepostion && p_str->offset < p_str->total_line - 5 )
		 			//p_str->offset++;
		 		//if ( curpostion < prepostion && p_str->offset > 0 )
		 			//p_str->offset--;
				
				p_str->offset = GetScrollPos( p_str->scroll_id,message,wparam,1 );

				/*by zl 2002.3.14*/
//				if ( p_str->offset > p_str->total_line - ITEMDISPLAY_MAX )
	//				p_str->offset = p_str->total_line - ITEMDISPLAY_MAX;
		//		SetScrollPos( p_str->scroll_id, p_str->offset, 0, WM_VSCROLL);

				break;
			case SB_ENDSCROLL:
				/*
				prepostion = GetScrollPos( p_str->scroll_id,message,wparam,0 );
		 		curpostion = GetScrollPos( p_str->scroll_id,message,wparam,1 );
		 		if ( curpostion > prepostion && p_str->offset < p_str->total_line - 5 )
		 			p_str->offset++;
		 		if ( curpostion < prepostion && p_str->offset > 0 )
		 			p_str->offset--;
		 		*/
//		 		curpostion = GetScrollPos( p_str->scroll_id,message,wparam,1 );
//		 		p_str -> offset = curpostion - 1;
				//flag=1;
				break;
			default: //by zl 2002.3.13
				break;
		}
		
		if (  p_str->offset != oldoffset )
		{
//			ClearRec( pGC, GPC_WHITE, p_str->pop_x+1, p_str->pop_y+1, p_str->pop_width-1, p_str->pop_height-1, GPC_REPLACE_STYLE ); //by zl 2002.3.13
			ClearRec( pGC, ColorTheme.form_backcolor, p_str->pop_x, p_str->pop_y, p_str->pop_width - SCROLL_WIDTH, p_str->pop_height, GPC_REPLACE_STYLE); // by zl 2002.3.13
			DrawRec( pGC,  ColorTheme.form_board, p_str->pop_x, p_str->pop_y, p_str->pop_x+p_str->pop_width - 1, p_str->pop_y + p_str->pop_height - 1, GPC_SOLID_LINE, GPC_REPLACE_STYLE );	
			if ( Lbox_drawitem( ITEMDISPLAY_MAX, p_str ) != ASIX_OK) //if ( Lbox_drawitem( 5, p_str ) != ASIX_OK) by zl 2002.3.13
			{
				Lbox_hide( p_str );
//				PutRec( pGC, p_str->lbox_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width+2, p_str->pop_height+2, GPC_REPLACE_STYLE,0);	//function Lbox_hide has done it By zl 2002.3.13
//				p_str->pop_status = POP_HIDE;
				return ASIX_ERROR;	
			}
			p_str->pop_status = POP_SHOW;
			//menu = p_str->total_line;
			//menu = menu << 16;
			//menu = menu | 0x0005;
			//SetScrollPos( p_str->scroll_id, wparam, menu, WM_VSCROLL);

			SetScrollPos( p_str->scroll_id, p_str->offset, 0, WM_VSCROLL);//by zl 2002.3.14
		}
	}
	
	switch ( p_str->lbox_style )
	{
		case LBS_POPUP:
			if ( wparam == SELECTED_DOWN )		Lbox_touch_down( p_str, message );
			if ( wparam == SELECTED_DISPLAY )	Lbox_touch_display( p_str, message );
			if ( wparam == SELECTED_MASK )		Lbox_touch_mask( p_str, message );
			if ( wparam == 0 )		
				if ( Lbox_touch_item( 0, p_str, message ) != ASIX_OK)
				{
					Lbox_hide( p_str );
					return ASIX_ERROR;	
				}

			if ( wparam == 1 )		
				if ( Lbox_touch_item( 1, p_str, message ) != ASIX_OK)
				{
					Lbox_hide( p_str );
					return ASIX_ERROR;	
				}
				
			if ( wparam == 2 )		
				if ( Lbox_touch_item( 2, p_str, message ) != ASIX_OK)

⌨️ 快捷键说明

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