📄 wordmem.c
字号:
/*
* In WordMem.c, We just to create the list for user, when user have chosen the
* list ,then we display the words in the list
*/
#include <stdio.h>
#include <string.h>
#include <sys\sysusr.h>
#include <sys\sysmsg.h>
#include <asixwin.h>
#include <asixapp.h>
#include <asixwin\asix_ed.h>
#include <asixwin\asix_tb.h>
#include <ctype.h>
#include <resource\bitmap.h>
#include "WordM1.h"
#include "List.h"
#include "WordMem.h"
//外部变量的申明
extern LEVEL Lev4,Lev6,LevM;
extern unsigned char *pWordBuf[MAXWORDNUM];
extern unsigned char *pExpBuf[MAXWORDNUM];
/*******************************************************************
* Function: ForthLevDict()
*
* Parameter: void
*
* Description: This Function use to create the window of Forth Level
* Words,and show the list
*
* returns:
*
*********************************************************************/
int ForthLevDict( void )
{
//窗口和控件ID
U32 Dic4mainwin;
U32 Dic4tskbar;
U32 Dic4ListButton[MAXWORDLIST];
U32 Dic4StrollBar;
U32 Button;
//函数变量
MSG msg;
U8 quit = 0;
U32 i,margin = 5;
S16 row = 1;
S16 dragflag = 0;
char *pListBuf;
int counter;
//按钮创建
Dic4mainwin = CreateWindow( WNDCLASS_WIN,
"单元选择",
WS_OVERLAPPEDWINDOW,
0, 0, LCD_WIDTH, LCD_HEIGHT,
0,
0,
NULL);
Dic4tskbar = CreateWindow( WNDCLASS_TSKBAR,
NULL,
WS_CHILD|TBS_TYPICAL,
0, 0, 0, 0,
Dic4mainwin,
0,
NULL);
for(i = 0; i < WM_LIST_NUM; i++)
{
Dic4ListButton[i] = CreateWindow( WNDCLASS_BUTTON,
NULL,
WS_CHILD|BS_BOARD,
margin,
LCD_HEIGHT/8+i*20,
LCD_WIDTH - 2*margin - 20,
20,
Dic4mainwin,
0,
NULL );
}
Dic4StrollBar = CreateWindow( WNDCLASS_SCROLL,
NULL, WS_CHILD|SBS_VERT,
LCD_WIDTH - margin - 20,
LCD_HEIGHT/8, 20,
WM_LIST_NUM*20,
Dic4mainwin,
MAKELONG(1, Lev4.Lindex - WM_LIST_NUM + 1),
NULL);
#ifdef SIM_ON_PC
if((pListBuf = (char *)calloc(WM_LIST_NUM*MAXLISTCHARNUM,sizeof(char)) == NULL)
{
printf("allocation erro!");
exit(1);
}
#else
if((pListBuf = (char *)SysLmalloc(WM_LIST_NUM*MAXLISTCHARNUM)) == NULL)
{
printf("allocation erro in ForthDict() in wordMem.c");
}
#endif
for(i = 0; i < WM_LIST_NUM; i++ )
{
sprintf(pListBuf+i*MAXLISTCHARNUM, "%s%d%c", "List", i + row, '\0');
SetWindowText(Dic4ListButton[i], pListBuf+i*MAXLISTCHARNUM , NULL);
}
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_PENDOWN:
for(i = 0; i < WM_LIST_NUM; i++)/* 判断点击哪个列表 */
{
if(msg.lparam == Dic4ListButton[i])
{
counter = FindWord(4,i+row);
ListWord(4,i+row,counter);
}
}
break;
case WM_VSCROLL:
if(msg.lparam == Dic4StrollBar)
{
switch(msg.wparam)
{
case SB_PAGEUP:
row -= WM_LIST_NUM;
if(row < 1)
row = 1;
break;
case SB_PAGEDOWN:
row += WM_LIST_NUM;
if (row > (Lev4.Lindex - WM_LIST_NUM + 1))
row = (Lev4.Lindex - WM_LIST_NUM + 1);
break;
case SB_LINEUP:
row -= 1;
if(row < 1)
row = 1;
break;
case SB_LINEDOWN:
row += 1;
if(row > (Lev4.Lindex - WM_LIST_NUM + 1))
row = (Lev4.Lindex - WM_LIST_NUM + 1);
break;
case SB_THUMBTRACK:
dragflag = 1;
break;
case SB_ENDSCROLL:
row = GetScrollPos(Dic4StrollBar,0,0,0);
dragflag = 0;
break;
}
if(!dragflag)
{
SetScrollPos(Dic4StrollBar,row,0,0); // 滚动条拖动定位
//显示的更新
for(i = 0; i < WM_LIST_NUM; i++)
{
sprintf(pListBuf+i*MAXLISTCHARNUM,"%s%d%c", "List", row + i, '\0');
SetWindowText( Dic4ListButton[i],
pListBuf+i*MAXLISTCHARNUM,
NULL);
}
SetScrollRange( Dic4StrollBar,
1,
(U16)(Lev4.Lindex - WM_LIST_NUM + 1));
SetScrollPos( Dic4StrollBar, (U16)(row + 1), 0, 0);
}
}
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
free(pListBuf);
DestroyWindow( Dic4mainwin );
return counter;
}
/*******************************************************************
* Function: SixthLevDict()
*
* Parameter: void
*
* Description: This Function use to create the window of Sixth Level
* Words,and show the list
*
* returns:
*
*********************************************************************/
int SixLevDict( void )
{
//窗口和控件ID
U32 Dic6mainwin;
U32 Dic6tskbar;
U32 Dic6ListButton[MAXWORDLIST];
U32 Dic6StrollBar;
U32 Button;
//函数变量
MSG msg;
U8 quit = 0;
U32 i,margin = 5;
S16 row = 1;
S16 dragflag = 0;
char ListBuf[WM_LIST_NUM][MAXLISTCHARNUM];
int counter;
//按钮创建
Dic6mainwin = CreateWindow( WNDCLASS_WIN,
"单元选择",
WS_OVERLAPPEDWINDOW,
0, 0, LCD_WIDTH, LCD_HEIGHT,
0,
0,
NULL );
Dic6tskbar = CreateWindow( WNDCLASS_TSKBAR,
NULL,
WS_CHILD|TBS_TYPICAL,
0, 0, 0, 0,
Dic6mainwin,
0,
NULL );
for(i = 0; i < WM_LIST_NUM; i++)
{
Dic6ListButton[i] = CreateWindow( WNDCLASS_BUTTON,
NULL,
WS_CHILD|BS_BOARD,
margin,
LCD_HEIGHT/8+i*20,
LCD_WIDTH - 2*margin - 20,
20,
Dic6mainwin,
0,
NULL );
}
Dic6StrollBar = CreateWindow( WNDCLASS_SCROLL,
NULL, WS_CHILD|SBS_VERT,
LCD_WIDTH - margin - 20,
LCD_HEIGHT/8,
20,
WM_LIST_NUM*20,
Dic6mainwin,
MAKELONG(1, Lev6.Lindex - WM_LIST_NUM + 1),
NULL );
for(i = 0; i < WM_LIST_NUM; i++ )
{
sprintf(ListBuf[i], "%s%d%c", "List", i + row, '\0');
SetWindowText(Dic6ListButton[i], ListBuf[i] , NULL);
}
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_PENDOWN:
for(i = 0; i < WM_LIST_NUM; i++) /*判断点击哪个列表并显示颜色*/
{
if(msg.lparam == Dic6ListButton[i])
{
counter = FindWord(6,i+row);
ListWord(6,i+row,counter);
}
}
break;
case WM_VSCROLL:
if(msg.lparam == Dic6StrollBar)
{
switch(msg.wparam)
{
case SB_PAGEUP:
row -= WM_LIST_NUM;
if(row < 1)
row = 1;
break;
case SB_PAGEDOWN:
row += WM_LIST_NUM;
if(row > (Lev6.Lindex - WM_LIST_NUM + 1))
row = (Lev6.Lindex - WM_LIST_NUM + 1);
break;
case SB_LINEUP:
row -= 1;
if(row < 1)
row = 1;
break;
case SB_LINEDOWN:
row += 1;
if(row > (Lev6.Lindex - WM_LIST_NUM + 1))
row = (Lev6.Lindex - WM_LIST_NUM + 1);
break;
case SB_THUMBTRACK:
dragflag = 1;
break;
case SB_ENDSCROLL:
row = GetScrollPos(Dic6StrollBar,0,0,0);
dragflag = 0;
break;
}
if(!dragflag)
{
SetScrollPos(Dic6StrollBar,row,0,0); /* 滚动条拖动定位*/
//显示的更新
for(i = 0; i < WM_LIST_NUM; i++)
{
sprintf(ListBuf[i],"%s%d%c", "List", row + i, '\0');
SetWindowText( Dic6ListButton[i],
ListBuf[i],
NULL);
}
SetScrollRange( Dic6StrollBar,
1,
(U16)(Lev6.Lindex - WM_LIST_NUM + 1));
SetScrollPos( Dic6StrollBar, (U16)(row + 1), 0,0);
}
}
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( Dic6mainwin );
return counter;
}
/*******************************************************************
* Function: MasterLevDict()
*
* Parameter: void
*
* Description: This Function use to create the window of Master Level
* Words,and show the list
*
* returns:
*
*********************************************************************/
int MasterLevDict( void )
{
//窗口和控件ID
U32 DicMmainwin;
U32 DicMtskbar;
U32 DicMListButton[MAXWORDLIST];
U32 DicMStrollBar;
U32 Button;
//函数变量
MSG msg;
U8 quit = 0;
U32 i,margin = 5;
S16 row = 1;
S16 dragflag = 0;
char ListBuf[WM_LIST_NUM][MAXLISTCHARNUM];
int counter ;
//按钮创建
DicMmainwin = CreateWindow( WNDCLASS_WIN,
"单元选择",
WS_OVERLAPPEDWINDOW,
0, 0, LCD_WIDTH, LCD_HEIGHT,
0,
0,
NULL );
DicMtskbar = CreateWindow( WNDCLASS_TSKBAR,
NULL,
WS_CHILD|TBS_TYPICAL,
0, 0, 0, 0,
DicMmainwin,
0,
NULL);
for(i = 0; i < WM_LIST_NUM; i++)
{
DicMListButton[i] = CreateWindow( WNDCLASS_BUTTON,
NULL,
WS_CHILD|BS_BOARD,
margin,
LCD_HEIGHT/8+i*20,
LCD_WIDTH - 2*margin - 20,
20,
DicMmainwin,
0,
NULL );
}
DicMStrollBar = CreateWindow( WNDCLASS_SCROLL,
NULL,
WS_CHILD|SBS_VERT,
LCD_WIDTH - margin - 20,
LCD_HEIGHT/8,
20,
WM_LIST_NUM*20,
DicMmainwin,
MAKELONG(1, LevM.Lindex - WM_LIST_NUM + 1),
NULL );
for(i = 0; i < WM_LIST_NUM; i++ )
{
sprintf(ListBuf[i], "%s%d%c", "List", i + row, '\0');
SetWindowText(DicMListButton[i], ListBuf[i] , NULL);
}
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_PENDOWN:
for(i = 0; i < WM_LIST_NUM; i++) /* 判断点击哪个列表并 */
{
if(msg.lparam == DicMListButton[i])
{
counter = FindWord(10,i+row);
ListWord(10,i+row,counter) ;
}
}
break;
case WM_VSCROLL:
if(msg.lparam == DicMStrollBar)
{
switch(msg.wparam)
{
case SB_PAGEUP:
row -= WM_LIST_NUM;
if(row < 1)
row = 1;
break;
case SB_PAGEDOWN:
row += WM_LIST_NUM;
if(row > (LevM.Lindex - WM_LIST_NUM + 1))
row = (LevM.Lindex - WM_LIST_NUM + 1);
break;
case SB_LINEUP:
row -= 1;
if(row < 1)
row = 1;
break;
case SB_LINEDOWN:
row += 1;
if(row > (LevM.Lindex - WM_LIST_NUM + 1))
row = (LevM.Lindex - WM_LIST_NUM + 1);
break;
case SB_THUMBTRACK:
dragflag = 1;
break;
case SB_ENDSCROLL:
row = GetScrollPos(DicMStrollBar,0,0,0);
dragflag = 0;
break;
}
if(!dragflag)
{
SetScrollPos(DicMStrollBar,row,0,0); // 滚动条拖动定位
//显示的更新
for(i = 0; i < WM_LIST_NUM; i++)
{
sprintf(ListBuf[i],"%s%d%c", "List", row + i, '\0');
SetWindowText( DicMListButton[i],
ListBuf[i],
NULL);
}
SetScrollRange( DicMStrollBar, 1,
(U16)(LevM.Lindex - WM_LIST_NUM + 1) );
SetScrollPos( DicMStrollBar, (U16)(row + 1), 0,0);
}
}
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( DicMmainwin );
return counter;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -