/******************************************************************* * * _DemoButton */ static void _DemoButton(void) { BUTTON_Handle hButton; int Stat = 0; GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Click on phone button...", 160,80); GUI_Delay(500); /* Create the button */ hButton = BUTTON_Create(142, 100, 36, 40, GUI_ID_OK, WM_CF_SHOW); /* Modify the button attributes */ BUTTON_SetBkColor(hButton, 1, GUI_RED); BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4); /* Loop until button is pressed */ while(GUI_GetKey() != GUI_ID_OK) { if (Stat ^= 1) { BUTTON_SetState(hButton, BUTTON_STATE_HASFOCUS | BUTTON_STATE_INACTIVE); } else { BUTTON_SetState(hButton, BUTTON_STATE_HASFOCUS | BUTTON_STATE_PRESSED); } GUI_Delay(500); } /* Delete button object */ BUTTON_Delete(hButton); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(1750); }
/******************************************************************* * * _DemoListBox */ static void _DemoListBox(void) { int i; int Entries; int ySize; LISTBOX_Handle hListBox; Entries = GUI_COUNTOF(_ListBox) - 1; ySize = GUI_GetYDistOfFont(&GUI_Font13B_1) * Entries; // // Create the listbox // hListBox = LISTBOX_Create(_ListBox, 130, 80, 60, ySize, WM_CF_SHOW); // // Change current selection of the listbox // for (i = 0; i < Entries-1; i++) { GUI_Delay(500); LISTBOX_IncSel(hListBox); WM_ExecIdle(); } for (i = 0; i < Entries-1; i++) { GUI_Delay(500); LISTBOX_DecSel(hListBox); WM_ExecIdle(); } GUI_Delay(750); // // Delete listbox widget // LISTBOX_Delete(hListBox); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(750); }
/******************************************************************* * * _DemoButton */ static void _DemoButton(void) { BUTTON_Handle hButton; int Stat = 0; GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Click on phone button...", 160,80); GUI_Delay(500); /* Create the button */ hButton = BUTTON_Create(142, 100, 36, 40, GUI_ID_OK, WM_CF_SHOW); /* Modify the button attributes */ BUTTON_SetBkColor (hButton, 1, GUI_RED); /* Loop until button is pressed */ while (1) { BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_1, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4); if (!_Wait(50)) break; BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_0, 2, 4); if (!_Wait(45)) break; BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_2, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_2, 2, 4); if (!_Wait(50)) break; BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_0, 2, 4); if (!_Wait(45)) break; } BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_1, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4); GUI_ClearRect(0, 80, 319, 120); GUI_DispStringHCenterAt("You have answered the telephone", 160, 145); GUI_Delay(2000); /* Delete button object */ BUTTON_Delete(hButton); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(400); }
/******************************************************************* * * _DemoCreateWindowAsChild Demonstrates the use of WM_CreateWindowAsChild */ static void _DemoCreateWindowAsChild(void) { /* Create windows */ _ChangeInfoText("WM_CreateWindowAsChild()"); GUI_Delay(SPEED); _hChild = WM_CreateWindowAsChild(10, 50, 145, 40, _hWindow2, WM_CF_SHOW | WM_CF_MEMDEV, _cbChild, 0); GUI_Delay(SPEED); }
int GUIDEMO_Delay(int t) { int r = 0; #if GUI_WINSUPPORT int tRem, tEnd = GUI_GetTime() + t; PROGBAR_Handle hProg; WM_SetForegroundWindow(_ahButton[0]); hProg = (t >100) ? PROGBAR_Create(_FrameWinPosX[1] + 10, _FrameWinPosY[1] + 25, _FrameWinSizeX[1] - 20, 7, WM_CF_SHOW|WM_CF_STAYONTOP) : 0; #if GUI_SUPPORT_MEMDEV PROGBAR_EnableMemdev(hProg); #endif PROGBAR_SetMinMax(hProg, 0, t); for (; tRem = tEnd - GUI_GetTime(), (tRem > 0) && !GUIDEMO_CheckCancel();) { PROGBAR_SetValue(hProg, t - tRem); WM_ExecIdle(); GUI_Delay(10); } PROGBAR_Delete(hProg); _UpdateCmdWin(); WM_ExecIdle(); #else GUI_Delay(t); #endif return r; }
/******************************************************************* * * _DemoResizeWindow Demonstrates the use of WM_ResizeWindow */ static void _DemoResizeWindow(void) { int i, tm,tDiff; _ChangeInfoText("WM_ResizeWindow()"); GUI_Delay(SPEED); _LiftUp(30); for (i = 0; i < 20; i++) { tm = GUI_GetTime(); WM_ResizeWindow(_hWindow1, 1, 1); WM_ResizeWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 40; i++) { tm = GUI_GetTime(); WM_ResizeWindow(_hWindow1, -1, -1); WM_ResizeWindow(_hWindow2, 1, 1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 20; i++) { tm = GUI_GetTime(); WM_ResizeWindow(_hWindow1, 1, 1); WM_ResizeWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } _LiftDown(30); GUI_Delay(SPEED); }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_Init(); // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } #if GUI_SUPPORT_MEMDEV WM_SetCreateFlags(WM_CF_MEMDEV); #endif WM_SetCallback(WM_HBKWIN, &_cbBkWindow); // // Create message box and wait until it is closed // while (1) { GUI_MessageBox("This text is shown\nin a message box", "Caption/Title", GUI_MESSAGEBOX_CF_MOVEABLE); GUI_Delay(750); // Wait for a short moment ... GUI_MessageBox("New message !", "Caption/Title", GUI_MESSAGEBOX_CF_MOVEABLE); GUI_Delay(750); } }
int GUIDEMO_Delay(int t) { int r = 0; #if GUI_WINSUPPORT int tm, value; #if GUIDEMO_LARGE PROGBAR_Handle hProg; #endif WM_SetForegroundWindow(_ahButton[0]); #if GUIDEMO_LARGE hProg = (t >100) ? PROGBAR_CreateAsChild(10, 10, 60, 7, _ahInfoWin[1], 0, WM_CF_SHOW | WM_CF_STAYONTOP| WM_CF_MEMDEV) : 0; PROGBAR_SetMinMax(hProg, 0, t); #endif tm = GUI_GetTime(); do { value = GUI_GetTime() - tm; #if GUIDEMO_LARGE PROGBAR_SetValue(hProg, value); WM_ExecIdle(); #endif GUI_Delay(10); } while ((value < t) && !GUIDEMO_CheckCancel()); #if GUIDEMO_LARGE PROGBAR_Delete(hProg); #endif _UpdateCmdWin(); WM_ExecIdle(); #else GUI_Delay(t); #endif return r; }
/******************************************************************* * * _DrawPolygon Draws polygons of different shapes and colors */ static void _DrawPolygon(void) { int y = 90; /* clear display */ GUI_SetBkColor(GUI_BLACK); GUI_Clear(); /* display text */ GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_DispStringAt("DrawPolygon - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringAt("using", 5, 40); GUI_DispStringAt("GUI_FillPolygon", 5, 55); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_DispStringAt("Polygons of arbitrary shape\nin any color", 160, y + 90); GUI_Delay(500); /* draw filled polygons */ while (1) { GUI_ClearRect(100, y, 220, y + 85); GUI_SetColor(GUI_BLUE); GUI_FillPolygon (&_aPointArrow[0], 7, 160, y + 80); GUI_Delay(1000); GUI_ClearRect(100, y, 220, y + 85); GUI_SetColor(GUI_RED); GUI_FillPolygon (&_aPointStar[0], 8, 160, y + 45); GUI_Delay(1000); GUI_ClearRect(100, y, 220, y + 85); GUI_SetColor(GUI_GREEN); GUI_FillPolygon(&_aPointHexagon[0], 6, 160, y + 45); GUI_Delay(1000); } }
/******************************************************************* * * _DemoListBox */ void _DemoListBox(void) { int i; int Entries = GUI_COUNTOF(_ListBox) - 1; LISTBOX_Handle hListBox; int xSize = LCD_GetXSize(); //int ySize = GUI_GetYDistOfFont(&GUI_Font13B_1) * Entries; int ySize = LCD_GetYSize(); /* Create the listbox */ hListBox = LISTBOX_Create(_ListBox, 0, 0, xSize, ySize, WM_CF_SHOW); /* Change current selection of the listbox */ for (i = 0; i < Entries-1; i++) { GUI_Delay(500); LISTBOX_IncSel(hListBox); WM_ExecIdle(); } GUI_Delay(75000); for (i = 0; i < Entries-1; i++) { GUI_Delay(500); LISTBOX_DecSel(hListBox); WM_ExecIdle(); } GUI_Delay(7500); /* Delete listbox widget */ LISTBOX_Delete(hListBox); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(750); }
/********************************************************************* * * MainTask */ void CreateWindow(void) { WM_HWIN hMultiPage; WM_HWIN hFrameWin; WM_HWIN hDialog; // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } WM_SetCallback(WM_HBKWIN, _cbBkWindow); // // Create the frame window // hFrameWin = FRAMEWIN_Create("Sample", NULL, WM_CF_SHOW, 0, 0, 240, 152); FRAMEWIN_SetClientColor(hFrameWin, GUI_GREEN); FRAMEWIN_SetActive(hFrameWin, 1); FRAMEWIN_SetMoveable(hFrameWin, 1); // // Create the MULTIPAGE widget // hMultiPage = MULTIPAGE_CreateEx(7, 6, 220, 120, WM_GetClientWindow(hFrameWin), WM_CF_SHOW, 0, 0); GUI_Delay(500); // // Create and attach the MULTIPAGE dialog windows // hDialog = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 1"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 2"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate3, GUI_COUNTOF(_aDialogCreate3), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 3"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate4, GUI_COUNTOF(_aDialogCreate4), _cbDialog4, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 4"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate5, GUI_COUNTOF(_aDialogCreate5), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 5"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate6, GUI_COUNTOF(_aDialogCreate6), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 6"); GUI_Delay(500); // // Demonstrate the use of MULTIPAGE_SetAlign // MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_RIGHT); GUI_Delay(500); MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_RIGHT | MULTIPAGE_ALIGN_BOTTOM); GUI_Delay(500); MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_LEFT | MULTIPAGE_ALIGN_BOTTOM); while (1) { GUI_Delay(100); } }
/******************************************************************* * * _DemoInvalidateWindow Demonstrates the use of WM_InvalidateWindow */ static void _DemoInvalidateWindow(void) { _ChangeInfoText("WM_InvalidateWindow()"); _WindowColor1 = GUI_BLUE; _FrameColor1 = GUI_GREEN; GUI_Delay(SPEED); WM_InvalidateWindow(_hWindow1); GUI_Delay(SPEED); }
/********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hMultiPage; WM_HWIN hFrameWin; WM_HWIN hDialog; // // Enable use of memory devices // WM_SetCreateFlags(WM_CF_MEMDEV); GUI_Init(); WM_SetCallback(WM_HBKWIN, _cbBkWindow); // // Create the frame window // hFrameWin = FRAMEWIN_Create("FrameWindow", NULL, WM_CF_SHOW, 40, 44, 240, 152); FRAMEWIN_SetClientColor(hFrameWin, GUI_GREEN); FRAMEWIN_SetActive(hFrameWin, 1); FRAMEWIN_SetMoveable(hFrameWin, 1); // // Create the MULTIPAGE widget // hMultiPage = MULTIPAGE_CreateEx(7, 6, 220, 120, WM_GetClientWindow(hFrameWin), WM_CF_SHOW, 0, 0); GUI_Delay(500); // // Create and attach the MULTIPAGE dialog windows // hDialog = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 1"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 2"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate3, GUI_COUNTOF(_aDialogCreate3), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 3"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate4, GUI_COUNTOF(_aDialogCreate4), _cbDialog4, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 4"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate5, GUI_COUNTOF(_aDialogCreate5), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 5"); GUI_Delay(500); hDialog = GUI_CreateDialogBox(_aDialogCreate6, GUI_COUNTOF(_aDialogCreate6), NULL, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 6"); GUI_Delay(500); // // Demonstrate the use of MULTIPAGE_SetAlign // MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_RIGHT); GUI_Delay(500); MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_RIGHT | MULTIPAGE_ALIGN_BOTTOM); GUI_Delay(500); MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_LEFT | MULTIPAGE_ALIGN_BOTTOM); while (1) { GUI_Delay(100); } }
/******************************************************************* * * _DemoHideShowChild Demonstrates the use of WM_HideWindow and WM_ShowWindow */ static void _DemoHideShowChild(void) { _ChangeInfoText("WM_HideWindow(Child)"); GUI_Delay(SPEED); WM_HideWindow(_hChild); GUI_Delay(SPEED); _ChangeInfoText("WM_ShowWindow(Child)"); GUI_Delay(SPEED); WM_ShowWindow(_hChild); GUI_Delay(SPEED); }
/********************************************************************* * * _DemoListView */ static void _DemoListView(void) { _ChangeMainText("LISTVIEW control without parent"); _ChangeInfoText("LISTVIEW_Create"); _hListView = LISTVIEW_Create(10, 80, 300, 89, 0, 1234, WM_CF_SHOW, 0); GUI_Delay(SPEED / 2); _Demo(); _ChangeInfoText("LISTVIEW_Delete"); LISTVIEW_Delete(_hListView); GUI_Delay(SPEED); }
/******************************************************************* * * _DemoCreateWindow Demonstrates the use of WM_CreateWindow */ static void _DemoCreateWindow(void) { /* Set callback for background window */ _cbBkWindowOld = WM_SetCallback(WM_HBKWIN, _cbBkWindow); /* Create windows */ _ChangeInfoText("WM_CreateWindow()"); GUI_Delay(SPEED); _hWindow1 = WM_CreateWindow( 50, 70, 165, 100, WM_CF_SHOW | WM_CF_MEMDEV, _cbWindow1, 0); GUI_Delay(SPEED/3); _hWindow2 = WM_CreateWindow(105, 125, 165, 100, WM_CF_SHOW | WM_CF_MEMDEV, _cbWindow2, 0); GUI_Delay(SPEED); }
/********************************************************************* * * _ChangeInfoText */ static int _ChangeInfoText(const char* pString, int Delay) { if (_hFrame) { GUI_Delay(Delay * 0.75); strcpy(_acInfoText, pString); WM_InvalidateWindow(WM_HBKWIN); } if (_hFrame) { GUI_Delay(Delay); return 0; } return 1; }
/******************************************************************* * * _DemoSetDesktopColor Demonstrates the use of WM_SetDesktopColor */ static void _DemoSetDesktopColor(void) { GUI_SetBkColor(GUI_BLUE); GUI_Clear(); _DrawInfoText("WM_SetDesktopColor()"); GUI_Delay(SPEED*3/2); WM_SetDesktopColor(GUI_BLACK); GUI_Delay(SPEED/2); /* Set background color and invalidate desktop color. This is needed for the later redrawing demo. */ GUI_SetBkColor(GUI_BLACK); WM_SetDesktopColor(GUI_INVALID_COLOR); }
/********************************************************************* * * _DemoVScreen */ static void _DemoVScreen(void) { GUI_RECT Rect; unsigned j; int xSize; int ySize; int n; int aDelay[] = { 20, 5 }; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); GUI_SetFont(&GUI_FontComic24B_ASCII); GUI_SetTextMode(GUI_TM_TRANS); Rect.x0 = 0; Rect.y0 = 0; Rect.x1 = xSize - 1; Rect.y1 = ySize - 1; GUI_SetColor(GUI_WHITE); GUI_DispStringInRect("Default screen", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER); GUI_Delay(250); Rect.y0 += ySize; Rect.y1 += ySize; GUI_DrawGradientV(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 0xFFFFFF, 0x000000); Rect.y1 -= ySize / 3; GUI_SetColor(GUI_DARKGREEN); GUI_DispStringInRect("Here is the virtual screen", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER); n = ySize / 5; for (j = 0; j < GUI_COUNTOF(aDelay); j++) { if (_Loop(0, 5, n, aDelay[j]) == 1) { return; } GUI_SetOrg(0, ySize); GUI_Delay(250); if (_Loop(ySize, -5, n, aDelay[j]) == 1) { return; } GUI_SetOrg(0, 0); GUI_Delay(250); if (GUIDEMO_CheckCancel()) { return; } } for (j = 0; j < 5; j++) { GUI_SetOrg(0, ySize); GUI_Delay(200); GUI_SetOrg(0, 0); GUI_Delay(200); if (GUIDEMO_CheckCancel()) { return; } } GUIDEMO_Delay(1000); }
void GUIDEMO_Messagebox(void) { GUI_COLOR Color; GUIDEMO_ShowIntro("Message boxes", "Message boxes" "\ncan easily be created"); Color = WM_SetDesktopColor(GUI_RED); GUI_MessageBox("Message", "Text", 0); GUI_Delay(1000); GUI_MessageBox("2. Message", "Text", 0); GUI_Delay(1000); WM_SetDesktopColor(Color); GUIDEMO_NotifyStartNext(); }
/******************************************************************* * * _DemoDeleteWindow Demonstrates the use of WM_DeleteWindow */ static void _DemoDeleteWindow(void) { _ChangeInfoText("WM_DeleteWindow()"); GUI_Delay(SPEED); WM_DeleteWindow(_hWindow2); GUI_Delay(SPEED/3); WM_DeleteWindow(_hWindow1); GUI_Delay(SPEED); _ChangeInfoText(""); GUI_Delay(SPEED); /* Restore background callback and window colors */ WM_SetCallback(WM_HBKWIN, _cbBkWindowOld); _WindowColor1 = GUI_GREEN; _WindowColor2 = GUI_RED; }
/******************************************************************* * * _DemoRedrawing Demonstrates how useful can be a callback */ static void _DemoRedrawing(void) { int i, tm, tDiff; _ChangeInfoText("Demonstrating redrawing"); // GUIDEMO_Delay(SPEED); _LiftUp(40); GUIDEMO_Delay(SPEED/3); _ChangeInfoText("Using a callback for redrawing"); GUIDEMO_Delay(SPEED/3); for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, 1, 1); WM_MoveWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, -1, -1); WM_MoveWindow(_hWindow2, 1, 1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } GUIDEMO_Delay(SPEED/4); _LiftDown(30); GUIDEMO_Delay(SPEED/2); _ChangeInfoText("Without redrawing"); GUIDEMO_Delay(SPEED); _LiftUp(30); GUIDEMO_Delay(SPEED/4); WM_SetCallback(WM_HBKWIN, _cbBkWindowOld); for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, 1, 1); WM_MoveWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, -1, -1); WM_MoveWindow(_hWindow2, 1, 1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } GUIDEMO_Delay(SPEED/3); WM_SetCallback(WM_HBKWIN, _cbBkWindow); _LiftDown(40); GUIDEMO_Delay(SPEED); GUIDEMO_NotifyStartNext(); }
/******************************************************************* * * _DemoDropDownAsChild */ static void _DemoDropDownAsChild(void) { WM_HWIN hFrame; WM_HWIN hDropDown; /* Display titel */ GUI_SetBkColor(0xB00000); GUI_SetColor(0xFFFFFF); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Dropdown as child - Sample", 160, 5); GUI_Delay(SPEED / 2); /* Create framewin */ GUI_SetFont(&GUI_Font8x16); GUI_SetTextAlign(GUI_TA_LEFT); GUI_DispStringAtCEOL("using", 5, 40); GUI_DispStringAtCEOL("FRAMEWIN_Create", 5, 55); GUI_Delay(SPEED); hFrame = FRAMEWIN_Create("DropDown", NULL, WM_CF_SHOW, 80, 80, 160, 140); FRAMEWIN_SetFont(hFrame, &GUI_Font16B_ASCII); FRAMEWIN_SetActive(hFrame, 1); GUI_Delay(SPEED * 0.75); /* Create listbox */ GUI_DispStringAtCEOL("DROPDOWN_CreateEx", 5, 55); GUI_Delay(SPEED); hDropDown = DROPDOWN_CreateEx(20, 20, 120, 65, WM_GetClientWindow(hFrame), WM_CF_SHOW, 0, 0); GUI_Delay(SPEED * 0.75); /* Show serveral functions of listbox */ _ShowSeveralFunctions(hDropDown); /* Delete framewin widget */ GUI_DispStringAtCEOL("FRAMEWIN_Delete", 5, 55); GUI_Delay(SPEED); FRAMEWIN_Delete(hFrame); GUI_Delay(SPEED * 0.75); /* Clear display */ GUI_Clear(); GUI_Delay(SPEED * 1.5); }
/******************************************************************* * * _DemoListBoxAsChild */ static void _DemoListBoxAsChild(void) { FRAMEWIN_Handle hFrame; LISTBOX_Handle hListBox; /* Display titel */ GUI_SetBkColor(0xB00000); GUI_SetColor(0xFFFFFF); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Listbox as child - Sample", 160, 5); GUI_Delay(SPEED / 2); /* Create framewin */ GUI_SetFont(&GUI_Font8x16); GUI_SetTextAlign(GUI_TA_LEFT); GUI_DispStringAtCEOL("using", 5, 40); GUI_DispStringAtCEOL("FRAMEWIN_Create", 5, 55); GUI_Delay(SPEED); hFrame = FRAMEWIN_Create("List box", NULL, WM_CF_SHOW, 100, 80, 120, 140); FRAMEWIN_SetFont(hFrame, &GUI_Font16B_ASCII); FRAMEWIN_SetActive(hFrame, 1); GUI_Delay(SPEED * 0.75); /* Create listbox */ GUI_DispStringAtCEOL("LISTBOX_CreateAsChild", 5, 55); GUI_Delay(SPEED); hListBox = LISTBOX_CreateAsChild(_ListBox, WM_GetClientWindow(hFrame), 0, 0, 0, 0, WM_CF_SHOW); GUI_Delay(SPEED * 0.75); /* Show serveral functions of listbox */ _ShowSeveralFunctions(hListBox); /* Delete framewin widget */ GUI_DispStringAtCEOL("FRAMEWIN_Delete", 5, 55); GUI_Delay(SPEED); FRAMEWIN_Delete(hFrame); GUI_Delay(SPEED * 0.75); /* Clear display */ GUI_Clear(); GUI_Delay(SPEED * 1.5); }
/********************************************************************* * * _DispCursor */ static void _DispCursor(void) { int i, x, y; GUI_DispStringHCenterAt("Available cursors:", 160, 80); for (i = 0; i < 12; i++) { x = 160 - (_apCursor[i]->pBitmap->XSize / 2); y = 120 - (_apCursor[i]->pBitmap->YSize / 2); GUI_DrawBitmap(_apCursor[i]->pBitmap, x, y); GUI_DispStringHCenterAt(_aacCursorName[i], 160,145); GUI_Delay(750); GUI_ClearRect(0, 100, 319, 165); } GUI_ClearRect(0, 80, 319, 100); GUI_Delay(500); }
/******************************************************************* * * _ShowComments * * Shows all comments of a GIF file */ static void _ShowComments(const char * pFile, int FileSize) { GUI_RECT Rect = {80, 100, 239, 199}; char acBuffer[256] = {0}; int CommentCnt; /* Display sample information */ GUI_SetFont(&GUI_Font8x16); GUI_ClearRect(0, 40, 319, 59); GUI_DispStringHCenterAt("Show all comments of a GIF file", 160, 40); /* Show all comments */ GUI_ClearRect(0, 60, 319, 239); /* Clear the image area */ CommentCnt = 0; while (!GUI_GIF_GetComment(pFile, FileSize, (unsigned char *)acBuffer, sizeof(acBuffer), CommentCnt)) { char acNumber[12] = "Comment #0:"; acNumber[9] = '0' + CommentCnt; GUI_DispStringHCenterAt(acNumber, 160, 80); GUI_SetBkColor(GUI_BLACK); GUI_SetColor(GUI_WHITE); GUI_ClearRectEx(&Rect); GUI_DispStringInRectWrap(acBuffer, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER, GUI_WRAPMODE_WORD); GUI_SetBkColor(GUI_WHITE); GUI_SetColor(GUI_BLACK); GUI_Delay(4000); /* Wait a while */ CommentCnt++; } }
/********************************************************************* * * 在触摸校正的时候使用这个来读取ADC的值 */ void Touch_MainTask(void) { GUI_CURSOR_Show(); GUI_CURSOR_Select(&GUI_CursorCrossL); GUI_SetBkColor(GUI_WHITE); GUI_SetColor(GUI_BLACK); GUI_Clear(); GUI_DispString("Measurement of\nA/D converter values"); while (1) { GUI_PID_STATE TouchState; int xPhys, yPhys; GUI_TOUCH_GetState(&TouchState); /* Get the touch position in pixel */ xPhys = GUI_TOUCH_GetxPhys(); /* Get the A/D mesurement result in x */ yPhys = GUI_TOUCH_GetyPhys(); /* Get the A/D mesurement result in y */ /* Display the measurement result */ GUI_SetColor(GUI_BLUE); GUI_DispStringAt("Analog input:\n", 0, 20); GUI_GotoY(GUI_GetDispPosY() + 2); GUI_DispString("x:"); GUI_DispDec(xPhys, 4); GUI_DispString(", y:"); GUI_DispDec(yPhys, 4); /* Display the according position */ GUI_SetColor(GUI_RED); GUI_GotoY(GUI_GetDispPosY() + 4); GUI_DispString("\nPosition:\n"); GUI_GotoY(GUI_GetDispPosY() + 2); GUI_DispString("x:"); GUI_DispDec(TouchState.x,4); GUI_DispString(", y:"); GUI_DispDec(TouchState.y,4); /* Wait a while */ GUI_Delay(100); }; }
/******************************************************************* * * _DemoSetCallback Demonstrates the use of WM_SetCallback */ static void _DemoSetCallback(void) { _ChangeInfoText("WM_SetCallback()"); GUI_Delay(SPEED); WM_SetCallback(_hWindow1, _cbDemoCallback1); WM_InvalidateWindow(_hWindow1); GUI_Delay(SPEED/2); WM_SetCallback(_hWindow2, _cbDemoCallback2); WM_InvalidateWindow(_hWindow2); GUI_Delay(SPEED*3); WM_SetCallback(_hWindow1, _cbWindow1); WM_InvalidateWindow(_hWindow1); GUI_Delay(SPEED/2); WM_SetCallback(_hWindow2, _cbWindow2); WM_InvalidateWindow(_hWindow2); GUI_Delay(SPEED); }
void _TestCalibration(void) { int IdleCnt=0; BUTTON_Handle hButton; GUI_SetBkColor(GUI_RED); GUI_SetColor(GUI_WHITE); GUI_Clear(); hButton = BUTTON_Create( 225, 15, 80, 40, 1, BUTTON_CF_SHOW ); BUTTON_SetText (hButton, "ABORT"); BUTTON_SetFont (hButton, &GUI_FontComic18B_ASCII); while ((IdleCnt<50) && (GUI_GetKey()==0)) { static GUI_PID_STATE StateLast; GUI_PID_STATE State; GUI_TOUCH_GetState(&State); if ((StateLast.Pressed != State.Pressed) && (State.Pressed == 0)) { GUI_Clear(); } if ((StateLast.x != State.x) || ((StateLast.y != State.y))) { if (State.Pressed) { GUI_FillCircle(State.x, State.y, 5); } StateLast = State; } if (State.Pressed) { IdleCnt =0; } else { IdleCnt++; } GUI_Delay (100); } EDIT_Delete(hButton); }
/********************************************************************* * * GUIDEMO_Delay * * This function has to be called if the current step of the sample * is the last one and consists of a single frame */ void GUIDEMO_Delay(int TimeDelay) { PROGBAR_Handle hProg; int NextState; U32 TimeStart; U32 TimeDiff; hProg = WM_GetDialogItem(_hDialogControl, GUI_ID_PROGBAR0); if (TimeDelay > SHOW_PROGBAR_AT) { _ShowProgress(); } PROGBAR_SetValue(hProg, 0); PROGBAR_SetMinMax(hProg, 0, TimeDelay); TimeStart = GUI_GetTime(); do { TimeDiff = GUIDEMO_GetTime() - TimeStart; if (TimeDelay > SHOW_PROGBAR_AT) { PROGBAR_SetValue(hProg, TimeDiff); } GUI_Delay(5); NextState = GUIDEMO_CheckCancel(); } while (TimeDiff < (U32)TimeDelay && !NextState); if (TimeDelay > SHOW_PROGBAR_AT) { _HideProgress(); } GUI_Exec(); }