1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /********************************************************************************
- * File Name: NumEdit.c
- * Function Describe: NumEdit 控件
- * Relate Module: GUI.c
- * Writer: Shliangwen
- * Date: 2016-1-31
- *********************************************************************************/
- #include "Includes.h"
- void NumEditInit(SUT_NUM_EDIT *p,unsigned short x,unsigned char y,char *def)
- {
- p->x=x;
- p->y=y;
- strncpy(p->buffer,def,NUM_EDIT_BUFFER_LEN_MAX);
- p->len=strlen(p->buffer);
- p->xlen=p->len*8;
- p->ylen=16;
- p->item=0;
- }
- void NumEditShow(SUT_NUM_EDIT *p)
- {
- unsigned short x,w;
- GuiClearArea(p->x,p->y,p->x+p->xlen,p->y+p->ylen-16); //没有16 清的太多
- x=p->item*8;
- GuiShowStr(p->x,p->y,p->buffer,0x01);
- x+=p->x;
- GuiReverseRect(x,p->y,8,14);
- }
- void NumEditShowNORect(SUT_NUM_EDIT *p)
- {
- unsigned short x,w;
- GuiClearArea(p->x,p->y,p->x+p->xlen,p->y+p->ylen);
- x=p->item*8;
- GuiShowStr(p->x,p->y,p->buffer,0x01);
- x+=p->x;
- }
- unsigned char NumEditResponse(SUT_NUM_EDIT *p)
- {
- char v;
- v=p->buffer[p->item];
- switch(g_ulKeyValue)
- {
- case KEY_PANEL_UP:
- if(v<'9')v++;
- else v='0';
- p->buffer[p->item]=v;
- NumEditShow(p);
- break;
- case KEY_PANEL_DOWN:
- #if 0//原来下是减值的
- if(v>'0')v--;
- else v='9';
- p->buffer[p->item]=v;
- NumEditShow(p);
- #else //现在改成向右移动
- if(p->item<(p->len-1)){
- p->item++;
- }else{
- p->item=0;
- }
- NumEditShow(p);
- #endif
- break;
- // case KEY_PANEL_P2:
- // if(p->item>0){
- // p->item--;
- // }else{
- // p->item=p->len-1;
- // }
- // NumEditShow(p);
- // break;
- // case KEY_PANEL_P3:
- // if(p->item<(p->len-1)){
- // p->item++;
- // }else{
- // p->item=0;
- // }
- // NumEditShow(p);
- // break;
- // case KEY_PANEL_MENU:
- // return 1;
- case KEY_PANEL_EXIT:
- return 2;
- }
- return 0;
- }
|