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

📄 asix_lb.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
	(p_str->lbox_mask).icon_id = 0;
	(p_str->lbox_mask).icon_status = ICON_DISABLE;
	
//	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);	//by zl 2002.3.13
	PutRec( pGC, p_str->lbox_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width, p_str->pop_height, GPC_REPLACE_STYLE, 0);
	p_str->item_selected = SELECTED_NONE;
	Lfree( (void *)p_str->lbox_coveredmap );
	p_str->pop_status = POP_HIDE;

	return ASIX_OK;
}

/****************************************************************************/
static STATUS Lbox_calculate( struct LBOX_STRUCTURE * p_str )
{
	U8					i=0;
	U16					maxlength=0, pop_height=0;
	U16					currentlen=0, x1, x2, y1, y2;

	struct LBOX_ITEM *  p_input = p_str->lbox_item;	
	
	if ( p_str == NULL)	return ASIX_ERROR; // by zl 2002.3.13

	while ( p_input->item_status != ICON_END )
	{
		switch (i)
		{
			case	0:
			case	1:
			case	2:
			case	3:
			case	4:	
				pop_height = pop_height + ITEM_1;
				break;
			default	 :	
				break;
		}
		currentlen = (U16)strlen( p_input->item_text );
		if ( maxlength < currentlen )	maxlength = currentlen;
		p_input++;
		i++;
	}
	
	switch ( p_str->lbox_style )
	{
		case LBS_ROLL:
			p_str->pop_width = 0;
			p_str->pop_height = 0;
			p_str->pop_x = 0;
			p_str->pop_y = 0;	
			p_str->total_line = i;
			break;
		
		case LBS_POPUP:
//			if ( maxlength > 10 )	maxlength = 10;//by zl 2002.3.27
//			if ( maxlength > ITEMTEXT_MAX )	maxlength = ITEMTEXT_MAX;//by zl 2002.3.28
//			p_str->pop_width = maxlength*ENGLISH_CHAR_WIDTH+2*MARGIN; // by zl 2002.3.13
			p_str->pop_width  = p_str->width;
			p_str->pop_height = pop_height;
						
			y1 = p_str->y+p_str->height; //y1 = p_str->y+p_str->height+1; //by zl 2002.3.13
			x1 = p_str->x; //x1 = p_str->x+1; //by zl 2002.3.13
			y2 = y1 + p_str->pop_height; //y2 = y1 + p_str->pop_height; //by zl 2002.3.13
			x2 = x1 + p_str->pop_width - 1; //x2 = x1 + p_str->pop_width;//by zl 2002.3.13
			
			if ( y2 >= ASIX_LCD_H )
			{
				x1 = p_str->x; //x1 = p_str->x-1; // by zl 2002.3.13
				y1 = p_str->y-p_str->pop_height; //y1 = p_str->y-p_str->pop_height-1; //by zl 2002.3.13
				x2 = x1+p_str->pop_width - 1; //x2 = x1+p_str->pop_width; // by zl 2002.3.13
				y2 = p_str->y - 1; //y2 = p_str->y; // by zl 2002.3.13
/*				
				if ( p_str->total_line > 5 )
				{
					if ( x2+SCROLL_WIDTH > ASIX_LCD_W )		x1 = x1-(x2+SCROLL_WIDTH-ASIX_LCD_W)-MARGIN;
				}
				else 
				{
					if ( x2 > ASIX_LCD_W )  	x1 = x1-(x2-ASIX_LCD_W)-MARGIN;
				}
			}
			else 
			{
				if ( p_str->total_line >5 )
				{
					if ( x2+SCROLL_WIDTH > ASIX_LCD_W ) 	x1 = x1-(x2+SCROLL_WIDTH-ASIX_LCD_W)-MARGIN;
				}
				else
				{
					if ( x2 > ASIX_LCD_W )		x1 = x1-(x2-ASIX_LCD_W)-MARGIN;
				}
*/
			}
	
			p_str->pop_x = x1;
			p_str->pop_y = y1;
			p_str->total_line = i;
			break;
						
		default:
			break;
			
	}
	return ASIX_OK;
}



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

extern STATUS	Lbox_create ( char *caption, U32 style, U16 x, U16 y, U16 width, U16 height, 
			U32 wndid, U32 menu, void **ctrl_str,void *exdata )
{
	struct LBOX_STRUCTURE *p_str;
	U8		i = 0;
	struct LBOX_ITEM *p_input;
//	char 						dispbuf[11];//BY zl 2002.3.13
	char	*dispbuf;
	U16		displayconter;
	U8		maxlength = 0;//by zl 2002.3.27
	U32		pGC;
	U16		arrow_upfrom;//by zl 2002.4.1
	U16		strX, strY;
	
	//check border by zl 2002.3.13
//	if ( width < ENGLISH_CHAR_WIDTH * ITEMTEXT_MIN + 2 * MARGIN + SCROLL_WIDTH )	return ASIX_ERROR;
	if ( height < ENGLISH_CHAR_HEIGHT + 2 * ITEMTEXT_UP_FROM ) return ASIX_ERROR;
	if ( x + width > ASIX_LCD_W || y + height > ASIX_LCD_H ) return ASIX_ERROR;
	if ( (style & LBS_ROLL == 0) && (style & LBS_POPUP == 0) )	return ASIX_ERROR;//the listbox can only use two styles BY ZL 2002.4.2
	if ( (style & LBS_ROLL) && (style & LBS_POPUP) )	return ASIX_ERROR;//the listbox has only one style By al 2002.4.2
	
	asix_lb_memdbgprintf( "### Create ListBox ###" );
	p_str = ( struct LBOX_STRUCTURE * ) Lcalloc ( sizeof ( struct LBOX_STRUCTURE ) );
	if ( p_str == NULL )
	{
		asix_lb_memdbgprintf( "### Create ListBox Error ###" );
		return ASIX_ERROR;
	}

	pGC = GetGC( );
	arrow_upfrom = (height - ARROW_WIDTH)/2;
	
	//PenIrptDisable(  );
	p_str->lbox_item = (struct LBOX_ITEM *)exdata;
	p_input = p_str->lbox_item;
	p_str->x = x;
	p_str->y = y;
	p_str->width = width;
	p_str->height = height;
	p_str->classid = (U32)WNDCLASS_LIST;
	p_str->windowid = wndid;
	p_str->item_selected = SELECTED_NONE;
	p_str->pop_status = POP_HIDE;
	if ( (style & LBS_ROLL) != 0 )
	{
		if ( width < ENGLISH_CHAR_WIDTH * ITEMTEXT_MIN + 2 * MARGIN + 2 * SCROLL_WIDTH )//by zl 2002.3.27
		{
			Lfree(p_str);	//by zl 2002.4.2
			asix_lb_memdbgprintf( "### Create ListBox Error ###" );
			return ASIX_ERROR;
		}
		p_str->lbox_style = LBS_ROLL;
		maxlength = ( width - 2 * SCROLL_WIDTH - 2 * MARGIN )/ ENGLISH_CHAR_WIDTH;//by zl 2002.3.27
	}
	else
	{
		if ( width < ENGLISH_CHAR_WIDTH * ITEMTEXT_MIN + 2 * MARGIN + SCROLL_WIDTH )//by zl 2002.3.27
		{
			Lfree(p_str);//by zl 2002.4.2
			asix_lb_memdbgprintf( "### Create ListBox Error ###" );
			return ASIX_ERROR;
		}
		p_str->lbox_style = LBS_POPUP;
		maxlength = ( width - SCROLL_WIDTH - 2 * MARGIN )/ ENGLISH_CHAR_WIDTH;//by zl 2002.3.27
	}
//	if ( maxlength > ITEMTEXT_MAX )	maxlength = ITEMTEXT_MAX;//by zl 2002.3.27//by zl 2002.3.28
	p_str->maxlength = maxlength;

	p_str->scroll_id = 0;
	p_str->offset = 0;
		
	i = 0;
	p_input = p_str->lbox_item;
	while ( p_input->item_status != ICON_END )
	{
		i++;
		p_input++;
	}
	p_input = p_str->lbox_item;
	p_str->total_line = i;
	
	for ( i = 0; i < ITEMDISPLAY_MAX; i++ ) //for ( i=0; i<5; i++ ) by zl 2002.3.13
	{
		( p_str->lbox_icon[i] ).icon_id = 0;
		( p_str->lbox_icon[i] ).icon_status = ICON_DISABLE;
	}
		
	switch ( p_str->lbox_style )
	{
		case LBS_ROLL:
			(p_str->lbox_display).icon_status = ICON_DISABLE;
			(p_str->lbox_display).icon_id = 0;	
			(p_str->lbox_mask).icon_status = ICON_DISABLE;
			(p_str->lbox_mask).icon_id = 0;	
			(p_str->lbox_up).icon_status = ICON_ENABLE; //(p_str->lbox_up).icon_status = ICON_DISABLE; by zl 2002.3.13
			(p_str->lbox_up).icon_id = 0;	
			(p_str->lbox_down).icon_status = ICON_ENABLE;
			(p_str->lbox_down).icon_id = 0;	
			break;
			
		case LBS_POPUP:
			(p_str->lbox_down).icon_status = ICON_ENABLE;
			(p_str->lbox_down).icon_id = 0;	
			(p_str->lbox_display).icon_status = ICON_ENABLE;
			(p_str->lbox_display).icon_id = 0;	
			(p_str->lbox_mask).icon_status = ICON_DISABLE;
			(p_str->lbox_mask).icon_id = 0;	
			(p_str->lbox_up).icon_status = ICON_DISABLE;
			(p_str->lbox_up).icon_id = 0;	
			break;
			
		default:
			break;
	} 
	
	if ( p_str->lbox_style == LBS_ROLL )	displayconter = x + width - 2 * SCROLL_WIDTH;
	else	displayconter = x + width - SCROLL_WIDTH;
	
//	if ( ActiveAreaEnable( &( (p_str->lbox_display).icon_id ), 	ICON_AREA, 0, x, y, displayconter, y+height ) != PPSM_OK)
	if ( ActiveAreaEnable( &( (p_str->lbox_display).icon_id ), 
		ICON_AREA, 0, x, y, displayconter - 1, y + height - 1, p_str->windowid ) != PPSM_OK)//by zl 2002.3.13
	{
		Lfree( ( void * )p_str );
		//PenIrptEnable(  );
		asix_lb_memdbgprintf( "### Create ListBox Error ###" );
		return ASIX_ERROR;	
	}
	
	switch ( p_str->lbox_style )
	{
		case LBS_ROLL:
//			if ( ActiveAreaEnable( &( (p_str->lbox_up).icon_id), ICON_AREA, 0, x+width-2*SCROLL_WIDTH, y, x+width-SCROLL_WIDTH, y+height ) != PPSM_OK )
			if ( ActiveAreaEnable( &( (p_str->lbox_up).icon_id), ICON_AREA, 0, 	x + width - 2 * SCROLL_WIDTH - 1,
				y, x + width - SCROLL_WIDTH - 1, y + height - 1, p_str->windowid ) != 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;
			}
			
//			if ( ActiveAreaEnable( &( (p_str->lbox_down).icon_id), ICON_AREA, 0, x+width-SCROLL_WIDTH, y, x+width, y+height ) != PPSM_OK )
			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 )	// by zl 2002.3.13
			{
				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;	
			}
			
			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
			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, y+height, GPC_SOLID_LINE, GPC_REPLACE_STYLE ); by zl 2002.3.13
			DrawVert( pGC, ColorTheme.form_line, x + width - 2*SCROLL_WIDTH - 1, y, height, GPC_SOLID_LINE, GPC_REPLACE_STYLE );		//DrawLine( pGC, GPC_BLACK, x+width-2*SCROLL_WIDTH, y, x+width-2*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 );		//DrawLine( pGC, GPC_BLACK, x+width-SCROLL_WIDTH, y, x+width-SCROLL_WIDTH, y+height, GPC_SOLID_LINE, GPC_REPLACE_STYLE ); by zl 2002.3.13
