m_index.c
来自「ucOS 模拟环境」· C语言 代码 · 共 749 行 · 第 1/2 页
C
749 行
//----------------------------------------------------------------------
// FileName : M_Index.c
// Project : SII_PHS
// Memo :
//----------------------------------------------------------------------
#ifdef PCVER
#include "assert.h"
#include "memory.h"
#endif
#include "M_MText.h"
#include "keydef.h"
#include "M_Index.h"
#include "draw.h"
#include "M_Data.h"
#include "keyEvent.h"
uchar ucCurrentIndexCode;
uchar ucTopCode;
uchar ucBottomCode;
uchar ucCodeGvram;
uchar ucCurrentIndexItem;
uchar ucTopItem;
uchar ucBottomItem;
uchar ucItemGvram;
uchar ucIndexFlag;
uchar ucCurrentHzItem;
uchar ucTopHz;
uchar ucBottomHz;
uchar ucHzGvram;
uint usHzCount;
unsigned short usHzBuf[512];
uint usCount;
static uchar MIndex_Up();
static uchar MIndex_Down();
static uchar MIndex_Left();
static uchar MIndex_Right();
static uchar MIndex_OutLine();
static uchar MIndex_OutLine();
static void RefIndexCodeMenu(uchar refMode);
static void RefIndexItemMemu(uchar refMode);
static void RefIndexHzMenu(uchar refMode);
static uint MIndexGetHz();
static void MIndexGetHzInfor();
static uchar MIndexGetCurrPY(uchar *ucPingYin);
extern uchar MT_GvRamNo;
Rect IndexArea;
const Rect IndexAreaRecord[2] = { {0,0,47,106}, {64,0,111,106} };
const g_char[MAXCODENUM]={'a','b','c','d','e','f','g','h','j','k','l','m',
'n','o','p','q','r','s','t','w','x','y','z'};
//======================================================================
// Function Name: void MainIndexInit()
// Purpose :
// Parameter :
// Return :
// Remarks :
// Change Log :
// Author Date Description
// -----------------------------------------------
//
//======================================================================
void MainIndexInit()
{
ucIndexFlag = 0;
ucCurrentIndexCode = 0;
ucTopCode = 0;
ucBottomCode = ucTopCode + REFCODENUM ;
ucCurrentIndexItem = 0;
ucTopItem = 0;
ucBottomItem = ucTopItem + REFITEMNUM -1;
ucTopHz = 0;
ucBottomHz = 5;
ucCurrentHzItem = 0;
}
//======================================================================
// Function Name: uchar MainIndex(uint *usTextNo)
// Purpose :
// Parameter :
// Return :
// Remarks :
// Change Log :
// Author Date Description
// -----------------------------------------------
//
//======================================================================
uchar MainIndex(uint *usTextNo)
{
ulong key;
short event;
uchar RefCodeMode;
uchar RefItemMode;
uchar RefHzMode;
event = 0;
MIndex_OutLine();
RefCodeMode = REF_ALL;
RefItemMode = REF_ALL;
RefHzMode = REF_ALL;
while(g_Thread)
{
if(!ucIndexFlag)
{
#ifndef PCVER
Lcdfreeze(1);
#endif
RefIndexCodeMenu(RefCodeMode);
RefIndexItemMemu(RefItemMode);
#ifndef PCVER
Lcdfreeze(0);
#endif
}
else
{
#ifndef PCVER
Lcdfreeze(1);
#endif
RefIndexHzMenu(RefHzMode);
#ifndef PCVER
Lcdfreeze(0);
#endif
}
#ifdef PCVER
UpdateGvram();
#endif
key = GetKey(event);
switch(key)
{
case KEY_DOWN_ENT:
if(!ucIndexFlag)
{
ucIndexFlag = TRUE;
MIndex_OutLine();
MIndexGetHzInfor();
}
else
{
MD_DelGvramArea(ucHzGvram);
DrawOnetext(usHzBuf[ucCurrentHzItem]);
ucIndexFlag = FALSE;
RefCodeMode = REF_ALL;
MainIndexInit();
MIndex_OutLine();
#ifdef PCVER
UpdateGvram();
#endif
}
break;
case KEY_DOWN_RIGHT:
if(!ucIndexFlag)
{
RefCodeMode = MIndex_Right();
if(RefCodeMode != REF_NO)
RefItemMode = REF_ALL;
else if(ucCurrentIndexCode != 'a' || ucCurrentIndexCode != 'A')
RefItemMode = REF_ALL;
else
RefItemMode = REF_NO;
}
else
{
RefHzMode = MIndex_Right();
}
break;
case KEY_DOWN_LEFT:
if(!ucIndexFlag)
{
RefCodeMode = MIndex_Left();
if(RefCodeMode != REF_NO)
RefItemMode = REF_ALL;
else if(ucCurrentIndexCode != 'z'|| ucCurrentIndexCode != 'Z')
RefItemMode = REF_ALL;
else
RefItemMode = REF_NO;
}
else
{
RefHzMode = MIndex_Left();
}
break;
case KEY_DOWN_UP:
if(!ucIndexFlag)
{
RefItemMode = MIndex_Up();
RefCodeMode = REF_NO;
}
else
{
RefHzMode = MIndex_Up();
}
break;
case KEY_DOWN_DOWN:
if(!ucIndexFlag)
{
RefItemMode = MIndex_Down();
RefCodeMode = REF_NO;
}
else
{
RefHzMode = MIndex_Down();
}
break;
case KEY_DOWN_C:
if(ucIndexFlag)
{
ucIndexFlag = FALSE;
MD_DelGvramArea(ucHzGvram);
MainIndexInit();
MIndex_OutLine();
RefHzMode = REF_ALL;
break;
}
else
{
MD_DelGvramArea(ucCodeGvram);
MD_DelGvramArea(ucItemGvram);
return KEY_DOWN_C;
}
default:
#ifdef PCVER
//assert(0);
#endif
break;
}
}
return 1;
}
//======================================================================
// Function Name: uchar MIndex_Up()
// Purpose :
// Parameter :
// Return :
// Remarks :
// Change Log :
// Author Date Description
// -----------------------------------------------
//
//======================================================================
static uchar MIndex_Up()
{
uchar ucCount;
ucTEXT ucText;
if(!ucIndexFlag)
{
ucText.ucChar = g_char[ucCurrentIndexCode];
ucCount = (uchar)MD_GetIndexDataCount(ucText);
if(!ucCurrentIndexItem)
{
ucCurrentIndexItem = ucCount -1;
ucBottomItem= ucCurrentIndexItem;
if(ucCount >= REFITEMNUM)
ucTopItem = ucBottomItem-REFITEMNUM+1;
else
ucTopItem = 0;
return REF_LAST_UP ;
}
if( ucTopItem < ucCurrentIndexItem && ucCurrentIndexItem <= ucBottomItem)
{
ucCurrentIndexItem -= 1;
return REF_LAST_UP ;
}
ucTopItem -= 1;
ucBottomItem -= 1;
ucCurrentIndexItem = ucTopItem;
return REF_LAST_UP ;
}
return 0;
}
//======================================================================
// Function Name: void MIndex_Down()
// Purpose :
// Parameter :
// Return :
// Remarks :
// Change Log :
// Author Date Description
// -----------------------------------------------
//
//======================================================================
static uchar MIndex_Down()
{
uchar ucCount;
ucTEXT ucText;
if(!ucIndexFlag)
{
ucText.ucChar = g_char[ucCurrentIndexCode];
ucCount = (uchar)MD_GetIndexDataCount(ucText);
if(ucCurrentIndexItem >= ucCount -1)
{
ucTopItem = 0;
ucBottomItem = ucTopItem +4;
ucCurrentIndexItem = ucTopItem;
return REF_LAST_UP;
}
if( ucTopItem <= ucCurrentIndexItem && ucCurrentIndexItem < ucBottomItem)
{
ucCurrentIndexItem += 1;
return REF_LAST_UP;
}else
{
ucTopItem += 1;
ucBottomItem += 1;
ucCurrentIndexItem = ucBottomItem;
return REF_LAST_UP;
}
}
return 1;
}
//======================================================================
// Function Name: void MIndex_Left()
// Purpose :
// Parameter :
// Return :
// Remarks :
// Change Log :
// Author Date Description
// -----------------------------------------------
//
//======================================================================
static uchar MIndex_Left()
{
ucTopItem =0;
ucBottomItem =ucTopItem+ 4;
ucCurrentIndexItem = 0;
if(!ucIndexFlag)
{
ucTopItem = 0;
ucBottomItem = ucTopItem + REFITEMNUM -1;
ucCurrentIndexItem = 0;
if(g_char[ucCurrentIndexCode] == 'a' || g_char[ucCurrentIndexCode] == 'A')
{
ucBottomCode = MAXCODENUM -1;
ucTopCode = ucBottomCode - REFCODENUM;
ucCurrentIndexCode = ucBottomCode;
return REF_LEFT;
}
if( ucTopCode < ucCurrentIndexCode && ucCurrentIndexCode <= ucBottomCode)
{
ucCurrentIndexCode -= 1;
return REF_LEFT;
}
else
{
ucTopCode -= 1;
ucBottomCode -= 1;
ucCurrentIndexCode = ucTopCode;
return REF_LEFT;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?