void GUI_DrawBitmapExp(int x0, int y0, int XSize, int YSize, int XMul, int YMul, int BitsPerPixel, int BytesPerLine, const U8* pData, const GUI_LOGPALETTE* pPal) { GUI_DRAWMODE PrevDraw; GUI_LOCK(); PrevDraw = GUI_SetDrawMode((pPal && pPal->HasTrans) ? GUI_DRAWMODE_TRANS : 0); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); { GUI_RECT r; r.x0 = x0; r.x1 = x0 + XSize * XMul -1; r.y0 = y0; r.y1 = y0 + YSize * YMul -1; WM_ITERATE_START(&r); { #endif LCD_DrawBitmap( x0, y0 ,XSize ,YSize, XMul, YMul ,BitsPerPixel, BytesPerLine, pData, pPal); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); } #endif GUI_SetDrawMode(PrevDraw); GUI_UNLOCK(); }
/********************************************************************* * * GUI_MEMDEV_WriteAt */ void GUI_MEMDEV_WriteAt(GUI_MEMDEV_Handle hMem, int x, int y) { if (hMem) { GUI_MEMDEV* pDevData; #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); pDevData = (GUI_MEMDEV*) GUI_ALLOC_h2p(hMem); /* Convert to pointer */ if (x == GUI_POS_AUTO) { x = pDevData->x0; y = pDevData->y0; } #if (GUI_WINSUPPORT) /* Calculate rectangle */ r.x1 = (r.x0 = x) + pDevData->XSize-1; r.y1 = (r.y0 = y) + pDevData->YSize-1;; /* Do the drawing. WIndow manager has to be on */ WM_ITERATE_START(&r) { GUI_MEMDEV__WriteToActiveAt(hMem,x,y); } WM_ITERATE_END(); #else GUI_MEMDEV__WriteToActiveAt(hMem,x,y); #endif GUI_UNLOCK(); } }
/********************************************************************* * * GUI_DrawBitmapEx */ void GUI_DrawBitmapEx(const GUI_BITMAP GUI_UNI_PTR * pBitmap, int x0, int y0, int xCenter, int yCenter, int xMag, int yMag) { GUI_COLOR OldColor; #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); OldColor = GUI_GetColor(); #if (GUI_WINSUPPORT) WM_ADDORG(x0, y0); if (xMag >= 0) { r.x0 = x0 + GUI__DivideRound32(((I32)(-xCenter) * (I32)(xMag)), 1000); r.x1 = x0 + GUI__DivideRound32(((I32)(pBitmap->XSize - xCenter - 1) * (I32)(xMag)), 1000); } else { r.x1 = x0 + GUI__DivideRound32(((I32)(-xCenter) * (I32)(xMag)), 1000); r.x0 = x0 + GUI__DivideRound32(((I32)(pBitmap->XSize - xCenter - 1) * (I32)(xMag)), 1000); } if (yMag >= 0) { r.y0 = y0 + GUI__DivideRound32(((I32)(-yCenter) * (I32)(yMag)), 1000); r.y1 = y0 + GUI__DivideRound32(((I32)(pBitmap->YSize - yCenter - 1) * (I32)(yMag)), 1000); } else { r.y1 = y0 + GUI__DivideRound32(((I32)(-yCenter) * (I32)(yMag)), 1000); r.y0 = y0 + GUI__DivideRound32(((I32)(pBitmap->YSize - yCenter - 1) * (I32)(yMag)), 1000); } WM_ITERATE_START(&r) { #endif GL_DrawBitmapEx(pBitmap, x0, y0, xCenter, yCenter, xMag, yMag); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_SetColor(OldColor); GUI_UNLOCK(); }
/********************************************************************* * * _DrawPolyLine */ static void _DrawPolyLine(const GUI_POINT * pPoints, int NumPoints, int x0, int y0) { unsigned PixelCnt; PixelCnt = 0; WM_ADDORG(x0,y0); WM_ITERATE_START(NULL); { GL_MoveTo(pPoints->x + x0, y0 - pPoints->y); while (--NumPoints >0) { pPoints++; GL_DrawLineToEx(pPoints->x + x0, y0 - pPoints->y, &PixelCnt); } } WM_ITERATE_END(); }
/* Note on usage of this routine: If at all possible, try to avoid using this, since every call will invoke the window manager. If possible, use the string routines. */ static void CL_DispChar(U16 c) { GUI_RECT r; WM_ADDORG(GUI_Context.DispPosX, GUI_Context.DispPosY); r.x1 = (r.x0 = GUI_Context.DispPosX) + GUI_GetCharDistX(c)-1; r.y1 = (r.y0 = GUI_Context.DispPosY) + GUI_GetFontSizeY()-1; WM_ITERATE_START(&r) { GL_DispChar(c); if (c != '\n') GUI_Context.DispPosX = r.x1 + 1; } WM_ITERATE_END(); WM_SUBORG(GUI_Context.DispPosX,GUI_Context.DispPosY); }
/********************************************************************* * * GUI_DrawPoint */ void GUI_DrawPoint(int x, int y) { GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x, y); WM_ITERATE_START(NULL); { #endif GL_DrawPoint(x, y); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
void GUI_DrawPolyLine (const GUI_POINT* pPoints, int NumPoints, int x0, int y0) { GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); WM_ITERATE_START(NULL); { #endif _DrawPolyLine (pPoints, NumPoints, x0, y0); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
/********************************************************************* * * GUI_DrawPie */ void GUI_DrawPie(int x0, int y0, int r, int a0, int a1, int Type) { GUI_LOCK(); #if GUI_WINSUPPORT WM_ADDORG(x0,y0); WM_ITERATE_START(NULL) { #endif _DrawPie( x0, y0, r, a0, a1, Type); #if GUI_WINSUPPORT } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
void GUI_DrawArc (int x0, int y0, int rx, int ry, int a0, int a1) { GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); WM_ITERATE_START(NULL) { #endif GL_DrawArc( x0, y0, rx, ry, a0, a1); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
/********************************************************************* * * GUI_DrawGraph */ void GUI_DrawGraph(I16 *pay, int NumPoints, int x0, int y0) { GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); WM_ITERATE_START(NULL); { #endif _DrawGraph(pay, NumPoints, x0, y0); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
/********************************************************************* * * _DrawMax */ static void _DrawMax(void) { GUI_RECT r; WM_GetInsideRect(&r); WM_ADDORG(r.x0, r.y0); WM_ADDORG(r.x1, r.y1); WM_ITERATE_START(&r); { LCD_DrawHLine(r.x0 + 1, r.y0 + 1, r.x1 - 1); LCD_DrawHLine(r.x0 + 1, r.y0 + 2, r.x1 - 1); LCD_DrawHLine(r.x0 + 1, r.y1 - 1, r.x1 - 1); LCD_DrawVLine(r.x0 + 1, r.y0 + 1, r.y1 - 1); LCD_DrawVLine(r.x1 - 1, r.y0 + 1, r.y1 - 1); } WM_ITERATE_END(); }
/********************************************************************* * * GUI_JPEG_Draw */ int GUI_JPEG_Draw(const void * pFileData, int DataSize, int x0, int y0) { #if (GUI_WINSUPPORT) GUI_RECT r; #endif int Ret = 0; GUI_HMEM hBuffer = 0; struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; GUI_LOCK(); _Init(&jerr, &cinfo, pFileData, DataSize); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); r.x1 = (r.x0 = x0) + cinfo.image_width - 1; r.y1 = (r.y0 = y0) + cinfo.image_height - 1; WM_ITERATE_START(&r) { #endif if (hBuffer) { _Init(&jerr, &cinfo, pFileData, DataSize); } /* 4. Set up parameters for decompression (optional ...) */ /* 5. jpeg_start_decompress(...); Should normally return quickly */ jpeg_start_decompress(&cinfo); /* 6. while (scan lines remain to be read) */ /* jpeg_read_scanlines(...); */ if (!hBuffer) { hBuffer = GUI_ALLOC_AllocNoInit(cinfo.image_width * 3); } while (cinfo.output_scanline < cinfo.output_height) { U8* p; p = (U8*)GUI_ALLOC_h2p(hBuffer); jpeg_read_scanlines(&cinfo, &p, 1); if (cinfo.jpeg_color_space == JCS_GRAYSCALE) { _WritePixelsGray(p, x0, y0 + cinfo.output_scanline, cinfo.image_width); } else { _WritePixelsRGB(p, x0, y0 + cinfo.output_scanline, cinfo.image_width); } } /* 7. jpeg_finish_decompress(...); */ /* Complete the decompression cycle. This causes working memory associated */ /* with the JPEG object to be released. */ jpeg_finish_decompress(&cinfo); /* 8. Release the JPEG decompression object. */ jpeg_destroy_decompress(&cinfo); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_ALLOC_Free(hBuffer); GUI_UNLOCK(); return Ret; }
/********************************************************************* * * GUI__DispLine */ void GUI__DispLine(const char GUI_UNI_PTR *s, int MaxNumChars, const GUI_RECT* pr) { GUI_RECT r; #if GUI_SUPPORT_ROTATION if (GUI_pLCD_APIList) { #if GUI_WINSUPPORT WM_ITERATE_START(NULL) { #endif /* Do the actual drawing via routine call. */ _DispLine(s, MaxNumChars, &r); #if GUI_WINSUPPORT } WM_ITERATE_END(); #endif } else #endif {
/********************************************************************* * * GUI_DrawFocusRect */ void GUI_DrawFocusRect(const GUI_RECT *pRect, int Dist) { GUI_RECT r; GUI__ReduceRect(&r, pRect, Dist); GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(r.x0, r.y0); WM_ADDORG(r.x1, r.y1); WM_ITERATE_START(&r); { #endif _DrawFocusRect(&r); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
void GUI_ClearRect(int x0, int y0, int x1, int y1) { GUI_DRAWMODE PrevDraw; GUI_LOCK(); PrevDraw = LCD_SetDrawMode(GUI_DRAWMODE_REV); #if GUI_WINSUPPORT WM_ADDORG(x0,y0); WM_ADDORG(x1,y1); WM_ITERATE_START(NULL) { #endif LCD_FillRect(x0,y0,x1,y1); #if GUI_WINSUPPORT } WM_ITERATE_END(); #endif LCD_SetDrawMode(PrevDraw); GUI_UNLOCK(); }
/********************************************************************* * * _DispLine */ static void _DispLine(const U16 GUI_UNI_PTR *s, int Len, const GUI_RECT* pr) { GUI_RECT r; r = *pr; #if GUI_WINSUPPORT WM_ADDORG(r.x0,r.y0); WM_ADDORG(r.x1,r.y1); WM_ITERATE_START(&r) { #endif GUI_Context.DispPosX[GUI_Context.SelLayer] = r.x0; GUI_Context.DispPosY[GUI_Context.SelLayer] = r.y0; _DispLine_UC(s, Len, &r); /* Do the actual drawing via routine call. */ #if GUI_WINSUPPORT } WM_ITERATE_END(); WM_SUBORG(GUI_Context.DispPosX[GUI_Context.SelLayer], GUI_Context.DispPosY[GUI_Context.SelLayer]); #endif }
/********************************************************************* * * GUI_DrawPixel */ void GUI_DrawPixel(int x, int y) { #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x,y); r.x0 = r.x1 = x; r.y0 = r.y1 = y; WM_ITERATE_START(&r); { #endif LCD_HL_DrawPixel(x,y); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
/********************************************************************* * * GUI_FillRect */ void GUI_FillRect(int x0, int y0, int x1, int y1) { #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); WM_ADDORG(x1,y1); r.x0 = x0; r.x1 = x1; r.y0 = y0; r.y1 = y1; WM_ITERATE_START(&r); { #endif LCD_FillRect(x0,y0,x1,y1); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
/********************************************************************* * * GUI_DrawVLine */ void GUI_DrawVLine(int x0, int y0, int y1) { #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); WM_ADDORGY(y1); r.x1 = r.x0 = x0; r.y0 = y0; r.y1 = y1; WM_ITERATE_START(&r); { #endif LCD_DrawVLine(x0, y0, y1); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
/********************************************************************* * * GUI_DrawHLine */ void GUI_DrawHLine(int y0, int x0, int x1) { #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); WM_ADDORGX(x1); r.x0 = x0; r.x1 = x1; r.y1 = r.y0 = y0; WM_ITERATE_START(&r) { #endif LCD_HL_DrawHLine(x0, y0, x1); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
/********************************************************************* * * _DrawRestore */ static void _DrawRestore(void) { GUI_RECT r; int Size; WM_GetInsideRect(&r); WM_ADDORG(r.x0, r.y0); WM_ADDORG(r.x1, r.y1); Size = ((r.x1 - r.x0 + 1) << 1) / 3; WM_ITERATE_START(&r); { LCD_DrawHLine(r.x1 - Size, r.y0 + 1, r.x1 - 1); LCD_DrawHLine(r.x1 - Size, r.y0 + 2, r.x1 - 1); LCD_DrawHLine(r.x0 + Size, r.y0 + Size, r.x1 - 1); LCD_DrawVLine(r.x1 - Size, r.y0 + 1, r.y1 - Size); LCD_DrawVLine(r.x1 - 1, r.y0 + 1, r.y0 + Size); LCD_DrawHLine(r.x0 + 1, r.y1 - Size, r.x0 + Size); LCD_DrawHLine(r.x0 + 1, r.y1 - Size + 1, r.x0 + Size); LCD_DrawHLine(r.x0 + 1, r.y1 - 1, r.x0 + Size); LCD_DrawVLine(r.x0 + 1, r.y1 - Size, r.y1 - 1); LCD_DrawVLine(r.x0 + Size, r.y1 - Size, r.y1 - 1); } WM_ITERATE_END(); }
/********************************************************************* * * GUI_InvertRect */ void GUI_InvertRect(int x0, int y0, int x1, int y1) { GUI_DRAWMODE PrevDraw; #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); PrevDraw = GUI_SetDrawMode(GUI_DRAWMODE_XOR); #if (GUI_WINSUPPORT) WM_ADDORG(x0, y0); WM_ADDORG(x1, y1); r.x0 = x0; r.x1 = x1; r.y0 = y0; r.y1 = y1; WM_ITERATE_START(&r); { #endif LCD_FillRect(x0, y0, x1, y1); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_SetDrawMode(PrevDraw); GUI_UNLOCK(); }
/********************************************************************* * * GUI_ClearRect */ void GUI_ClearRect(int x0, int y0, int x1, int y1) { GUI_DRAWMODE PrevDraw; #if GUI_WINSUPPORT GUI_RECT r; #endif GUI_LOCK(); PrevDraw = LCD_SetDrawMode(GUI_DRAWMODE_REV); #if GUI_WINSUPPORT WM_ADDORG(x0,y0); WM_ADDORG(x1,y1); r.x0 = x0; r.x1 = x1; r.y0 = y0; r.y1 = y1; WM_ITERATE_START(&r) { #endif LCD_FillRect(x0,y0,x1,y1); #if GUI_WINSUPPORT } WM_ITERATE_END(); #endif LCD_SetDrawMode(PrevDraw); GUI_UNLOCK(); }
/********************************************************************* * * GUI_MEMDEV_WriteAlphaAt */ void GUI_MEMDEV_WriteAlphaAt(GUI_MEMDEV_Handle hMem, int Alpha, int x, int y) { if (hMem) { GUI_MEMDEV* pDevData; #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); pDevData = (GUI_MEMDEV*) GUI_ALLOC_h2p(hMem); /* Convert to pointer */ if (x == GUI_POS_AUTO) { x = pDevData->x0; y = pDevData->y0; } #if (GUI_WINSUPPORT) r.x1 = (r.x0 = x) + pDevData->XSize-1; r.y1 = (r.y0 = y) + pDevData->YSize-1;; WM_ITERATE_START(&r) { _WriteAlphaToActiveAt(hMem, Alpha, x,y); } WM_ITERATE_END(); #else _WriteAlphaToActiveAt(hMem, Alpha, x,y); #endif GUI_UNLOCK(); } }
/********************************************************************* * * _Paint */ static void _Paint(EDIT_Obj* pObj, EDIT_Handle hObj) { GUI_RECT rFillRect, rInside, rText, rInvert; const char GUI_UNI_PTR * pText = NULL; int IsEnabled, CursorWidth = 0; IsEnabled = WM__IsEnabled(hObj); /* Set colors and font */ LCD_SetBkColor(pObj->Props.aBkColor[IsEnabled]); LCD_SetColor(pObj->Props.aTextColor[0]); GUI_SetFont(pObj->Props.pFont); /* Calculate size */ WIDGET__GetInsideRect(&pObj->Widget, &rFillRect); if (pObj->hpText) { pText = (const char*) GUI_ALLOC_h2p(pObj->hpText); } rInside = rFillRect; rInside.x0 += pObj->Props.Border + EDIT_XOFF; rInside.x1 -= pObj->Props.Border + EDIT_XOFF; GUI__CalcTextRect(pText, &rInside, &rText, pObj->Props.Align); /* Calculate position and size of cursor */ if (pObj->Widget.State & WIDGET_STATE_FOCUS) { int NumChars; CursorWidth = ((pObj->XSizeCursor > 0) ? (pObj->XSizeCursor) : (1)); NumChars = GUI__GetNumChars(pText); if (pText) { U16 Char; int i, IsRTL = 0; if ((pObj->EditMode != GUI_EDIT_MODE_INSERT) || (pObj->SelSize)) { if (pObj->CursorPos < NumChars) { if (pObj->SelSize) { CursorWidth = 0; for (i = pObj->CursorPos; i < (int)(pObj->CursorPos + pObj->SelSize); i++) { Char = GUI__GetCursorCharacter(pText, i, NumChars, 0); CursorWidth += GUI_GetCharDistX(Char); } if (!CursorWidth) { CursorWidth = 1; } } else { Char = GUI__GetCursorCharacter(pText, pObj->CursorPos, NumChars, &IsRTL); CursorWidth = GUI_GetCharDistX(Char); } } } rInvert = rText; if (IsRTL) { rInvert.x0 -= CursorWidth; } rInvert.x0 += GUI__GetCursorPosX(pText, pObj->CursorPos, NumChars); } } /* WM loop */ WM_ITERATE_START(NULL) { /* Set clipping rectangle */ WM_SetUserClipRect(&rFillRect); /* Display text */ WIDGET__FillStringInRect(pText, &rFillRect, &rInside, &rText); /* Display cursor if needed */ if (pObj->Widget.State & WIDGET_STATE_FOCUS) { GUI_InvertRect(rInvert.x0, rInvert.y0, rInvert.x0 + CursorWidth - 1, rInvert.y1); } WM_SetUserClipRect(NULL); /* Draw the 3D effect (if configured) */ WIDGET__EFFECT_DrawDown(&pObj->Widget); } WM_ITERATE_END(); }