static void D4D_TextBoxValue2Coor(D4D_OBJECT* pThis) { D4D_TEXTBOX* pTextBox = D4D_GET_TEXTBOX(pThis); D4D_INDEX tmpIx; _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); D4D_ComputeGeometry(&(_calc.contentGeom), pThis); _calc.txtGeom = _calc.contentGeom; #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE _calc.txtGeom.pnt.y += (D4D_COOR)(pThis->radius / 2); _calc.txtGeom.pnt.x += (D4D_COOR)(pThis->radius / 2); #endif if(D4D_GET_TEXTBOX_SCROLL_BAR_HOR(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE) _calc.txtGeom.sz.cx -= D4D_TXTBX_SCRLBR_WIDTH; #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE _calc.txtGeom.sz.cx -= pThis->radius; _calc.txtGeom.sz.cy -= pThis->radius; #endif // Compute the lines count in object _calc.lineCount = (D4D_COOR) (_calc.txtGeom.sz.cy / D4D_GetFontHeight(pTextBox->textFontId)); tmpIx = D4D_TextBoxGetLineCount(pThis); if(_calc.lineCount > tmpIx) _calc.lineCount = tmpIx; }
static void D4D_CnslValue2Coor(D4D_OBJECT* pThis) { D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pThis); _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); //margin (bevels :-) ) D4D_ComputeGeometry(&(_calc.txtGeom), pThis); #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE _calc.txtGeom.pnt.y += (D4D_COOR)(pThis->radius / 2); _calc.txtGeom.pnt.x += (D4D_COOR)(pThis->radius / 2); _calc.txtGeom.sz.cx -= (D4D_COOR)(pThis->radius / 2); _calc.txtGeom.sz.cy -= (D4D_COOR)(pThis->radius / 2); #endif _calc.charArrSize.cx = (D4D_COOR) (_calc.txtGeom.sz.cx / D4D_GetFontWidth(pCnsl->textFontId)); // check if the if(_calc.charArrSize.cx < pCnsl->txtArrSize.cx) _calc.txtGeom.sz.cy -= D4D_CNSL_SCRLBR_WIDTH; else _calc.charArrSize.cx = pCnsl->txtArrSize.cx; _calc.charArrSize.cy = (D4D_COOR) (_calc.txtGeom.sz.cy / D4D_GetFontHeight(pCnsl->textFontId)); if(_calc.charArrSize.cy < pCnsl->txtArrSize.cy) { _calc.txtGeom.sz.cx -= D4D_CNSL_SCRLBR_WIDTH; _calc.charArrSize.cx = (D4D_COOR) (_calc.txtGeom.sz.cx / D4D_GetFontWidth(pCnsl->textFontId)); } else _calc.charArrSize.cy = pCnsl->txtArrSize.cy; }
static void D4D_IconValue2Coor(D4D_OBJECT* pThis) { D4D_ICON* pIcon = D4D_GET_ICON(pThis); _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); D4D_ComputeGeometry(&_calc.contentGeom, pThis); _calc.txtPos = _calc.contentGeom.pnt; _calc.txtPos.x += pIcon->txtOff.x; _calc.txtPos.y += pIcon->txtOff.y; }
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; } }
static void D4D_PrgrsBarValue2Coor(D4D_OBJECT* pThis) { D4D_PROGRESS_BAR* pPrgrsBar = D4D_GET_PROGRESS_BAR(pThis); _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); D4D_ComputeGeometry(&_calc.contentGeom, pThis); _calc.barXY.x = (D4D_COOR)(_calc.contentGeom.pnt.x + D4D_PRGRS_BAR_BAR_OFF); _calc.barXY.y = (D4D_COOR)(_calc.contentGeom.pnt.y + D4D_PRGRS_BAR_BAR_OFF); _calc.barSize = _calc.contentGeom.sz; _calc.barSize.cx -= (D4D_COOR)(2 * D4D_PRGRS_BAR_BAR_OFF); _calc.barSize.cy -= (D4D_COOR)(2 * D4D_PRGRS_BAR_BAR_OFF); // value and origin coordinates _calc.resultC1 = (D4D_COOR)(_calc.barXY.x + D4D_MulDivUU(pPrgrsBar->pData->value, _calc.barSize.cx, D4D_COLOR_PRGRS_BAR_MAX_VAL)); _calc.resultC2 = _calc.resultC1; #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE if(pThis->radius - D4D_PRGRS_BAR_BAR_OFF) { _calc.inner_radius = (D4D_COOR)(pThis->radius - D4D_PRGRS_BAR_BAR_OFF); if((_calc.resultC2 - _calc.inner_radius) < _calc.barXY.x) _calc.resultC2 = _calc.barXY.x; else _calc.resultC2 -= _calc.inner_radius; if((_calc.barXY.x + _calc.barSize.cx - _calc.resultC2) < (2 * _calc.inner_radius)) _calc.resultC2 = (D4D_COOR)(_calc.barXY.x + _calc.barSize.cx - (2 * _calc.inner_radius)); if((_calc.resultC1 - _calc.barXY.x) < (2 * _calc.inner_radius)) _calc.resultC1 = (D4D_COOR)(_calc.barXY.x + (2 * _calc.inner_radius)); } else _calc.inner_radius = 0; #endif }
static void D4D_CheckBoxValue2Coor(D4D_OBJECT* pThis) { D4D_CHECKBOX* pCheckB = D4D_GET_CHECKBOX(pThis); D4D_SIZE sizeBmpEnabled; D4D_COOR tmp_BorderOffset; _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); D4D_ComputeGeometry(&(_calc.contentGeom), pThis); sizeBmpEnabled = D4D_GetBmpSize(pCheckB->pBmpChecked); _calc.BmpGeom = _calc.contentGeom; if(!sizeBmpEnabled.cx || !sizeBmpEnabled.cy) { _calc.BmpGeom.sz.cy = (D4D_COOR)((_calc.BmpGeom.sz.cy * 2) / 3); _calc.BmpGeom.sz.cx = _calc.BmpGeom.sz.cy; }else _calc.BmpGeom.sz = sizeBmpEnabled; tmp_BorderOffset = (D4D_COOR)((_calc.contentGeom.sz.cy - _calc.BmpGeom.sz.cy) / 2); _calc.BmpGeom.pnt.x += tmp_BorderOffset; _calc.BmpGeom.pnt.y += tmp_BorderOffset; if(pCheckB->textBuff.pText) { _calc.TxtGeom = _calc.contentGeom; _calc.TxtGeom.pnt.x = (D4D_COOR) (_calc.BmpGeom.pnt.x + _calc.BmpGeom.sz.cx + D4D_CHECKBOX_TEXT_OFFSET); _calc.TxtGeom.sz.cx -= (D4D_COOR) (_calc.TxtGeom.pnt.x - _calc.contentGeom.pnt.x); #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE _calc.TxtGeom.sz.cx -= (D4D_COOR) (pThis->radius / 2); #endif } #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE _calc.iconRadius = pThis->radius; #endif }
static void D4D_LblValue2Coor(D4D_OBJECT* pThis) { _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); D4D_ComputeGeometry(&_calc.contentGeom, pThis); }
static void D4D_ScrlBrValue2Coor(D4D_OBJECT* pThis) { D4D_SCROLL_BAR* pScrlBr = D4D_GET_SCROLL_BAR(pThis); D4D_SCRLBAR_DATA* pData = pScrlBr->pData; _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); D4D_ComputeGeometry(&(_calc.contentGeom), pThis); _calc.scrollRadius = pThis->radius; if(pThis->size.cx > pThis->size.cy) { // horizontal scroll bar _calc.refreshPos = _calc.contentGeom.pnt; _calc.refreshPos.x += (D4D_COOR)(_calc.contentGeom.sz.cy + 1); //_calc.refreshPos.y++; _calc.refreshSize = _calc.contentGeom.sz; _calc.refreshSize.cx -= (D4D_COOR)((_calc.contentGeom.sz.cy * 2) + 2); //_calc.refreshSize.cy -= 2; _calc.scrollSize = _calc.refreshSize; _calc.scrollSize.cy -= 2; _calc.scrollSize.cx = (D4D_COOR)D4D_MulDivUU16(_calc.refreshSize.cx, (Word)pData->page, (Word)(pData->maximum - pData->minimum)); if(_calc.scrollSize.cx < D4D_SCRLBAR_MIN_TAB_SIZE) _calc.scrollSize.cx = D4D_SCRLBAR_MIN_TAB_SIZE; _calc.scrollPos = _calc.refreshPos; if(pData->maximum - pData->page - pData->minimum) _calc.scrollPos.x += (D4D_COOR)(D4D_MulDivUU16((Word)(_calc.refreshSize.cx - _calc.scrollSize.cx - 1), (Word)pData->position, (Word)(pData->maximum - pData->page - pData->minimum)) + 1); _calc.scrollPos.y++; }else { // vertical scroll bar _calc.refreshPos = _calc.contentGeom.pnt; _calc.refreshPos.y += (D4D_COOR)(_calc.contentGeom.sz.cx + 1); // _calc.refreshPos.x++; _calc.refreshSize = _calc.contentGeom.sz; //_calc.refreshSize.cx -= 2; _calc.refreshSize.cy -= (D4D_COOR)((_calc.contentGeom.sz.cx * 2) + 2); _calc.scrollSize = _calc.refreshSize; _calc.scrollSize.cx -= 2; _calc.scrollSize.cy = (D4D_COOR)D4D_MulDivUU16((Word)_calc.refreshSize.cy, (Word)pData->page, (Word)(pData->maximum - pData->minimum)); if(_calc.scrollSize.cy < D4D_SCRLBAR_MIN_TAB_SIZE) _calc.scrollSize.cy = D4D_SCRLBAR_MIN_TAB_SIZE; _calc.scrollPos = _calc.refreshPos; if(pData->maximum - pData->page - pData->minimum) _calc.scrollPos.y += (D4D_COOR)(D4D_MulDivUU16((Word)(_calc.refreshSize.cy - _calc.scrollSize.cy - 1), (Word)pData->position, (Word)(pData->maximum - pData->page - pData->minimum)) + 1); _calc.scrollPos.x++; } if(_calc.scrollRadius) _calc.scrollRadius = (D4D_COOR)(pThis->radius - ((pThis->size.cx - _calc.contentGeom.sz.cx) / 2)); }
static void D4D_SldrValue2Coor(D4D_OBJECT* pThis) { D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis); D4D_COOR barMin; D4D_COOR barMax; D4D_COOR c1, c2; D4D_POINT tmpBarOff = pSldr->barOff; sWord tmp_scale = (sWord)(pSldr->pData->limits.valueMax - pSldr->pData->limits.valueMin); _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position); D4D_ComputeGeometry(&(_calc.contentGeom), pThis); if(tmp_scale < 0) tmp_scale *= -1; if(pThis->size.cx > pThis->size.cy) _calc.isHorizontal = D4D_TRUE; else _calc.isHorizontal = D4D_FALSE; _calc.bar1Geom.sz = pSldr->barSize; if(_calc.isHorizontal) { if(!tmpBarOff.x) tmpBarOff.x = D4D_SLDR_BAR_OFF_LENGTH; if(!tmpBarOff.y) tmpBarOff.y = D4D_SLDR_BAR_OFF_WIDTH; } else { if(!tmpBarOff.x) tmpBarOff.x = D4D_SLDR_BAR_OFF_WIDTH; if(!tmpBarOff.y) tmpBarOff.y = D4D_SLDR_BAR_OFF_LENGTH; } if(!_calc.bar1Geom.sz.cx) _calc.bar1Geom.sz.cx = (D4D_COOR)(_calc.contentGeom.sz.cx - (tmpBarOff.x * 2)); if(!_calc.bar1Geom.sz.cy) _calc.bar1Geom.sz.cy = (D4D_COOR)(_calc.contentGeom.sz.cy - (tmpBarOff.y * 2)); _calc.bar1Geom.pnt = _calc.contentGeom.pnt; _calc.bar1Geom.pnt.x += tmpBarOff.x; _calc.bar1Geom.pnt.y += tmpBarOff.y; // horizontal? if(_calc.isHorizontal) { barMin = (D4D_COOR)(_calc.bar1Geom.pnt.x); barMax = (D4D_COOR)(barMin + _calc.bar1Geom.sz.cx - 1); } // vertical? else { barMin = (D4D_COOR)(_calc.bar1Geom.pnt.y); barMax = (D4D_COOR)(barMin + _calc.bar1Geom.sz.cy - 1); } // value and origin coordinates c1 = D4D_MulDivUU((D4D_COOR)(pSldr->pData->limits.valueOrg - pSldr->pData->limits.valueMin), (D4D_COOR)(barMax-barMin), (D4D_COOR)tmp_scale); c2 = D4D_MulDivUU((D4D_COOR)(pSldr->pData->value - pSldr->pData->limits.valueMin), (D4D_COOR)(barMax-barMin), (D4D_COOR)tmp_scale); #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE if(tmpBarOff.x > tmpBarOff.y) tmp_scale = (sWord)(tmpBarOff.x - tmpBarOff.y); else tmp_scale = (sWord)(tmpBarOff.y - tmpBarOff.x); tmp_scale /=2; tmp_scale = (sWord)(pThis->radius - tmp_scale); if(tmp_scale > 0) _calc.inner_radius = (D4D_COOR)tmp_scale; else _calc.inner_radius = 0; _calc.bar_radius = _calc.inner_radius; #endif // bar rectangle range need to be "sorted" if(c1 > c2) { D4D_COOR tmp_coor; tmp_coor = c2; c2 = c1; c1 = tmp_coor; } _calc.bar3Geom.sz = _calc.bar2Geom.sz = _calc.bar1Geom.sz; // X grows to right, Y grows to top if(_calc.isHorizontal) { if(pSldr->pData->limits.valueOrg > pSldr->pData->value) _calc.dir = D4D_DIR_LEFT; else _calc.dir = D4D_DIR_RIGHT; _calc.bar3Geom.sz.cx -= c2; _calc.bar1Geom.sz.cx = c1; _calc.bar2Geom.sz.cx = (D4D_COOR)(c2 - c1 + 1); _calc.bar2Geom.pnt.x = (D4D_COOR)(_calc.bar1Geom.pnt.x + c1); _calc.bar2Geom.pnt.y = _calc.bar1Geom.pnt.y; _calc.bar3Geom.pnt.x = (D4D_COOR)(_calc.bar1Geom.pnt.x + c2); _calc.bar3Geom.pnt.y = _calc.bar1Geom.pnt.y; #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE if(_calc.inner_radius) { _calc.bar1Geom.sz.cx += _calc.inner_radius * 2; _calc.bar3Geom.sz.cx += _calc.inner_radius * 2; _calc.bar_radius = D4D_LimitU(_calc.bar_radius, 0, (D4D_COOR)(_calc.bar2Geom.sz.cx / 2)); if(_calc.inner_radius != _calc.bar_radius) { D4D_COOR tmp_coor; //tmp_coor = D4D_RndCornerGetNonPrintedPxl(_calc.inner_radius, (D4D_COOR)(_calc.pnt2.x + _calc.sz2.cx - (_calc.pnt1.x + _calc.sz1.cx + 0))); tmp_coor = (D4D_COOR)(_calc.inner_radius - D4D_RndCornerGetNonPrintedPxl((D4D_COOR)(_calc.inner_radius + 1), (D4D_COOR)(_calc.inner_radius - (_calc.bar2Geom.sz.cx / 2)))); _calc.bar2Geom.sz.cy -= (D4D_COOR)(tmp_coor*2); _calc.bar2Geom.pnt.y += tmp_coor; } _calc.bar1Geom.sz.cx = D4D_LimitU(_calc.bar1Geom.sz.cx, (D4D_COOR)(_calc.inner_radius * 2), (D4D_COOR)(barMax - barMin + 1)); _calc.bar3Geom.sz.cx = D4D_LimitU(_calc.bar3Geom.sz.cx, (D4D_COOR)(_calc.inner_radius * 2), (D4D_COOR)(barMax - barMin + 1)); _calc.bar3Geom.pnt.x -= (D4D_COOR)(2 * _calc.inner_radius); _calc.bar3Geom.pnt.x = D4D_LimitU(_calc.bar3Geom.pnt.x, _calc.bar1Geom.pnt.x, (D4D_COOR)(barMax- (_calc.inner_radius * 2))); } #endif }else { if(pSldr->pData->limits.valueOrg > pSldr->pData->value) _calc.dir = D4D_DIR_DOWN; else _calc.dir = D4D_DIR_UP; _calc.bar3Geom.pnt = _calc.bar2Geom.pnt = _calc.bar1Geom.pnt; _calc.bar2Geom.pnt.y += (D4D_COOR)(_calc.bar1Geom.sz.cy - (c2 + 1)); _calc.bar1Geom.pnt.y += (D4D_COOR)(_calc.bar1Geom.sz.cy - (c1 + 1)); _calc.bar3Geom.sz.cy = (D4D_COOR)(_calc.bar1Geom.sz.cy - (c2 + 1)); _calc.bar1Geom.sz.cy = (D4D_COOR)(c1 + 1); _calc.bar2Geom.sz.cy = (D4D_COOR)(c2 - c1 + 1); #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE if(_calc.inner_radius) { _calc.bar1Geom.sz.cy += (D4D_COOR)(_calc.inner_radius * 2); _calc.bar3Geom.sz.cy += (D4D_COOR)(_calc.inner_radius * 2); _calc.bar_radius = D4D_LimitU(_calc.bar_radius, 0, (D4D_COOR)(_calc.bar2Geom.sz.cy / 2)); if(_calc.inner_radius != _calc.bar_radius) { D4D_COOR tmp_coor; tmp_coor = (D4D_COOR)(_calc.inner_radius - D4D_RndCornerGetNonPrintedPxl((D4D_COOR)(_calc.inner_radius + 1), (D4D_COOR)(_calc.inner_radius - (_calc.bar2Geom.sz.cy / 2)))); _calc.bar2Geom.sz.cx -= (D4D_COOR)(tmp_coor * 2); _calc.bar2Geom.pnt.x += tmp_coor; } _calc.bar1Geom.sz.cy = D4D_LimitU(_calc.bar1Geom.sz.cy, (D4D_COOR)(_calc.inner_radius * 2 + 1), (D4D_COOR)(barMax - barMin + 1)); _calc.bar3Geom.sz.cy = D4D_LimitU(_calc.bar3Geom.sz.cy, (D4D_COOR)(_calc.inner_radius * 2), (D4D_COOR)(barMax - barMin + 1)); _calc.bar1Geom.pnt.y -= (D4D_COOR)(2 * _calc.inner_radius); _calc.bar1Geom.pnt.y = D4D_LimitU(_calc.bar1Geom.pnt.y, _calc.bar3Geom.pnt.y, (D4D_COOR)(barMax - (_calc.inner_radius * 2))); } #endif } }