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

📄 asix_st.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
字号:
/*************************************************************************
*
* Copyright  2000 National ASIC Center, All right Reserved
*
* FILE NAME:			asix_wn.c
* PROGRAMMER:			Lingming
* Date of Creation:		2001/04/18
* 
* DESCRIPTION: 			The asix win static control implementation. this 
*						file defines the control related infomation. 
*
* NOTE:			 		
*
* FUNCTIONS LIST:
* fun1(arg1,arg2)		description of func1
* fun2(arg1,arg2,arg3)	description of func2
*
* GLOBAL VARS LIST:
* 
*
**************************************************************************
* MODIFICATION HISTORY
*
* 2001/04/18	by Lingming		Creation of this file
*								
*							
*************************************************************************/

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

#include "wintype.h"

#include "asixwin.h"

#include "asix_st.h"

#include "bitmap.h"

#include "gpc.h"

//modified by xuanhui 2002/3/13
//static void drawstatic(U16 x, U16 y, U16 width, U16 hight, U32 style, P_U8 caption, U32 menu, void *exdata);	
static STATUS drawstatic(U16 x, U16 y, U16 width, U16 hight, U32 style, P_U8 caption, U32 menu, void *exdata);	


STATUS st_create(char *caption, U32 style, U16 x, U16 y, U16 width, U16 hight,
				 U32 wndid, U32 menu, void **ctrl_str, void *exdata)
{
//	P_U8	screenbuf;
	struct st_ctrl	*ctrl_ptr;
	U32		pGC;

	//modified by xuanhui 2002/4/3
	//if ( (x+width)>ASIX_LCD_W || (y+hight)>ASIX_LCD_H ) return ASIX_ERROR;
	if ( (U16)(x+width-1)>=ASIX_LCD_W || (U16)(y+hight-1)>=ASIX_LCD_H ) return ASIX_ERROR;
	
	pGC = GetGC( );
	
	asix_st_memdbgprintf( "### Create Static ### " );

	ctrl_ptr = Lcalloc( sizeof(struct st_ctrl) );
	
	//modified by xuanhui 2002/3/12
	if ( ctrl_ptr == NULL )
	{
		asix_st_memdbgprintf( "### Create Static Error ### " );
		return ASIX_NO_MEM;
	}
	
	ctrl_ptr->classid = WNDCLASS_STATIC;
	ctrl_ptr->wndid = wndid;
	
	if (style & WS_SAVESCREEN )	{
//		if ( (ctrl_ptr->saved_screen = Lmalloc(width*hight/4+1)) == NULL){	 /*The result may not be int, so we add 1*/
		if ( (ctrl_ptr->saved_screen = (P_U8)GetBlock( width, hight )) == NULL){	 /*The result may not be int, so we add 1*/
		/* "4"表示一个字节所能保存位图的像素数 */	//modified by xuanhui 2002/3/13
			Lfree(ctrl_ptr);
			asix_st_memdbgprintf( "### Create Static Error ### " );
			return ASIX_NO_MEM;
		}	
		
		//modified by xuanhui 2002/3/12
		//SaveRec( pGC, ctrl_ptr->saved_screen, x, y, width, hight,0);
		if( SaveRec( pGC, ctrl_ptr->saved_screen, x, y, width, hight,0 ) != PPSM_OK )	/* "0"表示预留项 */  //modified by xuanhui 2002/3/13
		{
			Lfree(ctrl_ptr->saved_screen);
			Lfree(ctrl_ptr);
			asix_st_memdbgprintf( "### Create Static Error ### " );
			return ASIX_ERROR;
		}
	}
	
	//modified by xuanhui 2002/3/14	
	//drawstatic( x, y, width, hight, style, caption, menu, exdata );
	if ( drawstatic( x, y, width, hight, style, caption, menu, exdata ) != ASIX_OK )
	{
		asix_st_memdbgprintf( "### Create Static Error ### " );
		return ASIX_ERROR;		
	}
		
	*ctrl_str = (void *)ctrl_ptr;
	
	asix_st_memdbgprintf( "### Create Static Successfully ### " );
	return ASIX_OK;
	
}


STATUS st_destroy(void *ctrl_str)
{
	struct st_ctrl *ctrl_ptr;
	ASIX_WINDOW		*wndptr;
	U32				pGC;

	pGC =GetGC();
	
	ctrl_ptr = (struct st_ctrl *)ctrl_str;
	wndptr = (ASIX_WINDOW *)(ctrl_ptr->wndid);
	
	asix_st_memdbgprintf( "### Destroy Static ### " );
	if ( ctrl_ptr->saved_screen != NULL ){
		//modified by xuanhui 2002/3/14
		//PutRec( pGC,ctrl_ptr->saved_screen, wndptr->x, wndptr->y, wndptr->width, wndptr->hight,GPC_REPLACE_STYLE,0 );
		if ( PutRec( pGC,ctrl_ptr->saved_screen, wndptr->x, wndptr->y, wndptr->width, wndptr->hight,GPC_REPLACE_STYLE,0 ) != PPSM_ERROR )
		{
			asix_st_memdbgprintf( "### Destroy Static Error ### " );
			return ASIX_ERROR; 
		}
		Lfree(ctrl_ptr->saved_screen);
	} else 
		//modified by xuanhui 2002/3/13
		//ClearRec( pGC,ColorTheme.form_client, wndptr->x, wndptr->y, wndptr->width, wndptr->hight, GPC_REPLACE_STYLE );
		ClearRec( pGC,ColorTheme.form_backcolor, wndptr->x, wndptr->y, wndptr->width, wndptr->hight, GPC_REPLACE_STYLE );
	
	Lfree(ctrl_ptr);
	
	
	asix_st_memdbgprintf( "### Destroy Static Successfully ### " );

	return ASIX_OK;
	
}		

STATUS st_msgproc(U32 win_id, U16 asix_msg, U32 lparam, void *data, U16 wparam, void *reserved)
{
	return ASIX_OK;	
}

STATUS st_msgtrans(void *ctrl_str, U16 msg_type, U32 areaId, P_U16 data, U32 size, PMSG trans_msg)
{
	return ASIX_NO_MSG;
}

STATUS st_repaint(void *ctrl_str, U32 lparam)
{
	
	ASIX_WINDOW		*wndptr;
	struct st_ctrl  *ctrlptr;
	
	if ( ctrl_str == NULL || *((U32 *)ctrl_str) != WNDCLASS_STATIC ) return ASIX_ERROR;

	ctrlptr = (struct st_ctrl *)ctrl_str;
	wndptr = (ASIX_WINDOW *)(ctrlptr->wndid);
	
	//modified by xuanhui 2002/3/14
	//drawstatic(wndptr->x, wndptr->y, wndptr->width, wndptr->hight,wndptr->style, wndptr->caption, wndptr->hmenu, wndptr->exdata);		
	if ( drawstatic(wndptr->x, wndptr->y, wndptr->width, wndptr->hight,wndptr->style, wndptr->caption, wndptr->hmenu, wndptr->exdata) == ASIX_ERROR )
		return ASIX_ERROR;		
		
	return ASIX_OK;
}

STATUS st_caption(void *ctrl_str, char *caption, void *exdata)
{
	ASIX_WINDOW		*wndptr;
	struct st_ctrl  *ctrlptr;
	
	ctrlptr = (struct st_ctrl *)ctrl_str;
	
	if ( ctrlptr == NULL || ctrlptr->classid != WNDCLASS_STATIC )
		return ASIX_ERROR;
	
	wndptr = (ASIX_WINDOW *)(ctrlptr->wndid);
		
	//modified by xuanhui 2002/3/14
	//drawstatic(wndptr->x, wndptr->y, wndptr->width, wndptr->hight,wndptr->style, caption, wndptr->hmenu, exdata);		
	if ( drawstatic(wndptr->x, wndptr->y, wndptr->width, wndptr->hight,wndptr->style, caption, wndptr->hmenu, exdata) != ASIX_OK )
		return ASIX_ERROR;		
	
	return ASIX_OK;	
}

