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

📄 asix_lb.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
/**********************************************************
*
*Copyright ? 2001 National ASIC	Center,	All right Reserved
*
* FILE NAME:			ASIX_LB.c
* PROGRAMMER:			Tianyuan
* Date of Creation:		2001/3/8
* 
*DESCRIPTION:			 
*NOTE:					none
*FUNCTIONS LIST:		
*						extern Lbox_create()
*						extern Lbox_destroy()
*						extern Lbox_msgtrans()
*						extern Lbox_msgproc()
*						static Lbox_calculate()
*						static Lbox_show()
*						static Lbox_hide()
*						static Lbox_drawicon()
						static Lbox_touch_up()
						static Lbox_touch_mask()
						static Lbox_touch_down()
						static Lbox_touch_item()
						static Lbox_cutdstring()
*
*GLOBAL	VARS LIST:		none
*
*********************************************************
*MODIFICATION HISTORY
* 2001/3/10	by 			Tianyuan		coding
* 2001/3/16 by			Tianyuan		recoding					
* 2001/11/27by			Lingming		Msg filtering in Lbox_msgproc()							
* 2002/03/28by 			zhuli			
***********************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "asixwin.h"
#include "asixapp.h"

//#include <hc.h>
#include "disp.h"
#include "asix_lb.h"

#include "bitmap.h"

#include "xasixlb.h"

//static U8 down[]= {0xff,0xff,0xf7,0xf9,0xfe,0x3f,0xf,0xc1,0xe0,0x78,0xc,0x3,0x2,0x00};
//static U8 up[] = {0xc,0x3,0x1,0xe0,0x78,0x3f,0xf,0xc7,0xf9,0xfe,0xff,0xff,0xf2,0x00};
//char down7x7[]  = {0x0,0x2,0xc,0x1c,0x78,0xfb,0xdf};
//char up7x7[]    = {0xef,0x8f,0x1c,0x18,0x20,0x0,0x5f};

static	STATUS	Lbox_calculate( struct LBOX_STRUCTURE *p_str );
static 	STATUS	Lbox_hide( struct LBOX_STRUCTURE * p_str);
static	STATUS 	Lbox_show( struct LBOX_STRUCTURE *p_str );
static 	STATUS  Lbox_drawicon( U16 cycle, struct LBOX_STRUCTURE *p_str );
static	STATUS	Lbox_drawitem( U16 cycle, struct LBOX_STRUCTURE *p_str );
static 	STATUS  Lbox_cutstring( char * string_input, U8 n, char* dispbuf );
static	STATUS	Lbox_touch_display( struct LBOX_STRUCTURE * p_str, U16 message );
static  STATUS  Lbox_touch_mask( struct LBOX_STRUCTURE * p_str, U16 message );
static  STATUS  Lbox_touch_down( struct LBOX_STRUCTURE * p_str, U16 message );
static 	STATUS	Lbox_touch_up( struct LBOX_STRUCTURE * p_str, U16 message );
static 	STATUS	Lbox_touch_item( U8 selected_item, struct LBOX_STRUCTURE * p_str, U16 message ); 


/*****************************************/
/*显示弹出栏*************************************************************************/

static STATUS Lbox_show( struct LBOX_STRUCTURE * p_str )
{	
	//U32		menu=0;
	U32			pGC;

	if ( p_str->pop_status == POP_SHOW )	return ASIX_ERROR;
	if ( p_str->lbox_style == LBS_ROLL )		return ASIX_ERROR;
	if ( p_str == NULL )		return ASIX_ERROR; //check the ping /by zl 2002.3.13
	
	pGC = GetGC( );

	Lbox_calculate( p_str );
	SysStopCursor( pGC );//by zl 2002.3.28
//	p_str->lbox_coveredmap = (U8 *)Lcalloc( (p_str->pop_width+2)*(p_str->pop_height+2)*2 + 2); //by zl 2002.3.13
//	p_str->lbox_coveredmap = (U8 *)Lcalloc( (p_str->pop_width) * (p_str->pop_height) * 2 + 2 );	 
	p_str->lbox_coveredmap = (U8 *)GetBlock( p_str->pop_width, p_str->pop_height );	 
	if (p_str->lbox_coveredmap == NULL)		return ASIX_ERROR;
	
	p_str->offset = 0;

//	SaveRec( pGC, p_str->lbox_coveredmap, p_str->pop_x, p_str->pop_y, (p_str->pop_width+2), (p_str->pop_height+2), 0 ); // move to line 93 by zl 2002.3.13
//	ClearRec( pGC, GPC_WHITE, p_str->pop_x, p_str->pop_y, (p_str->pop_width+1), (p_str->pop_height+1), GPC_REPLACE_STYLE); //move to line 94by zl 2002.3.13
		
	if ( ActiveAreaEnable( &((p_str->lbox_mask).icon_id), ICON_AREA, 0, 0, 0, ASIX_LCD_W-1, ASIX_LCD_H-1, p_str->windowid ) != PPSM_OK )
	{
//		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 );
		return	ASIX_ERROR;
	}   
	(p_str->lbox_mask).icon_status = ICON_ENABLE;

	SaveRec( pGC, p_str->lbox_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width, p_str->pop_height, 0 ); // by zl 2002.3.13
	ClearRec( pGC, ColorTheme.form_backcolor, p_str->pop_x, p_str->pop_y, p_str->pop_width, p_str->pop_height, GPC_REPLACE_STYLE); // by zl 2002.3.13

//	DrawRec( pGC,  GPC_BLACK, p_str->pop_x, p_str->pop_y, p_str->pop_x+p_str->pop_width,	p_str->pop_y+p_str->pop_height, GPC_SOLID_LINE, 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 ( p_str->total_line > ITEMDISPLAY_MAX )	//if ( p_str->total_line > 5 )	by zl 2002.3.13
	{
		if ( Lbox_drawicon( ITEMDISPLAY_MAX, p_str ) != ASIX_OK ) //if ( Lbox_drawicon( 5, p_str ) != ASIX_OK ) by zl 2002.3.13
		{
			ActiveAreaDisable( (p_str->lbox_mask).icon_id );
			(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 );
			Lfree( (void *)p_str->lbox_coveredmap );
			return ASIX_ERROR;
		}
				
		//menu = p_str->total_line;
		//menu = menu << 16;
		//menu = menu | 0x0005;			
		/* we changed to new scroll bar, LM 2001/06/27*/

//		p_str->scroll_id = CreateWindow( WNDCLASS_SCROLL, NULL, WS_CHILD|SBS_VERT|WS_SAVESCREEN, (U16)(p_str->pop_x+p_str->pop_width),(U16)(p_str->pop_y), SCROLL_WIDTH, (U16)p_str->pop_height, p_str->windowid,MAKELONG(0, p_str->total_line-1), NULL  ); //by zl 2002.3.13 
		p_str->scroll_id = CreateWindow( WNDCLASS_SCROLL, NULL, WS_CHILD|SBS_VERT|WS_SAVESCREEN, (U16)(p_str->pop_x + p_str->pop_width - SCROLL_WIDTH),(U16)(p_str->pop_y), SCROLL_WIDTH, (U16)p_str->pop_height, p_str->windowid,MAKELONG(0, p_str->total_line -ITEMDISPLAY_MAX), NULL  );

		if ( p_str -> scroll_id  == 0 )
		{
			ActiveAreaDisable( (p_str->lbox_mask).icon_id );
			(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 );
			Lfree( (void *)p_str->lbox_coveredmap );
			return ASIX_ERROR;
		}			
	}
	else 
	{
		if ( Lbox_drawicon( p_str->total_line, p_str ) != ASIX_OK )
		{
			ActiveAreaDisable( (p_str->lbox_mask).icon_id );
			(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 );
			Lfree( (void *)p_str->lbox_coveredmap );
			return ASIX_ERROR;	
		}
	}

	p_str->pop_status = POP_SHOW;
	return ASIX_OK;	
}
	
	

/************************************************************************************/
/*画栏*******************************************************************************/	
static 	STATUS  Lbox_drawicon( U16 cycle, struct LBOX_STRUCTURE *p_str )
{
	U8	i=0, j=0;

	if ( p_str == NULL )		return ASIX_ERROR; //check the ping /by zl 2002.3.13
	
	for ( i=0; i<cycle; i++ )
	{
		if ( ActiveAreaEnable( &((p_str->lbox_icon[i]).icon_id), ICON_AREA, 0, p_str->pop_x,  p_str->pop_y+i*ITEM_1, p_str->pop_x+p_str->pop_width, p_str->pop_y+(i+1)*ITEM_1, p_str->windowid ) != PPSM_OK ) // by zl 2002.3.13
//		if ( ActiveAreaEnable( &((p_str->lbox_icon[i]).icon_id), ICON_AREA, 0, p_str->pop_x, p_str->pop_y + i * ITEM_1 - 1, 
//			p_str->pop_x + p_str->pop_width - 1, p_str->pop_y + (i + 1) * ITEM_1 - 1 ) != PPSM_OK )
		{
			for ( j = 0; j < i; j++)
			{
				ActiveAreaDisable( (p_str->lbox_icon[j]).icon_id );
				(p_str->lbox_icon[j]).icon_id = 0;
				(p_str->lbox_icon[j]).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 );
			Lfree( (void *)p_str->lbox_coveredmap );
*/
			return 	ASIX_ERROR;
		}
	}
	
	Lbox_drawitem( cycle, p_str );
	
	return ASIX_OK;
}


/**********************************************************/
/***画内容*************/

