NumEdit.c 2.1 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. SUT_NUM_EDIT sutNumEdit;
  10. void NumEditInit(SUT_NUM_EDIT *p,unsigned short x,unsigned char y,char *def)
  11. {
  12. p->x=x;
  13. p->y=y;
  14. strncpy(p->buffer,def,NUM_EDIT_BUFFER_LEN_MAX);
  15. p->len=strlen(p->buffer);
  16. p->xlen=p->len*8;
  17. p->ylen=16;
  18. p->item=0;
  19. }
  20. void NumEditShow(SUT_NUM_EDIT *p)
  21. {
  22. unsigned short x,w;
  23. char info[2];
  24. unsigned char revIndex;
  25. guiClearRect(p->x,p->y,p->x+p->xlen,p->y+p->ylen-16,guiGetBackColor()); //没有16 清的太多
  26. x=p->item*8;
  27. guiShowStr(p->x,p->y,p->buffer,FONT_MODE_16X16,REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  28. x+=p->x;
  29. //GuiReverseRect(x,p->y,8,16);
  30. revIndex=(x-p->x)/8;
  31. info[0]=p->buffer[revIndex];info[1]=0;
  32. guiShowStr(x, p->y,info, FONT_MODE_16X16,REVERSED_NO, guiGetBackColor(), COLOR_STATUS_BAR);
  33. }
  34. void NumEditShowNORect(SUT_NUM_EDIT *p)
  35. {
  36. unsigned short x,w;
  37. guiClearArea(p->x,p->y,p->x+p->xlen,p->y+p->ylen,guiGetBackColor());
  38. x=p->item*8;
  39. guiShowStr(p->x,p->y,p->buffer,FONT_MODE_16X16,REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  40. x+=p->x;
  41. }
  42. unsigned char NumEditResponse(SUT_NUM_EDIT *p)
  43. {
  44. char v;
  45. v=p->buffer[p->item];
  46. switch(getKeyValue())
  47. {
  48. case MKEY_VALUE_F1:
  49. if(v<'9')v++;
  50. else v='0';
  51. p->buffer[p->item]=v;
  52. NumEditShow(p);
  53. break;
  54. case MKEY_VALUE_F2:
  55. #if 0//原来下是减值
  56. if(v>'0')v--;
  57. else v='9';
  58. p->buffer[p->item]=v;
  59. NumEditShow(p);
  60. #else //现在改成向右移动
  61. if(p->item<(p->len-1)){
  62. p->item++;
  63. }else{
  64. p->item=0;
  65. }
  66. NumEditShow(p);
  67. #endif
  68. break;
  69. // case KEY_PANEL_P2:
  70. // if(p->item>0){
  71. // p->item--;
  72. // }else{
  73. // p->item=p->len-1;
  74. // }
  75. // NumEditShow(p);
  76. // break;
  77. // case KEY_PANEL_P3:
  78. // if(p->item<(p->len-1)){
  79. // p->item++;
  80. // }else{
  81. // p->item=0;
  82. // }
  83. // NumEditShow(p);
  84. // break;
  85. // case KEY_PANEL_MENU:
  86. // return 1;
  87. case MKEY_VALUE_ESC:
  88. return 2;
  89. }
  90. return 0;
  91. }