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); }
/********************************************************************* * * _DrawDiagramAt */ static void _DrawDiagramAt(GUI_MEMDEV_Handle hMem, int xPos, int yPos, int * py, int xBlend) { GUI_MEMDEV_Handle hMemOld; GUI_RECT Rect; int IndexBmBar; int ySizeBar; int i; hMemOld = GUI_MEMDEV_Select(hMem); // // Draw blue background // GUI_SetColor(0x4a2210); GUI_FillRoundedRect(xPos, yPos, xPos + GRAPH_WIDTH, yPos + GRAPH_HEIGHT, 4); // // Draw grid lines // GUI_SetColor(0x774830); for (i = 0; i < 12; i++) { GUI_DrawHLine(yPos + 6 + i * 10, xPos + 2, xPos + GRAPH_WIDTH - 2); } // // Draw bars // for (i = 0; i < 10; i++) { IndexBmBar = (i < 6) ? i / 2 : 4 - (i / 2); ySizeBar = *(py + i); GUI_DrawBitmapMag(_apBmBar[IndexBmBar], xPos + 8 + i * 16, yPos + GRAPH_HEIGHT - ySizeBar - 6, 1, ySizeBar); } // // Draw alpha effect // Rect.x0 = xPos; Rect.x1 = xPos + 3; Rect.y0 = yPos; Rect.y1 = yPos + GRAPH_HEIGHT; GUI_SetClipRect(&Rect); GUI_SetColor(0xd99100); GUI_SetAlpha(168); GUI_FillRoundedRect(xPos, yPos, xPos + GRAPH_WIDTH, yPos + GRAPH_HEIGHT, 4); GUI_SetClipRect(NULL); GUI_FillRect(xPos + 4, yPos + 1, xPos + xBlend, yPos + GRAPH_HEIGHT - 1); GUI_SetAlpha(0); // // Draw orange frame // GUI_SetColor(0x0094f3); GUI_DrawRoundedRect(xPos, yPos, xPos + GRAPH_WIDTH, yPos + GRAPH_HEIGHT, 4); // // Label // _DrawLabel(hMem, xPos, yPos); GUI_MEMDEV_CopyToLCD(hMem); GUI_MEMDEV_Select(hMemOld); }
void main_ui(void) { #if 0 _MY_GetTouchPos(); #endif GUI_SetBkColor(GUI_BLACK); GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Hello World!", 30, 200); GUI_DispStringAt("Hello emWin!", 30, 216); GUI_DrawRoundedRect(0,0,200,200,5); GUI_DrawRoundedFrame(2,2,180,20,5,2); }
/********************************************************************* * * _Paint */ static void _Paint_PopupWin(WM_HWIN hWin) { GUI_RECT WinRect; xIconSelBtn_OBJ *pWidget; xICON *pIcon; xICON_CHECK_XY *pIconChkXY; int i; if(!hWin) return; DEBUGOUT("xIconSelBtn::PopupWin hWin = 0x%08x\r\n", hWin); WM_GetClientRect(&WinRect); DEBUGOUT("xIconSelBtn::PopupWin Paint(%d,%d,%d,%d)\r\n",WinRect.x0, WinRect.y0, WinRect.x1, WinRect.y1); WM_GetUserData(hWin, &pWidget, sizeof(xIconSelBtn_OBJ*)); //Draw Window Background area GUI_SetColor(pWidget->PopupWinBkColor[1]); //Base Color GUI_FillRoundedRect(WinRect.x0+1,WinRect.y0+1,WinRect.x1-1,WinRect.y1-1, 2); GUI_SetColor(pWidget->PopupWinBkColor[0]); //OutLine Color GUI_DrawRoundedRect(WinRect.x0,WinRect.y0,WinRect.x1,WinRect.y1, 2); //Draw icons BMP for(i=0; i<pWidget->NumItems; i++) { pIcon= &pWidget->xIconArray[i]; pIconChkXY = &pWidget->xIconCheckXyArray[i]; if(pIcon->pBMP) { if(i == pWidget->MovingIndex) { //Draw Forcus Frame on Icon BMP outside int x0 = pIcon->x0 - pWidget->IconFocusFrameHWidth; int y0 = pIcon->y0 - pWidget->IconFocusFrameVWidth; int x1, y1; x1 = x0 + pIcon->pBMP->XSize + (pWidget->IconFocusFrameHWidth*2); y1 = y0 + pIcon->pBMP->YSize + (pWidget->IconFocusFrameVWidth*2); GUI_SetColor(pWidget->PopupWinIconFocusColor); GUI_FillRect(x0, y0, x1, y1); } GUI_DrawBitmap(pIcon->pBMP, pIcon->x0, pIcon->y0); } if( (pWidget->pCheckedBMP) && (i == pWidget->SelectedIndex) ) { GUI_DrawBitmap(pWidget->pCheckedBMP, pIconChkXY->x0, pIconChkXY->y0); } } }