/******************************************************************* * * MainTask * ******************************************************************** */ void MainTask_AppCalendar(void) { WM_HWIN hWinCalendar; u32 curtimestamp = 0; struct tm currUtime; //Init Time curtimestamp = Time_GetRTCTimeByUnix(); currUtime = Time_ConvUnixToCalendar(curtimestamp); cldDate.year = currUtime.tm_year; cldDate.month = currUtime.tm_mon+1; cldDate.day = currUtime.tm_mday; if (currUtime.tm_wday == 0) cldDate.weekday = 7; else cldDate.weekday = currUtime.tm_wday; //GUI_Init(); hWinCalendar = WM_CreateWindow(320, 0, 320, 240, WM_CF_SHOW, _cbCalendar, 0); WM_SetFocus(hWinCalendar); _MoveShiftWindow(&hWinCalendar, MEMDEV_ANIMATION_LEFT, WM_Shift_ToLCD, 0); WM_EnableMemdev(hWinCalendar); _ShowButton(hWinCalendar); while (!GUI_CheckCancel(APP_Calendar)) { //GUI_Delay(10); GUI_Exec(); GUI_X_ExecIdle(); } WM_DeleteWindow(hWinCalendar); hWinCalendar = 0; }
void GUIDEMO_WM(void) { /* Show message */ /* GUIDEMO_ShowIntro("Windows Manager", "\nExamples for the" "\nWindows manager"); */ GUIDEMO_NotifyStartNext(); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); GUIDEMO_HideInfoWin(); _DemoSetDesktopColor(); _DemoCreateWindow(); _DemoCreateWindowAsChild(); _DemoInvalidateWindow(); _DemoBringToTop(); _DemoMoveTo(); _DemoBringToBottom(); _DemoMoveWindow(); _DemoHideShowParent(); _DemoHideShowChild(); //_DemoClipping(); _DemoRedrawing(); _DemoResizeWindow(); _DemoSetCallback(); _DemoDeleteWindow(); }
/********************************************************************* * * MainTask * ********************************************************************** */ void MainTask(void) { GUI_Init(); WM_EnableMemdev(WM_HBKWIN); WM_SetCreateFlags(WM_CF_MEMDEV); WM_SetCallback(WM_HBKWIN, _cbBkWindow); GUI_CURSOR_Show(); while(1) { _DemoListView(); } }
/********************************************************************* * * _Main */ static void _Main(void) { int xSize; int ySize; WM_SelectWindow(WM_HBKWIN); GUI_Clear(); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) // GUI_CURSOR_Show(); #endif // // Create and configure Control and Information window // xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); _hDialogControl = GUI_CreateDialogBox(_aFrameWinControl, GUI_COUNTOF(_aFrameWinControl), &_cbFrameWinControl, WM_HBKWIN, xSize - CONTROL_SIZE_X, ySize - CONTROL_SIZE_Y); _hDialogInfo = GUI_CreateDialogBox(_aFrameWinInfo, GUI_COUNTOF(_aFrameWinInfo), &_cbFrameWinInfo, WM_HBKWIN, (xSize >> 1) - 1, 0); WM_HideWindow(_hDialogInfo); // // Show Intro // WM_InvalidateWindow(_hDialogControl); WM_DisableMemdev(WM_HBKWIN); GUI_Exec(); WM_EnableMemdev(WM_HBKWIN); GUI_SetBkColor(GUI_RED); GUI_Clear(); GUI_SetBkColor(GUI_GREEN); GUI_Clear(); GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUIDEMO_Intro(); // // Run the demos // for (_iDemo = 0; _GUIDemoConfig.apFunc[_iDemo]; _iDemo++) { _ClearHalt(); GUIDEMO_UpdateControlText(); (*_GUIDemoConfig.apFunc[_iDemo])(); _iDemoMinor = 0; _Pressed = 0; } _iDemo = 0; // // Cleanup // WM_DeleteWindow(_hDialogControl); WM_DeleteWindow(_hDialogInfo); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) GUI_CURSOR_Hide(); #endif }
void MainTask(void) { GUI_Init(); /* Use memory devices for all windows */ WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); WM_SetDesktopColor(GUI_GREEN); while(1) { _Font = 0; _Color = 0; _pcbCallback = 0; GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, 0, 0, 0); GUI_Delay(1000); } }
void MainTask(void) { WM_HWIN hWin; GUI_Init(); GUI_CURSOR_Show(); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, &_cbBkWindow); while (1) { hWin = GUI_CreateDialogBox(_aDialogOrder, GUI_COUNTOF(_aDialogOrder), &_cbDialogOrder, WM_HBKWIN, 0, 0); WM_MakeModal(hWin); GUI_ExecCreatedDialog(hWin); GUI_Delay(1500); } }
/******************************************************************* * * MainTask * ******************************************************************** */ void MainTask_AppMenu(void) { WM_HWIN hWinMenu; GUI_Init(); hWinMenu = WM_CreateWindow(0, 0, 320, 240, WM_CF_SHOW, _cbMenu, 0); WM_SetFocus(hWinMenu); WM_EnableMemdev(hWinMenu); while (!GUI_CheckCancel(APP_MainMenu)) { GUI_Delay(10); } WM_DisableWindow(hWinMenu); }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_Init(); // // Use memory devices for all windows // #if GUI_SUPPORT_MEMDEV WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); #endif WM_SetDesktopColor(GUI_GREEN); while(1) { _Font = _Color = 0; GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, 0, 0, 0); GUI_Delay(1000); } }
void MainTask_AppCalculator(void) { WM_HWIN hWinCalculator; hWinCalculator = WM_CreateWindow(320, 0, 320, 240, WM_CF_SHOW, _cbCalculator, 0); WM_SetFocus(hWinCalculator); _MoveShiftWindow(&hWinCalculator, MEMDEV_ANIMATION_LEFT, WM_Shift_ToLCD, 0); WM_EnableMemdev(hWinCalculator); CreateCalculator(hWinCalculator); while (!GUI_CheckCancel(APP_Calculator)) { GUI_Delay(10); } WM_DeleteWindow(hWinCalculator); hWinCalculator = 0; }
static void _Main(void) { WM_SelectWindow(WM_HBKWIN); GUI_Clear(); WM_InvalidateWindow(_hDialogControl); WM_DisableMemdev(WM_HBKWIN); GUI_Exec(); WM_EnableMemdev(WM_HBKWIN); GUIDEMO_Intro(); GUIDEMO_TransparentDialog(); GUIDEMO_Graph(); GUIDEMO_ColorBar(); _iDemo = 0; WM_DeleteWindow(_hDialogControl); }
void MainTask(void) { WM_HWIN hWin; GUI_Init(); // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } GUI_CURSOR_Show(); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, &_cbBkWindow); while (1) { hWin = GUI_CreateDialogBox(_aDialogOrder, GUI_COUNTOF(_aDialogOrder), &_cbDialogOrder, WM_HBKWIN, 0, 0); WM_MakeModal(hWin); GUI_ExecCreatedDialog(hWin); GUI_Delay(1500); } }
/********************************************************************* * * Task_0 */ void Task_0(void) { WM_HWIN hWin = 0; _Auto = 1; GUI_SelectLayer(LAYER); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, _cbBkWindow); GUI_Exec(); GUI_CURSOR_ShowEx(LAYER); hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0); while (1) { if (_Auto) { _PlayNextEvent(hWin); } else { SIM_Delay(100); } if (WM_IsWindow(hWin) == 0) { SIM_Delay(1000); hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, WM_GetDesktopWindowEx(LAYER), 0, 0); } } }
void MainTask(void) { GUI_Init(); GUI_SetBkColor(GUI_BLACK); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); while (1) { _DemoSetDesktopColor(); _DemoCreateWindow(); _DemoCreateWindowAsChild(); _DemoInvalidateWindow(); _DemoBringToTop(); _DemoMoveTo(); _DemoBringToBottom(); _DemoMoveWindow(); _DemoHideShowParent(); _DemoHideShowChild(); _DemoClipping(); _DemoRedrawing(); _DemoResizeWindow(); _DemoSetCallback(); _DemoDeleteWindow(); } }
/********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hScrollbar, hDlgOptions; GUI_RECT RectDlg, RectClient; int Cnt = 0, IndexEffect = 0, ButtonState = 0, DropdownState = 0; int ProgbarValue = 0, ProgbarInc = 1; int SliderValue = 0, SliderInc = 1; int ScrollbarValue = 0, ScrollbarInc = 1; int ListViewInc = 1; int ListBoxInc = 1; int MultiEditInc = 1; int Vz = 1; const WIDGET_EFFECT * _apEffect[] = {&WIDGET_Effect_3D, /* Array of effects */ &WIDGET_Effect_Simple, &WIDGET_Effect_None}; const char * _apEffects[] = {"Widget effect: 3D", "Widget effect: Simple", "Widget effect: None"}; GUI_Init(); GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWindow); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ WM_EnableMemdev(WM_HBKWIN); /* Enable use of memory devices for desktop windows */ /* Create framewindow and set its properties */ _hFrameWin = FRAMEWIN_CreateEx(0, 0, 640, 480, 0, WM_CF_SHOW, 0, 0, "", &_cbCallbackFramewin); FRAMEWIN_SetMoveable(_hFrameWin, 1); FRAMEWIN_SetText(_hFrameWin, _apEffects[0]); FRAMEWIN_SetFont(_hFrameWin, &GUI_Font13B_ASCII); /* Create main dialog window as child from framewindows client window */ _hDlg = GUI_CreateDialogBox(_aDlgWidgets, GUI_COUNTOF(_aDlgWidgets), &_cbCallbackWidgets, WM_GetClientWindow(_hFrameWin), 0, 0); /* Attach scrollbar to framewindows client window and set its properties */ hScrollbar = SCROLLBAR_CreateAttached(WM_GetClientWindow(_hFrameWin), 0); WM_GetWindowRectEx(_hDlg, &RectDlg); WM_GetClientRectEx(WM_GetClientWindow(_hFrameWin), &RectClient); SCROLLBAR_SetNumItems(hScrollbar, RectDlg.x1); SCROLLBAR_SetPageSize(hScrollbar, RectClient.x1); /* Create options dialog with 'stay on top' and 'moveable' attribute */ hDlgOptions = GUI_CreateDialogBox(_aDlgOptions, GUI_COUNTOF(_aDlgOptions), &_cbCallbackOptions, WM_HBKWIN, 0, 0); FRAMEWIN_SetMoveable(hDlgOptions, 1); WM_SetStayOnTop(hDlgOptions, 1); /* Main loop for modifying the widgets */ while (1) { if (_AutoMode) { Cnt++; /* Modify progbar */ if ((Cnt % 2) == 0) { ProgbarValue += ProgbarInc; if ((ProgbarValue == 110) || (ProgbarValue == -10)) { ProgbarInc *= -1; } PROGBAR_SetValue(_ahWin[PROGBAR0], ProgbarValue); } /* Modify slider */ if ((Cnt % 2) == 0) { int j; SliderValue += SliderInc; if ((SliderValue == 100) || (SliderValue == 0)) { SliderInc *= -1; } for (j = 0; j < 3; j++) { SLIDER_SetValue(_ahWin[SLIDER0 + j], SliderValue); } } /* Modify scrollbar */ if ((Cnt % 3) == 0) { int j; ScrollbarValue += ScrollbarInc; if ((ScrollbarValue == 90) || (ScrollbarValue == 0)) { ScrollbarInc *= -1; } for (j = 0; j < 3; j++) { SCROLLBAR_SetValue(_ahWin[SCROLLBAR0 + j], ScrollbarValue); } } /* Modify multipage */ if ((Cnt % 120) == 0) { MULTIPAGE_SelectPage(_ahWin[MULTIPAGE0], MULTIPAGE_GetSelection(_ahWin[MULTIPAGE0]) ^ 1); } /* Modify dropdown */ if ((Cnt % 120) == 0) { DropdownState ^= 1; if (DropdownState) { DROPDOWN_Expand(_ahWin[DROPDOWN0]); } else { DROPDOWN_Collapse(_ahWin[DROPDOWN0]); } } /* Modify button */ if ((Cnt % 40) == 0) { ButtonState ^= 1; BUTTON_SetPressed(_ahWin[BUTTON0], ButtonState); } /* Modify listbox */ if ((Cnt % 30) == 0) { int Sel; Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if (Sel < 0) { Sel = 0; } LISTBOX_SetSel(_ahWin[LISTBOX0], Sel + ListBoxInc); Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if ((Sel == (int)LISTBOX_GetNumItems(_ahWin[LISTBOX0]) - 1) || (Sel == 0)) { ListBoxInc *= -1; } } /* Modify listview */ if ((Cnt % 50) == 0) { int Sel; Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if (Sel < 0) { Sel = 0; } LISTVIEW_SetSel(_ahWin[LISTVIEW0], Sel + ListViewInc); Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if ((Sel == (int)LISTVIEW_GetNumRows(_ahWin[LISTVIEW0]) - 1) || (Sel == 0)) { ListViewInc *= -1; } } /* Modify multiedit */ if ((Cnt % 5) == 0) { int Sel, Len; char acBuffer[100]; MULTIEDIT_SetCursorOffset(_ahWin[MULTIEDIT0], MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]) + MultiEditInc); MULTIEDIT_GetText(_ahWin[MULTIEDIT0], acBuffer, sizeof(acBuffer)); Sel = MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]); Len = strlen(acBuffer); if ((Sel == (Len - 1)) || (Sel == 0)) { MultiEditInc *= -1; } if (!DropdownState) { WM_SetFocus(_ahWin[MULTIEDIT0]); } } /* Modify graph */ _AddValues(_ahWin[GRAPH0], 95); /* Move window */ if ((Cnt % 1200) == 0) { int Inc; WM_HWIN hScroll; WM_SCROLL_STATE ScrollState; hScroll = WM_GetScrollbarH(WM_GetClientWindow(_hFrameWin)); WM_GetScrollState(hScroll, &ScrollState); Inc = (ScrollState.NumItems - ScrollState.PageSize) / 2; ScrollState.v += Inc * Vz; if ((ScrollState.v >= Inc * 2) || (ScrollState.v <= 0)) { Vz *= -1; } SCROLLBAR_SetValue(hScroll, ScrollState.v); } /* Change effect */ if ((Cnt % 400) == 0) { int Index; WM_HWIN hWin; IndexEffect++; Index = IndexEffect % GUI_COUNTOF(_apEffect); _SetEffect(Index); hWin = WM_GetDialogItem(hDlgOptions, GUI_ID_RADIO0); RADIO_SetValue(hWin, Index); } } /* Wait a while */ GUI_Delay(10); } }
/********************************************************************* * * _Main */ static void _Main(void) { int xSize; int ySize; /* 设置要用于绘制的活动窗口 */ WM_SelectWindow(WM_HBKWIN); GUI_Clear(); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) //GUI_CURSOR_Show(); #endif // // Create and configure Control and Information window // xSize = LCD_GetXSize();// ySize = LCD_GetYSize();// if(win_foucus_button_x) _hDialogControl = GUI_CreateDialogBox(_aFrameWinControl, GUI_COUNTOF(_aFrameWinControl), &_cbFrameWinControl, WM_HBKWIN, 0, 0); //_hDialogInfo = GUI_CreateDialogBox(_aFrameWinInfo, GUI_COUNTOF(_aFrameWinInfo), &_cbFrameWinInfo, WM_HBKWIN, (xSize >> 1) - 1, 0); else _hDialogDis = GUI_CreateDialogBox(_aFrameWinDis, GUI_COUNTOF(_aFrameWinDis), &_cbFrameWinDis, WM_HBKWIN, 0, 0); /*是窗口不可见*/ //WM_SetFocus(_hDialogDis); //WM_HideWindow(_hDialogInfo); // // Show Intro ///* 使窗口无效 */ // //WM_HideWindow(_hDialogDis); //else //WM_HideWindow(_hDialogControl); WM_InvalidateWindow(_hDialogDis); /* 禁用存储设备用于重绘 */ WM_DisableMemdev(WM_HBKWIN); //WM_HideWindow(_hDialogControl); /* 执行回调函数(通常用以重绘) */ GUI_Exec1(); /* 允许存储设备用于重绘 */ WM_EnableMemdev(WM_HBKWIN); /*GUIDEMO_Intro(); // // Run the demos // for (_iDemo = 0; _GUIDemoConfig.apFunc[_iDemo]; _iDemo++) { _ClearHalt(); GUIDEMO_UpdateControlText(); (*_GUIDemoConfig.apFunc[_iDemo])(); _iDemoMinor = 0; _Pressed = 0; } _iDemo = 0;*/ // // Cleanup // // // WM_DeleteWindow(_hDialogInfo); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) GUI_CURSOR_Hide(); #endif }
void GUIDEMO_Bitmap(void) { int XSize = LCD_GetXSize(); int YSize = LCD_GetYSize(); GUIDEMO_ShowIntro("Bitmaps", "Showing" "\ndifferent bitmaps with" "\nand without compression"); GUI_SetBkColor(GUI_BLUE); GUI_Clear(); #if GUI_WINSUPPORT & GUI_SUPPORT_MEMDEV WM_EnableMemdev(WM_HBKWIN); #endif #if GUIDEMO_LARGE GUI_DrawBitmap(&_bmLadyBug, 20, 50); GUI_SetFont(&GUI_Font13_1); GUI_DispStringAt("RLE Compressed bitmaps", 10, 10); GUIDEMO_Wait(); GUI_Clear(); GUI_DispStringAt("1/2/4/8 bpp bitmaps", 10, 10); GUI_DrawBitmap(&GUIDEMO_bm4bpp, 20, 50); GUIDEMO_Delay(4000); GUIDEMO_NotifyStartNext(); /* Tile display with image */ { int ix, iy; for (ix = 0; ix < XSize / GUIDEMO_bm4bpp.XSize + 1; ix++) { for (iy = 0; iy < YSize / GUIDEMO_bm4bpp.YSize + 1; iy++) { GUI_DrawBitmap(&GUIDEMO_bm4bpp, GUIDEMO_bm4bpp.XSize * ix , GUIDEMO_bm4bpp.YSize * iy); } } } GUIDEMO_Delay(2000); GUIDEMO_NotifyStartNext(); GUIDEMO_ShowInfo("Bitmaps may also be\nmagnified and rotated"); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_Font16_1); { int i, tm; double xMul, Angle; for (i = 200; (i < 3000) && !GUIDEMO_CheckCancel();) { tm = GUI_GetTime(); GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, i, i); GUI_DispStringHCenterAt("Bitmaps can be magnified...", XSize / 2, 100); GUI_Exec(); while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel()); i += (GUI_GetTime() - tm) * 6; } GUIDEMO_Delay(2000); GUIDEMO_NotifyStartNext(); GUI_Clear(); GUI_DispStringHCenterAt("...and rotated.", XSize / 2, ((YSize + GUIDEMO_bm4bpp.YSize) >> 1) + 5); for (Angle = 0; Angle < PI4 && !GUIDEMO_CheckCancel();) { tm = GUI_GetTime(); xMul = cos(Angle) * 1000; GUI_ClearRect((XSize - GUIDEMO_bm4bpp.XSize) >> 1, (YSize - GUIDEMO_bm4bpp.YSize) >> 1, (XSize + GUIDEMO_bm4bpp.XSize) >> 1, (YSize + GUIDEMO_bm4bpp.YSize) >> 1); GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, xMul, 1000); GUI_Exec(); while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel()); Angle += (GUI_GetTime() - tm) / 250.0f; } GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, 1000, 1000); } GUIDEMO_Wait(); #else { const GUI_BITMAP * pBm; int TextModeOld = GUI_SetTextMode(GUI_TM_XOR); GUI_SetFont(&GUI_Font8_ASCII); pBm = &_bmLadyBug; GUI_DrawBitmap(pBm, (XSize - (int)pBm->XSize) / 2, (YSize - (int)pBm->YSize) / 2); GUI_DispStringAt("RLE Compressed bitmaps", 8, 10); GUIDEMO_Wait(); GUI_Clear(); GUI_SetTextMode(GUI_TM_TRANS); pBm = &GUIDEMO_bm4bpp; GUI_DrawBitmap(pBm, (XSize - (int)pBm->XSize) / 2, (YSize - (int)pBm->YSize) / 2); GUI_DispStringAt("1/2/4/8 bpp bitmaps", 8, 10); GUIDEMO_Wait(); GUI_Clear(); { int i, tm; double xMul, Angle; for (i = 200; (i < 2000) && !GUIDEMO_CheckCancel();) { tm = GUI_GetTime(); GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, i, i); GUI_DispStringAt("Bitmaps can be magnified...", 8, 10); GUI_Exec(); while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel()); i += (GUI_GetTime() - tm) * 6; } GUIDEMO_Delay(2000); GUIDEMO_NotifyStartNext(); GUI_Clear(); for (Angle = 0; Angle < PI4 && !GUIDEMO_CheckCancel();) { tm = GUI_GetTime(); xMul = cos(Angle) * 1000; GUI_ClearRect((XSize - GUIDEMO_bm4bpp.XSize) >> 1, (YSize - GUIDEMO_bm4bpp.YSize) >> 1, (XSize + GUIDEMO_bm4bpp.XSize) >> 1, (YSize + GUIDEMO_bm4bpp.YSize) >> 1); GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, xMul, 1000); GUI_DispStringAt("...and rotated.", 8, 10); GUI_Exec(); while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel()); Angle += (GUI_GetTime() - tm) / 250.0f; } GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, 1000, 1000); GUI_DispStringAt("...and rotated.", 8, 10); } GUIDEMO_Wait(); GUI_SetTextMode(TextModeOld); } #endif #if GUI_WINSUPPORT & GUI_SUPPORT_MEMDEV WM_DisableMemdev(WM_HBKWIN); #endif }
static void _cbDialog(WM_MESSAGE * pMsg) { int i; WM_HWIN hItem; int NCode; int Id; gui_msg_t msg; msg.exec = RT_NULL; switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = pMsg->hWin; WM_EnableMemdev(hItem); //WM_MoveTo(hItem, 0, -30); //WM_MOTION_SetMoveable(hItem, WM_CF_MOTION_Y, 1); WINDOW_SetBkColor(hItem, GUI_WHITE); int fd; /* load APP */ for(i=0;i<GUI_COUNTOF(UIApp);i++) { hItem = BUTTON_CreateAsChild(10, 10, 50, 50, pMsg->hWin, UIApp[i].GUID, WM_CF_SHOW); BUTTON_SetText(hItem, UIApp[i].text); WM_EnableMemdev(hItem); struct stat s; stat(UIApp[i].logoPath, &s); UIApp[i].plogo = rt_malloc(s.st_size); if(UIApp[i].plogo) { fd = open(UIApp[i].logoPath, O_RDONLY , 0); if(fd >=0) { rt_kprintf("%s", UIApp[i].logoPath); read(fd, UIApp[i].plogo, s.st_size); //WM_MoveTo(hItem, 0+(i%2)*120, (i/2)*120 + 0); WM_SetSize(hItem, GUI_BMP_GetXSize(UIApp[i].plogo), GUI_BMP_GetYSize(UIApp[i].plogo)); //xPos+= xSize; //yPos+= ySize; BUTTON_SetBMPEx(hItem, BUTTON_BI_UNPRESSED, UIApp[i].plogo ,0, 0); BUTTON_SetBMPEx(hItem, BUTTON_BI_PRESSED, UIApp[i].plogo ,1, 1); BUTTON_SetTextOffset(hItem, 0, 50); close(fd); } } else { rt_kprintf("no mem!\r\n"); } } /* algin Apps */ int xPos, yPos, xSize, ySize; xPos = 0; xSize = 0; yPos = 0; ySize = 0; for(i=0;i<GUI_COUNTOF(UIApp);i++) { hItem = WM_GetDialogItem(pMsg->hWin, UIApp[i].GUID); xSize = GUI_BMP_GetXSize(UIApp[i].plogo); ySize = GUI_BMP_GetYSize(UIApp[i].plogo); if(xSize == 0 || xSize > 9999) { xSize = 60; } if(ySize == 0 || ySize > 9999) { ySize = 60; } if(abs(LCD_GetXSize() - xPos) >= xSize) { WM_MoveTo(hItem, xPos, yPos); xPos+=xSize; } else { xPos = 0; yPos+=ySize; WM_MoveTo(hItem, xPos, yPos); xPos+=xSize; } } // char *p; // p = rt_malloc(38399); // fd = open("/SD/DESKTOP.JPG",O_RDONLY , 0); // read(fd, p, 38399); // hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0); // WM_EnableMemdev(hItem); // IMAGE_SetJPEG(hItem, p, 38399); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; if(NCode == WM_NOTIFICATION_RELEASED) { for(i=0;i<GUI_COUNTOF(UIApp);i++) { if(Id == UIApp[i].GUID) { msg.exec = UIApp[i].exec; break; } } if(msg.exec != RT_NULL) { rt_mq_send(guimq, &msg, sizeof(msg)); } } break; default: WM_DefaultProc(pMsg); break; } }
/******************************************************************* * * _DemoProgBar */ static void _DemoProgBar(void) { int i; PROGBAR_Handle ahProgBar[2]; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_Progbar - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringAt("Progress bar", 100,80); // // Create the progbars // ahProgBar[0] = PROGBAR_Create(100,100,100,20, WM_CF_SHOW); ahProgBar[1] = PROGBAR_Create( 80,150,140,10, WM_CF_SHOW); // // Use memory device (optional, for better looks) // WM_EnableMemdev(ahProgBar[0]); WM_EnableMemdev(ahProgBar[1]); PROGBAR_SetMinMax(ahProgBar[1], 0, 500); PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16); GUI_Delay(500); while(1) { PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16); if (LCD_GetDevCap(LCD_DEVCAP_BITSPERPIXEL) <= 4) { PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY); } else { PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED); } PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_HCENTER); PROGBAR_SetText(ahProgBar[0], NULL); for (i=0; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], i); GUI_Delay(5); } PROGBAR_SetText(ahProgBar[0], "Tank empty"); for (; i>=0; i--) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 200-i); GUI_Delay(5); } PROGBAR_SetText(ahProgBar[0], "Any text..."); PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_LEFT); for (; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 200+i); GUI_Delay(5); } PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_RIGHT); for (; i>=0; i--) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 400-i); GUI_Delay(5); } PROGBAR_SetFont(ahProgBar[0], &GUI_FontComic18B_1); PROGBAR_SetText(ahProgBar[0], "Any font..."); for (; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 400+i); GUI_Delay(5); } GUI_Delay(500); } }
/********************************************************************* * * MainTask * ********************************************************************** */ void MainTask(void) { GUI_Init(); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, &_cbBkWin); GUI_SetBkColor(GUI_BLUE); GUI_SetFont(&GUI_Font16B_1); GUI_Clear(); ahButton[0] = BUTTON_Create(318-52,152,75-21, 20, GUI_ID_ADC, BUTTON_CF_SHOW ); BUTTON_SetTextColor(ahButton[0],BUTTON_CI_UNPRESSED,GUI_GREEN); BUTTON_SetFont(ahButton[0],&GUI_Font16B_1); BUTTON_SetText(ahButton[0],"Inc"); ahButton[1] = BUTTON_Create(318-52,174,75-21, 20, GUI_ID_DAC, BUTTON_CF_SHOW ); BUTTON_SetTextColor(ahButton[1],BUTTON_CI_UNPRESSED,GUI_GREEN); BUTTON_SetFont(ahButton[1],&GUI_Font16B_1); BUTTON_SetText(ahButton[1],"Dec"); ahButton[2] = BUTTON_Create(318-52,196,75-21, 20, GUI_ID_FFT, BUTTON_CF_SHOW ); BUTTON_SetTextColor(ahButton[2],BUTTON_CI_UNPRESSED,GUI_GREEN); BUTTON_SetFont(ahButton[2],&GUI_Font16B_1); BUTTON_SetText(ahButton[2],"Switch"); ahButton[3] = BUTTON_Create(318-52,218,75-21, 20, GUI_ID_Spectrum, BUTTON_CF_SHOW ); BUTTON_SetTextColor(ahButton[3],BUTTON_CI_UNPRESSED,GUI_GREEN); BUTTON_SetFont(ahButton[3],&GUI_Font16B_1); BUTTON_SetText(ahButton[3],"Spectr"); ahProgbar[0]=PROGBAR_Create(318-52,2,75-21,20,WM_CF_SHOW); PROGBAR_SetBarColor(ahProgbar[0],0,GUI_MAGENTA); PROGBAR_SetBarColor(ahProgbar[0],1,GUI_RED); PROGBAR_SetFont(ahProgbar[0],&GUI_Font16B_1); PROGBAR_SetMinMax(ahProgbar[0],0,100); WIDGET_SetEffect(ahProgbar[0], &WIDGET_Effect_3D); ahScrollbar[0]=SCROLLBAR_Create(0,11,12,217,0,GUI_ID_OSCLevel,WM_CF_SHOW,SCROLLBAR_CF_VERTICAL); SCROLLBAR_SetNumItems(ahScrollbar[0],200); SCROLLBAR_SetValue(ahScrollbar[0],100); DispButton(); DispChInfo(); ConfigRefresh=0; fRefresh =1; while(1) { if(ConfigRefresh == 0) { if (fRefresh) { fRefresh = 0; if(g_DSO.HoldEn == 1) { DispChInfo(); } } if (g_DSO.HoldEn == 0) { StopADC(); /* 暂停采样 */ DispFrame(); DispChInfo(); DispCh1Wave(); FFT_Convert(); StartADC(); /* 开始采样 */ } PROGBAR_SetValue(ahProgbar[0],OSCPUUsage); } GUI_Delay(50); } }