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

📄 ed_sftkb.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
字号:
/**********************************************************
*
*Copyright ? 2001 National ASIC Center, All right Reserved
*
* FILE NAME:		editor.c
* PROGRAMMER:		ZengXianWei
* Date of Creation:	2001/3/18
* 
*DESCRIPTION: 		editor.c and editor.h accomodate several functions which will be used in creating a editor application program
*
*NOTE:			 	the function createditor() is a absolute application program
*
*FUNCTIONS LIST:
*the following define eight member function.
*STATUS CreateEditor( char *caption, char *extern_buffer, U16 size )
*		_caption is the name of the string which was edited
*		_extern_buffer is the point of the buffer which use give me
*		_size is the size of the buffer
*
*void InsertStr( char *insert_ptr, struct seditor *editor )
*		_insert_ptr is the pointer of the string which will be inserted to another string
*		_editor
*void Input_proc( U16 data,struct seditor *editor )
*		_data is the char which was inputed
*		_editor
*void Backdelete_proc( struct seditor *editor )
*		_editor
*void Calculatecur( P_U16 data,struct seditor *editor )
*		_data translate the x coordinate and the y coordinate
*		_editor
*void Refresh( char *disp_str ,U8 style )
*		_disp_ptr point to the head char which will be displayed
*		_style is the style which will be displayed,include OPEN AND SECRET
*
*		
*GLOBAL VARS LIST:
*
*********************************************************
*MODIFICATION HISTORY
*
*
* 2001/3/18	by ZengXianWei		Description of the changes mode to the file
*							    changes should be listed in the reverse order
* 2002/6/10		by longn_qi		revised
*						
***********************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

#include "ppsm.h"

#include "disp.h"

#include "asix_ed.h"

#define		LEFT_BUTTON_X			1//1
#define		LEFT_BUTTON_Y			125//44
#define		LEFT_BUTTON_WIDTH		30//20
#define		LEFT_BUTTON_HEIGHT		20//22

#define		RIGHT_BUTTON_X			33//(INPUT_X + INPUT_WIDTH+1)
#define		RIGHT_BUTTON_Y			125//LEFT_BUTTON_Y
#define		RIGHT_BUTTON_WIDTH		30//20
#define		RIGHT_BUTTON_HEIGHT		20//22

#define		BUTTON_OK_X				65//3
#define		BUTTON_OK_Y				125//80
#define		BUTTON_OK_WIDTH			30//48
#define		BUTTON_OK_HEIGHT		20//20

#define		BUTTON_CANCEL_X			97//55
#define		BUTTON_CANCEL_Y			125//80
#define		BUTTON_CANCEL_WIDTH		30//48
#define		BUTTON_CANCEL_HEIGHT	20//20

#define		BUTTON_RESET_X			129//107
#define		BUTTON_RESET_Y			125//80
#define		BUTTON_RESET_WIDTH		30//48
#define		BUTTON_RESET_HEIGHT		20//20

#define		INPUT_X					2//(LEFT_BUTTON_X+LEFT_BUTTON_WIDTH+1)
#define		INPUT_Y					40//LEFT_BUTTON_Y
#define		INPUT_WIDTH				155
#define		INPUT_HEIGHT			22

//#define		KEY_BOARD_X			
//#define		KEY_BOARD_Y
//#define		KEY_BOARD_WIDTH
//#define		KEY_BOARD_HEIGHT
static U8		left[] = {
// 头信息
0x42,0x4D,		// 位图的标识符('BM')
0x12,0x00,		// 位图的宽度(150 pixels)
0x14,0x00,		// 位图的高度(58 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,0x00,0x00,0x02,0x00,0x01,0x80,0x00,0xe0,0x00,0x78,0x00,0x3e,0x00,0x1f,0x80,
0x0f,0xe0,0x07,0xf8,0x01,0xfe,0x00,0x3f,0x80,0x07,0xe0,0x00,0xf8,0x00,0x1e,0x00,
0x03,0x80,0x00,0x60,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static U8		right[] = {
// 头信息
0x42,0x4D,		// 位图的标识符('BM')
0x12,0x00,		// 位图的宽度(150 pixels)
0x14,0x00,		// 位图的高度(58 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)
0x0,0x0,0x0,0x80,0x0,0x30,0x0,0xe,0x0,0x3,0xc0,0x0,0xf8,0x0,0x3f,0x0,
0xf,0xe0,0x3,0xfc,0x0,0xff,0x0,0x3f,0x80,0xf,0xc0,0x3,0xe0,0x0,0xf0,0x0,
0x38,0x0,0xc,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
//modified by xh 02/6/6

STATUS OpenSingleEditor( char *caption, char *tips, char *extern_buffer, U16 size, U32 style )
{
	U32		frame;
	
	U32		left_button;
	U32		right_button;
	
	U32		button_ok;
	U32		button_cancel;
	U32		button_reset;
	
	U32		keyboard;
	U32		editor;	//modified by xh 02/6/7
	
	MSG		Msg, ed_msg;
	
	U8		quit = FALSE;
	U32		pGC;
	U8		title_is_saved = FALSE;
	
	
	pGC = GetGC();

	//create frame
	frame = CreateWindow(WNDCLASS_WIN, caption, WS_OVERLAPPEDWINDOW|WS_SAVESCREEN, 0,0,LCD_WIDTH-1,LCD_HEIGHT-1,0,0,NULL);

	//create toolbar
	left_button = CreateWindow(WNDCLASS_BUTTON, left, WS_CHILD|BS_TOOLBAR, LEFT_BUTTON_X,LEFT_BUTTON_Y,LEFT_BUTTON_WIDTH,LEFT_BUTTON_HEIGHT,frame,0x00140012,left );
	right_button = CreateWindow(WNDCLASS_BUTTON, NULL, WS_CHILD|BS_TOOLBAR, RIGHT_BUTTON_X,RIGHT_BUTTON_Y,RIGHT_BUTTON_WIDTH,RIGHT_BUTTON_HEIGHT,frame,0x00140012,right );
	button_ok = CreateWindow(WNDCLASS_BUTTON, "确定\\确定", WS_CHILD|BS_REGULAR, BUTTON_OK_X,BUTTON_OK_Y,BUTTON_OK_WIDTH,BUTTON_OK_HEIGHT,frame,0x00200020,NULL );
	button_cancel = CreateWindow(WNDCLASS_BUTTON, "取消\\取消", WS_CHILD|BS_REGULAR, BUTTON_CANCEL_X,BUTTON_CANCEL_Y,BUTTON_CANCEL_WIDTH,BUTTON_CANCEL_HEIGHT,frame,0x00200020,NULL );
	button_reset = CreateWindow(WNDCLASS_BUTTON, "重置\\重置", WS_CHILD|BS_REGULAR, BUTTON_RESET_X,BUTTON_RESET_Y,BUTTON_RESET_WIDTH,BUTTON_RESET_HEIGHT,frame,0x00200020,NULL );
	
	//create keyboard
	//modified by xh 02/6/6
	keyboard = CreateWindow(WNDCLASS_KEYBD,NULL,WS_CHILD|style|0xff,1,(U16)(LCD_HEIGHT-16),(U16)(LCD_WIDTH-2),16,frame,0,NULL);
	Disp16String(tips, 2, 22 );

	//modified by xh 02/6/7
	editor = CreateWindow(WNDCLASS_EDITOR,NULL,WS_CHILD|ES_SINGLE_REGULAR,INPUT_X,INPUT_Y,INPUT_WIDTH,INPUT_HEIGHT,frame,size,NULL);

	SetWindowText( editor, extern_buffer, 0 );
	/*------the upper created the area for edit------*/



	/*------the following helps to realize the editor function------*/
	
	SetFocus( editor );		//modified by xh 02/6/7
	
	while(!quit)  
	{
		
		ASIXGetMessage(&Msg,NULL,0,0);
		
		switch (Msg.message )
		{
			case WM_COMMAND:
				if ( Msg.lparam == left_button )
				{
					ed_msg.message = WM_CHAR;
					ed_msg.lparam = editor;
					ed_msg.wparam = ASIX_KEY_LEFT;
					ed_msg.data = ((ASIX_WINDOW *)editor)->ctrl_str;

					AdvSendMessage(GetCurTask()->id, (P_MESSAGE)(&ed_msg), NO_SWAP_TASK);
					break;
				}		
				else if( Msg.lparam == right_button ) 
				{	
					ed_msg.message = WM_CHAR;
					ed_msg.lparam = editor;
					ed_msg.wparam = ASIX_KEY_RIGHT;
					ed_msg.data = ((ASIX_WINDOW *)editor)->ctrl_str;

					AdvSendMessage(GetCurTask()->id, (P_MESSAGE)(&ed_msg), NO_SWAP_TASK);
					break;
				}
				else if( Msg.lparam == button_ok )
				{
					GetEditorStr( editor, extern_buffer, size );//modified by xh 02/6/7	
					title_is_saved = TRUE;//modified by xh 02/6/7
					quit = TRUE;
					break;
				}
				else if( Msg.lparam == button_cancel )
				{
					quit = TRUE;
					break;	
				}
				else if( Msg.lparam == button_reset )
				{
					ed_msg.message = WM_CHAR;
					ed_msg.lparam = editor;
					ed_msg.wparam = ASIX_KEY_CANCEL;
					ed_msg.data = ((ASIX_WINDOW *)editor)->ctrl_str;

					AdvSendMessage(GetCurTask()->id, (P_MESSAGE)(&ed_msg), NO_SWAP_TASK);
					break;
				}
				break;
			case WM_QUIT:
				//modified by xh 02/6/7
				if(title_is_saved!=TRUE)
				{
					if( MessageBox( frame, "保存字符串并退出吗?", "警告", MB_OKCANCEL ) == IDOK )
					{
						GetEditorStr( editor, extern_buffer, size );//modified by xh 02/6/7	
						title_is_saved = TRUE;
					}
				}

				quit = TRUE;
				break;

		}
		DefWindowProc(Msg.message, Msg.lparam, Msg.data, Msg.wparam); 		
		
	}
	
	DestroyWindow( frame );
	//EndofTask();
	return ASIX_OK;
}

STATUS CreateMultiEditor( char *caption, char *extern_buffer, U16 size )
{
	U32		frame;
	U32		editor;
	
	U32		left_button;
	U32		right_button;
	
	U32		button_ok;
	U32		button_cancel;
	U32		button_reset;
	
	U32		keyboard;
//	U32		edit_str;	//modified by xh 02/6/7
	
//	U32		editor_areaid;
	
	MSG		Msg, ed_msg;
	
//	int		i;
	
	U8		quit = FALSE;
	
	U32		pGC;
	U8		title_is_saved = FALSE;
	pGC = GetGC();

	frame = CreateWindow(WNDCLASS_WIN, "编辑", WS_OVERLAPPEDWINDOW|WS_SAVESCREEN, 0,0,LCD_WIDTH-1,LCD_HEIGHT-1,0,0,NULL);

	left_button = CreateWindow(WNDCLASS_BUTTON, NULL, WS_CHILD|BS_TOOLBAR, LEFT_BUTTON_X,LEFT_BUTTON_Y,LEFT_BUTTON_WIDTH,LEFT_BUTTON_HEIGHT,frame,0x00140012,left );
	right_button = CreateWindow(WNDCLASS_BUTTON, NULL, WS_CHILD|BS_TOOLBAR, RIGHT_BUTTON_X,RIGHT_BUTTON_Y,RIGHT_BUTTON_WIDTH,RIGHT_BUTTON_HEIGHT,frame,0x00140012,right );
	button_ok = CreateWindow(WNDCLASS_BUTTON, "确定\\确定", WS_CHILD|BS_TOOLBAR, BUTTON_OK_X,BUTTON_OK_Y,BUTTON_OK_WIDTH,BUTTON_OK_HEIGHT,frame,0x00200020,NULL );
	button_cancel = CreateWindow(WNDCLASS_BUTTON, "取消\\取消", WS_CHILD|BS_TOOLBAR, BUTTON_CANCEL_X,BUTTON_CANCEL_Y,BUTTON_CANCEL_WIDTH,BUTTON_CANCEL_HEIGHT,frame,0x00200020,NULL );
	button_reset = CreateWindow(WNDCLASS_BUTTON, "重置\\重置", WS_CHILD|BS_TOOLBAR, BUTTON_RESET_X,BUTTON_RESET_Y,BUTTON_RESET_WIDTH,BUTTON_RESET_HEIGHT,frame,0x00200020,NULL );
	
	keyboard = CreateWindow(WNDCLASS_KEYBD,NULL,WS_CHILD|KBS_PINGYING|0xff,1,(U16)(LCD_HEIGHT-16),(U16)(LCD_WIDTH-2),16,frame,0,NULL);
	Disp16String(caption, 2, 22 );
	editor = CreateWindow(WNDCLASS_EDITOR,NULL,WS_CHILD|ES_MULTI_REGULAR,INPUT_X,INPUT_Y,INPUT_WIDTH,INPUT_HEIGHT+55,frame,size,NULL);

	SetWindowText(editor,extern_buffer,0);
	
	SetFocus(editor);	
	
	while(!quit)  
	{
		
		ASIXGetMessage(&Msg,NULL,0,0);
		
		switch (Msg.message )
		{
			case WM_COMMAND:
				if ( Msg.lparam == left_button )
				{
					ed_msg.message = WM_CHAR;
					ed_msg.lparam = editor;
					ed_msg.wparam = ASIX_KEY_LEFT;
					ed_msg.data = ((ASIX_WINDOW *)editor)->ctrl_str;

					AdvSendMessage(GetCurTask()->id, (P_MESSAGE)(&ed_msg), NO_SWAP_TASK);
					break;
				}		
				else if( Msg.lparam == right_button ) 
				{	
					ed_msg.message = WM_CHAR;
					ed_msg.lparam = editor;
					ed_msg.wparam = ASIX_KEY_RIGHT;
					ed_msg.data = ((ASIX_WINDOW *)editor)->ctrl_str;

					AdvSendMessage(GetCurTask()->id, (P_MESSAGE)(&ed_msg), NO_SWAP_TASK);
					break;
				}
				else if( Msg.lparam == button_ok )
				{
					GetEditorStr( editor, extern_buffer, size );//modified by xh 02/6/7	
					title_is_saved = TRUE;//modified by xh 02/6/7
					quit = TRUE;
					break;
				}
				else if( Msg.lparam == button_cancel )
				{
					quit = TRUE;
					break;	
				}
				else if( Msg.lparam == button_reset )
				{
					ed_msg.message = WM_CHAR;
					ed_msg.lparam = editor;
					ed_msg.wparam = ASIX_KEY_CANCEL;
					ed_msg.data = ((ASIX_WINDOW *)editor)->ctrl_str;

					AdvSendMessage(GetCurTask()->id, (P_MESSAGE)(&ed_msg), NO_SWAP_TASK);
					break;
				}
				break;
			case WM_QUIT:
				//modified by xh 02/6/7
				if(title_is_saved!=TRUE)
				{
					if( MessageBox( frame, "保存字符串并退出吗?", "警告", MB_OKCANCEL ) == IDOK )
					{
						GetEditorStr( editor, extern_buffer, size );//modified by xh 02/6/7	
						title_is_saved = TRUE;
					}
				}

				quit = TRUE;
				break;
		}
		DefWindowProc(Msg.message, Msg.lparam, Msg.data, Msg.wparam); 				
	}
//	ActiveAreaDisable( editor_areaid );	
	DestroyWindow( frame );
	return ASIX_OK;
}

⌨️ 快捷键说明

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