static void D4D_MenuValue2Coor(D4D_OBJECT* pThis) { D4D_MENU* pMenu = D4D_GET_MENU(pThis); _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); D4D_ComputeGeometry(&(_calc.contentGeom), pThis); _calc.titleBar_y = D4D_GetTitleBarHeight(pThis); _calc.maxIcon = D4D_GetIconsMaxSize(pMenu); _calc.textOff = pMenu->textOff; _calc.itemsCnt = D4D_GetItemsCount(pMenu); // Get the position count if(!pMenu->posCnt) { if(_calc.maxIcon.cy > (D4D_GetFontHeight(pMenu->itemsFontId))) _calc.posCnt = (D4D_MENU_INDEX)((_calc.contentGeom.sz.cy - D4D_GetTitleBarHeight(pThis)) / (_calc.maxIcon.cy + 3)); else _calc.posCnt = (D4D_MENU_INDEX)((_calc.contentGeom.sz.cy - D4D_GetTitleBarHeight(pThis)) / (D4D_GetFontHeight(pMenu->itemsFontId) + 3)); } // if count of items position or text offsets are not declared , then use automatic values if(!_calc.textOff) { if(_calc.posCnt > 1) _calc.textOff = (D4D_COOR)( (pThis->size.cy - _calc.titleBar_y) / (_calc.posCnt)); else _calc.textOff = (D4D_COOR)((pThis->size.cy - _calc.titleBar_y) / 2); } if(pThis->initFlags & D4D_MENU_F_INDEX) { // Draw index counter _calc.index_txt_len = D4D_SprintDecU8((Byte)(pMenu->pData->ix + 1), _calc.index_txt, (D4D_TCHAR) 0); _calc.index_txt[_calc.index_txt_len++] = '/'; _calc.index_txt_len += D4D_SprintDecU8((Byte)_calc.itemsCnt, &_calc.index_txt[_calc.index_txt_len], (D4D_TCHAR) 0); _calc.index_txt[_calc.index_txt_len] = 0; } }
/**************************************************************************/ /*! * @brief The function convert decimal signed 8 bit number to string * @param val - the input numerical value * @param pText - pointer to output text buffer * @param fill - the fill character for non number characters (before number) * @return count of printed chars * @note If fill parameter is 0 {'\0'}, only the numerical characters are printed. *******************************************************************************/ Byte D4D_SprintDecS8(sByte val, D4D_TCHAR *pText, D4D_TCHAR fill) { Byte cnt = 0; if(val < 0) { *pText++ = '-'; cnt++; val *= -1; } return (Byte)(cnt + D4D_SprintDecU8((Byte)val, pText, fill)); }