STATUS drawstatic(U16 x, U16 y, U16 width, U16 hight, U32 style, P_U8 caption, U32 menu, void *exdata)
{
	U32		pGC;
	U16		strX, strY;
		
	pGC = GetGC();
	
	ClearRec( pGC, ColorTheme.form_client, x, y, width, hight, GPC_REPLACE_STYLE );
	
	//modified by xuanhui 2002/4/3
	//if ( style & SS_TEXT )
	if ( style & SS_TEXT && !(style & SS_GROUP) && !(style & SS_ICON) )
		//modified by xuanhui 2002/3/13
		//DisplayMsg(caption, x+2, y+2, x+width-3,y+hight-3, GPC_REPLACE_STYLE);
	{
		if ( caption != NULL )	//modified by xuanhui 2002/4/4
		{
			//modified by xuanhui 2002/3/28
			if ( width < (U16)(ST_INTERVAL*3+ENGLISH_CHAR_WIDTH) 
			|| hight < (U16)(ST_INTERVAL*2+CHINESE_CHAR_HEIGHT) )
				return ASIX_ERROR;

			if( style & SS_MULTILINE )
				DisplayMsg(caption, x+ST_INTERVAL, y+ST_INTERVAL, x+width-ST_INTERVAL-1,y+hight-ST_INTERVAL-1, GPC_REPLACE_STYLE);
			else
			{
				U8		algin;

				switch( style & SS_ALIGN )
				{
					case SS_LEFT:
						algin = GPC_ALIGN_LEFT;
						break;
					case SS_RIGHT:
						algin = GPC_ALIGN_RIGHT;
						break;
					default:
						algin = GPC_ALIGN_CENTER;
				}
				strX = AlignString( caption, x +ST_INTERVAL+1, width - ST_INTERVAL*2, algin );
				strY = y + ST_INTERVAL + ( ( hight - ST_INTERVAL*2 - CHINESE_CHAR_HEIGHT )>>1 );
				TextOut( pGC, caption, strX, strY, NULL, ColorTheme.form_text, GPC_REPLACE_STYLE );
			}
		}
	}
	else if ((style & SS_ICON) && !(style & SS_TEXT) && !(style & SS_GROUP) )		//modified by xuanhui 2002/3/28
	{
		//modified by xuanhui 2002/3/28
//		if ( width < (U16)(LOWORD(menu)+2) || hight < (U16)(HIWORD( menu )+2) )
//			return ASIX_ERROR;
		//modified by longn_qi 2002/6/14
		if ( width < (U16)(LOWORD(menu)) || hight < (U16)(HIWORD( menu )) )
			return ASIX_ERROR;
			
//		switchonetotwo(exdata, x, y, LOWORD(menu), HIWORD(menu));	
		//modified by xuanhui 2002/3/13
		//DrawMonoImage( pGC, exdata, x, y, LOWORD(menu), HIWORD(menu), GPC_BLACK, GPC_WHITE);	
//		DrawMonoImage( pGC, exdata, x, y, LOWORD(menu), HIWORD(menu), ColorTheme.form_frontcolor, ColorTheme.form_backcolor);	
		{
			U32	hbmp;
			//U32	trColor;
			U16 lx = x;
			U16 ly = y;
			U32 palette[2];
			
			palette[0] = ColorTheme.form_client;
			palette[1] = ColorTheme.form_frontcolor;

			hbmp = LoadBitmap( exdata, 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 );
			}
		}
	}
	
	//modified by xuanhui 2002/4/3
	//if ( style & SS_BOARD )
	if ( style & SS_BOARD && !(style & SS_GROUP) )
	{
		//modified by xuanhui 2002/4/3
/*		//modified by xuanhui 2002/3/28
		if ( width < (U16)(ENGLISH_CHAR_WIDTH+2) || hight < (U16)(CHINESE_CHAR_HEIGHT+2))
			return ASIX_ERROR;
*/			
		DrawRec( pGC, ColorTheme.form_board, x, y, x+width-1, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
	}
	else if ( (style & SS_GROUP) && !(style & SS_TEXT) && !(style & SS_BOARD) && !(style & SS_ICON)){		//modified by xuanhui 2002/3/28
		
/*		if ( hight <= ST_CLEAR_HEIGHT || width <= (ST_SPACE*2+2) || ST_LINE_POSITION <= ST_CLEAR_HEIGHT )	//modified by xuanhui 2002/3/14
			return ASIX_ERROR;
*/
		if ( caption != NULL )	//modified by xuanhui 2002/4/4
		{
			//modified by xuanhui 2002/3/28
			if ( width < (U16)(ST_SPACE*2+2+ENGLISH_CHAR_WIDTH) 
			|| hight < (U16)(CHINESE_CHAR_HEIGHT+ST_TEXT_AREA+2) 
			|| ST_LINE_POSITION < ST_TEXT_AREA )  //modified by xuanhui 2002/4/3
				return ASIX_ERROR;
			//DrawRec( pGC, ColorTheme.form_board, x, y+ST_LINE_POSITION, x+width-1, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);	
			DrawRec( pGC, ColorTheme.form_board, x, y, x+width-1, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
			//modified by xuanhui 2002/3/13
//			ClearRec( pGC,ColorTheme.form_client, x+1, y+1, width-2, hight-2, GPC_REPLACE_STYLE);
			
			//modified by xuanhui 2002/4/3
			//ClearRec( pGC,ColorTheme.form_backcolor,x, y, width-ST_SPACE, ST_CLEAR_HEIGHT, GPC_REPLACE_STYLE);
		
			//modified by xuanhui 2002/3/13
			//DrawLine( pGC,GPC_DARKGREY, x, y+9, x+width-1, y+9, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
			//DrawLine( pGC,GPC_DARKGREY, x, y+9, x, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
			//DisplayMsg(caption, x+4, y+1, min( (x+strlen(caption)*ENGLISH_CHAR_WIDTH+4),(x+width-4) ), y+17, GPC_REPLACE_STYLE);	
			
			//DrawLine( pGC,ColorTheme.form_line, x, y+ST_LINE_POSITION, x+width-1, y+ST_LINE_POSITION, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
			//DrawLine( pGC,ColorTheme.form_line, x, y+ST_LINE_POSITION, x, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
			if( style & SS_MULTILINE )
				DisplayMsg( caption, x+ST_SPACE, y+1, min( (U16)(x+strlen(caption)*ENGLISH_CHAR_WIDTH+ST_SPACE),(U16)(x+width-ST_SPACE) ), y+ST_TEXT_AREA, GPC_REPLACE_STYLE);	
			else
			{
				U8		algin;

				switch( style & SS_ALIGN )
				{
					case SS_LEFT:
						algin = GPC_ALIGN_LEFT;
						break;
					case SS_RIGHT:
						algin = GPC_ALIGN_RIGHT;
						break;
					default:
						algin = GPC_ALIGN_CENTER;
				}
				strX = AlignString( caption, x +ST_INTERVAL+1, width - ST_INTERVAL*2, algin );
				strY = y + ST_INTERVAL + ( ( hight - ST_INTERVAL*2 - CHINESE_CHAR_HEIGHT )>>1 );
				TextOut( pGC, caption, strX, strY, NULL, ColorTheme.form_text, GPC_REPLACE_STYLE );
			}
		}else{
			DrawRec( pGC, ColorTheme.form_board, x, y, x+width-1, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);	
		}		
	}
	return ASIX_OK;
}			 

⌨️ 快捷键说明

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