static STATUS Lbox_drawitem( U16 cycle, struct LBOX_STRUCTURE * p_str )
{
	struct LBOX_ITEM * p_input = p_str->lbox_item + p_str->offset; 
	U8 		i=0;
//	char 	dispbuf[11]; //by zl 2002.3.13
	char *	dispbuf;
	U32		pGC;
	U16		strX, strY;
	
	if ((dispbuf = (char *)Lmalloc( p_str->maxlength + SCROLL_WIDTH/ENGLISH_CHAR_WIDTH - 1 )) == NULL)	return ASIX_ERROR;//by zl 2002.3.28

	pGC = GetGC( );
	for ( i = 0; i < cycle; i++ )
	{
		(p_str->lbox_icon[i]).icon_status = p_input->item_status;
/*
		if ( p_input->item_underline == UNDERLINE )
		{
//			DrawLine( pGC, GPC_BLACK, p_str->pop_x, p_str->pop_y+(i+1)*ITEM_1, p_str->pop_x+p_str->pop_width, p_str->pop_y+ITEM_1*(i+1), GPC_SOLID_LINE, GPC_REPLACE_STYLE); // by zl 2002.3.13
			if (p_str->total_line > ITEMDISPLAY_MAX)
			{
				DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x, p_str->pop_y + (i + 1) * ITEM_1 - 1, p_str->pop_width - SCROLL_WIDTH, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
				Lbox_cutstring( p_input->item_text, p_str->maxlength, dispbuf );
			}
			else
			{
				DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x, p_str->pop_y + (i + 1) * ITEM_1 - 1, p_str->pop_width, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
				Lbox_cutstring( p_input->item_text, (U8)( p_str->pop_width / ENGLISH_CHAR_WIDTH - 1 ), dispbuf );
			}
		}
*/
//by zl 2002.4.2
		if (p_str->total_line > ITEMDISPLAY_MAX)
		{
			if ( p_input->item_underline == UNDERLINE )
			{
				DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x, p_str->pop_y + (i + 1) * ITEM_1 - 1, p_str->pop_width - SCROLL_WIDTH, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
			}
			Lbox_cutstring( p_input->item_text, p_str->maxlength, dispbuf );
		}
		else
		{
			if ( p_input->item_underline == UNDERLINE )
			{
				DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x, p_str->pop_y + (i + 1) * ITEM_1 - 1, p_str->pop_width, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
			}
			Lbox_cutstring( p_input->item_text, (U8)( p_str->pop_width / ENGLISH_CHAR_WIDTH - 1 ), dispbuf );
		}
		

//		Lbox_cutstring( p_input->item_text, 10, dispbuf ); // by zl 2002.3.13
//		Lbox_cutstring( p_input->item_text, p_str->maxlength, dispbuf );
		if ( p_input->item_status == ICON_ENABLE)
		{
//			Disp16String( dispbuf, p_str->pop_x+MARGIN, p_str->pop_y+i*ITEM_1+2); // by zl 2002.3.13
//			Disp16String( dispbuf, p_str->pop_x + MARGIN, p_str->pop_y+i * ITEM_1 + ITEMTEXT_UP_FROM);
			strX = AlignString( dispbuf, p_str->pop_x+MARGIN, p_str->pop_width -SCROLL_WIDTH-MARGIN*2, GPC_ALIGN_CENTER );
			strY = p_str->pop_y+i * ITEM_1 + ITEMTEXT_UP_FROM;
			TextOut( pGC, dispbuf, strX, strY, NULL, ColorTheme.form_poptext, GPC_REPLACE_STYLE );
		}
		else 
		{
//			Disp16StringGrey( ColorTheme.disablecolor, dispbuf, p_str->pop_x+MARGIN, p_str->pop_y+i*ITEM_1+2); //by zl 2002.3.13
//			Disp16StringGrey( ColorTheme.form_disablecolor, dispbuf, p_str->pop_x + MARGIN, p_str->pop_y+i*ITEM_1+ITEMTEXT_UP_FROM);
			strX = AlignString( dispbuf, p_str->pop_x+MARGIN, p_str->pop_width -SCROLL_WIDTH-MARGIN*2, GPC_ALIGN_CENTER );
			strY = p_str->pop_y+i * ITEM_1 + ITEMTEXT_UP_FROM;
			TextOut( pGC, dispbuf, strX, strY, NULL, ColorTheme.form_disablecolor, GPC_REPLACE_STYLE );
		}
		p_input++;
	}
	Lfree( (void *)dispbuf);
	
	return ASIX_OK;
}


/**********************************************************************************/
/*消隐弹出框*************************************************************************/
static STATUS Lbox_hide( struct LBOX_STRUCTURE * p_str)
{
	U8		 i = 0;
	U8 		cycle=p_str->total_line;
	U32		pGC;
	
	
	if ( p_str->lbox_style == LBS_ROLL )		return ASIX_ERROR;
	
	pGC = GetGC( );
//	StartCursor( pGC );

	if ( cycle > ITEMDISPLAY_MAX )		cycle = ITEMDISPLAY_MAX; //if ( cycle > 5 )	cycle = 5; by zl 2002.3.13
		
	for ( i = 0; i < cycle; i++ )
	{
		ActiveAreaDisable( (p_str->lbox_icon[i]).icon_id );
		(p_str->lbox_icon[i]).icon_id = 0;
		(p_str->lbox_icon[i]).icon_status = ICON_DISABLE;	
	}
	if ( p_str->total_line > ITEMDISPLAY_MAX ) //if ( p_str->total_line > 5 ) by zl 2002.3.13
	{
		DestroyWindow( p_str->scroll_id );
		p_str->scroll_id = 0;
	}
	
	ActiveAreaDisable( (p_str->lbox_mask).icon_id );

⌨️ 快捷键说明

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