?? test1.c
字號(hào):
/* 連接相應(yīng)的圖標(biāo)數(shù)據(jù) */
mainmenu[0].icodat = (uint8 *) menuico1;
mainmenu[0].title = (uint8 *) menuchar1;
mainmenu[1].icodat = (uint8 *) menuico2;
mainmenu[1].title = (uint8 *) menuchar2;
mainmenu[2].icodat = (uint8 *) menuico3;
mainmenu[2].title = (uint8 *) menuchar3;
mainmenu[3].icodat = (uint8 *) menuico4;
mainmenu[3].title = (uint8 *) menuchar4;
mainmenu[4].icodat = (uint8 *) menuico5;
mainmenu[4].title = (uint8 *) menuchar5;
mainmenu[5].icodat = (uint8 *) menuico6;
mainmenu[5].title = (uint8 *) menuchar6;
mainmenu[6].icodat = (uint8 *) menuico7;
mainmenu[6].title = (uint8 *) menuchar7;
mainmenu[7].icodat = (uint8 *) menuico8;
mainmenu[7].title = (uint8 *) menuchar8;
/* 連接菜單功能函數(shù) */
mainmenu[0].Function = (void(*)())DemoLine;
mainmenu[1].Function = (void(*)())DemoCircle;
mainmenu[2].Function = (void(*)())DemoArc;
mainmenu[3].Function = (void(*)())DemoEllipse;
mainmenu[4].Function = (void(*)())DemoRectang;
mainmenu[5].Function = (void(*)())DemoPoly;
mainmenu[6].Function = (void(*)())DemoBmp;
mainmenu[7].Function = (void(*)())MoveCircle;
/* 設(shè)置默認(rèn)菜單 */
mainmenu[0].state = 1;
select = 0;
/* 進(jìn)行主菜單顯示及選擇操作 */
while(1)
{ for(i=0; i<8; i++) // 顯示圖標(biāo)菜單
{ GUI_MenuIcoDraw(&mainmenu[i]);
}
/* 選擇功能 */
while(1)
{ key = WaitKey();
if(key==KEY_OK) break; // 點(diǎn)擊OK鍵選擇
if(key==KEY_NEXT)
{ mainmenu[select].state = 0; // 取消上一選擇
GUI_MenuIcoDraw(&mainmenu[select]);
select++; // 指向下一菜單
if(select>7) select=0;
mainmenu[select].state = 1;
GUI_MenuIcoDraw(&mainmenu[select]);
}
if(key==KEY_BACK)
{ mainmenu[select].state = 0; // 取消上一選擇
GUI_MenuIcoDraw(&mainmenu[select]);
if(select==0) select=7;
else select--; // 指向下一菜單
mainmenu[select].state = 1;
GUI_MenuIcoDraw(&mainmenu[select]);
}
}
/* 執(zhí)行相應(yīng)功能 */
(*mainmenu[select].Function)();
if(select>=6) GUI_WindowsDraw(&mainwindows); // 主窗口重繪(清屏)
}
}
/*-- 調(diào)入了一幅圖像:C:\WINDOWS\Desktop\Critter2.ico --*/
/*-- 寬度x高度=32x32 --*/
uint8 const critter[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0xF0,0x00,0x00,0x07,0xFC,0x00,0x00,0x0C,0x9F,0x00,0x00,0x1A,0xCF,0x80,0x00,
0x1C,0x8F,0x80,0x00,0x1F,0xFF,0xC0,0x00,0x1F,0xFF,0xE0,0x00,0x0F,0xFF,0xF0,0x00,
0x0F,0xFF,0xF8,0x00,0x07,0xFF,0xFC,0x00,0x03,0xFF,0xFF,0x00,0x01,0xFF,0xFF,0xC0,
0x00,0xFF,0xFF,0xC0,0x00,0xFF,0xFF,0xC0,0x1F,0xFF,0xFF,0xC0,0x3F,0xFF,0xFF,0xC0,
0x1F,0xFF,0xFF,0xC0,0x0F,0xFF,0xFF,0xC0,0x0F,0xFF,0xFF,0xC0,0x00,0x1F,0xFF,0xC0,
0x00,0x0F,0xFF,0x80,0x00,0x0F,0xFF,0x80,0x00,0x1F,0xFF,0x80,0x00,0x1F,0xFF,0x80,
0x00,0x3F,0xFF,0x80,0x00,0x7F,0x9F,0x00,0x00,0x7F,0x1F,0x00,0x00,0x7E,0x1F,0x00
};
/****************************************************************************
* 名稱:RunOpen()
* 功能:執(zhí)行"Open"菜單命令,打開一個(gè)圖標(biāo)。
* 入口參數(shù):無
* 出口參數(shù):無
****************************************************************************/
void RunOpen(void)
{ GUI_LoadPic(105, 70, (uint8 *)critter, 32, 32);
}
/****************************************************************************
* 名稱:RunClose()
* 功能:執(zhí)行"Close"菜單命令,關(guān)閉一個(gè)圖標(biāo)。
* 入口參數(shù):無
* 出口參數(shù):無
****************************************************************************/
void RunClose(void)
{ GUI_RectangleFill(105, 70, 137, 102, 0);
}
/****************************************************************************
* 名稱:RunBye()
* 功能:執(zhí)行"Exit"菜單命令,顯示退出信息。
* 入口參數(shù):無
* 出口參數(shù):無
****************************************************************************/
void RunBye(void)
{ GUI_PutString(80, 105, "Goodbye sir!");
DelayNS(50);
}
/****************************************************************************
* 名稱:NotThing()
* 功能:顯示執(zhí)行信息,然后退出。
* 入口參數(shù):無
* 出口參數(shù):無
****************************************************************************/
void NotThing(void)
{ GUI_PutString(80, 105, "Do notthing!");
DelayNS(50);
GUI_PutString(80, 105, " ");
}
/****************************************************************************
* 名稱:RunAbout()
* 功能:顯示關(guān)于信息,然后退出。
* 入口參數(shù):無
* 出口參數(shù):無
****************************************************************************/
void RunAbout(void)
{ GUI_PutString(80, 105, "ZLG_GUI v0.1");
DelayNS(100);
GUI_PutString(80, 105, " ");
}
/****************************************************************************
* 名稱:RunMenuDemo()
* 功能:進(jìn)行菜單的演示操作。
* 入口參數(shù):無
* 出口參數(shù):無
****************************************************************************/
void RunMenuDemo(void)
{ WINDOWS mainwindows;
MMENU mainmenu;
SMENU submenu[5];
uint8 mselect;
uint8 select, bak;
uint8 key;
/* 設(shè)置主窗口并顯示輸出 */
mainwindows.x = 0;
mainwindows.y = 0;
mainwindows.with = 240;
mainwindows.hight = 128;
mainwindows.title = (uint8 *) "Down Menu Demo!";
mainwindows.state = (uint8 *) "ready (Let's make things better.)";
GUI_WindowsDraw(&mainwindows); // 繪制主窗口
mainmenu.win = &mainwindows; // 設(shè)置主菜單所屬窗口
mainmenu.no = 5; // 主菜單項(xiàng)個(gè)數(shù)
mainmenu.str[0] = (char *) "File"; // 主菜單項(xiàng)各項(xiàng)字符
mainmenu.str[1] = (char *) "Edit";
mainmenu.str[2] = (char *) "View";
mainmenu.str[3] = (char *) "Find";
mainmenu.str[4] = (char *) "Help";
GUI_MMenuDraw(&mainmenu); // 顯示主菜單
/* 子菜單設(shè)置 */
for(bak=0; bak<5; bak++)
{ submenu[bak].win = &mainwindows; // 設(shè)置菜單所屬的窗口
submenu[bak].mmenu_no = bak;
submenu[bak].state = 0;
}
submenu[0].no = 3;
submenu[0].str[0] = (char *) "Open";
submenu[0].str[1] = (char *) "Close";
submenu[0].str[2] = (char *) "Exit";
submenu[0].Function[0] = (void(*)()) RunOpen;
submenu[0].Function[1] = (void(*)()) RunClose;
submenu[0].Function[2] = (void(*)()) RunBye;
submenu[1].no = 4;
submenu[1].str[0] = (char *) "Cut";
submenu[1].str[1] = (char *) "Copy";
submenu[1].str[2] = (char *) "Paste";
submenu[1].str[3] = (char *) "Delete";
submenu[1].Function[0] = (void(*)()) NotThing;
submenu[1].Function[1] = (void(*)()) NotThing;
submenu[1].Function[2] = (void(*)()) NotThing;
submenu[1].Function[3] = (void(*)()) NotThing;
submenu[2].no = 2;
submenu[2].str[0] = (char *) "Tools";
submenu[2].str[1] = (char *) "Font";
submenu[2].Function[0] = (void(*)()) NotThing;
submenu[2].Function[1] = (void(*)()) NotThing;
submenu[3].no = 3;
submenu[3].str[0] = (char *) "Find";
submenu[3].str[1] = (char *) "Replace";
submenu[3].str[2] = (char *) "Next";
submenu[3].Function[0] = (void(*)()) NotThing;
submenu[3].Function[1] = (void(*)()) NotThing;
submenu[3].Function[2] = (void(*)()) NotThing;
submenu[3].Function[3] = (void(*)()) NotThing;
submenu[4].no = 1;
submenu[4].str[0] = (char *) "About";
submenu[4].Function[0] = (void(*)()) RunAbout;
/* 進(jìn)行子菜單1顯示及選擇操作 */
mselect = 0;
while(1)
{ /* 選擇主菜單項(xiàng) */
while(1)
{ GUI_MMenuSelect(&mainmenu, mselect); // 顯示當(dāng)前主菜單項(xiàng)
key = WaitKey(); // 等待按鍵操作
if(key==KEY_OK) break; // 若是OK鍵,則退出主菜單選擇
if(key==KEY_BACK) // BACK鍵操作
{ if(mselect>0)
{ GUI_MMenuNSelect(&mainmenu, mselect); // 取消當(dāng)前主菜單項(xiàng)選擇
mselect--; // 指向下一主菜單項(xiàng)
}
}
if(key==KEY_NEXT) // NEXT鍵操作
{ if( mselect<(mainmenu.no-1) )
{ GUI_MMenuNSelect(&mainmenu, mselect); // 取消當(dāng)前主菜單項(xiàng)選擇
mselect++; // 指向下一主菜單項(xiàng)
}
}
}
GUI_MMenuNSelect(&mainmenu, mselect);
/* 下拉子菜單,選擇功能 */
select = submenu[mselect].state;
bak = select;
GUI_SMenuDraw(&submenu[mselect]); // 顯示子菜單
while(1)
{ key = WaitKey();
if(key==KEY_OK) break; // 點(diǎn)擊OK鍵選擇
if(key==KEY_NEXT)
{ bak = select;
select++;
if(select>=submenu[mselect].no) select = 0;
GUI_SMenuSelect(&submenu[mselect], bak, select);
}
if(key==KEY_BACK)
{ bak = select;
if(select==0) select = submenu[mselect].no - 1;
else select--;
GUI_SMenuSelect(&submenu[mselect], bak, select);
}
}
GUI_SMenuHide(&submenu[mselect]);
(*submenu[mselect].Function[select])(); // 調(diào)用相應(yīng)的服務(wù)程序
if( (mselect==0) && (select==2) )
{ break;
}
}
}
/***********************************************************************
* 名稱:main()
* 功能:主程序,用于GUI測(cè)試及演示。
***********************************************************************/
int main(void)
{ uint8 LPC2210_LOG[8] = {0x0f, 0x00, 0x01, 0x02, 0x02, 0x0c, 0x16, 0x14};
PointXY test_p[] = { {20,30},
{70,60},
{100,50},
{90,110},
{20,30}
};
TargetInit();
ZLG7290_SendBuf(LPC2210_LOG,8);
TargetInit(); // 初始化IO設(shè)置等(在target.c文件中)
GUI_Initialize(); // 初始化LCM
GUI_Spline(test_p, 5, 1);
GUI_FloodFill(50,80, 1);
GUI_SetColor(1, 0);
DispLog(); // 顯示LOG
RunMenuDemo(); // 顯示菜單
RunDemo(); // 運(yùn)行演示程序
while(1);
return(0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -