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

📄 asix_wn.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************
*
* Copyright  2000 National ASIC Center, All right Reserved
*
* FILE NAME:			asix_wn.c
* PROGRAMMER:			Lingming
* Date of Creation:		2001/02/19
* 
* DESCRIPTION: 			The asix win container 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/02/19	by Lingming		Creation of this file
*								
*							
*************************************************************************/

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

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

#include "keydef.h"

#include "asix_wn.h"
#include "asix_mn.h"

#include "gpc.h"

//#include <uartsvr.h>

#ifdef ASIX_DEBUG
//#include "hc.h"
#endif


struct MENU_ITEM		SysMenu_Item[MAX_SYSMENU+1];/* the largest item number is 15 */
SYSTCB				*SysMenu_Taskptr[MAX_SYSMENU+1];/* the last one is unused*/

/* 14*14 */
static const U8 closebox_icon[]={
// 头信息
0x42,0x4D,		// 位图的标识符('BM')
0x0e,0x00,		// 位图的宽度(14 pixels)
0x0e,0x00,		// 位图的高度(14 pixels)
0x01,			// 位图的像素深度(1 bits/pixel)
0x00,			// 位图的状态标志位
				// |7|6|5|4|3|2|1|0|
				// 0位:使用系统调色板
				// 1位:不使用压缩算法
0x02,0x00,0x00,0x00,	// 位图实际使用到的颜色数(2 colors)
0x10,0x00,0x00,0x00,	// 数据区的偏移量(16 bytes)
// 数据区
0x00,0x01,0x80,0x67,0x03,0x8e,0x1c,0x1c,0xe0,0x3f,
0x00,0x78,0x01,0xe0,0x0f,0xc0,0x73,0x83,0x87,0x1c,
0x0e,0x60,0x18,0x00,0x03
};	
/* 16*16 */
static const U8 sysmenu_icon[]={
// 头信息
0x42,0x4D,		// 位图的标识符('BM')
0x10,0x00,		// 位图的宽度(16 pixels)
0x10,0x00,		// 位图的高度(16 pixels)
0x01,			// 位图的像素深度(1 bits/pixel)
0x00,			// 位图的状态标志位
				// |7|6|5|4|3|2|1|0|
				// 0位:使用系统调色板
				// 1位:不使用压缩算法
0x02,0x00,0x00,0x00,	// 位图实际使用到的颜色数(2 colors)
0x10,0x00,0x00,0x00,	// 数据区的偏移量(16 bytes)
// 数据区
0xff,0xff,0x80,0x05,0x80,0x0d,0xaf,0xed,0xaf,0xed,
0xad,0xed,0xac,0x6d,0xae,0x6d,0xaf,0xed,0xa0,0x0f,
0xbf,0xfb,0x80,0x07,0x80,0xf7,0x80,0x07,0xbf,0xfd,
0xff,0xff
};	
/* 16*16 */
static const U8 usermenu_icon[]={
// 头信息
0x42,0x4D,		// 位图的标识符('BM')
0x10,0x00,		// 位图的宽度(16 pixels)
0x10,0x00,		// 位图的高度(16 pixels)
0x01,			// 位图的像素深度(1 bits/pixel)
0x00,			// 位图的状态标志位
				// |7|6|5|4|3|2|1|0|
				// 0位:使用系统调色板
				// 1位:不使用压缩算法
0x02,0x00,0x00,0x00,	// 位图实际使用到的颜色数(2 colors)
0x10,0x00,0x00,0x00,	// 数据区的偏移量(16 bytes)
// 数据区
0xff,0xfe,0x80,0x00,0x80,0x02,0x9f,0xf2,0x9f,0xd2,
0x98,0x12,0x98,0x12,0x98,0x12,0x98,0x12,0x90,0x12,
0x9f,0xf2,0x80,0x02,0x80,0x02,0x80,0x02,0xbf,0xfe,
0x00,0x00
};

