|
发表于 2020-11-18 13:16:13
|
显示全部楼层
#include "dialog.h"
WM_HWIN hPage[3] = {0, 0, 0};
void MainTask(void)
{
GUI_Init();
//CreateFramewinMain(); //test
CreateWindowBkgd();
//CreateFramewinMain();
// if(!hPage[0])
// hPage[0] = CreateWindowBkgd(WM_HBKWIN); //Determine whether the handle is 0 before creating the window,clear when deleted
// if(!hPage[1])
// hPage[1] = CreateFramewinMain(hPage[0]);
//WM_AttachWindow(hPage[1], hPage[0]); //make hPage[1] as hPage[0]'s child window
// if(!hPage[2])
// hPage[2] = CreateFramewinSub(hPage[1]);
//WM_AttachWindow(hPage[2], hPage[1]); //make hPage[2] as hPage[1]'s child window
// WM_MoveChildTo(hPage[2], 5, 156);
//WM_SetFocus(hPage[1]); //emwin will look for and focuses on the first widget in the hPage[1] window
//WM_SetFocus(hPage[0]);
while(1)
{
GUI_Delay(20);
}//Call GUI_Delay() function delay 20ms,The ultimate goal is to call the GUI_Exec() function
}
/*********************************************************************
* *
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
* *
**********************************************************************
* *
* C-file generated by: *
* *
* GUI_Builder for emWin version 5.30 *
* Compiled Jul 1 2015, 10:50:32 *
* (c) 2015 Segger Microcontroller GmbH & Co. KG *
* *
**********************************************************************
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
*/
// USER START (Optionally insert additional includes)
// USER END
#include "DIALOG.h"
#include "stdio.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x02)
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "WindowBkgd", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "QRcode", ID_BUTTON_0, 115, 170, 80, 30, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
// USER START (Optionally insert additional variables)
// USER END
int NCode;
int Id;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'WindowBkgd'
//
hItem = pMsg->hWin;
WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00FFFF00));
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
// USER START (Optionally insert additional message handling)
// USER END
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (Id) {
case ID_BUTTON_0: // Notifications sent by 'Button'
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
GUI_EndDialog(pMsg->hWin, 0); //2020-9-18 结束本对话框
CreateFramewinMain(WM_HBKWIN); //2020-9-18
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
// USER START (Optionally insert additional code for further Ids)
// USER END
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateWindowBkgd
*/
WM_HWIN CreateWindowBkgd(void);
WM_HWIN CreateWindowBkgd(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/
/*********************************************************************
* *
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
* *
**********************************************************************
* *
* C-file generated by: *
* *
* GUI_Builder for emWin version 5.30 *
* Compiled Jul 1 2015, 10:50:32 *
* (c) 2015 Segger Microcontroller GmbH & Co. KG *
* *
**********************************************************************
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
*/
// USER START (Optionally insert additional includes)
// USER END
#include "DIALOG.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
//#define ID_TEXT_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_0 (GUI_ID_USER + 0x02)
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "FramewinMain", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x0, 0 },
//{ TEXT_CreateIndirect, "Text", ID_TEXT_0, 2, 0, 300, 16, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Return", ID_BUTTON_0, 115, 170, 80, 30, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*
// USER START (Optionally insert additional static code)
static void GUI_renew_gui_memory(WM_HWIN hParent, int textID)
{
char buff[48];
sprintf(buff, "Memory used: %dKBytes free: %dKBytes", GUI_ALLOC_GetNumUsedBytes()/1024, GUI_ALLOC_GetNumFreeBytes()/1024);
//TEXT_SetTextColor(WM_GetDialogItem(hParent, textID), (0x008000FF));
TEXT_SetText(WM_GetDialogItem(hParent, textID), buff);
}*/
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
// USER START (Optionally insert additional variables)
static GUI_HMEM hMem[3] = {0, 0, 0};
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'FramewinMain'
//
//hItem = pMsg->hWin;
//FRAMEWIN_SetTitleHeight(hItem, 16);
//
// Initialization of 'Text'
//
// hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
//TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
// USER START (Optionally insert additional code for further widget initialization)
// FRAMEWIN_SetMoveable(pMsg->hWin, 1);
// FRAMEWIN_SetTitleHeight(pMsg->hWin, 16);
// FRAMEWIN_AddCloseButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);
// FRAMEWIN_AddMaxButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);
// FRAMEWIN_AddMinButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);
//不能重复创建,否则内存越占越多(比如不能放在WM_PAINT消息中)
if(!hMem[0]) hMem[0] = GUI_QR_Create("http://www.neqee.com/", 4, GUI_QR_ECLEVEL_L, 0); //(1):屏蔽此段而保留下面的 WM_PAINT:下的显示函数,二维码显示不成功;得出必须同时保留这两部分才能显示,
if(!hMem[1]) hMem[1] = GUI_QR_Create("http://www.baidu.com/", 3, GUI_QR_ECLEVEL_L, 0);
if(!hMem[2]) hMem[2] = GUI_QR_Create("http://www.segger.com/", 2, GUI_QR_ECLEVEL_L, 0);
//GUI_renew_gui_memory(pMsg->hWin, ID_TEXT_0);//Update memory usage. Note: It also needs to be executed where memory changes.
// USER END
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_0: // Notifications sent by 'Button'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
GUI_EndDialog(pMsg->hWin, 0); //2020-9-18 结束本对话框
CreateWindowBkgd(WM_HBKWIN); //2020-9-18
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
// USER START (Optionally insert additional code for further Ids)
// USER END
}
break;
// USER START (Optionally insert additional message handling)
//窗口重绘消息,这个比较难说明白,反正在Framewin或Window窗口之中我们一般是用控件,如果要在Framewin或Window窗口之中显示文字或绘制直线、矩形、圆等在这里实现.
//Window redraw message, this is difficult to explain,anyway,we usually use widget in framewin or windows,If we want to draw lines,rectangles,circles,etc. in framewin or windows,we can do it here.
case WM_PAINT: //2020-11-17 (2):屏蔽此段保留上面的创建,就不显示二维码了
GUI_SetColor(GUI_BLUE);
GUI_DispStringAt("http://www.neqee.com/", 2, 18);
GUI_QR_Draw(hMem[0], 10, 30);
GUI_SetColor(GUI_GREEN);
GUI_DispStringAt("http://www.baidu.com/", 170, 18);
GUI_QR_Draw(hMem[1], 190, 30);
GUI_SetColor(GUI_RED);
GUI_DispStringAt("http://www.segger.com/", 170, 135);
GUI_QR_Draw(hMem[2], 210, 148);
break;
// USER END
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateFramewinMain
*/
WM_HWIN CreateFramewinMain(void);
WM_HWIN CreateFramewinMain(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/
|
|