/******************************************************************************** * File Name: Palace.c * Function Describe:宫格菜单 * Relate Module: * Writer: Shliangwen * Date: 2019-1-15 *******************************************************************************/ #include "includes.h" #include "Palace.h" /* flag=0 全部刷新 flag>0 刷index图标 突出显示 flag<0 刷index图标 恢复正常 */ void PalaceShow(SUT_PALACE *sutPalace,int flag,int index) { int r,c,x,y; char filename[20]; #if(PALACE_ICON_TYPE==USE_ICON_PALACE) if(flag==0){ GuiClearAll(); sutPalace->Index=0; //GuiCaptionWithInfo(3, sutPalace->mainTile, sutPalace->Title[sutPalace->Index]); ShowCaption(sutPalace->Title[sutPalace->Index],STATUS_BAR_HEIGH); //GuiDrawHLine(0,160,18,1); for(r=0;rwide+sutPalace->ox; y=PALACE_TOP+r*sutPalace->high+sutPalace->oy; if(r==0 && c==0){//if(sutPalace->Index==r*PALACE_COL+c) sprintf(filename,"%s%dP.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c); //logTrace(filename,1); }else{ sprintf(filename,"%s%d.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c); } GuiShowBmp(x,y,filename); } } }else{ //GuiCaptionWithInfo(3, sutPalace->mainTile, sutPalace->Title[sutPalace->Index]); ShowCaption(sutPalace->Title[sutPalace->Index],18); r=index/PALACE_COL; c=index%PALACE_COL; x=PALACE_LEFT+c*sutPalace->wide+sutPalace->ox; y=PALACE_TOP+r*sutPalace->high+sutPalace->oy; if(flag>0){ sprintf(filename,"%s%dP.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c); }else{ sprintf(filename,"%s%d.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c); } GuiShowBmp(x,y,filename); } #else if(flag==0){ GuiClearAll(); //GuiCaptionWithInfo(3, sutPalace->mainTile, sutPalace->Title[sutPalace->Index]); ShowCaption(sutPalace->Title[sutPalace->Index],STATUS_BAR_HEIGH); //sutPalace->Index=0; /*********** // GuiDrawHLine(0,LCD_WIDTH-1,35,2); for(r=0;rwide+sutPalace->ox; y=PALACE_TOP+r*sutPalace->high+sutPalace->oy; sprintf(filename,"%s%d.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c); if(sutPalace->Index==r*PALACE_COL+c){//if(r==0 && c==0){//if(sutPalace->Index==r*PALACE_COL+c) GuiShowBmp(x,y,filename); GuiFillRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y,COLOR_WARN_RED); 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); GuiFillRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH,COLOR_WARN_RED); GuiFillRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,COLOR_WARN_RED); }else{ GuiClearRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH+PALACE_SURROUND_SIZE); GuiShowBmp(x,y,filename); } } } sutPalace->showAlreadyFlag=1; }else{ //GuiCaptionWithInfo(3, sutPalace->mainTile, sutPalace->Title[sutPalace->Index]); ShowCaption(sutPalace->Title[sutPalace->Index],STATUS_BAR_HEIGH); r=index/PALACE_COL; c=index%PALACE_COL; x=PALACE_LEFT+c*sutPalace->wide+sutPalace->ox; y=PALACE_TOP+r*sutPalace->high+sutPalace->oy; if(flag>0){ GuiFillRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y,COLOR_WARN_RED); 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); GuiFillRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH,COLOR_WARN_RED); GuiFillRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,COLOR_WARN_RED); }else{ GuiClearRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y); GuiClearRect(x-PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH+PALACE_SURROUND_SIZE); GuiClearRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH); GuiClearRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH); } if(sutPalace->showAlreadyFlag==0){ sprintf(filename,"%s%d.bmp",sutPalace->FileNamePrefix,r*PALACE_COL+c); GuiShowBmp(x,y,filename); } } #endif } void PalaceInit(SUT_PALACE *sutPalace,const char **title , const char *prefix, const char *mainInfo) { int a,b; unsigned char index; if(g_ulKeyValue==KEY_PANEL_EXIT||UI_Stack.OK_back) { index=PullUiStack(&UI_Stack); if(index>4){ //p->page=1; sutPalace->Index=index;// }else{ //p->page=0; sutPalace->Index=index; } UI_Stack.OK_back=0; }else if(g_ulKeyValue==KEY_PANEL_MENU){ sutPalace->Index=0; } sutPalace->mainTile=mainInfo; //sutPalace->Index=0; sutPalace->Title=title; sutPalace->FileNamePrefix=prefix; sutPalace->wide=(LCD_WIDTH-PALACE_LEFT*2)/PALACE_COL; sutPalace->high=(LCD_HEIGHT-PALACE_TOP)/PALACE_ROW; if(sutPalace->wide>PALACE_ICON_WIDE)sutPalace->ox=(sutPalace->wide-PALACE_ICON_WIDE)/2; else sutPalace->ox=0; if(sutPalace->high>PALACE_ICON_HIGH)sutPalace->oy=(sutPalace->high-PALACE_ICON_HIGH)/2; else sutPalace->oy=0; PalaceShow(sutPalace,0,0); // GuiShowStr(1,110,"确定",0x01,0); // GuiShowStr(125,110,"返回",0x01,0); } unsigned short PalaceResponse(SUT_PALACE *sutPalace) { switch(g_ulKeyValue) { case KEY_PANEL_UP: PalaceShow(sutPalace,-1,sutPalace->Index); if(sutPalace->Index>0)sutPalace->Index--; else sutPalace->Index = (PALACE_COL*PALACE_ROW)-1; PalaceShow(sutPalace,1,sutPalace->Index); break; case KEY_PANEL_DOWN: PalaceShow(sutPalace,-1,sutPalace->Index); if(sutPalace->Index<(PALACE_COL*PALACE_ROW-1))sutPalace->Index++; else sutPalace->Index=0; PalaceShow(sutPalace,1,sutPalace->Index); break; case KEY_PANEL_MENU: break; case KEY_PANEL_EXIT: sutPalace->showAlreadyFlag=0; break; } return g_ulKeyValue; }