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_GotoX */ char GUI_GotoX(int x) { char r; GUI_LOCK(); r = _GotoX(x); GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_CURSOR_Activate */ void GUI_CURSOR_Activate(void) { GUI_LOCK(); if ((--_CursorDeActCnt) ==0) { _Show(); } GUI_UNLOCK(); }
U8 GUI_GetPenShape (void) { U8 r; GUI_LOCK(); r = GUI_Context.PenShape; GUI_UNLOCK(); return r; }
int GUI_GetTextAlign(void) { int r; GUI_LOCK(); r = GUI_Context.TextAlign; GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_GetCharDistX */ int GUI_GetCharDistX(U16 c) { int r; GUI_LOCK(); r = GUI_Context.pAFont->pfGetCharDistX(c); GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_Color2Index */ int GUI_Color2Index(GUI_COLOR Color) { int Index; GUI_LOCK(); Index = LCD_Color2Index(Color); GUI_UNLOCK(); return Index; }
/********************************************************************* * * GUI_GetColor */ GUI_COLOR GUI_GetColor(void) { GUI_COLOR r; GUI_LOCK(); r = LCD_Index2Color(LCD_GetColorIndex()); GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_UC_GetCharSize */ int GUI_UC_GetCharSize(const char GUI_UNI_PTR * s) { int r; GUI_LOCK(); r = GUI_Context.pUC_API->pfGetCharSize(s); GUI_UNLOCK(); return r; }
void GUI_ALLOC_Free(GUI_HMEM hMem) { int Size; if (hMem == GUI_HMEM_NULL) /* Note: This is not an error, it is permitted */ return; GUI_LOCK(); GUI_DEBUG_LOG1("\nGUI_ALLOC_Free(%d)", hMem); /* Do some error checking ... */ #if GUI_DEBUG_LEVEL>0 /* Block not allocated ? */ if (aBlock[hMem].Size==0) { GUI_DEBUG_ERROROUT("GUI_ALLOC_Free(): Invalid hMem"); return; } #endif Size = aBlock[hMem].Size; #ifdef WIN32 memset(&GUI_Heap.abHeap[aBlock[hMem].Off], 0xcc, Size); #endif GUI_ALLOC.NumFreeBytes += Size; GUI_ALLOC.NumUsedBytes -= Size; aBlock[hMem].Size = 0; { int Next = aBlock[hMem].Next; int Prev = aBlock[hMem].Prev; aBlock[Prev].Next = Next; if (Next) aBlock[Next].Prev = Prev; } GUI_ALLOC.NumFreeBlocks++; GUI_ALLOC.NumUsedBlocks--; GUI_UNLOCK(); }
/********************************************************************* * * GUI_GetColorIndex */ int GUI_GetColorIndex(void) { int r; GUI_LOCK(); r = LCD_GetColorIndex(); GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_GetFontDistY */ int GUI_GetFontDistY(void) { int r; GUI_LOCK(); r = GUI_Context.pAFont->YDist; GUI_UNLOCK(); return r; }
GUI_DRAWMODE GUI_SetDrawMode(GUI_DRAWMODE dm) { GUI_DRAWMODE OldMode; GUI_LOCK(); { OldMode = LCD_SetDrawMode(dm); } GUI_UNLOCK(); return OldMode; }
int GUI_GetTextMode(void) { int r; GUI_LOCK(); r = GUI_Context.TextMode; GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_CURSOR_GetState */ int GUI_CURSOR_GetState(void) { int r; GUI_LOCK(); r = _CursorOn; GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_UC_GetCharCode */ U16 GUI_UC_GetCharCode(const char GUI_UNI_PTR * s) { U16 r; GUI_LOCK(); r = GUI_Context.pUC_API->pfGetCharCode(s); GUI_UNLOCK(); return r; }
U8 GUI_GetLineStyle (void) { U8 r; GUI_LOCK(); r = GUI_Context.LineStyle; GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_USAGE_Select */ void GUI_USAGE_Select(GUI_USAGE_Handle hUsage) { GUI_MEMDEV * pDev; GUI_LOCK(); pDev = GUI_MEMDEV_H2P(GUI_Context.hDevData); pDev->hUsage = hUsage; GUI_UNLOCK(); }
/********************************************************************* * * GUI_GetDispPosY * * Purpose: * Return Y-component of current display position */ int GUI_GetDispPosY(void) { int r; GUI_LOCK(); r = GUI_Context.DispPosY; GUI_UNLOCK(); return r; }
void GUI_DispStringInRect(const char GUI_FAR *s, GUI_RECT* pRect, int TextAlign) { #if (GUI_WINSUPPORT) const GUI_RECT *pClipRect_Old = NULL; #else GUI_RECT Rect_Old; #endif if (s) { GUI_LOCK(); if (pRect) { #if (GUI_WINSUPPORT) pClipRect_Old = WM_SetUserClipRect(pRect); #else Rect_Old = GUI_Context.ClipRect; LCD_SetClipRectEx(pRect); #endif } _DispStringInRect(s, pRect, TextAlign); #if (GUI_WINSUPPORT) WM_SetUserClipRect(pClipRect_Old); #else LCD_SetClipRectEx(&Rect_Old); #endif GUI_UNLOCK(); } }
/********************************************************************* * * GUI_TIMER_Delete */ void GUI_TIMER_Delete(GUI_TIMER_HANDLE hObj) { /* Unlink Timer */ GUI_LOCK(); _Unlink(hObj); GUI_ALLOC_Free(hObj); GUI_UNLOCK(); }
FRAMEWIN_Handle FRAMEWIN_CreateAsChild( int x0, int y0, int xsize, int ysize, WM_HWIN hParent, const char* pText, WM_CALLBACK* cb, int Flags) { FRAMEWIN_Handle hObj; /* Create the window */ GUI_LOCK(); hObj = WM_CreateWindowAsChild(x0, y0, xsize/*+2*HBorder*/, ysize/*+TBorder+BBorder*/, hParent, Flags, _FRAMEWIN_Callback, sizeof(FRAMEWIN_Obj) - sizeof(WM_Obj)); if (hObj) { FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj); /* init widget specific variables */ WIDGET__Init(&pObj->Widget, WIDGET_STATE_FOCUSSABLE | WIDGET_STATE_ENABLED); /* init member variables */ pObj->pFont = _pDefaultFont; memcpy(pObj->BarColor, _aBarColor, sizeof(pObj->BarColor)); pObj->TextColor = 0xffffff; pObj->TextAlign = GUI_TA_LEFT; pObj->ClientColor = _DefaultClientColor; pObj->pText = pText; pObj->XOff = 1; pObj->YOff = 1; pObj->cb = cb; CalcPositions(hObj); pObj->hClient = WM_CreateWindowAsChild(0, 0, 0, 0, hObj, WM_CF_SHOW, FRAMEWIN__cbClient, 0); } GUI_UNLOCK(); return hObj; }
/********************************************************************* * * 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(); } }
/********************************************************************* * * _Draw */ static void _Draw(void) { int x, y, xSize, ySize; LCD_PIXELINDEX* pData; const GUI_BITMAP GUI_UNI_PTR * pBM; GUI_LOCK(); if (_hBuffer) { /* Save bitmap data */ pBM = _pCursor->pBitmap; pData = (LCD_PIXELINDEX*)GUI_ALLOC_h2p(_hBuffer); xSize = _Rect.x1 - _Rect.x0 + 1; ySize = _Rect.y1 - _Rect.y0 + 1; for (y = 0; y < ySize; y++) { for (x = 0; x < xSize; x++) { int BitmapPixel; *(pData + x) = _GetPixelIndex(_Rect.x0 + x, _Rect.y0 + y); BitmapPixel = GUI_GetBitmapPixelIndex(pBM, x, y); if (BitmapPixel) { _SetPixelIndex(_Rect.x0 + x, _Rect.y0 + y, _Log2Phys(BitmapPixel)); } } pData += pBM->XSize; } } GUI_UNLOCK(); }
/********************************************************************* * * GUI_GotoY */ char GUI_GotoY(int y) { char r; GUI_LOCK(); r = _GotoY(y); GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_CURSOR_Select */ const GUI_CURSOR GUI_UNI_PTR * GUI_CURSOR_Select(const GUI_CURSOR GUI_UNI_PTR * pCursor) { int AllocSize; const GUI_BITMAP GUI_UNI_PTR * pBM; const GUI_CURSOR GUI_UNI_PTR * pOldCursor; GUI_LOCK(); pOldCursor = _pCursor; if (pCursor != _pCursor) { int i; pBM = pCursor->pBitmap; i = pBM->pPal->NumEntries > 4 ? 4 : pBM->pPal->NumEntries; while (i--) { LCD_COLOR Color = *(pBM->pPal->pPalEntries + i); _ColorIndex[i] = LCD_Color2Index(Color); } _Hide(); AllocSize = pBM->XSize * pBM->YSize * sizeof(LCD_PIXELINDEX); if (AllocSize != _AllocSize) { GUI_ALLOC_Free(_hBuffer); _hBuffer = 0; } _hBuffer = GUI_ALLOC_AllocZero(AllocSize); _CursorOn = 1; _pCursor = pCursor; _CalcRect(); _Show(); } GUI_UNLOCK(); return pOldCursor; }
/********************************************************************* * * 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(); }
/********************************************************************* * * GUI_Index2Color */ GUI_COLOR GUI_Index2Color(int Index) { GUI_COLOR Color; GUI_LOCK(); Color = LCD_Index2Color(Index); GUI_UNLOCK(); return Color; }
/********************************************************************* * * GUI_GetFontSizeY */ int GUI_GetFontSizeY(void) { int r; GUI_LOCK(); r = GUI__GetFontSizeY(); GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_GotoXY */ char GUI_GotoXY(int x, int y) { char r; GUI_LOCK(); r = _GotoX(x); r |= _GotoY(y); GUI_UNLOCK(); return r; }