STATUS wn_create(char *caption, U32 style, U16 x, U16 y, U16 width, U16 hight,
				 U32 wndid, U32 menu, void **ctrl_str, void *exdata)
{
	struct wn_ctrl		*ctrl_ptr;
	//char			captionstr[ASIX_LCD_W/ENGLISH_CHAR_WIDTH+1];
	U32				titleid=0,clientid=0, closebox=0,userbox=0,sysmenu=0;
	P_U8			screenbuf = NULL;
	U8				caption_len;
	//char			*charptr;
	//register	U8	i = 0;
	U32				pGC;
	U16				tempx;
	
	
	if (x+width>ASIX_LCD_W || y+hight>ASIX_LCD_H ) return ASIX_ERROR;
	
	if (ActiveAreaEnable(&clientid, ICON_AREA, STROKE_MODE, x, y, x+width-1, y+hight-1, wndid) != PPSM_OK)
		return ASIX_ERROR;
	
	
	pGC = GetGC( );
	if (style & WS_SAVESCREEN )	{
		// bitmap pixel is 2 bytes (longn_qi 2001/11/15 revised )
		// longn_qi 2002/01/25 for monitor memory leak
		asix_wn_memdbgprintf( "asix_wn appeal mem for screen buffer" );
//		if ( (screenbuf = Lmalloc(width*hight*2+2)) == NULL) /*The result may not be int, so we add 1*/
		if ( (screenbuf = (P_U8)GetBlock( width, hight )) == NULL) /*The result may not be int, so we add 1*/
		{
			ActiveAreaDisable(clientid);
			return ASIX_NO_MEM;
		}	
		SaveRec( pGC, screenbuf, x, y, width, hight,0);
	}
	
	if (style & WS_BORDER) {
		//DrawRec( pGC, GPC_BLACK, x, y, x+width-1, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
		//DrawRec( pGC, GPC_PLUM, x, y, x+width-1, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
		/* 2001-11-24 16:18 */
		DrawRec( pGC, ColorTheme.form_board, x, y, x+width-1, y+hight-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
	}
	
	if (style & WS_POPUP) {
		//ClearRec( pGC, GPC_LIGHTGREY, x+1, y+1, width-2, hight-2,GPC_REPLACE_STYLE);	
		/* 2001-11-24 16:18 */
		ClearRec( pGC, ColorTheme.form_popclient, x+1, y+1, width-2, hight-2,GPC_REPLACE_STYLE);	//here +1 or -2 because the procession is done inside the Rectangle from (x, y) to (x + width - 1 , y + height - x) By zl 2002.3.18
	} else {
		//ClearRec( pGC, GPC_WHITE, x+1, y+1, width-2, hight-2,GPC_REPLACE_STYLE);	//
		/* 2001-11-24 16:18 */
		ClearRec( pGC, ColorTheme.form_client, x+1, y+1, width-2, hight-2,GPC_REPLACE_STYLE);	//
	}	
	
	caption_len = width/ENGLISH_CHAR_WIDTH-2;

	if (style & WS_USERBOX)	caption_len -=2;
	if (style & WS_SYSMENU) caption_len -=2;	
	if (style & WS_CLOSEBOX) caption_len -= 2; 
	
	
	if ( (style & WS_BORDER) && (style & WS_DLGFRAME) ) {
		if (ActiveAreaEnable(&titleid, ICON_AREA, STROKE_MODE, x, y, x+width-1, y+CHINESE_CHAR_HEIGHT+4, wndid) != PPSM_OK)
		{
			PutRec( pGC, screenbuf, x, y, width, hight, GPC_REPLACE_STYLE, 0);
			// longn_qi 2002/01/25 for monitor memory leak
			asix_wn_memdbgprintf( "asix_wn free mem of screen buffer" );
			Lfree(screenbuf);


			ActiveAreaDisable(clientid);
			return ASIX_ERROR;
		}		
//		DrawRec( pGC,GPC_BLACK, x, y, x+width-1, y+CHINESE_CHAR_HEIGHT+4, 0, GPC_REPLACE_STYLE); // by zl 2002.3.16
		DrawRec( pGC,ColorTheme.form_board, x, y, x + width - 1, y + TITLE_HEIGHT - 1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
		
		//if (style & WS_POPUP) 
			//ClearRec( pGC, GPC_WHITE, x+1, y+1, width-2, CHINESE_CHAR_HEIGHT+4,GPC_REPLACE_STYLE);
			
		
		//ClearRec( pGC, GPC_BLUE, x+1, y+1, width-2, CHINESE_CHAR_HEIGHT+4,GPC_REPLACE_STYLE);
		/* 2001-11-24 16:19 */
//		ClearRec( pGC, ColorTheme.form_title, x+1, y+1, width-2, CHINESE_CHAR_HEIGHT+4,GPC_REPLACE_STYLE); by zl 2002.3.16
		ClearRec( pGC, ColorTheme.form_title, x + 1, y + 1, width - 2, TITLE_HEIGHT - 1, GPC_REPLACE_STYLE);
		
		//DisplayMsg(caption, x+1, y+2, x+caption_len*ENGLISH_CHAR_WIDTH-1, y+1+CHINESE_CHAR_HEIGHT, GPC_REPLACE_STYLE);
//		DrawText(pGC, caption, x + 1, y + 2, x + caption_len * ENGLISH_CHAR_WIDTH -1, y + 1 + CHINESE_CHAR_HEIGHT, HZK_16X16_FONT, ColorTheme.form_caption, GPC_REPLACE_STYLE);//by zl 2002.3.18
		DrawText(pGC, caption, x + CAPTION_LEFT, y + CAPTION_UP, x + caption_len * ENGLISH_CHAR_WIDTH + CAPTION_LEFT - 1, y + CHINESE_CHAR_HEIGHT + CAPTION_UP - 1, \
		HZK_16X16_FONT, ColorTheme.form_caption, GPC_REPLACE_STYLE);
		//InvRec( pGC, x+1, y+1, width-2, CHINESE_CHAR_HEIGHT+3);
		
	}
			
	
	// longn_qi 2002/01/25 for monitor memory leak
	asix_wn_memdbgprintf( "asix_wn appeal mem for itself" );
	ctrl_ptr = Lcalloc( sizeof(struct wn_ctrl) );
	if (ctrl_ptr == NULL ) {
		ActiveAreaDisable(clientid);
		ActiveAreaDisable(titleid);
		PutRec( pGC, screenbuf, x, y, width, hight, GPC_REPLACE_STYLE, 0);
		// longn_qi 2002/01/25 for monitor memory leak
		asix_wn_memdbgprintf( "asix_wn free mem of screen buffer" );
		Lfree(screenbuf);


	 	return ASIX_NO_MEM;
	}

	tempx = x + width - BOX_WIDTH - 1;
	if (style & WS_CLOSEBOX)
	{
//		closebox = CreateWindow(WNDCLASS_BUTTON, NULL, WS_CHILD|BS_REGULAR, (U16)(x+width-17),(U16)(y+1),16,16,wndid,0x000e000e, ( char* )closebox_icon);//by zl 2002.3.18
		closebox = CreateWindow(WNDCLASS_BUTTON, NULL, WS_CHILD|BS_ICON, tempx,(U16)(y + 1), BOX_WIDTH, (U16)(TITLE_HEIGHT - 1), wndid, 0x000e000e, ( char* )closebox_icon);
		tempx -= BOX_WIDTH;
	}

	if (style & WS_SYSMENU)
	{
//		sysmenu = CreateWindow(WNDCLASS_MENU, ( char* )usermenu_icon, WS_CHILD, (U16)(x+width-33),(U16)(y+1),16,16,wndid,0x00100010,(void *)SysMenu_Item);//by zl 2002.3.18
		sysmenu = CreateWindow(WNDCLASS_MENU, ( char* )usermenu_icon, WS_CHILD | MNS_ICON, tempx,(U16)(y + 1),BOX_WIDTH, (U16)(TITLE_HEIGHT - 1),wndid,0x00100010,(void *)SysMenu_Item);
		tempx -= BOX_WIDTH;
	}
	
	if (style & WS_USERBOX) {
		ctrl_ptr->usermenu_itemptr = (struct MENU_ITEM *)exdata;
//		userbox = CreateWindow(WNDCLASS_MENU, ( char* )usermenu_icon, WS_CHILD, (U16)(x+width-49),(U16)(y+1),16,16,wndid,0x00100010,exdata);//by zl 2000.3.18
		userbox = CreateWindow(WNDCLASS_MENU, ( char* )usermenu_icon, WS_CHILD | MNS_ICON, tempx,(U16)(y + 1),BOX_WIDTH, (U16)(TITLE_HEIGHT - 1),wndid,0x00100010,exdata);
		tempx -= BOX_WIDTH;
	}	
	
		
		
	ctrl_ptr->close_wndid = closebox;
	ctrl_ptr->user_wndid = userbox;
	ctrl_ptr->sys_wndid = sysmenu;
	
	ctrl_ptr->classid = (U32)WNDCLASS_WIN;
	ctrl_ptr->wndid = wndid;
	ctrl_ptr->titleid = titleid;
	ctrl_ptr->clientid = clientid;
	ctrl_ptr->saved_screen = screenbuf;
	
	*ctrl_str = (void *)ctrl_ptr;
	
	return ASIX_OK;
	
	
	
	
	
	

⌨️ 快捷键说明

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