?? menu.c
字號:
#include"MYGUIConfig.h"
/****************************************************************************
顯示主菜單,加上邊框。
****************************************************************************/
uint8 GUI_MMenuDraw(MMENU *men)
{ WINDOWS *mwin;
uint8 i;
uint8 xx;
/* 參數過濾 */
if( (men->no)==0 ) return(0);
mwin = men->win; // 取得窗口句柄
/* 判斷是否可以顯示主菜單 */
if( (mwin->hight)<50 ) return(0);
if( (mwin->with)<50 ) return(0);
/* 畫菜單條,并顯示菜主單 */
GUI_HLine(mwin->x, mwin->y + 22, mwin->x + mwin->with - 1);
xx = mwin->x;
for(i=0; i<(men->no); i++)
{ if( (xx+MMENU_WIDTH) > (mwin->x + mwin->with) ) return(0);
GUI_PutNoStr(xx+2, mwin->y + 14, men->str[i], 4);// 書寫主菜單文字
xx += MMENU_WIDTH;
GUI_RLine(xx, mwin->y + 12, mwin->y + 22); // 顯示主菜單分界線
}
return(1);
}
/****************************************************************************
當前主菜單,加下劃線,顏色取反
no:0~2
****************************************************************************/
void GUI_MMenuSelect(MMENU *men, uint8 no)
{ WINDOWS *mwin;
uint8 xx,color;
//參數過濾
if( (men->no)==0 ) return;
if( no>(men->no) ) return;
mwin = men->win; // 取得窗口句柄
// 判斷是否可以顯示主菜單
if( (mwin->hight)<50 ) return;
if( (mwin->with)<50 ) return;
// 顏色取反
xx = mwin->x + no*MMENU_WIDTH;
color=LCD_BGColor;
LCD_BGColor=LCD_ZiColor;
LCD_ZiColor=color;
GUI_PutNoStr(xx+2, mwin->y + 14, men->str[no], 4);// 書寫主菜單文字
color=LCD_BGColor;
LCD_BGColor=LCD_ZiColor;
LCD_ZiColor=color;
}
/****************************************************************************
取消當前主菜單,恢復原來狀態
****************************************************************************/
void GUI_MMenuNSelect(MMENU *men, uint8 no)
{
WINDOWS *mwin;
uint8 xx;
//參數過濾
if( (men->no)==0 ) return;
if( no>(men->no) ) return;
mwin = men->win; // 取得窗口句柄
//判斷是否可以顯示主菜單
if( (mwin->hight)<50 ) return;
if( (mwin->with)<50 ) return;
xx = mwin->x + no*MMENU_WIDTH;
GUI_PutNoStr(xx+2, mwin->y + 14, men->str[no], 4);// 書寫主菜單文字
}
/****************************************************************************
顯示子菜單,加上邊框。
****************************************************************************/
uint8 GUI_SMenuDraw(SMENU *men)
{
WINDOWS *mwin;
uint32 xx, yy;
uint8 i,color;
mwin = men->win;
//判斷是否可以顯示主菜單
if( (mwin->hight)<50 ) return(0);
if( (mwin->with)<50 ) return(0);
//畫菜子單項。下拉子菜單,以向左下拉為原則,若右邊溢出則以右下拉顯示
xx = mwin->x;
xx += (men->mmenu_no)*MMENU_WIDTH;
yy = mwin->y + 22;
yy += (men->no) * 11 + 2;
if( (xx+SMENU_WIDTH) <= (mwin->x + mwin->with - 1) )
{
//以左下拉為原則顯示子菜單
if( (men->mmenu_no) == 0 )
{ GUI_RLine(xx+SMENU_WIDTH, mwin->y + 22, yy);
GUI_HLine(xx, yy, xx+SMENU_WIDTH);
}
else
{ GUI_Rectangle(xx, mwin->y + 22, xx+SMENU_WIDTH, yy);
}
GUI_HLine(xx+1, mwin->y + 22, xx+MMENU_WIDTH-1);
}
else
{
//以右下拉為原則
if( (xx+MMENU_WIDTH) == (mwin->x + mwin->with - 1) )
{
GUI_RLine(xx-(SMENU_WIDTH-MMENU_WIDTH), mwin->y + 22, yy);
GUI_HLine(xx-(SMENU_WIDTH-MMENU_WIDTH), yy, xx+MMENU_WIDTH);
}
else
{
GUI_Rectangle(xx-(SMENU_WIDTH-MMENU_WIDTH), mwin->y + 22, xx+MMENU_WIDTH, yy);
}
GUI_HLine(xx+1, mwin->y + 22, xx+MMENU_WIDTH-1);
xx = xx-(SMENU_WIDTH-MMENU_WIDTH);
}
// 顯示菜單文字
xx++;
yy = mwin->y + 22 + 2;
for(i=0; i<(men->no); i++)
{ if( i == (men->state) ) // 判斷所選擇的菜單項
{
color=LCD_PenColor;
LCD_PenColor=LCD_BGColor;
GUI_RectangleFill(xx, yy, xx+SMENU_WIDTH-2, yy+10);
LCD_PenColor=color;
color=LCD_BGColor;
LCD_BGColor=LCD_ZiColor;
LCD_ZiColor=color;
GUI_PutNoStr(xx+1, yy+1, men->str[i], 6); // 書寫子菜單文字
color=LCD_BGColor;
LCD_BGColor=LCD_ZiColor;
LCD_ZiColor=color;
}
else
{
color=LCD_PenColor;
LCD_PenColor=LCD_BGColor;
GUI_RectangleFill(xx, yy, xx+SMENU_WIDTH-2, yy+10);
LCD_PenColor=color;
// 顯示菜單字符
GUI_PutNoStr(xx+1, yy+1, men->str[i], 6); // 書寫子菜單文字
}
yy += 11;
}
return(1);
}
/****************************************************************************
消隱子菜單項
****************************************************************************/
uint8 GUI_SMenuHide(SMENU *men)
{
WINDOWS *mwin;
uint8 xx, yy,color;
mwin = men->win;
//判斷是否可以顯示主菜單
if( (mwin->hight)<50 ) return(0);
if( (mwin->with)<50 ) return(0);
//畫菜子單項。下拉子菜單,以向左下拉為原則,若右邊溢出則以右下拉顯示
xx = mwin->x;
xx += (men->mmenu_no)*MMENU_WIDTH;
yy = mwin->y + 22;
yy += (men->no) * 11 + 2;
if( (xx+SMENU_WIDTH) <= (mwin->x + mwin->with - 1) )
{ // 以左下拉為原則顯示子菜單
if( (men->mmenu_no) == 0 )
{
color=LCD_PenColor;
LCD_PenColor=LCD_BGColor;
GUI_RectangleFill(xx+1, mwin->y + 22+1, xx+SMENU_WIDTH, yy);
LCD_PenColor=color;
}
else
{
color=LCD_PenColor;
LCD_PenColor=LCD_BGColor;
GUI_RectangleFill(xx, mwin->y + 22+1, xx+SMENU_WIDTH, yy);
LCD_PenColor=color;
}
GUI_HLine(xx+1, mwin->y + 22, xx+MMENU_WIDTH-1);
}
else
{ // 以右下拉為原則
if( (xx+MMENU_WIDTH) == (mwin->x + mwin->with - 1) )
{
color=LCD_PenColor;
LCD_PenColor=LCD_BGColor;
GUI_RectangleFill(xx-(SMENU_WIDTH-MMENU_WIDTH), mwin->y + 22+1, xx+MMENU_WIDTH-1, yy);
LCD_PenColor=color;
}
else
{
color=LCD_PenColor;
LCD_PenColor=LCD_BGColor;
GUI_RectangleFill(xx-(SMENU_WIDTH-MMENU_WIDTH), mwin->y + 22+1, xx+MMENU_WIDTH, yy);
LCD_PenColor=color;
}
GUI_HLine(xx+1, mwin->y + 22, xx+MMENU_WIDTH-1);
}
return(1);
}
/****************************************************************************
顯示圖標菜單。
****************************************************************************/
uint8 GUI_MenuIcoDraw(MENUICO *ico)
{
uint8 color;
// 參數過濾
if( ( (ico->x)<1 ) || ( (ico->x)>(GUI_LCM_XMAX-34 ) ) ) return(0); // 顯示起始地址判斷
if( ( (ico->icodat)==NULL ) || ( (ico->title)==NULL ) ) return(0); // 顯示數據內容判斷
GUI_LoadPic(ico->x, ico->y, (uint8 *) ico->icodat, 32, 32); // 顯示ICO圖32x32
color=LCD_PenColor;
LCD_PenColor=LCD_BGColor;
GUI_HLine(ico->x, ico->y+32, ico->x+32); // 顯示一空行
LCD_PenColor=color;
if( (ico->state)==0 )
{
GUI_PutNoStr(ico->x, ico->y+33, ico->title, 5);
}
else
{
color=LCD_BGColor;
LCD_BGColor=LCD_ZiColor;
LCD_ZiColor=color;
GUI_PutNoStr(ico->x, ico->y+33, ico->title, 5);
color=LCD_BGColor;
LCD_BGColor=LCD_ZiColor;
LCD_ZiColor=color;
}
return(1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -