/********************************************************************* * * _DrawScreen */ static void _DrawScreen(void) { GUI_RECT Rect; int yd; GUI_DrawBitmap(&_bmSeggerLogo_50x25, 10, 10); GUI_SetFont(GUI_FONT_20B_ASCII); GUI_DispStringHCenterAt("Antialiased text sample", 190, 5); GUI_SetFont(GUI_FONT_13_ASCII); GUI_DispStringHCenterAt("Shows antialiased text on different backgrounds.", 190, 25); Rect.x0 = 0; Rect.y0 = 43; Rect.x1 = 59; Rect.y1 = Rect.y0 + 95; yd = (Rect.y1 - Rect.y0) / 3; // // 4 bit antialiasing sample // _DrawText("Antialiased text\n (4 bpp)", &Rect); GUI_SetFont(&_FontAA4_32); _DrawSample(&Rect, yd); // // 2 bit antialiasing sample // GUI_MoveRect(&Rect, 0, 101); _DrawText("Antialiased text\n (2 bpp)", &Rect); GUI_SetFont(&_FontAA2_32); _DrawSample(&Rect, yd); }
/********************************************************************* * * GUIDEMO_ShowIntro * * This function has to be called by every sample */ void GUIDEMO_ShowIntro(const char * acTitle, const char * acDescription) { int xSize, ySize, xCenter, yCenter, FontDistY, TimeWait, i; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); xCenter = xSize >> 1; yCenter = ySize >> 1; GUIDEMO_HideInfoWin(); GUIDEMO_ShowControlWin(); GUI_Exec(); GUIDEMO_DrawBk(1); GUI_SetColor(GUI_WHITE); // // Title // GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontRounded22); GUI_DispStringHCenterAt(acTitle, xCenter, 60); // // Description // GUI_SetFont(&GUI_FontSouvenir18); FontDistY = GUI_GetFontDistY(); GUI_DispStringHCenterAt(acDescription, xCenter, yCenter - FontDistY + 10); // // Determine time to wait // i = 0; while (acDescription[i]) { i++; } TimeWait = i * 80; GUIDEMO_Wait(TimeWait); }
/******************************************************************* * * _DemoHardkey * * Function description * Demonstrates HARDKEY simulation with a listbox */ static void _DemoHardkey(void) { LISTBOX_Handle hListBox; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringAt("Hardkey - Sample", 160, 5); GUI_SetFont(&GUI_Font8x8); GUI_DispStringHCenterAt("Exit", 65, 230); GUI_DispStringHCenterAt("Up", 160, 230); GUI_DispStringHCenterAt("Down", 255, 230); /* Create the listbox */ hListBox = LISTBOX_Create(_aListBox, 100, 100, 120, 75, WM_CF_SHOW); WM_SetFocus(hListBox); LISTBOX_SetFont(hListBox, &GUI_Font13B_1); SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL); /* Handle the listbox */ while (!_Ready) { GUI_Delay(10); } /* Delete listbox widget */ LISTBOX_Delete(hListBox); GUI_Clear(); }
void GUIDEMO_ShowIntro(const char * s, const char * sExp) { GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); _sInfo = s; _sExplain = sExp; GUI_SetDefault(); GUIDEMO_HideInfoWin(); GUI_SetBkColor(GUI_BLUE); GUI_SetColor(GUI_WHITE); GUI_Clear(); //GUI_SetFont(&GUI_FontComic18B_ASCII); GUI_SetFont(&GUI_FontHZ12); GUI_DispStringHCenterAt(s, LCD_GET_XSIZE() / 2, LCD_GET_YSIZE() / 3 - 10); if (_sExplain) { GUI_SetFont(&GUI_Font8_ASCII); GUI_DispStringHCenterAt(_sExplain, LCD_GET_XSIZE() / 2, LCD_GET_YSIZE() / 2 - 10); } GUIDEMO_Delay(_sExplain ? 2000 : 4000); #if GUI_WINSUPPORT _UpdateInfoWin(); _UpdateCmdWin(); #endif GUI_RestoreContext(&ContextOld); #if GUI_WINSUPPORT WM_ExecIdle(); #endif GUIDEMO_NotifyStartNext(); GUI_SetBkColor(GUI_RED); GUI_Clear(); }
/******************************************************************* * * _DemoAntialiasing Draws lines with different antialiasing factors */ static void _DemoAntialiasing(void) { int i, x1, x2, y1, y2; const GUI_FONT *font_old; y1 = 65; y2 = 5; /* Set drawing attributes */ GUI_SetColor(GUI_WHITE); GUI_SetBkColor(GUI_BLACK); GUI_SetPenShape(GUI_PS_FLAT); GUI_Clear(); /* draw headline */ font_old = GUI_SetFont(&GUI_Font24_ASCII); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_DispStringAt("AA_Lines - Sample", 160, 5); /* Draw lines without antialiased */ GUI_Delay(1000); GUI_SetFont(&GUI_Font8x16); GUI_SetTextAlign(GUI_TA_LEFT); GUI_DispStringAtCEOL("draw normal lines using", 5, 40); GUI_DispStringAtCEOL("GUI_DrawLine", 5, 55); GUI_Delay(2500); x1 = 20; x2 = 100; GUI_SetFont(font_old); GUI_DispStringHCenterAt("Normal", (x1 + x2) / 2, 30 + y1); for (i = 1; i < 8; i++) { GUI_SetPenSize(i); GUI_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2); } /* Draw lines with antialiasing quality factor 2 */ GUI_Delay(3000); GUI_SetFont(&GUI_Font8x16); GUI_DispStringAtCEOL("", 5, 40); GUI_DispStringAtCEOL("", 5, 55); GUI_Delay(200); GUI_DispStringAtCEOL("draw antialiased lines using", 5, 40); GUI_DispStringAtCEOL("GUI_AA_DrawLine", 5, 55); GUI_Delay(3500); x1 = 120; x2 = 200; GUI_AA_SetFactor(2); GUI_SetFont(font_old); GUI_DispStringHCenterAt("Antialiased\nusing factor 2", (x1 + x2) / 2, 30 + y1); for (i = 1; i < 8; i++) { GUI_SetPenSize(i); GUI_AA_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2); } /* Draw lines with antialiasing quality factor 6 */ GUI_Delay(1500); x1 = 220; x2 = 300; GUI_AA_SetFactor(6); GUI_SetFont(font_old); GUI_DispStringHCenterAt("Antialiased\nusing factor 6", (x1 + x2) / 2, 30 + y1); for (i = 1; i < 8; i++) { GUI_SetPenSize(i); GUI_AA_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2); } GUI_Delay(7500); }
/******************************************************************* * * _DrawJPEGS * * Iterates over all JPEG files of a directory */ static void _DrawJPEGS(void) { WIN32_FIND_DATA Context; static char acPath[_MAX_PATH]; HANDLE hFind; char acMask[_MAX_PATH]; char acFile[_MAX_PATH]; char acBuffer[_MAX_PATH]; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Drawing scaled JPEGs - Sample", 160, 5); GetWindowsDirectory(acBuffer, sizeof(acBuffer)); _GetFirstBitmapDirectory(acBuffer, acPath); GUI_SetFont(&GUI_Font8x16); sprintf(acMask, "%s*.jp*", acPath); hFind = FindFirstFile(acMask, &Context); if (hFind != INVALID_HANDLE_VALUE) { do { sprintf(acFile, "%s%s", acPath, Context.cFileName); GUI_DispStringAtCEOL(acFile, 5, 40); _DrawJPEG(acFile); } while (FindNextFile(hFind, &Context)); } else { GUI_DispStringHCenterAt("No JPEG files found!", 160, 60); GUI_Delay(2000); } }
/******************************************************************* * * _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++; } }
void GUIDEMO_Intro(void) { int xCenter = LCD_GET_XSIZE() / 2; int y; char acText[50] = "Version of µC/GUI: "; strcat(acText, GUI_GetVersionString()); GUI_SetBkColor(GUI_BLUE); GUI_SetColor(GUI_YELLOW); GUI_Clear(); GUI_SetFont(&GUI_Font13B_1); GUI_DispStringHCenterAt("µC/GUI", xCenter, y= 10); GUI_SetFont(&GUI_Font10_ASCII); GUI_SetColor(GUI_WHITE); GUI_DispStringHCenterAt("Universal graphic software" "\nfor embedded applications" , xCenter, y += 20); GUI_SetFont(&GUI_Font10S_ASCII); GUI_DispStringHCenterAt("Compiled " __DATE__ " "__TIME__, xCenter, y += 25); GUI_DispStringHCenterAt(acText, xCenter, y += 16); GUIDEMO_Delay(5000); GUI_Clear(); GUI_DrawBitmap(&bmMicriumLogo, (LCD_GET_XSIZE() - bmMicriumLogo.XSize) / 2, 6); GUI_SetFont(&GUI_Font13B_1); GUI_DispStringHCenterAt("www.micrium.com", LCD_GET_XSIZE() / 2, LCD_GET_YSIZE() - 50); GUIDEMO_Delay(5000); }
void DemoShiftJIS(void) { GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("FONT_ShiftJIS - Sample", 160, 5); /* Set ShiftJIS font */ GUI_SetFont(&GUI_FontSJIS13); /* Display string */ GUI_DispStringHCenterAt(aSJIS, 160, 80); }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_Init(); while(1) { GUI_DispStringHCenterAt("WIDGET_Window sample\nshows how to use a WINDOW widget", 160, 5); GUI_ExecDialogBox(_aDialog, GUI_COUNTOF(_aDialog), _cbDialog, WM_HBKWIN, 30, 30); GUI_Clear(); GUI_DispStringHCenterAt("Dialog has been closed", 160, 5); GUI_Delay(1000); GUI_Clear(); } }
/******************************************************************* * * Demonstrates output of ShiftJIS characters * ******************************************************************** */ static void _DemoShiftJIS(void) { GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("FONT_ShiftJIS - Sample", 160, 5); // // Set ShiftJIS font // GUI_SetFont(&GUI_FontSJIS13); // // Display string // GUI_DispStringHCenterAt(aSJIS, 160, 80); }
/********************************************************************* * * _cbBkWin * * Function description * Callback routine of desktop window */ static void _cbBkWin(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_Clear(); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_SortedListview - Sample", 160, 5); GUI_SetFont(&GUI_Font10_ASCII); GUI_DispStringHCenterAt("Please touch the header of the LISTVIEW for sorting...", 160, 35); break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbBkWin */ static void _cbBkWin(WM_MESSAGE * pMsg) { const WM_KEY_INFO * pKeyInfo; int NCode; int Id; switch (pMsg->MsgId) { case WM_KEY: pKeyInfo = (const WM_KEY_INFO*)pMsg->Data.p; if (pKeyInfo->PressedCnt > 0) { switch (pKeyInfo->Key) { case GUI_KEY_TAB: WM_SetFocusOnNextChild(pMsg->hWin); break; case GUI_KEY_BACKTAB: WM_SetFocusOnPrevChild(pMsg->hWin); break; case GUI_KEY_ESCAPE: _Break = 1; break; } } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); // Id of widget NCode = pMsg->Data.v; // Notification code switch (NCode) { case WM_NOTIFICATION_RELEASED: // React only if released switch (Id) { case GUI_ID_BUTTON0: _AppSelection = APP_DASHBOARD; break; case GUI_ID_BUTTON1: _AppSelection = APP_CASHTERMINAL; break; } break; } break; case WM_PAINT: GUI_DrawGradientV(0, 0, 639, 479, GUI_BLUE, GUI_BLACK); GUI_SetFont(&GUI_FontAA2_32); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_DispStringHCenterAt("emWin VGA Demonstration\n", 400, 44); GUI_SetFont(&GUI_FontAA2_21); GUI_DispStringHCenterAt("Press the 'Dashboard' or the 'Cash Terminal'\nbutton to start one of the applications\n", 320, 150); GUI_DrawBitmap(&bmSeggerLogo, 30, 30); break; } }
/******************************************************************* * * MainTask */ void MainTask(void) { int xSizeH; GUI_Init(); xSizeH = LCD_GetXSize() / 2; GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Fading sample", xSizeH, 5); GUI_SetFont(&GUI_Font16B_ASCII); GUI_DispStringHCenterAt("Shows how to use memory devices\nfor a fading effect", xSizeH, 40); _DemoFade(); while (1) { GUI_Delay(100); } }
/********************************************************************* * * _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); }
/******************************************************************* * * _ShowHiresAntialiasing * * Function description * This function creates the memory auto devices and handle the * rotation of the pointers */ static void _ShowHiresAntialiasing(void) { GUI_AUTODEV aAuto[2]; PARAM Param; unsigned i; Param.Factor = 3; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringAt("AA_HiResAntialiasing - Sample", 160, 5); GUI_SetFont(&GUI_Font6x8); GUI_DispStringHCenterAt("Using\nhigh\nresolution\nmode", 110, 180); GUI_DispStringHCenterAt("Not using\nhigh\nresolution\nmode", 210, 180); // // Create GUI_AUTODEV objects // for (i = 0; i < countof(aAuto); i++) { GUI_MEMDEV_CreateAuto(&aAuto[i]); } // // Calculate pointer for high resolution // for (i = 0; i < countof(_aPointer); i++) { _aPointerHiRes[i].x = _aPointer[i].x * Param.Factor; _aPointerHiRes[i].y = _aPointer[i].y * Param.Factor; } GUI_AA_SetFactor(Param.Factor); /* Set antialiasing factor */ while (1) { for (i = 0; i < 1800; i++) { float Angle = (i >= 900) ? 1800 - i : i; Angle *= 3.1415926f / 1800; // // Draw pointer with high resolution // GUI_AA_EnableHiRes(); GUI_RotatePolygon(Param.aPoints, _aPointerHiRes, countof(_aPointer), Angle); GUI_MEMDEV_DrawAuto(&aAuto[0], &Param.AutoInfo, _DrawHiRes, &Param); // // Draw pointer without high resolution // GUI_AA_DisableHiRes(); GUI_RotatePolygon(Param.aPoints, _aPointer, countof(_aPointer), Angle); GUI_MEMDEV_DrawAuto(&aAuto[1], &Param.AutoInfo, _Draw, &Param); GUI_Delay(2); } } }
/******************************************************************** * * _Draw * * Function description * Draws some coloured output to the current device (display or memory device) */ static void _Draw(void) { int i; GUI_SetBkColor(GUI_YELLOW); GUI_ClearRect(0, 75, 319, 138); GUI_SetColor(GUI_RED); GUI_SetFont(&GUI_Font32B_ASCII); GUI_DispStringHCenterAt("Printing demo", 160, 75); for (i = 0; i < 12; i += 2) { GUI_SetColor(GUI_GREEN); GUI_DrawRect(5 + i, 80 + i, 50 - i, 101 - i); GUI_SetColor(GUI_BLUE); GUI_DrawRect(269 + i, 80 + i, 314 - i, 101 - i); } for (i = 0; i < 32; i += 8) { GUI_SetColor(GUI_BLUE); GUI_FillRect(0, 107 + i, 319, 110 + i); GUI_SetColor(GUI_YELLOW); GUI_FillRect(0, 111 + i, 319, 114 + i); } i = 8; _DrawBitmap(&bmTestPicture1, i + 0, 111, 0, 0); _DrawBitmap(&bmTestPicture1, i + 35, 111, 1, 0); _DrawBitmap(&bmTestPicture1, i + 70, 111, 0, 1); _DrawBitmap(&bmTestPicture2, i + 105, 111, 0, 0); _DrawBitmap(&bmTestPicture2, i + 140, 111, 1, 0); _DrawBitmap(&bmTestPicture4, i + 175, 111, 0, 0); _DrawBitmap(&bmTestPicture4, i + 210, 111, 1, 0); _DrawBitmap(&bmTestPicture8, i + 245, 111, 0, 0); _DrawBitmap(&bmTestPicture8, i + 280, 111, 1, 0); }
/************************************************************************************** * FunctionName : _DrawCalendar() * Description : 绘制日历表格 * EntryParameter : None * ReturnValue : None **************************************************************************************/ void _DrawCalendar(CLD_DAY *pDay) { const U8 cstWek[][4] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; U8 tmpWth = 320 / 7; U8 tmpHgh = 180 / 6; U8 i = 0, n = 0; GUI_SetColor(GUI_GRAY); // 设置灰色 for (i = 0; i < 7; i++) // 画水平线 { GUI_DrawHLine((60 + i*tmpHgh) - 1, 0, 320); for (n = 0; n < 7; n++) { if (i < 6) { pDay[i * 7 + n].Y = (60 + i*tmpHgh) + tmpHgh / 2; } } } for (i = 0; i < 7; i++) // 画垂直平线 { if (i < 6) GUI_DrawVLine((i + 1)*tmpWth, 60, 240); for (n = 0; n < 6; n++) { pDay[i + 7 * n].X = ((i + 1)*tmpWth) - tmpWth / 2; } } for (i = 0; i < 7; i++) // 显示星期 { GUI_DispStringHCenterAt(cstWek[i], i*tmpWth + tmpWth / 2, 45); } }
/******************************************************************* * * _cbBkWindow */ static void _cbBkWindow(WM_MESSAGE* pMsg) { switch (pMsg->MsgId) { case MSG_CHANGE_MAIN_TEXT: strcpy(_acMainText, pMsg->Data.p); WM_InvalidateWindow(pMsg->hWin); break; case MSG_CHANGE_INFO_TEXT: strcpy(_acInfoText, pMsg->Data.p); WM_InvalidateWindow(pMsg->hWin); break; case WM_PAINT: GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("LISTVIEW Widget - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringAt(_acMainText, 5, 40); GUI_SetFont(&GUI_Font8x8); GUI_DispStringAt(_acInfoText, 5, 60); break; default: WM_DefaultProc(pMsg); } }
/******************************************************************* * * _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); }
/********************************************************************* * * _MoveCursor */ static void _MoveCursor(){ int x, y, tm, cnt = 0; int yStep=-1; int xPos,yPos; xPos = LCD_GetXSize() / 2 - bmSeggerLogoBlue.XSize/2; yPos = LCD_GetYSize() / 2 - bmSeggerLogoBlue.YSize/2+25; GUI_DispStringHCenterAt("Cursor shape can be changed\nand the cursor can be moved", 160, 75); GUI_CURSOR_Show(); GUI_DrawBitmap(&bmSeggerLogoBlue, xPos, yPos ); y = 150; for (x = 0; x < 320; x++) { if ((x % 54) == 0) { GUI_CURSOR_Select(_apCursor[cnt++]); } tm = GUI_GetTime(); y += yStep; if(y<=80) yStep=1; if(y>=150) yStep=-1; GUI_CURSOR_SetPosition(x, y); while ((GUI_GetTime() - tm) < 10); } for (x = 320; x > 0; x--) { tm = GUI_GetTime(); if ((x % 54) == 0) { GUI_CURSOR_Select(_apCursor[cnt++]); } y += yStep; if(y<=80) yStep=1; if(y>=150) yStep=-1; GUI_CURSOR_SetPosition(x, y); while ((GUI_GetTime() - tm) < 10); } GUI_CURSOR_Hide(); GUI_Delay(500); }
static void _UpdateInfoWin(void) { #if GUI_WINSUPPORT && GUIDEMO_LARGE GUI_RECT rClient; WM_HWIN hWin; GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); /* Update info window */ WM_ShowWindow(_ahInfoWin[0]); WM_ShowWindow(_ahFrameWin[0]); hWin = WM_SelectWindow(_ahInfoWin[0]); GUI_GetClientRect(&rClient); GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_BLACK); //GUI_SetFont(&GUI_Font13_1); GUI_SetFont(&GUI_FontHZ12); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_DispStringHCenterAt(_sInfo, (rClient.x1 - rClient.x0) / 2, 0); GUI_SetTextAlign(GUI_TA_LEFT); GUI_SetFont(&GUI_Font8_ASCII); GUI_DispStringAt(_sExplain, 0, 20); WM_SelectWindow(hWin); GUI_RestoreContext(&ContextOld); #endif }
/******************************************************************* * * _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); }
/******************************************************************* * * MainTask */ void MainTask(void) { int xPos; int yPos; int xSize; int i; i = 0; GUI_Init(); // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } xPos = LCD_GetXSize() / 2; yPos = LCD_GetYSize() / 3; GUI_SetTextMode(GUI_TM_REV); GUI_SetFont(GUI_FONT_20F_ASCII); GUI_DispStringHCenterAt("Hello world!", xPos, yPos); GUI_SetFont(GUI_FONT_D24X32); xSize = GUI_GetStringDistX("0000"); xPos -= xSize / 2; yPos += 24 + 10; while (1) { GUI_DispDecAt( i++, xPos, yPos, 4); if (i > 9999) { i = 0; } } }
/******************************************************************* * * _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); }
/******************************************************************* * * _DrawInfoText Drawes the info text directly on the display. This function is for the moments when no callback is set. */ static void _DrawInfoText(char* pStr) { GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WindowManager - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringAtCEOL(pStr, 5, 40); }
static void drawDate(struct tm *t) { char day[15]; char date[15]; char year[15]; /* Format the date */ sprintf(day, "%s", dayNames[t->tm_wday]); sprintf(date, "%s %d", monthNames[t->tm_mon], t->tm_mday); sprintf(year, "%d", 1900 + t->tm_year); /* Draw to display */ GUI_DispStringHCenterAt(day, 63, 30); GUI_DispStringHCenterAt(date, 63, 50); GUI_DispStringHCenterAt(year, 63, 70); }
void Draw_button(int x,int y,int w,int h,const char* text,uint32_t color,uint32_t fill_color,uint32_t textcolor){ uint32_t colormemory; uint32_t bkcolormemory; bkcolormemory=GUI_GetBkColor(); colormemory=GUI_GetColor(); GUI_SetColor(color); //if(filled){ GUI_DrawRoundedRect(x,y,x+w,y+h,10); GUI_SetColor(fill_color); GUI_FillRoundedRect(x+2,y+2,x+w-2,y+h-2,8); GUI_SetBkColor(color); //}else{ // GUI_DrawRoundedRect(x,y,x+w,y+h,10); //} GUI_SetFont(&GUI_Font16_1); GUI_SetColor(textcolor); GUI_SetBkColor(fill_color); GUI_DispStringHCenterAt(text,x+(w/2),y+h/2-8); GUI_SetBkColor(bkcolormemory); GUI_SetColor(colormemory); }
/******************************************************************* * * _DrawWindowsDirectoryBitmaps * * Iterates over all *.jpg-files of the windows directory */ static void _DrawWindowsDirectoryBitmaps(void) { char acPath[_MAX_PATH]; char acMask[_MAX_PATH]; char acFile[_MAX_PATH]; char acBuffer[_MAX_PATH]; WIN32_FIND_DATA Context; HANDLE hFind; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("DrawJPG - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GetWindowsDirectory(acBuffer, sizeof(acBuffer)); _GetFirstBitmapDirectory(acBuffer, acPath); sprintf(acMask, "%s\\*.jpg", acPath); hFind = FindFirstFile(acMask, &Context); if (hFind != INVALID_HANDLE_VALUE) { do { sprintf(acFile, "%s\\%s", acPath, Context.cFileName); GUI_DispStringAtCEOL(acFile, 5, 40); _ShowJPG(acFile); } while (FindNextFile(hFind, &Context)); } }
/******************************************************************* * * _Label Labels the x & y-axis */ static void _Label(void) { int x, y; GUI_SetBkColor(GUI_RED); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("MEMDEV_DrawGraph - Sample", 160, 5); GUI_SetPenSize(1); GUI_ClearRect(0, (LCD_YSIZE - 21) - YSIZE, (LCD_XSIZE - 1), (LCD_YSIZE - 1)); GUI_DrawRect(18, (LCD_YSIZE - 21) - YSIZE, (LCD_XSIZE - 1), (LCD_YSIZE - 20)); GUI_SetFont(&GUI_Font6x8); for (x = 0; x < (LCD_XSIZE - 20); x += 40) { int xPos = x + 18; GUI_DrawVLine(xPos, (LCD_YSIZE - 20), (LCD_YSIZE - 14)); GUI_DispDecAt(x / 40, xPos - 2, (LCD_YSIZE - 9), 1); } for (y = 0; y < YSIZE / 2; y += 20) { int yPos = (LCD_YSIZE - 20) - YSIZE / 2 + y; GUI_DrawHLine(yPos, 13, 18); if (y) { GUI_GotoXY(1, yPos - 4); GUI_DispSDec(-y / 20, 2); yPos = (LCD_YSIZE - 20) - YSIZE / 2 - y; GUI_DrawHLine(yPos, 13, 18); GUI_GotoXY(1, yPos - 4); GUI_DispSDec(y / 20, 2); } else { GUI_DispCharAt('0', 7, yPos - 4); } } }