123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- /********************************************************************************
- * File Name: Palace.c
- * Function Describe:宫格菜单
- * Relate Module:
- * Writer: Shliangwen
- * Date: 2019-1-15
- *******************************************************************************/
- #include "gui.h"
- #include "Palace.h"
- #include "includes.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(guiGetBackColor());
- sutPalace->Index=0;
- guiShowCaption(0,sutPalace->Title[sutPalace->Index],UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
- for(r=0;r<PALACE_ROW;r++){
- for(c=0;c<PALACE_COL;c++){
- x=PALACE_LEFT+c*sutPalace->wide+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{
- guiShowCaption(0,sutPalace->Title[sutPalace->Index],18,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
- 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(guiGetBackColor());
- guiShowCaption(0,sutPalace->Title[sutPalace->Index],UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
- for(r=0;r<PALACE_ROW;r++){
- for(c=0;c<PALACE_COL;c++){
- x=PALACE_LEFT+c*sutPalace->wide+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_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_RED);
- guiFillRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH,COLOR_RED);
- guiFillRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,COLOR_RED);
- }else{
- guiClearRect(x-PALACE_SURROUND_SIZE+1,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH+PALACE_SURROUND_SIZE,guiGetBackColor());
- guiShowBmp(x,y,filename);
- }
- }
- }
- sutPalace->showAlreadyFlag=1;
- }else{
- guiShowCaption(0,sutPalace->Title[sutPalace->Index],UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
- 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_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_RED);
- guiFillRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH,COLOR_RED);
- guiFillRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,COLOR_RED);
- }else{
- guiClearRect(x-PALACE_SURROUND_SIZE,y-PALACE_SURROUND_SIZE,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y,guiGetBackColor());
- guiClearRect(x-PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH+PALACE_SURROUND_SIZE,guiGetBackColor());
- guiClearRect(x-PALACE_SURROUND_SIZE,y,x,y+PALACE_ICON_HIGH,guiGetBackColor());
- guiClearRect(x+PALACE_ICON_WIDE,y,x+PALACE_ICON_WIDE+PALACE_SURROUND_SIZE,y+PALACE_ICON_HIGH,guiGetBackColor());
- }
- 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(getKeyValue()==MKEY_VALUE_ESC)//||UI_Stack.OK_back)
- {
- index=uiPullStack();
- if(index>4){
- //p->page=1;
- sutPalace->Index=index;//
- }else{
- //p->page=0;
- sutPalace->Index=index;
- }
-
- //UI_Stack.OK_back=0;
-
- }else if(getKeyValue()==MKEY_VALUE_MENU){
- sutPalace->Index=0;
- }
-
- sutPalace->mainTile=mainInfo;
- //sutPalace->Index=0;
-
- sutPalace->Title=title;
- sutPalace->FileNamePrefix=prefix;
- sutPalace->wide=(GLCD_WIDTH-PALACE_LEFT*2)/PALACE_COL;
- sutPalace->high=(GLCD_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);
- }
- unsigned short PalaceResponse(SUT_PALACE *sutPalace)
- {
- switch(getKeyValue())
- {
- case MKEY_VALUE_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 MKEY_VALUE_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 MKEY_VALUE_MENU:
- break;
- case MKEY_VALUE_ESC:
- sutPalace->showAlreadyFlag=0;
- break;
- }
- return getKeyValue();
- }
|