📄 phedit.c
字号:
/**********************************************************
*
*Copyright ? 2001-2003 National ASIC Center, All right Reserved
*
* FILE NAME: Phedit.c
* PROGRAMMER: Christian-ren
* Date of Creation: 2002/08/28
*
* DESCRIPTION: PHONEBOOK module,focus on EDIT module
*
* NOTE:
*------------------------------------------------------------------
* FUNCTIONS LIST:
* -- PUBLIC FUNCTIONS --
*
*------------------------------------------------------------------
* -- LOCAL FUNCTIONS --
* STATUS PhBookEditDisplay(P_S8 * recordinf,P_S8 * cueinf, U16 len, S16 startpos, S16 endpos, U32 *editor,U32 *st)
* void DispIndex(U32 *btindex,INDEXSTATE state,U8 ctel,U8 cmob,U8 cbp)
* void SelectCall(U32 hGC,P_S8 text,P_S8 inf1,P_S8 inf2,P_S8 inf3,P_S8 inf4,SELECTITEM * selitemptr)
* void AddRecordItem(P_S8 *recordinf,P_S8 *cueinf,PHONESTYLE phonstyle,S8 ctel,S8 cmob,S8 cbp)//在某个位置之后添加
* void DelRecordItem(P_S8 *recordinf,P_S8 *cueinf,PHONESTYLE phonstyle,S8 ctel,S8 cmob,S8 cbp,SELECTITEM select)//在某个位置之后添加
* void SaveEditorInfToReordinf(U32 *editor,P_S8 *recordinf,U16 startp)
* U8 EditDetailNote(PHONEBOOK * thisptr, ACCESSSTYLE mode ,U8 PhStyle,U8 *wintext,SAVEMODE savemode,U32 hGC)
* STATUS DispSetSelCallItem(U32 *bt,P_S8 inf1,P_S8 inf2,P_S8 inf3,P_S8 inf4)
*------------------------------------------------------------------
*
* GLOBAL VARS LIST:
* DBLACB *phbooklacb; //定义一个数据库控制块的变量
*-------------------------------------------------------------------
*
* MODIFICATION HISTORY
*
*
* 2002/08/28 by Christian-ren Create the file
*
*************************************************************/
#include <string.h>
#include <asixwin.h>
#include <asixapp.h>
#include <asixwin\asix_lb.h>
#include <asixwin\asix_ed.h>
#include <asixwin\button.h>
#include <resource\bitmap.h>
#include "phbook.h"
#include <database\carddb.h>
extern void AddRecordToDB(PHONEBOOK *thisptr,SAVEMODE mode,DBLACB *phbooklacb);
extern void CompareModAndSrc(PHONEBOOK *thisptr,P_S8 *recordinf,U8 ctel,U8 cmob,U8 cbp,P_U8 ismodfptr);
extern STATUS SaveModfToSrc(PHONEBOOK *thisptr,P_S8 * recordinf,U8 ctel,U8 cmob,U8 cbp);
//extern DBLACB *phbooklacb;
//是在编辑模块中调用
STATUS PhBookEditDisplay(P_S8 * recordinf,P_S8 * cueinf, U16 len, S16 startpos, S16 endpos, U32 *editor,U32 *st)
// displaylist是现在需要显示的记录类,listlen是此记录的长度,
//startpos,endpos 分别是链表显示信息的起始和终止记录
//bt是显示记录button的ID,
{
U16 count;
// U32 btstatus;
// S16 status;
for(count = 0; count < DISP_EDIT_NUM; count++)
{
//status = GetWindowStatus ( *editor, &btstatus );
if(*editor != 0) //如果是此记录的控件存在
{
SetWindowText(*editor, NULL, NULL);
}
SetWindowText(*st, "", NULL);
EnableWindow(*editor,FALSE);
editor++;
st++;
}
editor -= DISP_EDIT_NUM;//XXXX需要注意暂时先显示8个记录,以后要变成9个
st -= DISP_EDIT_NUM;
if(len <= 0)
{
SetWindowText(*editor, " 此记录为空", NULL);
return ASIX_OK;
}
for(count = startpos; count < endpos; count++)
{
// status = GetWindowStatus ( *editor, &btstatus );
if(*editor != 0) //如果是此记录的控件存在
{
EnableWindow(*editor, TRUE);
SetWindowText(*editor, *(recordinf+count), NULL);
}
SetWindowText(*st, *(cueinf+count),NULL);
editor++;
st++;
}
return ASIX_OK;
}
void DispIndex(U32 *btindex,INDEXSTATE state,U8 ctel,U8 cmob,U8 cbp)
{
U8 count;
U32 hGC;
hGC = GetGC();
//GroupOn(hGC);
for(count = 0; count < PHBOOK_INDEXNUM; count++)
{
SetWindowText(*btindex, NULL, NULL);
EnableWindow(*btindex,FALSE);
btindex++;
}
btindex -=PHBOOK_INDEXNUM;
if(state ==NEW_ITEM)
{
EnableWindow(*btindex,TRUE);
//SetWindowText(*btindex++, "固话", NULL); //注意将来是需要贴图XXXX
SetWindowText(*btindex++, "\\固话", (char*)zi_phone);
EnableWindow(*btindex,TRUE);
SetWindowText(*btindex++, "\\手机",(char*)zi_mobile);
EnableWindow(*btindex,TRUE);
SetWindowText(*btindex++, "\\寻呼",(char*)zi_bp);
EnableWindow(*btindex,FALSE);
SetWindowText(*btindex++, "\\姓名",(char*)zi_name);
EnableWindow(*btindex,FALSE);
SetWindowText(*btindex++, "\\关系",(char*)zi_relation);
}else
if(state ==DEL_ITEM) //如果是存在此记录
{
SetWindowText(*btindex,"\\固话", (char*)zi_phone); //注意将来是需要贴图XXXX
if(ctel !=0)
{
EnableWindow(*btindex,TRUE);
}
btindex++;
SetWindowText(*btindex, "\\手机",(char*)zi_mobile);
if(cmob != 0)
{
EnableWindow(*btindex,TRUE);
}
btindex++;
SetWindowText(*btindex, "\\寻呼",(char*)zi_bp);
if(cbp != 0)
{
EnableWindow(*btindex,TRUE);
}
btindex++;
EnableWindow(*btindex,FALSE);
SetWindowText(*btindex++, "\\姓名",(char*)zi_name);
EnableWindow(*btindex,FALSE);
SetWindowText(*btindex++, "\\关系",(char*)zi_relation);
}else
if(state == EDIT_ITEM)
{
SetWindowText(*btindex,"\\固话", (char*)zi_phone); //注意将来是需要贴图XXXX
if(ctel !=0)
{
EnableWindow(*btindex,TRUE);
}
btindex++;
SetWindowText(*btindex, "\\手机",(char*)zi_mobile);
if(cmob != 0)
{
EnableWindow(*btindex,TRUE);
}
btindex++;
SetWindowText(*btindex, "\\寻呼",(char*)zi_bp);
if(cbp != 0)
{
EnableWindow(*btindex,TRUE);
}
btindex++;
EnableWindow(*btindex,TRUE);
SetWindowText(*btindex++, "\\姓名",(char*)zi_name);
EnableWindow(*btindex,TRUE);
SetWindowText(*btindex++, "\\关系",(char*)zi_relation);
}
// GroupOff(hGC, 4, 163, 158, 206);
}
STATUS DispSetSelCallItem(U32 *bt,P_S8 inf1,P_S8 inf2,P_S8 inf3,P_S8 inf4)
{
U8 count;
for(count = 0; count < SELCALLNUM; count++)
{
SetWindowText(*bt, NULL, NULL);
EnableWindow(*bt,FALSE);
bt++;
}
bt -= SELCALLNUM;
//if((inf1 !=NULL)&&(*inf1!=NULL))
if(inf1 !=NULL)
{
EnableWindow(*bt,TRUE);
SetWindowText(*bt, inf1, NULL);
}
bt++;
// if((inf2 !=NULL)&&(*inf2!=NULL))
if(inf2 !=NULL)
{
EnableWindow(*bt,TRUE);
SetWindowText(*bt, inf2, NULL);
}
bt++;
// if((inf3 !=NULL)&&(*inf3!=NULL))
if(inf3 !=NULL)
{
EnableWindow(*bt,TRUE);
SetWindowText(*bt, inf3, NULL);
}
bt++;
// if((inf4 !=NULL)&&(*inf4!=NULL))
if(inf4 !=NULL)
{
EnableWindow(*bt,TRUE);
SetWindowText(*bt, inf4, NULL);
}
return ASIX_OK;
}
//输入选择是下拉框,以后需要用选择框XXXXX
void SelectCall(P_S8 text,P_S8 inf1,P_S8 inf2,P_S8 inf3,P_S8 inf4,SELECTITEM * selitemptr)
{
//可以考虑添加参数输入号码的记录
MSG msg;
U32 hGC;
U32 selcallwin,bt1,bt2,st;
U8 quit = 0;
SELECTITEM tmpselect;
U32 bt[SELCALLNUM];
U8 count;
U8 sel_bt = SELCALLNUM;
hGC = GetGC();
// GroupOn(hGC);
selcallwin = CreateWindow(WNDCLASS_WIN,
"提示信息",
WS_OVERLAPPEDWINDOW,
0,0,
PHY_LCD_W,PHY_LCD_H,
0,
0,
NULL);
bt1 = CreateWindow( WNDCLASS_BUTTON,
"确定",
WS_CHILD|BS_REGULAR,
35,180,
30,
20,
selcallwin,
0,
NULL);
bt2 = CreateWindow( WNDCLASS_BUTTON,
"取消",
WS_CHILD|BS_REGULAR,
80,180,
30,
20,
selcallwin,
0,
NULL);
st = CreateWindow(WNDCLASS_STATIC, //提示信息
text,
WS_CHILD|SS_TEXT|SS_MULTILINE,
35,36,
100,
22,
selcallwin,
0,
NULL);
for(count = 0; count < SELCALLNUM; count++)
{
bt[count] = CreateWindow(WNDCLASS_BUTTON,
NULL,
WS_CHILD|BS_TOOLBAR,
10,
(U16)(count * 21 + 68),
138,
21,
selcallwin,
0,
NULL);
}
hGC = GetGC();
EnableWindow(bt1, FALSE);
DispSetSelCallItem(bt,inf1,inf2,inf3,inf4);
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
if ( msg.lparam == bt1 )
{
*selitemptr = tmpselect;
quit = 1;
} else
if( msg.lparam == bt2 )
{
*selitemptr = CANCEL_SEL;
quit = 1;
}
for(count=0;count<SELCALLNUM;count++)
{
if(msg.lparam == bt[count])
{
if(sel_bt == SELCALLNUM)
{
//
}else{
//RepaintWindow(bt[sel_bt], BS_INVERT);
RepaintWindow(bt[sel_bt], BS_INVERT); //选中则返黑
}
tmpselect = count+1;
EnableWindow( bt1, TRUE);
sel_bt=count;
break;
}
}
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( selcallwin );
}
//不仅需要在记录内容中添加数据
//而且需要在提示框中添加空的数据
void AddRecordItem(P_S8 *recordinf,P_S8 *cueinf,PHONESTYLE phonstyle,S8 ctel,S8 cmob,S8 cbp)//在某个位置之后添加
{
U8 count;
P_S8 *tmpptr =recordinf;
U8 countall = ctel+cmob+cbp+2;
switch(phonstyle)
{
case TELEPHONE:
if(ctel>=MAXTELNUM) break;
else{
for(count=(countall);count>(1+ctel);count--)//需要确定是>= or >
{
// *(tmpptr+count) = *(tmpptr+count-1);//XXXXX modified on 0920
*(cueinf+count) = *(cueinf+count-1); //需要注意,这是因为他们的数据都一样XXX
strcpy(recordinf[count],recordinf[count-1]);//added on 0920
}
memset((recordinf[1+ctel+1]),0x0,MAXNAMELEN);//空的内容,需要添加
*(cueinf+1+ctel+1) = NULL;
if(ctel ==0)
{
*(cueinf+1+ctel+1) = "固话:";
}
}
break;
case MOBILE :
if(cmob>=MAXMOBNUM) break;
else{
for(count=(countall);count>(1+ctel+cmob);count--)//需要确定是>= or >
{
// *(tmpptr+count) = *(tmpptr+count-1);//modified on 0920
*(cueinf+count) = *(cueinf+count-1);
strcpy(recordinf[count],recordinf[count-1]);
}
// *(tmpptr+1+ctel+cmob+1) = NULL;//空的内容,需要添加
memset((recordinf[1+ctel+cmob+1]),0x0,MAXNAMELEN);
*(cueinf+1+ctel+cmob+1) = NULL;
if(cmob == 0)
{
*(cueinf+1+ctel+cmob+1) = "手机:";
}
}
break;
case BP:
if(cbp>=MAXBPNUM) break;
else{
for(count=(countall);count>(1+ctel+cmob+cbp);count--)//需要确定是>= or >
{
//*(tmpptr+count) = *(tmpptr+count-1); // modified on 0920
strcpy(recordinf[count],recordinf[count-1]);
*(cueinf+count) = *(cueinf+count-1);
}
//*(tmpptr+1+ctel+cmob+cbp+1) = NULL;//空的内容,需要添加
memset((recordinf[1+ctel+cmob+cbp+1]),0x0,MAXNAMELEN);
*(cueinf+1+ctel+cmob+cbp+1) = NULL;
if(cbp == 0)
{
*(cueinf+1+ctel+cmob+cbp+1) = "寻呼:";
}
}
break;
default:
break;
}
}
void DelRecordItem(P_S8 *recordinf,P_S8 *cueinf,PHONESTYLE phonstyle,S8 ctel,S8 cmob,S8 cbp,SELECTITEM select)//在某个位置之后添加
{
/*
SEL_FIRST,
SEL_SECOND,
SEL_THIRD,
SEL_FOURTH
*/
U8 count;
// P_S8 *tmpptr =recordinf;
U8 countall = ctel+cmob+cbp+2;
switch(phonstyle)
{
case TELEPHONE:
if(ctel<=0) break;
else{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -