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

📄 dialog_1000msgproc.c

📁 arena SDK开发应用
💻 C
字号:
/*******************************************************************************
*  COPYRIGHT DaTang Mobile Communications Equipment CO.,LTD                    *
********************************************************************************
* Filename	 : 		Dialog_1000MsgPro.c					
*
* Description: 
* Notes		 : NA                                       
*******************************************************************************/

#include "UIResource.h"
#include <de_api.h>
#include "MotechDict.h"
#include <multimedia.h>
#include <os_file_api.h>


#define MAX_CONTENT_SIZE		2048
#define MAX_LISTITEM_SIZE		12
#define MAX_FILE_NUM 7  /******* 20061130 wangjf ********/
#define MAX_BUF_NUM				2048
#define TIMER_COUNT				400
#define IDC_TIMER_RECITE		100
#define MAX_LINE_SIZE           80

//add dengll 07.10.16
typedef struct STOP_APP_CTRL_INFO_
{
  APP_ID id;
  VOID* add_data;   
}APP_STOP_CTRL_INFO;

APP_STOP_CTRL_INFO g_ctrl_info;

static int g_nState = 0;

//小图标的logo图片大小为16*16 and 2 bytes/pixel
//文本图标
const static unsigned char bmp_app2_bits [] = {
		0x1f, 0xf8, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 
		0xe0, 0x60, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xe0, 0x60, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 
		0xe0, 0x60, 0xfd, 0xff, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0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f8, 0x1f, 0xf8, 
		0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0xe0, 0x60, 0xe0, 0x60, 0x13, 0xf7, 0x13, 0xf7, 0x13, 0xf7, 0x13, 0xf7, 0x13, 0xf7, 0x13, 0xf7, 0x13, 0xf7, 0xe0, 0x60, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 
		0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0xe0, 0x60, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 
};
const BITMAP bmp_text = {
    0x10, 0x10, 0x02, 0x00,
		0x0000f81f,
		0x0000001D, 0x00000060, 0x00000020,
		(void*)bmp_app2_bits
};
//焦点单词
unsigned short g_szFocusWord[MAX_WORD_SIZE];

//unsigned short g_szContent[MAX_CONTENT_SIZE];
DWORD	g_CurWordID;
typedef struct _RichTextItem 
{
	DWORD	dwType;  // 文字的类型
	CHAR*	pText;   // 文字的指针
	long	lLength; // 该行的长度
	long	lLine;   // 所在的行
	long	lX0;     // 输出时的开始位置

} RichTextItem;

typedef struct _ReciteOption
{
	int nFileIndex;//选取的单词库文件下标 /**/
	DWORD chBegCh;//开始字母 /**/
	DWORD chEndCh;//结束字母 /**/
	BOOL bPronouce;//发音与否/**/
	int nTimerCount;//背诵单词时间间隔 /**/

	BOOL bPlay;//播放与否
	int	nBegWordIndex;//背诵单词的首单词下标
	int	nCurWordIndex;//背诵单词的当前单词的下标
	int	nEndWordIndex;//背诵单词的结束单词下标
	int	nCount;// timer循环次数
	int	nTotalWordNum;//总共的单词数目

}ReciteOption;
ReciteOption g_ReciteOption;



unsigned short g_szFocusWord[MAX_WORD_SIZE];//当前的焦点单词
unsigned short g_szContent[MAX_CONTENT_SIZE];//当前单词的解释
DWORD			g_CurWordID;//当前列表单词的ID标示
//static int		Flag_NewWord = 0 ;
static	unsigned short g_szCurWord[MAX_WORD_SIZE];
static	unsigned short g_szOutputBuf[MAX_BUF_NUM];
static	unsigned short g_szPhonetic[40];
MAN_MM_AUDIO_PARAM	g_mAuo;//播放器设置参数

char g_ReciteList[][10] = {"cet4","cet6","gre","toefl","gz","ielts","gmat"};


HWND g_szDialog1hWnd[4] = {HWND_INVALID,HWND_INVALID,HWND_INVALID,HWND_INVALID};
int g_Dlg1hWndIndex = 0;


