NumEdit.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /********************************************************************************
  2. * File Name: NumEdit.c
  3. * Function Describe: NumEdit 控件
  4. * Relate Module: GUI.c
  5. * Writer: Shliangwen
  6. * Date: 2016-1-31
  7. *********************************************************************************/
  8. #include "Includes.h"
  9. void NumEditInit(SUT_NUM_EDIT *p,unsigned short x,unsigned char y,char *def)
  10. {
  11. p->x=x;
  12. p->y=y;
  13. strncpy(p->buffer,def,NUM_EDIT_BUFFER_LEN_MAX);
  14. p->len=strlen(p->buffer);
  15. p->xlen=p->len*8;
  16. p->ylen=16;
  17. p->item=0;
  18. }
  19. void NumEditShow(SUT_NUM_EDIT *p)
  20. {
  21. unsigned short x,w;
  22. char info[2];
  23. unsigned char revIndex;
  24. GuiClearRect(p->x,p->y,p->x+p->xlen,p->y+p->ylen-16); //没有16 清的太多
  25. x=p->item*8;
  26. GuiShowStr(p->x,p->y,p->buffer,0x01,0);
  27. x+=p->x;
  28. //GuiReverseRect(x,p->y,8,16);
  29. revIndex=(x-p->x)/8;
  30. info[0]=p->buffer[revIndex];info[1]=0;
  31. GuiShowStr(x, p->y,info, 1, 1);
  32. }
  33. void NumEditShowNORect(SUT_NUM_EDIT *p)
  34. {
  35. unsigned short x,w;
  36. GuiClearArea(p->x,p->y,p->x+p->xlen,p->y+p->ylen);
  37. x=p->item*8;
  38. GuiShowStr(p->x,p->y,p->buffer,0x01,0);
  39. x+=p->x;
  40. }
  41. unsigned char NumEditResponse(SUT_NUM_EDIT *p)
  42. {
  43. char v;
  44. v=p->buffer[p->item];
  45. switch(g_ulKeyValue)
  46. {
  47. case KEY_PANEL_OK:
  48. if(v<'9')v++;
  49. else v='0';
  50. p->buffer[p->item]=v;
  51. NumEditShow(p);
  52. break;
  53. case KEY_PANEL_DOWN:
  54. #if 0//原来下是减值的
  55. if(v>'0')v--;
  56. else v='9';
  57. p->buffer[p->item]=v;
  58. NumEditShow(p);
  59. #else //现在改成向右移动
  60. if(p->item<(p->len-1)){
  61. p->item++;
  62. }else{
  63. p->item=0;
  64. }
  65. NumEditShow(p);
  66. #endif
  67. break;
  68. // case KEY_PANEL_P2:
  69. // if(p->item>0){
  70. // p->item--;
  71. // }else{
  72. // p->item=p->len-1;
  73. // }
  74. // NumEditShow(p);
  75. // break;
  76. // case KEY_PANEL_P3:
  77. // if(p->item<(p->len-1)){
  78. // p->item++;
  79. // }else{
  80. // p->item=0;
  81. // }
  82. // NumEditShow(p);
  83. // break;
  84. // case KEY_PANEL_MENU:
  85. // return 1;
  86. case KEY_PANEL_EXIT:
  87. return 2;
  88. }
  89. return 0;
  90. }