//			Advswitchonetotwo( up, x+width-2*SCROLL_WIDTH+5, y+5, 10, 10, BLACK_TO_GREY, 
//				WHITE_TO_WHITE);				
//			switchonetotwo( down, x+width-SCROLL_WIDTH+5, y+5, 10, 10);
//			DrawMonoImage( pGC, up7x7, x + width - 2 * SCROLL_WIDTH + ARROW_LEFT_FROM - 1, y + ARROW_UP_FROM - 1, ARROW_WIDTH, ARROW_HEIGHT, ColorTheme.form_disablecolor, ColorTheme.form_backcolor);		//DrawMonoImage( pGC, up, x+width-2*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_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, up7x7, x + width - 2 * SCROLL_WIDTH + ARROW_LEFT_FROM - 1, y + arrow_upfrom - 1, ARROW_WIDTH, ARROW_HEIGHT, ColorTheme.form_disablecolor, ColorTheme.form_backcolor);		//	 by zl 2002.4.2
			{
				U32	hbmp;
				//U32	trColor;
				U16 lx = x + width - 2 * SCROLL_WIDTH + ARROW_LEFT_FROM - 1;
				U16 ly = y + arrow_upfrom - 1;
				U32 palette[2];
				
				palette[0] = ColorTheme.form_client;
				palette[1] = ColorTheme.form_disablecolor;

				hbmp = LoadBitmap( up7x7, 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 );
				}
			}
//			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];
				

⌨️ 快捷键说明

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