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

📄 phedit.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
                 for(count=1+(U8)select;count<(countall);count++)
                 {
                   	 recordinf[count] = recordinf[count+1];  //内容上移//可以不用考虑将最后的清空
                   	 cueinf[count]=cueinf[count+1];//提示内容上移  //,因为已经完全移动完,而且是多余的都是零
                 }
                 if((select == SEL_FIRST)&&(ctel>=2))//如果是选择第一项,就要把第一项提示重新显示
                 {
                     cueinf[2]="固话:";  
                 }
             }
             break;
        case MOBILE :  
        	if(cmob<0)  break;
              else{
                 for(count=1+ctel+(U8)select;count<(countall);count++)
                 {
                   	 recordinf[count] = recordinf[count+1];  //内容上移//可以不用考虑将最后的清空
                   	 cueinf[count]=cueinf[count+1];//提示内容上移  //,因为已经完全移动完,而且是多余的都是零
                 }
                 if((select == SEL_FIRST)&&(cmob>=2))//如果是选择第一项,就要把第一项提示重新显示
                 {
                     cueinf[2+ctel]="手机:";  
                 }
             }
        	 break;
        case BP:
        	if(cbp<0)  break;
             else{
                 for(count=1+ctel+cmob+(U8)select;count<(countall);count++)
                 {
                   	 recordinf[count] = recordinf[count+1];  //内容上移//可以不用考虑将最后的清空
                   	 cueinf[count]=cueinf[count+1];//提示内容上移  //,因为已经完全移动完,而且是多余的都是零
                 }
                 if((select == SEL_FIRST)&&(cbp>=2))//如果是选择第一项,就要把第一项提示重新显示
                 {
                     cueinf[2+ctel+cmob]="寻呼:";  
                 }
             }
        	 break;
        default:        
        	break;
    }
}







void  SaveEditorInfToReordinf(U32 *editor,P_S8 *recordinf,U16 startp)
{
    U8 	i;
    S8 	buf[50];
    U8 	len;
    U8 	flag=0;
    memset(buf,0x0,50);
    for(i = 0;i<DISP_EDIT_NUM;i++)
    {
    	if((void*)editor[i]!= NULL)
    	{
	        if( GetEditorStr(editor[i],buf,50) == NULL ) 
				return;
	        else{
	          	if((void*)(*buf )!= NULL) 
	          	{
	          		len = (U8)strlen(buf)+1;
	          	  //strcpy(recordinf[startp+i],buf);//注意需要保证recordinf是有足够的空间用于拷贝
	                memcpy(recordinf[i+startp],buf,len);
	          	}
	        }                                                 //所以在开缓冲区的时候需要考虑
    	} else{
    		flag=1;
    	}       
    }
}




U8  EditDetailNote(PHONEBOOK * thisptr, ACCESSSTYLE  mode ,U8 PhStyle,U8 *outputname,SAVEMODE savemode,DBLACB	*phbooklacb) 
{

    U32 editwin,bt1,bt2,bt3,bt4,bt5,bt6,editor[DISP_EDIT_NUM],lbox = 0,scroll,tskbar;//st1,st2;
    U32        st[DISP_EDIT_NUM];
    U32        btindex[PHBOOK_INDEXNUM];
    U32        keyboard = 0;
    MSG       msg;
    U32        hGC;
    
      
   struct LBOX_ITEM	lboxitem[] =
   {     //"全部"没有加上
	ICON_ENABLE,	UNDERLINE,	"其他",
	ICON_ENABLE,	UNDERLINE,	"朋友",
	ICON_ENABLE,	UNDERLINE,	"家人",
	ICON_ENABLE,	UNDERLINE,	"同学",
	ICON_ENABLE,	UNDERLINE,	"同事",
	ICON_END,	UNDERLINE,	NULL
   };
   
   U8		 quit=0;
   S8        ctel = 0,cmob = 0,cbp = 0,countall = 0;  //需要使用s8否则在减一的时候到零的时候会有问题
   P_S8      nameptr,relationptr;  
   P_S8      recordinf[MAX_PHBOOKINFNUM];//需要分配空间
   P_S8      cueinf[MAX_PHBOOKINFNUM];    	
   U8        count,pos;
   U8        relationpos;
   U8		 topdir=FALSE,enddir=FALSE;//标志滚动滑块在页首和页尾,用于阻止相同页面的重刷  
   S16		 startp = 0,endp = 0,high = 0,low = 0;
   S16       startpbefore = 0;
   U32       hmenu;
  // P_S8      string;
   U32		liststatus = 0;
   INDEXSTATE    indexstate;
   INDEXSTATE    oldindexst;
   U32       keybstatus =0;
   U32       btstatus = 0;
   //S16       status;
   PHONESTYLE  selphstyle;
   SELECTITEM   selitem = SEL_FIRST;
   U8 isjumptokeyb = 0;
   P_S8    string1 = "选择编辑信息";
   P_S8    string2 = "选择删除信息";
   P_S8    string3 = "姓名尚未输入,所编辑信息将不保存,是否退出编辑?";
   P_S8    string4 = "姓名尚未输入,所新建信息将不保存,是否退出新建?";
   P_S8    string5 ="尚未修改信息,是否退出?";
   P_S8  inf1 = NULL,inf2 = NULL,inf3 = NULL,inf4 = NULL;
   U8     isrefreshindex = 0;
   U8     ismodified = 0;
   U8     isrefreshitem = 0;
   S8     otherrela = OTHERS,friendrela = FRIEND,familyrela = FAMILY,schmaterela = SCHMATE,colleaguerela = COLLEAGUE;
   U8    j =0;//for debug

   U8    issavetodbok = 0;
   U8 *wintext;
   if(savemode == SAVE_INEDIT){
   	wintext = "编辑电话本记录";
   }else
   if(savemode == SAVE_INNEW){
   	wintext =  "新建电话本记录";
   }

   
   hGC = GetGC();
   
   //给暂存变量分配空间//added on 0920 XXXXXX
   for(count=0;count<MAX_PHBOOKINFNUM;count++)
   {
       recordinf[count] =  (P_S8)Lmalloc(MAXNAMELEN);//暂时定位100
	if(recordinf[count]==NULL)  
	{ 
	   return ASIX_ERROR;
	}  
	   memset(recordinf[count],0x0,MAXNAMELEN);
   }
/*  //没有必要申请空间,因为都是一样长度的数据,直接赋值就可以了
   for(count=0;count<MAX_PHBOOKINFNUM;count++)
   {
       cueinf[count] =  (P_S8)Lmalloc(MAXNAMELEN);//暂时定位100
	if(cueinf[count]==NULL)  
	{ 
	   return ASIX_ERROR;
	}  
   }
   */
   nameptr = thisptr->name;
   switch (thisptr->relation)   //XXX主要是为了统一压缩数组的风格XXX需要改动
   {
       case OTHERS:	          relationptr = &otherrela;   break;
       case FRIEND:           relationptr = &friendrela;   break;
       case FAMILY:           relationptr = &familyrela;   break;
       case SCHMATE:        relationptr = &schmaterela;  break;
       case COLLEAGUE:       relationptr = &colleaguerela;  break; 	      
   }
   for(count = 0;count<DISP_EDIT_NUM;count++)
  {
    editor[count] = 0;
  }

//先把结构中的数据暂时存到压缩的数组中去//有电话号码和提示信息
  // memset( (P_VOID)recordinf, 0x0 , MAX_PHBOOKINFNUM*sizeof(P_S8));//初试化新的记录//XXXXdel on 0920
   memset( (P_VOID)cueinf, 0x0 , MAX_PHBOOKINFNUM*sizeof(P_S8));//初试化新的记录
   //recordinf[0] = nameptr;
   //recordinf[1] = relationptr;//考虑如何添加setwindowtext
   strcpy(recordinf[0],nameptr);
   strcpy(recordinf[1],relationptr);
   pos = 1;
   for (count =0;count<(MAXTELNUM);count++)//modified on 0920  XXXXXX
  {
       if((void*)(*(thisptr->tel[count]))!= NULL)//modified on 0920
      	{
      	    ctel++;
          pos++;
      	  strcpy(recordinf[pos], thisptr->tel[count]);
      	}
 }
     
for (count =0;count<(MAXMOBNUM);count++)
{
    if((void*)(*(thisptr->mobile[count]))!= NULL)//modified on 0920 因为是指向内存区域,但是不为空
    {
      	  cmob++;
      	  pos++;
      	  strcpy(recordinf[pos], thisptr->mobile[count]);
    }
}
     
 for (count =0;count<(MAXBPNUM);count++)
{
   if((void*)(*(thisptr->bp[count]))!= NULL)
   {
      	 cbp++;
      	 pos++;
       strcpy( recordinf[pos],thisptr->bp[count]);
    }
}
     

   countall = ctel + cmob + cbp +2;//表示有多少数据
     //需要先初始化数组
   cueinf[0] = "姓名:";
   cueinf[1] = "关系:";
   if(ctel != 0)
   {
       cueinf[2] = "固话:"; 
   }
   if(cmob != 0)
   {
       cueinf[2+ctel] = "手机:";
   }
   if(cbp != 0)
   {
       cueinf[2+ctel+cmob] = "寻呼:";
   }

   editwin = CreateWindow(WNDCLASS_WIN,			
						wintext,			
						WS_OVERLAPPEDWINDOW,	
						0,0,					
						PHY_LCD_W,PHY_LCD_H,	
						0,						
						0,						
						NULL);					
   tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,editwin, 0, NULL);

   bt1 = CreateWindow( WNDCLASS_BUTTON,
						"确定",
						WS_CHILD|BS_REGULAR,
						(LCD_WIDTH - 64)/2,20,
						20,
						20,
						editwin,
						0,
						(char*)zi_ok);
   bt2 = CreateWindow( WNDCLASS_BUTTON,
						"取消",
						WS_CHILD|BS_REGULAR,
						(LCD_WIDTH - 64)/2 + 24,20,
						20,
						20,
						editwin,
						0,
						(char*)zi_cancel);
   bt3 = CreateWindow( WNDCLASS_BUTTON,
						"键盘",
						WS_CHILD|BS_REGULAR,
						(LCD_WIDTH - 64)/2 + 48,20,
						20,
						20,
						editwin,
						0,
						(char*)zi_jianpan);
   bt4 = CreateWindow( WNDCLASS_BUTTON,
						"新建",
						WS_CHILD|BS_TOOLBAR,
						//WS_CHILD|BS_REGULAR,
						(LCD_WIDTH - 160)/2,142,
						52,
						20,
						editwin,
						0,
						NULL);
   bt5 = CreateWindow( WNDCLASS_BUTTON,
						"删除",
						//WS_CHILD|BS_REGULAR,
						WS_CHILD|BS_TOOLBAR,
						(LCD_WIDTH - 160)/2 + 56,142,
						52,
						20,
						editwin,
						0,
						NULL);
   bt6 = CreateWindow( WNDCLASS_BUTTON,
						"修改",
						WS_CHILD|BS_TOOLBAR,
						//WS_CHILD|BS_REGULAR,
						(LCD_WIDTH - 160)/2 + 112,142,
						52,
						20,
						editwin,
						0,
						NULL);


	
    for(count = 0; count < DISP_EDIT_NUM; count++)//XXX需要注意的是先暂时定显示为4行,以后需要加
    {
        editor[count] = CreateWindow(WNDCLASS_EDITOR,
        	                                  NULL, 
                                                WS_CHILD|ES_SINGLE_REGULAR,
                                               (LCD_WIDTH - 126)/2 + 36,
        	                                   (U16)(count * 21 + 44),
        	                                   90,
        	                                   20,
        	                                   editwin,
        	                                   0,
        	                                   NULL);
    }

    for(count = 0; count < DISP_EDIT_NUM; count++)//XXX需要注意的是先暂时定显示为4行,以后需要加
    {
       st[count] = CreateWindow(WNDCLASS_STATIC,
        	                    NULL, 
        	                    // WS_CHILD| BS_ICON,
								WS_CHILD|SS_TEXT,
                                (LCD_WIDTH - 126)/2,
        	                    (U16)(count * 21 +44),
                                36,
                                23,
                                editwin,
                                0,
                                NULL);
    }
    
    for (count=0;count<PHBOOK_INDEXNUM;count++)
     {
            btindex[count] = CreateWindow( WNDCLASS_BUTTON,
						                    NULL,
						                    WS_CHILD|BS_REGULAR,
						                    (U16)((LCD_WIDTH - 120)/2+25*count),
						                    164,
						                    20,
						                    20,
						                    editwin,
						                    0,
						                    NULL); 
     }


	if(mode == SEARCH_ACCESS)
	{
		EnableWindow(bt4, FALSE);
		EnableWindow(bt5, FALSE);
		EnableWindow(bt6, FALSE);
		for (count=0;count<PHBOOK_INDEXNUM;count++)
		{
			EnableWindow(btindex[count], FALSE);
		}
	}



	low=0;                                   //需要考虑是low=1 or low =0;
	/*
	if(countall <= DISP_EDIT_NUM)
	{
		high = 0;
		endp=countall ;
	}
	else
	{
		high = countall -DISP_EDIT_NUM;
		endp=DISP_EDIT_NUM;
	}
	*/


    startp=0;
    if(countall > DISP_EDIT_NUM)
    {
  	high = countall-1;
  	if((S8)(startp)<0)
  	{
  		startp = 0;
  		endp = startp+DISP_EDIT_NUM;
  	}else
  	if(startp>(countall -1))	
  	{
  		startp = (countall -1);		
  		endp = (countall);
  	}else{
  		endp = startp+DISP_EDIT_NUM;
  		if(endp >(countall))
  			endp = countall;
  	}
    }
   else{
   	high = countall-1;
   	if(startp <0)  startp = 0;
   	if(startp >high)	startp = high;
  
  	//startp = 0;
  	endp=countall;
   }




	
	//startp=0;
	relationpos = 1;
	hmenu = MAKELONG(low, high);


	
    scroll = CreateWindow(WNDCLASS_SCROLL, 
	                            "Scroll", 
	                            WS_CHILD|SBS_VERT, 
	                            (LCD_WIDTH - 126)/2 + 136,44,
	                            16,
	                            84,
	                            editwin,
	                            hmenu,
	                            NULL);


  

	hGC = GetGC();
	GroupOn(hGC);
	if(countall >= DISP_EDIT_NUM)      //显示屏幕初始化
		PhBookEditDisplay(recordinf,cueinf,countall,0, DISP_EDIT_NUM, editor,st);
	else
		PhBookEditDisplay(recordinf,cueinf,countall,0, countall, editor,st);
	if(startp == 0)
	{
	     DestroyWindow ( editor[1] );
	     editor[1] = 0;
	     lbox = CreateWindow( WNDCLASS_LIST,
     	                      "ListBox",
     	                      WS_CHILD|LBS_POPUP,
     	                      (LCD_WIDTH - 126)/2 + 36,65,//XXXX应该是原来的第一行的记录的位置
     	                      90,
     	                      20,
     	                      editwin,
     	                      0,
     	                      lboxitem);
	     SelectListBox( lbox,*recordinf[1]);//修改选择项显示内容
	}
	GroupOff(hGC, 1, 21,(LCD_WIDTH - 126)/2 + 136,128);
    indexstate = EDIT_ITEM;
    oldindexst = EDIT_ITEM;//用来判断先前的快速索引的状态
    DispIndex(btindex,indexstate,ctel,cmob,cbp);
    //返黑列表框TAP
    //InvRec( hGC, 106,  163, 52, 20 );   //XXXX将TAP返黑表示已经是处于编辑

⌨️ 快捷键说明

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