初级会员
- 积分
- 116
- 金钱
- 116
- 注册时间
- 2015-12-14
- 在线时间
- 15 小时
|
楼主 |
发表于 2016-2-15 14:09:18
|
显示全部楼层
#include "button_bitmap.h"
#include "DIALOG.h"
WM_HWIN hwindow1,hwindow2;
WM_HWIN hButton_1,hButton_2,PROGBAR1;
WM_HWIN hText1,hText2;
GUI_BITMAP buttonbmp_tab[2];
static void BKWin_Getdata(WM_MESSAGE * pMsg)
{
switch (pMsg->MsgId) {
case WM_PAINT: //ÖØ»æ±3¾°
GUI_SetColor(GUI_GREEN);
GUI_FillRect(0,0,LCD_GetXSize(),LCD_GetYSize());
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
static void h1_Getdata(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
int NCode;
int Id;
static u8 led0flag=0,led1flag=0;
switch(pMsg->MsgId)
{
case WM_NOTIFY_PARENT: //í¨Öa¸¸′°¿ú£¬Ô-′°¿ú·¢éúá˱ä»ˉ
Id = WM_GetId(pMsg->hWinSrc); // ¿Ø¼tμÄID£¬Äĸö¿Ø¼t·¢éúá˱ä»ˉ
NCode = pMsg->Data.v; // í¨Öa′úÂ룬¼′·¢éúáËÔõÑùμıä»ˉ
switch(Id)
{
case GUI_ID_BUTTON0:
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON0);
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
LED0=~LED0; //LED0·′×a
led0flag = ~led0flag;
BUTTON_SetBitmapEx(hItem,0,led0flag?&buttonbmp_tab[1]:&buttonbmp_tab[0],0,0);
break;
}
break;
case GUI_ID_BUTTON1:
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON1);
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
LED1=~LED1; //LED0·′×a
led1flag = ~led1flag;
BUTTON_SetBitmapEx(hItem,0,(led1flag>0)?&buttonbmp_tab[1]:&buttonbmp_tab[0],0,0);
break;
}
break;
}
break;
case WM_PAINT: //ÖØ»æ±3¾°
GUI_SetBkColor(GUI_RED);
GUI_FillRect(0,0,240,320);
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
static void h2_Getdata(WM_MESSAGE * pMsg)
{
switch (pMsg->MsgId) {
case WM_PAINT: //ÖØ»æ±3¾°
// GUI_SetBkColor((0x80uL << 24) | GUI_GREEN);
GUI_SetBkColor(GUI_INVALID_COLOR);
GUI_FillRect(20,150,150,100);
// GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
void CreateWindow1(void)
{
buttonbmp_tab[0]=bmBUTTON1;
buttonbmp_tab[1]=bmbfzn_001;
hwindow1 = WM_CreateWindowAsChild(
0,
0,
240,
320,
WM_HBKWIN,
WM_CF_SHOW|WM_CF_MEMDEV,
h1_Getdata,
0);
hText1 = TEXT_CreateEx(20,30,60,40,hwindow1,WM_CF_SHOW,TEXT_CF_HCENTER|TEXT_CF_VCENTER,GUI_ID_TEXT0,"LED0:");
TEXT_SetTextColor(hText1,GUI_BLUE);
TEXT_SetFont(hText1,GUI_FONT_24B_ASCII);
TEXT_SetBkColor(hText1,GUI_INVALID_COLOR);
hText2 = TEXT_CreateEx(20,75,60,40,hwindow1,WM_CF_SHOW,TEXT_CF_HCENTER|TEXT_CF_VCENTER,GUI_ID_TEXT1,"LED1:");
TEXT_SetTextColor(hText2,GUI_BLUE);
TEXT_SetFont(hText2,GUI_FONT_24B_ASCII);
WIDGET_SetDefaultEffect_None();
hButton_1 = BUTTON_CreateEx(100,30,40,20,hwindow1,WM_CF_SHOW|WM_CF_HASTRANS,0,GUI_ID_BUTTON0);
// BUTTON_SetDefaultBkColor(GUI_INVALID_COLOR,BUTTON_CI_PRESSED |BUTTON_CI_UNPRESSED|BUTTON_CI_DISABLED);
BUTTON_SetFocussable(hButton_1, 0);
BUTTON_SetBitmapEx(hButton_1,BUTTON_BI_UNPRESSED,&buttonbmp_tab[0],0,0);
hButton_2 = BUTTON_CreateEx(100,75,128,128,hwindow1,WM_CF_SHOW|WM_CF_HASTRANS,0,GUI_ID_BUTTON1);
BUTTON_SetBkColor(hButton_2,BUTTON_CI_UNPRESSED, (0XFFuL<<24)|GUI_BLUE);
BUTTON_SetBkColor(hButton_2,BUTTON_CI_PRESSED, (0XFFuL<<24)|GUI_ORANGE);
// BUTTON_SetDefaultBkColor(GUI_INVALID_COLOR,BUTTON_CI_PRESSED |BUTTON_CI_UNPRESSED|BUTTON_CI_DISABLED);
BUTTON_SetFocussable(hButton_2,0);
BUTTON_SetBitmapEx(hButton_2,BUTTON_BI_UNPRESSED,&buttonbmp_tab[0],0,0);
// WM_SetDesktopColor(GUI_GREEN);
}
void CreateWindow2(void)
{
hwindow2 = WM_CreateWindowAsChild(
20,
150,
150,
100,
hwindow1,
WM_CF_SHOW | WM_CF_MEMDEV | WM_CF_HASTRANS,
h2_Getdata,
0);
// PROGBAR1 = PROGBAR_CreateEx(20,40,120,40,hwindow2,WM_CF_SHOW,PROGBAR_CF_HORIZONTAL,GUI_ID_PROGBAR1);
}
void SetDefaultSkin(void)
{
//¸ü»»Æ¤·ô
BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX);
CHECKBOX_SetDefaultSkin(CHECKBOX_SKIN_FLEX);
DROPDOWN_SetDefaultSkin(DROPDOWN_SKIN_FLEX);
FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX);
HEADER_SetDefaultSkin(HEADER_SKIN_FLEX);
MENU_SetDefaultSkin(MENU_SKIN_FLEX);
MULTIPAGE_SetDefaultSkin(MULTIPAGE_SKIN_FLEX);
PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX);
RADIO_SetDefaultSkin(RADIO_SKIN_FLEX);
SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX);
SLIDER_SetDefaultSkin(SLIDER_SKIN_FLEX);
SPINBOX_SetDefaultSkin(SPINBOX_SKIN_FLEX);
}
void windows(void)
{
INT32U i,num;
OS_STK_DATA StackBytes;
GUI_EnableAlpha(1);
WM_EnableMemdev(WM_HBKWIN);//ÆôóÃ′æ′¢é豸óÃóúÖØ»æ//WM_HBKWIN×àÃæ′°¿ú¾ä±ú
// SetDefaultSkin();
WM_SetCallback(WM_HBKWIN, BKWin_Getdata);
CreateWindow1();
CreateWindow2();
while(1)
{
OSTaskStkChk(LED1_TASK_PRIO, &StackBytes);
if(i == 10)
{
i = 0;
num = StackBytes.OSUsed*100/(StackBytes.OSFree+StackBytes.OSUsed);
PROGBAR_SetValue(PROGBAR1,num);
}
i++;
GUI_Exec();
OSTimeDly(50);
}
}
|
-
|