/********************************************************************* * * GUI_SelectLayer */ unsigned int GUI_SelectLayer(unsigned int Index) { unsigned int OldIndex; GUI_LOCK(); OldIndex = GUI_Context.SelLayer; if (Index < GUI_NUM_LAYERS) { GUI_Context.SelLayer = Index; GUI_SelectLCD(); } GUI_UNLOCK(); return OldIndex; }
/********************************************************************* * * Exported code * ********************************************************************** */ void CHECKBOX_SetImage(CHECKBOX_Handle hObj, const GUI_BITMAP * pBitmap, unsigned int Index) { if (hObj) { CHECKBOX_Obj * pObj; GUI_LOCK(); pObj = CHECKBOX_H2P(hObj); if (Index <= GUI_COUNTOF(pObj->Props.apBm)) { pObj->Props.apBm[Index] = pBitmap; } GUI_UNLOCK(); } }
/********************************************************************* * * GUI_ALLOC_AllocZero */ GUI_HMEM GUI_ALLOC_AllocZero(GUI_ALLOC_DATATYPE Size) { GUI_HMEM hMem; GUI_LOCK(); GUI_DEBUG_LOG2("\nGUI_ALLOC_Alloc... requesting %d, %d avail", Size, GUI_ALLOC_GetMaxSize()); hMem = GUI_ALLOC_AllocNoInit(Size); if (hMem) { GUI_MEMSET((U8*)GUI_ALLOC_h2p(hMem), 0, Size); /* Zeroinit ! */ } GUI_UNLOCK(); return hMem; }
void GUI_DispCharAt(U16 c, I16P x, I16P y) { GUI_LOCK(); GUI_Context.DispPosX =x; GUI_Context.DispPosY =y; #if (GUI_WINSUPPORT) CL_DispChar(c); #else GL_DispChar(c); #endif GUI_UNLOCK(); }
int GUI_GetUsedMem(void) { int NumUsedBytes=0; int i; GUI_LOCK(); CheckInit(); for (i=1; i; i = aBlock[i].Next) { NumUsedBytes += aBlock[i].Size; } GUI_UNLOCK(); return NumUsedBytes; }
/********************************************************************* * * 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(); }
/********************************************************************* * * 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(); }
/********************************************************************* * * GUI_ALLOC_AllocNoInit */ GUI_HMEM GUI_ALLOC_AllocNoInit(GUI_ALLOC_DATATYPE Size) { GUI_HMEM hMem; if (Size == 0) { return (GUI_HMEM)0; } GUI_LOCK(); GUI_DEBUG_LOG2("\nGUI_ALLOC_AllocNoInit... requesting %d, %d avail", Size, GUI_ALLOC.NumFreeBytes); hMem = _Alloc(Size); GUI_DEBUG_LOG1("\nGUI_ALLOC_AllocNoInit : Handle", hMem); GUI_UNLOCK(); return hMem; }
/********************************************************************* * * GUI_DispStringLen */ void GUI_DispStringLen(const char GUI_UNI_PTR *s, int MaxNumChars) { U16 Char; GUI_LOCK(); while (MaxNumChars && ((Char = GUI_UC__GetCharCodeInc(&s)) != 0)) { GUI_DispChar(Char); MaxNumChars--; } while (MaxNumChars--) { GUI_DispChar(' '); } 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(); }
void GUI_DispStringInRectMax(const char GUI_UNI_PTR *s, GUI_RECT* pRect, int TextAlign, int MaxLen) { GUI_RECT Rect_Old, r; if (s && pRect) { GUI_LOCK(); Rect_Old = GUI_Context.ClipRect[GUI_Context.SelLayer]; GUI__IntersectRects(&r, pRect, &Rect_Old); LCD_SetClipRectEx(&r); GUI__DispStringInRect(s, pRect, TextAlign, MaxLen); LCD_SetClipRectEx(&Rect_Old); 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(); }
/********************************************************************* * * FRAMEWIN_SetFont */ void FRAMEWIN_SetFont(FRAMEWIN_Handle hObj, const GUI_FONT GUI_UNI_PTR * pFont) { GUI_LOCK(); if (hObj) { FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj); int OldHeight = FRAMEWIN__CalcTitleHeight(pObj); pObj->Props.pFont = pFont; FRAMEWIN__UpdatePositions(pObj); FRAMEWIN__UpdateButtons(pObj, OldHeight); FRAMEWIN_Invalidate(hObj); } GUI_UNLOCK(); }
unsigned int GUI_SelLCD(unsigned int Index) { unsigned int OldIndex = 0; if (Index < LCD_NUM_DISPLAYS) { GUI_LOCK(); GUI_SetDefault(); OldIndex = (GUI_Context.pDeviceAPI == aAPI[0]) ? 0 : 1; GUI_Context.pDeviceAPI = aAPI[Index]; LCD_SetClipRectMax(); } GUI_UNLOCK(); return OldIndex; }
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_MEASDEV_ClearRect */ void GUI_MEASDEV_ClearRect(GUI_MEASDEV_Handle hMemDev) { if (hMemDev) { GUI_MEASDEV* pDevData; GUI_LOCK(); pDevData = (GUI_MEASDEV*)GUI_ALLOC_h2p(hMemDev); pDevData->rUsed.x0 = GUI_XMAX; pDevData->rUsed.y0 = GUI_YMAX; pDevData->rUsed.x1 = GUI_XMIN; pDevData->rUsed.y1 = GUI_YMIN; GUI_UNLOCK(); } }
/********************************************************************* * * GUI_UC_Encode */ int GUI_UC_Encode(char* s, U16 Char) { #if GUI_COMPILER_SUPPORTS_FP int r; GUI_LOCK(); r = GUI_Context.pUC_API->pfEncode(s, Char); GUI_UNLOCK(); return r; #else GUI_USE_PARA(s); GUI_USE_PARA(Char); return 0; #endif }
/********************************************************************* * * Static code * ********************************************************************** */ static const GUI_ROTATION * _SetRotation(const GUI_ROTATION* pLCD_Api) { const GUI_ROTATION * pLCD_ApiOld; GUI_LOCK(); pLCD_ApiOld = GUI_pLCD_APIList; if (pLCD_Api) { GUI_Context.pClipRect_HL = NULL; /* Do not perform high level clipping in rotated mode */ } else { GUI_Context.pClipRect_HL = &GUI_Context.ClipRect; } GUI_pLCD_APIList = pLCD_Api; GUI_UNLOCK(); return pLCD_ApiOld; }
/********************************************************************* * * GUI_TIMER_Restart */ void GUI_TIMER_Restart(GUI_TIMER_HANDLE hObj) { GUI_TIMER_Obj* pObj; GUI_LOCK(); { if (hObj == 0) { hObj = _hActiveTimer; } pObj = GUI_TIMER_H2P(hObj); pObj->t0 = GUI_GetTime() +pObj->Period; _Unlink(hObj); _Link(hObj); } GUI_UNLOCK(); }
/********************************************************************* * * GUI_MEASDEV_GetRect */ void GUI_MEASDEV_GetRect(GUI_MEASDEV_Handle hMem, GUI_RECT* pRect) { if (hMem) { GUI_MEASDEV* pDev; GUI_LOCK(); pDev = (GUI_MEASDEV*)GUI_ALLOC_h2p(hMem); if (pRect) { pRect->x0 = pDev->rUsed.x0; pRect->y0 = pDev->rUsed.y0; pRect->x1 = pDev->rUsed.x1; pRect->y1 = pDev->rUsed.y1; } GUI_UNLOCK(); } }
/********************************************************************* * * 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_MEMDEV_GetYSize */ int GUI_MEMDEV_GetYSize(GUI_MEMDEV_Handle hMem) { int r = 0; GUI_MEMDEV* pDevData; GUI_LOCK(); if (hMem == 0) { hMem = GUI_Context.hDevData; } if (hMem) { pDevData = (GUI_MEMDEV*) GUI_ALLOC_h2p(hMem); /* Convert to pointer */ r = pDevData->YSize; } GUI_UNLOCK(); return r; }
/********************************************************************* * * GUI_UC_DispString */ void GUI_UC_DispString(const U16 GUI_UNI_PTR *s) { int xAdjust, yAdjust, xOrg; int FontSizeY; if (!s) return; GUI_LOCK(); FontSizeY = GUI_Context.pAFont->YSize; xOrg = GUI_Context.DispPosX[GUI_Context.SelLayer]; /* Adjust vertical position */ yAdjust = GUI_GetYAdjust(); GUI_Context.DispPosY[GUI_Context.SelLayer] -= yAdjust; for (; *s; s++) { GUI_RECT r; int LineLen= _GetLineLen(s,0x7fff); int xLineSize = _GetLineDistX(s, LineLen); /* Check if x-position needs to be changed due to h-alignment */ switch (GUI_Context.TextAlign & GUI_TA_HORIZONTAL) { case GUI_TA_CENTER: xAdjust= xLineSize/2; break; case GUI_TA_RIGHT: xAdjust= xLineSize; break; default: xAdjust= 0; } r.x0 = GUI_Context.DispPosX[GUI_Context.SelLayer] -= xAdjust; r.x1 = r.x0 + xLineSize-1; r.y0 = GUI_Context.DispPosY[GUI_Context.SelLayer]; r.y1 = r.y0 + FontSizeY-1; _DispLine(s, LineLen, &r); GUI_Context.DispPosY[GUI_Context.SelLayer] = r.y0; s += LineLen; if (*s=='\n') { switch (GUI_Context.TextAlign & GUI_TA_HORIZONTAL) { case GUI_TA_CENTER: case GUI_TA_RIGHT: GUI_Context.DispPosX[GUI_Context.SelLayer] = xOrg; break; default: GUI_Context.DispPosX[GUI_Context.SelLayer] = GUI_Context.LBorder; break; } GUI_Context.DispPosY[GUI_Context.SelLayer] += GUI_GetFontDistY(); } else { GUI_Context.DispPosX[GUI_Context.SelLayer] = r.x0+xLineSize; } if (*s==0) /* end of string (last line) reached ? */ break; } GUI_Context.DispPosY[GUI_Context.SelLayer] += yAdjust; GUI_Context.TextAlign &= ~GUI_TA_HORIZONTAL; GUI_UNLOCK(); }
/********************************************************************* * * GL_DispChar */ void GL_DispChar(U16 c) { /* check for control characters */ if (c == '\n') { GUI_DispNextLine(); } else { if (c != '\r') { GUI_LOCK(); GUI_Context.pAFont->pfDispChar(c); if (GUI_pfDispCharStyle) { GUI_pfDispCharStyle(c); } GUI_UNLOCK(); } } }
/********************************************************************* * * 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(); }
/********************************************************************* * * GUI_DRAW_SELF_Create */ WM_HMEM GUI_DRAW_SELF_Create(GUI_DRAW_SELF_CB* pfDraw, int x, int y) { WM_HMEM hMem; hMem = GUI_ALLOC_AllocZero(sizeof(GUI_DRAW)); if (hMem) { GUI_DRAW* pObj; GUI_LOCK(); pObj = (GUI_DRAW*)GUI_ALLOC_h2p(hMem); pObj->pConsts = &_ConstObjData; pObj->Data.pfDraw = pfDraw; pObj->xOff = x; pObj->yOff = y; GUI_UNLOCK(); } return hMem; }
/********************************************************************* * * GUI_CURSOR_Show */ void GUI_CURSOR_Show(void) { GUI_LOCK(); LCDDEV_L0_GetRect(&_ClipRect); _Hide(); _CursorOn = 1; /* Set function pointer which window manager can use */ GUI_CURSOR_pfTempHide = _TempHide; GUI_CURSOR_pfTempUnhide = _TempUnhide; if (!_pCursor) { GUI_CURSOR_Select(GUI_DEFAULT_CURSOR); } else { _Show(); } GUI_UNLOCK(); }
/********************************************************************* * * GUI_MEMDEV_ReduceYSize */ void GUI_MEMDEV_ReduceYSize(GUI_MEMDEV_Handle hMem, int YSize) { /* Make sure memory handle is valid */ if (!hMem) hMem = GUI_Context.hDevData; if (!hMem) return; { GUI_MEMDEV * pDevData; GUI_LOCK(); pDevData = (GUI_MEMDEV*) GUI_ALLOC_h2p(hMem); /* Convert to pointer */ if (YSize < pDevData->YSize) { pDevData->YSize = YSize; } 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(); }
/********************************************************************* * * GUI_GetYAdjust * * Returns adjustment in vertical (Y) direction * * Note: The return value needs to be subtracted from * the y-position of the character. */ int GUI_GetYAdjust(void) { int r = 0; GUI_LOCK(); switch (GUI_Context.TextAlign & GUI_TA_VERTICAL) { case GUI_TA_BOTTOM: r = GUI_Context.pAFont->YSize - 1; break; case GUI_TA_VCENTER: r = GUI_Context.pAFont->YSize / 2; break; case GUI_TA_BASELINE: r = GUI_Context.pAFont->YSize / 2; } GUI_UNLOCK(); return r; }