Palace.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /********************************************************************************
  2. * File Name: Palace.c
  3. * Function Describe:宫格菜单
  4. * Relate Module:
  5. * Writer: Shliangwen
  6. * Date: 2019-1-15
  7. *******************************************************************************/
  8. #include "includes.h"
  9. #include "Palace.h"
  10. /*
  11. flag=0 全部刷新
  12. flag>0 刷index图标 突出显示
  13. flag<0 刷index图标 恢复正常
  14. */
  15. void PalaceShow(SUT_PALACE *sutPalace,int flag,int index)
  16. {
  17. int r,c,x,y;
  18. char filename[20];
  19. #if(PALACE_ICON_TYPE==USE_ICON_PALACE)
  20. if(flag==0){
  21. GuiClearAll();
  22. sutPalace->Index=0;
  23. //GuiCaptionWithInfo(3, sutPalace->mainTile, sutPalace->Title[sutPalace->Index]);
  24. ShowCaption(sutPalace->Title[sutPalace->Index],STATUS_BAR_HEIGH);
  25. //GuiDrawHLine(0,160,18,1);
  26. for(r=0;r<PALACE_ROW;r++){
  27. for(c=0;c<PALACE_COL;c++){
  28. x=PALACE_LEFT+c*sutPalace->wide+sutPalace->ox;
  29. y=PALACE_TOP+r*sutPalace->high+sutPalace->oy;
  30. if(r==0 && c==0){//if(sutPalace->Index==r*PALACE_COL+c)
  31. sprintf(filename,"%s%dP.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c);
  32. //logTrace(filename,1);
  33. }else{
  34. sprintf(filename,"%s%d.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c);
  35. }
  36. GuiShowBmp(x,y,filename);
  37. }
  38. }
  39. }else{
  40. //GuiCaptionWithInfo(3, sutPalace->mainTile, sutPalace->Title[sutPalace->Index]);
  41. ShowCaption(sutPalace->Title[sutPalace->Index],18);
  42. r=index/PALACE_COL;
  43. c=index%PALACE_COL;
  44. x=PALACE_LEFT+c*sutPalace->wide+sutPalace->ox;
  45. y=PALACE_TOP+r*sutPalace->high+sutPalace->oy;
  46. if(flag>0){
  47. sprintf(filename,"%s%dP.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c);
  48. }else{
  49. sprintf(filename,"%s%d.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c);
  50. }
  51. GuiShowBmp(x,y,filename);
  52. }
  53. #else
  54. if(flag==0){
  55. GuiClearAll();
  56. //GuiCaptionWithInfo(3, sutPalace->mainTile, sutPalace->Title[sutPalace->Index]);
  57. ShowCaption(sutPalace->Title[sutPalace->Index],STATUS_BAR_HEIGH);
  58. //sutPalace->Index=0; /***********
  59. // GuiDrawHLine(0,LCD_WIDTH-1,35,2);
  60. for(r=0;r<PALACE_ROW;r++){
  61. for(c=0;c<PALACE_COL;c++){
  62. x=PALACE_LEFT+c*sutPalace->wide+sutPalace->ox;
  63. y=PALACE_TOP+r*sutPalace->high+sutPalace->oy;
  64. sprintf(filename,"%s%d.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c);
  65. if(sutPalace->Index==r*PALACE_COL+c){//if(r==0 && c==0){//if(sutPalace->Index==r*PALACE_COL+c)
  66. GuiShowBmp(x,y,filename);
  67. GuiFillRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y,COLOR_WARN_RED);
  68. GuiFillRect(x-PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH+PALACE_SURROUND_SIZE,COLOR_WARN_RED);
  69. GuiFillRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH,COLOR_WARN_RED);
  70. GuiFillRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,COLOR_WARN_RED);
  71. }else{
  72. GuiClearRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH+PALACE_SURROUND_SIZE);
  73. GuiShowBmp(x,y,filename);
  74. }
  75. }
  76. }
  77. sutPalace->showAlreadyFlag=1;
  78. }else{
  79. //GuiCaptionWithInfo(3, sutPalace->mainTile, sutPalace->Title[sutPalace->Index]);
  80. ShowCaption(sutPalace->Title[sutPalace->Index],STATUS_BAR_HEIGH);
  81. r=index/PALACE_COL;
  82. c=index%PALACE_COL;
  83. x=PALACE_LEFT+c*sutPalace->wide+sutPalace->ox;
  84. y=PALACE_TOP+r*sutPalace->high+sutPalace->oy;
  85. if(flag>0){
  86. GuiFillRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y,COLOR_WARN_RED);
  87. GuiFillRect(x-PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH+PALACE_SURROUND_SIZE,COLOR_WARN_RED);
  88. GuiFillRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH,COLOR_WARN_RED);
  89. GuiFillRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,COLOR_WARN_RED);
  90. }else{
  91. GuiClearRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y);
  92. GuiClearRect(x-PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH+PALACE_SURROUND_SIZE);
  93. GuiClearRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH);
  94. GuiClearRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH);
  95. }
  96. if(sutPalace->showAlreadyFlag==0){
  97. sprintf(filename,"%s%d.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c);
  98. GuiShowBmp(x,y,filename);
  99. }
  100. }
  101. #endif
  102. }
  103. void PalaceInit(SUT_PALACE *sutPalace,const char **title , const char *prefix, const char *mainInfo)
  104. {
  105. int a,b;
  106. unsigned char index;
  107. if(g_ulKeyValue==KEY_PANEL_EXIT||UI_Stack.OK_back)
  108. {
  109. index=PullUiStack(&UI_Stack);
  110. if(index>4){
  111. //p->page=1;
  112. sutPalace->Index=index;//
  113. }else{
  114. //p->page=0;
  115. sutPalace->Index=index;
  116. }
  117. UI_Stack.OK_back=0;
  118. }else if(g_ulKeyValue==KEY_PANEL_MENU){
  119. sutPalace->Index=0;
  120. }
  121. sutPalace->mainTile=mainInfo;
  122. //sutPalace->Index=0;
  123. sutPalace->Title=title;
  124. sutPalace->FileNamePrefix=prefix;
  125. sutPalace->wide=(LCD_WIDTH-PALACE_LEFT*2)/PALACE_COL;
  126. sutPalace->high=(LCD_HEIGHT-PALACE_TOP)/PALACE_ROW;
  127. if(sutPalace->wide>PALACE_ICON_WIDE)sutPalace->ox=(sutPalace->wide-PALACE_ICON_WIDE)/2;
  128. else sutPalace->ox=0;
  129. if(sutPalace->high>PALACE_ICON_HIGH)sutPalace->oy=(sutPalace->high-PALACE_ICON_HIGH)/2;
  130. else sutPalace->oy=0;
  131. PalaceShow(sutPalace,0,0);
  132. // GuiShowStr(1,110,"确定",0x01,0);
  133. // GuiShowStr(125,110,"返回",0x01,0);
  134. }
  135. unsigned short PalaceResponse(SUT_PALACE *sutPalace)
  136. {
  137. switch(g_ulKeyValue)
  138. {
  139. case KEY_PANEL_UP:
  140. PalaceShow(sutPalace,-1,sutPalace->Index);
  141. if(sutPalace->Index>0)sutPalace->Index--;
  142. else sutPalace->Index = (PALACE_COL*PALACE_ROW)-1;
  143. PalaceShow(sutPalace,1,sutPalace->Index);
  144. break;
  145. case KEY_PANEL_DOWN:
  146. PalaceShow(sutPalace,-1,sutPalace->Index);
  147. if(sutPalace->Index<(PALACE_COL*PALACE_ROW-1))sutPalace->Index++;
  148. else sutPalace->Index=0;
  149. PalaceShow(sutPalace,1,sutPalace->Index);
  150. break;
  151. case KEY_PANEL_MENU:
  152. break;
  153. case KEY_PANEL_EXIT:
  154. sutPalace->showAlreadyFlag=0;
  155. break;
  156. }
  157. return g_ulKeyValue;
  158. }