/******************************************************************************** * File Name: NumEdit.c * Function Describe: NumEdit 控件 * Relate Module: GUI.c * Writer: Shliangwen * Date: 2016-1-31 *********************************************************************************/ #include "Includes.h" SUT_NUM_EDIT sutNumEdit; 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; char info[2]; unsigned char revIndex; guiClearRect(p->x,p->y,p->x+p->xlen,p->y+p->ylen-16,guiGetBackColor()); //没有16 清的太多 x=p->item*8; guiShowStr(p->x,p->y,p->buffer,FONT_MODE_12X12,REVERSED_NO, COLOR_BLACK, guiGetBackColor()); x+=p->x; //GuiReverseRect(x,p->y,8,16); revIndex=(x-p->x)/8; info[0]=p->buffer[revIndex];info[1]=0; guiShowStr(x, p->y,info, FONT_MODE_12X12,REVERSED_NO, guiGetBackColor(), COLOR_STATUS_BAR); } void NumEditShowNORect(SUT_NUM_EDIT *p) { unsigned short x,w; guiClearArea(p->x,p->y,p->x+p->xlen,p->y+p->ylen,guiGetBackColor()); x=p->item*8; guiShowStr(p->x,p->y,p->buffer,FONT_MODE_12X12,REVERSED_NO, COLOR_BLACK, guiGetBackColor()); x+=p->x; } unsigned char NumEditResponse(SUT_NUM_EDIT *p) { char v; v=p->buffer[p->item]; switch(getKeyValue()) { case MKEY_VALUE_UP: if(v<'9')v++; else v='0'; p->buffer[p->item]=v; NumEditShow(p); break; case MKEY_VALUE_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 MKEY_VALUE_ESC: return 2; } return 0; }