HWND g_szDialog2hWnd[6] = {HWND_INVALID,HWND_INVALID,HWND_INVALID,HWND_INVALID,HWND_INVALID,HWND_INVALID};//背诵单词中的控件句柄
int g_Dlgh2WndIndex = 0;


HWND g_szDialog3hWnd[7] = {HWND_INVALID,HWND_INVALID,HWND_INVALID,HWND_INVALID,HWND_INVALID,HWND_INVALID,HWND_INVALID};
int g_Dlg3hWndIndex = 0;






// 初始化字典主界面(第一个界面)
static SINT32 OnMainInitDialog(HWND hWnd,WPARAM w,LPARAM l)
{

	WORD wInWord[MAX_WORD_SIZE] = {0}, wOutWord[MAX_WORD_SIZE] = {0};
	CHAR szWord[MAX_WORD_SIZE] = {0};

	DLCITOR itor = INVALID_ITOR;
    ListExItem item_st = {0};
	CHAR text[MAX_WORD_SIZE] = {0};
	SINT32 i = 0;
	ListExSkin NewSkin = {0};
	SKINTYPE skt = 0;
	unsigned short wTempWord[MAX_WORD_SIZE] = {0};
	const CHAR *pCurWord = NULL;
//	CHAR szContent[1024];
	CHAR *pWchar = (char *)wTempWord;
	unsigned char ch = 0;
	BOOL bFlag = FALSE;

	
	g_CurWordID = 0;
	// 初始化发音引擎 tts
	DDE_InitTTS();
	// 初始化引擎 engine
	if ( !DDE_InitDDEngine() )
		return -1;
	//初始化发音设备tp
	bFlag =  tp_man_mm_audio_init();
	if (OS_SUCCESS != bFlag)
	{
		MessageBox(hWnd,"tp_man_mm_audio_init fail !","error",MB_OK);
	}


	wInWord[0] = 0;
	DDE_SearchWord( wInWord, wOutWord );
	
    g_szDialog1hWnd[0] = GetDlgItem( hWnd, IDC_LISTCTRLEX_1006 );// 列表框
	g_szDialog1hWnd[1] = GetDlgItem(hWnd,IDC_SLEDIT_1008);//编辑框
//	g_szDialog1hWnd[2] = GetDlgItem(hWnd,IDC_BUTTON_1003);//查找
	g_szDialog1hWnd[2] = GetDlgItem(hWnd,IDC_BUTTON_1004);//上一个
	g_szDialog1hWnd[3] = GetDlgItem(hWnd,IDC_BUTTON_1005);//下一个

	/*clean all and add*/
	LEClearAll( g_szDialog1hWnd[0] );
	/*add Items to show*/
    for ( i = 0; i < MAX_LISTITEM_SIZE; i++ )
    {
			memset(wTempWord,0x00,MAX_WORD_SIZE);
			DDE_GetWord( i, wTempWord );
			tp_sc_unicode_to_gbk( wTempWord, MAX_WORD_SIZE,text,MAX_WORD_SIZE );

            item_st.nID = i;
            item_st.dwItemData = i;
            item_st.szInfo = N_("ListItem_info");
            item_st.szText = (CONST CHAR*)(text);
			//item_st.pLogoBmp = &bmp_text;
			//item_st.pCurselLogoBmp = &bmp_text;

    		itor = LEAddItem(g_szDialog1hWnd[0], &item_st, itor);
			LEEnsureItemVisible(g_szDialog1hWnd[0],itor);
    }
	NewSkin.pBmpBkGnd = &bmp_text;

	LESetCtrlSkin( &NewSkin, skt);


	/*set current select */
	itor = LEGetFirst( g_szDialog1hWnd[0] );
	bFlag = LESetCurSel( g_szDialog1hWnd[0], itor);
	SetFocusChild(g_szDialog1hWnd[0]);  


	return DefaultMainWinProc(hWnd, MSG_INITDIALOG, w, l);
}



// 从菜单界面返回
static SINT32 OnMotechDictmenukeydown(HWND hWnd,WPARAM wparam,LPARAM lparam)
{

	switch ( wparam )
	{
	    case KEY_RSK:
	    	DestroyMainWindowIndirect(hWnd);
	    	return 0;
	    	
	    default:
	    	break;
	}

	return DefaultMainWinProc(hWnd, MSG_KEYDOWN, wparam, lparam);
}



//创建菜单函数,有“背诵单词”、“帮助“...等选项。问题就出在该函数调用。
SINT32 Motech_create_menu(HWND hWnd, SINT32 index)
{
	SINT32 num = 0;
	HWND ret = HWND_INVALID;
	


	BEGIN_STATIC_MSGMAP(main_wnd_maps)
         MAPMESSAGE(MSG_KEYDOWN,OnMotechDictmenukeydown)
	END_STATIC_MSGMAP(main_wnd_maps)


	ListExItem main_item_a[] = {
	    {MOTECHDICT_STR_RECITE,N_(""),NULLPTR,0,0},
	    {MOTECHDICT_STR_HELP,N_(""),NULLPTR,1,1},
		{MOTECHDICT_STR_ABOUT,N_(""),NULLPTR,2,2},
	    {MOTECHDICT_STR_DELETE,N_(""),NULLPTR,3,3},
	    };


	num = sizeof(main_item_a)/sizeof(main_item_a[0]);


	ret = app_simple_list_create( hWnd,
							APP_STR_OPTIONS,
							APP_STR_SELECT,
							APP_STR_BACK,
							main_item_a,
							num,
							&main_wnd_maps,
							(DWORD)index);
	if ( HWND_INVALID == ret )
	{
		return APP_ERR_FAILURE;
	}

	return APP_ERR_SUCCESS;
}



// 字典主界面事件处理:创建菜单界面
static SINT32 OnMotechDictMainKeyDown(HWND hWnd,WPARAM wparam,LPARAM lparam)
{
	HWND list =  HWND_INVALID;
	DLCITOR itor = INVALID_ITOR;
	SINT32 index = 0;
	SINT32 iCount=0;
	HWND hwnd_child=HWND_INVALID;

	unsigned short szWtemp[MAX_WORD_SIZE] = {0};
	char szText[MAX_WORD_SIZE] = {0};
	int i = 0;
	int itor1,itor2;
	int nID = -1;


	switch ( wparam )
	{
		case KEY_OK:
	    case KEY_LSK://左软键
	    {


			list = GetDlgItem( hWnd, IDC_SIMPLE_LISTEX );
			if ( HWND_INVALID == list )
			{
				return -1;
			}

			itor = LEGetCurSel( list );
			if ( INVALID_ITOR == itor )
			{
				return -1;
			}

			index = LEGetItemID( list, itor);

			Motech_create_menu(hWnd, index);  //创建菜单

	   	}
	    	break;


	    default:
	    	break;
	}

	return DefaultMainWinProc(hWnd, MSG_KEYDOWN, wparam, lparam);
}



SINT32 OnMainDestroy(HWND hWnd, WPARAM wparam, LPARAM lparam)
{


	return app_simple_list_default_destroy(hWnd,wparam,lparam);
}


// 程序入口
HWND MotechDict_create_main_window(HWND hParentWnd)
{
	HWND hWnd = HWND_INVALID;
	BEGIN_STATIC_MSGMAP(Main_Dialog_maps)
		MAPMESSAGE(MSG_INITDIALOG,OnMainInitDialog)
		MAPMESSAGE(MSG_KEYDOWN,OnMotechDictMainKeyDown)
		MAPMESSAGE(MSG_DESTROY,OnMainDestroy)
	END_STATIC_MSGMAP(Main_Dialog_maps)

	hWnd = tp_resource_window_create( hParentWnd,(LPARAM)NULL,&Main_Dialog_maps,DIALOG_1000_PATH,"Dialog_1000",0);
	
	if(HWND_INVALID==hWnd)
	{
		return APP_ERR_FAILURE;
	}

	return hWnd;
}


⌨️ 快捷键说明

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