diff --git a/src/elem/XKeyPad.c b/src/elem/XKeyPad.c index 8264575e1..46dc3373b 100644 --- a/src/elem/XKeyPad.c +++ b/src/elem/XKeyPad.c @@ -321,6 +321,15 @@ gslc_tsElemRef* gslc_XKeyPadCreateBase(gslc_tsGui* pGui, int16_t nElemId, int16_ rElem.w = (nButtonSzW * pConfig->nMaxCols) + (2 * pConfig->nFrameMargin); rElem.h = (nButtonSzH * pConfig->nMaxRows) + (2 * pConfig->nFrameMargin); + // Things tend to drop off on very small screens + // Move it as far left/up as it goes. And ignore + // the issue if it is still too large. + // + if (rElem.x + rElem.w > pGui->nDispW) + rElem.x = pGui->nDispW - rElem.w; + if (rElem.y + rElem.h > pGui->nDispH) + rElem.y = pGui->nDispH - rElem.h; + gslc_tsElem sElem; gslc_tsElemRef* pElemRef = NULL; @@ -349,8 +358,8 @@ gslc_tsElemRef* gslc_XKeyPadCreateBase(gslc_tsGui* pGui, int16_t nElemId, int16_ // Determine offset coordinate of compound element so that we can // specify relative positioning during the sub-element Create() operations. - int16_t nOffsetX = nX0 + pConfig->nFrameMargin; - int16_t nOffsetY = nY0 + pConfig->nFrameMargin; + int16_t nOffsetX = rElem.x + pConfig->nFrameMargin; + int16_t nOffsetY = rElem.y + pConfig->nFrameMargin; // Reset buffer and associated state gslc_ElemXKeyPadReset(pXData); diff --git a/src/elem/XListbox.c b/src/elem/XListbox.c index c84704d0f..1009a0a52 100644 --- a/src/elem/XListbox.c +++ b/src/elem/XListbox.c @@ -65,10 +65,6 @@ extern const char GSLC_PMEM ERRSTR_PXD_NULL[]; // ---------------------------------------------------------------------------- -// TODO: Combine with GUIslice MAX_STR -// Defines the maximum length of a listbox item -#define XLISTBOX_MAX_STR 20 - // ============================================================================ // Extended Element: Listbox // - A Listbox control @@ -620,8 +616,7 @@ bool gslc_ElemXListboxDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw // Determine top-left coordinate of list matrix nItemBaseX = nX0 + pListbox->nMarginW; nItemBaseY = nY0 + pListbox->nMarginH; - char acStr[XLISTBOX_MAX_STR+1] = ""; - + char * acStr = (char *)""; // Loop through the items in the list int16_t nItemTop = pListbox->nItemTop; @@ -645,8 +640,8 @@ bool gslc_ElemXListboxDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw } // Fetch the list item - bool bOk = gslc_ElemXListboxGetItem(pGui, pElemRef, nItemInd, acStr, XLISTBOX_MAX_STR); - if (!bOk) { + acStr = gslc_ElemXListboxGetItemAddr(pListbox, nItemInd); + if (NULL == acStr) { // TODO: Erorr handling break; }