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

📄 textinput.c

📁 brew 文件浏览器实现,是纯c编写的
💻 C
字号:
//////////////////////////////////////////////////////////////////////////
//TextInput.c
//////////////////////////////////////////////////////////////////////////

#include "TextInput.h"
 // handle key event.
static boolean TextInput_HandleKeyEvent(TextInput* pthis,uint16 wParam);
 //handle command event.
static boolean TextInput_HandleCommandEvent(TextInput* pthis, uint16 wParam,uint32 dwParam);
 //handle pen event
static boolean TextInput_HandlePenEvent(TextInput* pthis,uint32 dwParam);
 //update screen
static void TextInputUpdate(TextInput* pthis); 


/************************************************************************
初始化文本输入框数据。
	@pthis文本框内部数据结构。
	@pMe主程序内部数据结构。
	@返回是否成功初始化。
************************************************************************/
boolean TextInputNew(TextInput* pthis,MainMenu *pMe)
{
	pthis->pMe=pMe;
	pthis->id=0;
	pthis->itext=(char*)MALLOC(sizeof(char)*AEE_MAX_FILE_NAME);

	if (pthis->itext == NULL) 
	{
		return FALSE;
	}

	pthis->text=NULL;

}


/************************************************************************
创建文本输入框界面。
	@pthis文本输入框内部数据结构。
	@返回是否创建成功。
************************************************************************/
boolean TextInputOpen(TextInput* pthis)
{

	AECHAR wp[AEE_MAX_FILE_NAME]={0};
    AEERect rect;
	uint16 fh=0;
	uint16 fw=0;


	if (SUCCESS != ISHELL_CreateInstance(pthis->pMe->a.m_pIShell,
		AEECLSID_TEXTCTL,(void**)&pthis->text))
	{
		return FALSE;
	}

	//set text control rect.

	rect.x=10;
	rect.y=10;
	rect.dx=pthis->pMe->xScreen-10;
	rect.dy=pthis->pMe->yScreen/2;

	ITEXTCTL_SetRect(pthis->text);

	if ((fh=IDisplay_GetFontMetrics(pthis->pMe->a.m_pIDisplay,AEE_FONT_NORMAL,0,0)) == EFAILED) 
	{
             fh=15; // if get font height failue,then set default height 15.
	}


	//draw softkey 
	if (0 != ISHELL_LoadResString(pthis->pMe->a.m_pIShell,RES_FILE,
		IDS_MENU_OK,wp,sizeof(wp)))
	{
       IDISPLAY_DrawText(pthis->pMe->a.m_pIDisplay,AEE_FONT_NORMAL,wp,
		   -1,0,pthis->pMe->yScreen-fh-1);      
	}


	if (0 != ISHELL_LoadResString(pthis->pMe->a.m_pIShell,RES_FILE,IDS_MENU_CANCEL,
		wp,sizeof(wp))) 
	{
		if ((fw=IDISPLAY_MeasureText(pthis->pMe->a.m_pIDisplay,AEE_FONT_NORMAL,wp)) != 0)
		{
			fw=20; //if get font width failue,then set default 20.
		}

		IDISPLAY_DrawText(pthis->pMe->a.m_pIDisplay,AEE_FONT_NORMAL,wp,-1,
			pthis->pMe->xScreen-fw,pthis->pMe->yScreen-fh-1);
	}
	
     
	TextInputUpdate(pthis);
	
	return TRUE;
	
}

/************************************************************************
更新窗口。
	@pthis文本输入框数据结构。
************************************************************************/
static void TextInputUpdate(TextInput* pthis)
{
	ITEXTCTL_SetActive(pthis->text);
	ITEXTCTL_Redraw(pthis->text);
}

/************************************************************************
文本输入框事件处理。
	@pthis文本框内部数据结构。
	@eCode事件类型。
	@wParam,dwParam事件附带数据。
	@返回是否对事件进行处理。
************************************************************************/
boolean TextInput_HandleEvent(TextInput* pthis,AEEEvent eCode,uint16 wParam,uint32 dwParam)
{
	switch(eCode) {
	case EVT_COMMAND:
		return TextInput_HandleCommandEvent(pthis,wParam,dwParam);
	case EVT_KEY:
        if ((wParam==EVK_SOFT1) || (dwParam==EVK_SOFT2)) 
		{
		return	TextInput_HandleKeyEvent(pthis,wParam);
        }
		else
		{
			return ITEXTCTL_HandleEvent(pthis->text,eCode,wParam,dwParam);
		}
	case EVT_APP_SUSPEND:
		return TRUE;
    case  EVT_APP_RESUME:
        TextInputUpdate(pthis);
		return TRUE;
	default:
		return FALSE;
	}

	return FALSE;
}

/************************************************************************
文本框按键处理函数。
	@pthis文本框内部数据结构。
	@wParam按键的键码。
	@返回是否处理了事件。
************************************************************************/
static boolean TextInput_HandleKeyEvent(TextInput* pthis,uint16 wParam)
{
	return FALSE;
}

/************************************************************************
指针事件处理。
	@pthis文本框数据结构。
	@dwParam前16位是y坐标,后16位是x坐标。
	@返回是否已经对消息进行处理了。
************************************************************************/
static boolean TextInput_HandlePenEvent(TextInput* pthis,uint32 dwParam)
{
	return FALSE;
}

/************************************************************************
关闭文本输入窗口.
	@pthis文本框的数据结构。
************************************************************************/
void TextInputClose(TextInput* pthis)
{
	if (pthis->text) {
		ITEXTCTL_Release(pthis->text);
	}

}


/************************************************************************
释放文本框申请的资源。
	@pthis文本框的数据结构。
************************************************************************/
void TextInputRelease(TextInput* pthis)
{
    if (pthis->itext) {
		FREEIF(pthis->itext);
    }

}

⌨️ 快捷键说明

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