static D4D_COOR D4D_GetTitleBarHeight(D4D_OBJECT* pThis) { D4D_MENU* pMenu = D4D_GET_MENU(pThis); D4D_COOR bar_height = 0; if(pMenu->title_text.pText != NULL) bar_height = D4D_GetFontHeight(pMenu->title_text.fontId); if(pThis->initFlags & D4D_MENU_F_INDEX) if(D4D_GetFontHeight(pMenu->indexFontId) > bar_height) bar_height = D4D_GetFontHeight(pMenu->indexFontId); if(pMenu->pIcon != NULL) if(D4D_GetBmpHeight(pMenu->pIcon) > bar_height) bar_height = D4D_GetBmpHeight(pMenu->pIcon); if(bar_height) { bar_height += 3; #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE bar_height += pThis->radius / 2; #endif } return bar_height; }
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_IconOnDraw(D4D_MESSAGE* pMsg) { D4D_OBJECT* pThis = pMsg->pObject; D4D_ICON* pIcon = D4D_GET_ICON(pThis); D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw; D4D_COLOR clrT, clrB; D4D_BMP_PROPERTIES bmpProp; D4D_IconValue2Coor(pThis); bmpProp = (D4D_ALIGN_V_TOP_MASK | D4D_ALIGN_H_CENTER_MASK); clrT = D4D_ObjectGetForeColor(pThis, draw); clrB = D4D_ObjectGetBckgColor(pThis, draw); // Draw the frame if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE)) D4D_DrawFrame(pThis, clrT, clrB); // draw the bitmap if(pIcon->pBmpX[pIcon->pData->index] != NULL) D4D_DrawRBmpRect(&_calc.contentGeom.pnt,&_calc.contentGeom.sz, pIcon->pBmpX[pIcon->pData->index], bmpProp, clrB, (D4D_BOOL)(!D4D_IsEnabled(pThis)), pThis->radius); // draw the text if(pIcon->textBuff.pText != NULL) { D4D_SIZE tmp_size; tmp_size.cx = D4D_GetTextWidth(pIcon->textBuff.fontId, pIcon->textBuff.pText); tmp_size.cy = D4D_GetFontHeight(pIcon->textBuff.fontId); D4D_DrawTextRect(&_calc.txtPos, &tmp_size, &pIcon->textBuff, clrT, clrB); } }
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; } }
/**************************************************************//*! * * Compute size of screen header * ******************************************************************/ D4D_COOR D4D_GetScrHeaderSize(D4D_SCREEN* pScreen) { D4D_COOR tmp_size = 0; if(pScreen == NULL) return 0; if((pScreen->flags & D4D_SCR_F_TITLEBAR) || pScreen->textBuff.pText) { tmp_size = (D4D_COOR)(D4D_SCR_TITLE_OFF_Y * 2 + D4D_GetFontHeight(pScreen->textBuff.fontId)); } if(pScreen->pIcon != NULL) if(tmp_size < (D4D_GetBmpHeight(pScreen->pIcon) + D4D_SCR_TITLE_OFF_Y * 2 + 1)) tmp_size = (D4D_COOR)(D4D_GetBmpHeight(pScreen->pIcon) + D4D_SCR_TITLE_OFF_Y * 2 + 1); if(pScreen->flags & D4D_SCR_F_TITLEBAR) if(tmp_size < D4D_SCR_HEADER_SIZE_MIN_SIZE) tmp_size = D4D_SCR_HEADER_SIZE_MIN_SIZE; return tmp_size; }
static void D4D_MenuOnDraw(D4D_MESSAGE* pMsg) { D4D_OBJECT* pThis = pMsg->pObject; D4D_MENU* pMenu = D4D_GET_MENU(pThis); D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw; D4D_COLOR clrT, clrB; D4D_POINT tmp_point; D4D_SIZE tmp_size; D4D_STRING tmp_txtbuff; D4D_STR_PROPERTIES tmp_str_prty; Byte tmpB; tmp_txtbuff.str_properties = &tmp_str_prty; tmp_txtbuff.printOff = 0; // Get background simple color clrT = D4D_ObjectGetForeFillColor(pThis); clrB = D4D_ObjectGetBckgFillColor(pThis); #ifdef D4D_DEBUG // sanity check D4D_ASSERT(sizeof(_calc) <= D4D_SCRATCHPAD_SIZE); #endif // Compute all tempoarary values D4D_MenuValue2Coor(pThis); // draw just a color rectangle instead of bitmap if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE) { D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius); if(pMenu->pIcon != NULL) { tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + 2); tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + ((_calc.titleBar_y - D4D_GetBmpHeight(pMenu->pIcon)) / 2)); D4D_DrawRBmp(&tmp_point, pMenu->pIcon, (D4D_BOOL)!D4D_IsEnabled(pThis), pThis->radius); } if(pMenu->title_text.pText) { tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + 4); #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE tmp_point.x += (D4D_COOR)(pThis->radius/2); #endif if(pMenu->pIcon != NULL) tmp_point.x += D4D_GetBmpHeight(pMenu->pIcon); tmp_point.y = _calc.contentGeom.pnt.y; tmp_size.cx = D4D_GetTextWidth(pMenu->title_text.fontId, pMenu->title_text.pText); tmp_size.cy = D4D_GetFontHeight(pMenu->title_text.fontId); D4D_DrawTextRect(&tmp_point, &tmp_size, &pMenu->title_text, clrT, clrB); } if(_calc.titleBar_y) { D4D_MoveToXY(_calc.contentGeom.pnt.x,\ (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y)); D4D_LineToXY((D4D_COOR)(_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cx - 1),\ (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y), D4D_LINE_THIN, clrT); } } // Draw the frame if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE)) D4D_DrawFrame(pThis, clrT, clrB); if(pThis->initFlags & D4D_MENU_F_INDEX) { // Draw index counter tmp_txtbuff.printLen = (D4D_INDEX)((_calc.itemsCnt < 10)? 3:5); tmp_size.cx = (D4D_COOR)(tmp_txtbuff.printLen * D4D_GetFontWidth(pMenu->indexFontId) + 2); tmp_size.cy = (D4D_COOR)(_calc.titleBar_y - 2); tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cx - tmp_size.cx - 2); tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y); #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE tmp_size.cy -= (D4D_COOR)(pThis->radius / 2); tmp_point.x -= (D4D_COOR)(pThis->radius / 2); tmp_point.y += (D4D_COOR)(pThis->radius / 2); #endif tmp_txtbuff.pText = _calc.index_txt; tmp_txtbuff.fontId = pMenu->indexFontId; tmp_str_prty.font_properties = D4D_MENU_IX_FNT_PRTY_DEFAULT; tmp_str_prty.text_properties = D4D_MENU_IX_TXT_PRTY_DEFAULT; D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB); } for(tmpB = 0; (tmpB < _calc.posCnt) && (tmpB + pMenu->pData->page_ix < _calc.itemsCnt); tmpB++) { if(((pMenu->pData->ix - pMenu->pData->page_ix) != tmpB) || (!D4D_IsEnabled(pThis))) { clrT = D4D_ObjectGetForeFillColor(pThis); clrB = D4D_ObjectGetBckgFillColor(pThis); } else { D4D_CLR_SCHEME *pScheme_tmp = D4D_ObjectGetScheme(pThis); clrT = pScheme_tmp->foreFocus; clrB = pScheme_tmp->bckgFocus; } // Draw menu item text if(pMenu->pItems[tmpB + pMenu->pData->page_ix].text.pText != NULL) { tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + _calc.maxIcon.cx + 4); tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y + 1 + (tmpB * _calc.textOff)); tmp_size.cx = (D4D_COOR)(_calc.contentGeom.sz.cx - (_calc.maxIcon.cx + 6 + ((D4D_GET_MENU_SCROLL_BAR_HOR(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE)? D4D_MENU_SCRLBR_WIDTH:0))); #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE tmp_point.x += (D4D_COOR)(pThis->radius / 2); tmp_size.cx -= (D4D_COOR)(pThis->radius / 1); #endif tmp_size.cy = D4D_GetFontHeight(pMenu->itemsFontId); // to invoke autosize capability in axis Y tmp_txtbuff.pText = pMenu->pItems[tmpB + pMenu->pData->page_ix].text.pText; tmp_txtbuff.fontId = pMenu->itemsFontId; tmp_txtbuff.buffSize = 0; tmp_txtbuff.printLen = D4D_GetTextLength(tmp_txtbuff.pText); tmp_str_prty.font_properties = D4D_MENU_ITEM_FNT_PRTY_DEFAULT; tmp_str_prty.text_properties = D4D_MENU_ITEM_TXT_PRTY_DEFAULT; D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB); } // Draw menu item icon if(_calc.maxIcon.cx) { tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + 3); if(_calc.maxIcon.cy < _calc.textOff) tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y + 3 + (tmpB * _calc.textOff) + ((D4D_GetFontHeight(pMenu->itemsFontId) - _calc.maxIcon.cy) / 2)); else tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y + 3 + (tmpB * _calc.textOff)); if(pMenu->pItems[tmpB + pMenu->pData->page_ix].pIcon != NULL) D4D_DrawRBmp(&tmp_point, pMenu->pItems[tmpB + pMenu->pData->page_ix].pIcon, (D4D_BOOL)!D4D_IsEnabled(pThis), pThis->radius); else D4D_FillRRect(&tmp_point, &_calc.maxIcon, D4D_ObjectGetBckgFillColor(pThis), pThis->radius); } } }
/**************************************************************//*! * * Print the String in ASCII in simple format up to 8 columns * ******************************************************************/ void D4D_LCD_PrintStr(D4D_PRINT_DESC* p_StrDes) { D4D_INDEX str_len, ch_ix; D4D_COOR orig_x = p_StrDes->x; D4D_COOR base_y, base_x; D4D_FONT_TYPE* pFontType = (D4D_FONT_TYPE*)p_StrDes->pFontType; D4D_FONT_DESCRIPTOR* pFontDescriptor = (D4D_FONT_DESCRIPTOR*)(pFontType->pFontDescriptor); const D4D_TCHAR pLongTextEnd[] = D4D_DEFSTR("..."); D4D_BOOL longText = D4D_FALSE; D4D_COOR tmp_MaxLen = p_StrDes->maxWidth; D4D_COOR longTextLen; D4D_TCHAR* pTextInt; // check if fontdescriptor exist and check the font scale value if((pFontDescriptor == NULL) || (pFontType->scale.width == 0) || (pFontType->scale.height == 0)) return; // long strings restriction if(tmp_MaxLen) { // check if the text fits into enabled width D4D_STRING tmpString; D4D_COOR tmp_txtLen; tmpString.pText = p_StrDes->pText; tmpString.buffSize = 0; tmpString.fontId = p_StrDes->pFontType->ix_font; tmpString.printLen = p_StrDes->textLength; tmpString.printOff = p_StrDes->textOffset; tmp_txtLen = D4D_GetTextBuffWidthTab(&tmpString, p_StrDes->pTab); if(p_StrDes->pTab) { if(tmp_txtLen > p_StrDes->pTab->tabOffset) tmp_txtLen -= p_StrDes->pTab->tabOffset; else return; } longTextLen = D4D_GetTextWidth(tmpString.fontId, (D4D_TCHAR*)pLongTextEnd); if(tmp_txtLen > p_StrDes->maxWidth) { if(tmp_txtLen < longTextLen) return; tmp_MaxLen -= longTextLen; longText = D4D_TRUE; } } pTextInt = D4D_GetInternalStringPointer(p_StrDes->pText); #if D4D_EXTSRC_TEXT_ENABLE != D4D_FALSE if(pTextInt == NULL) { D4D_INDEX charCnt = 0; D4D_INDEX charOff = p_StrDes->textOffset; D4D_INDEX charCntTmp; do { charOff += charCnt; charCnt = (D4D_INDEX)d4d_extsrcLocale.D4DLOCALE_TranslateStr(p_StrDes->pText, (D4D_TCHAR*)d4d_extsrcBuffer, charOff, D4D_EXTSRC_BUFF_SIZE); // get the lenght of string str_len = charCnt; if(p_StrDes->textLength) if(str_len > p_StrDes->textLength) str_len = p_StrDes->textLength; str_len += (charOff - 1); for(charCntTmp = 0; charCntTmp < charCnt; charCntTmp++) { if((!((D4D_TCHAR*)d4d_extsrcBuffer)[charCntTmp]) || (str_len < (charCntTmp + charOff))) { charCnt = 0; break; } if(longText) { D4D_COOR tmp_Len; tmp_Len = D4D_GetCharWidth(p_StrDes->pFontType->ix_font, ((D4D_TCHAR*)d4d_extsrcBuffer)[charCntTmp]); if(tmp_MaxLen - tmp_Len <= 0) { charCnt = 0; break; } tmp_MaxLen -= tmp_Len; } p_StrDes->x += D4D_LCD_PrintChr(((D4D_TCHAR*)d4d_extsrcBuffer)[charCntTmp], p_StrDes); // print the char and automatically update the coordintaion of next char } }while(charCnt == D4D_EXTSRC_BUFF_SIZE); }else #endif { pTextInt = &pTextInt[p_StrDes->textOffset]; // get the lenght of string str_len = D4D_GetTextLength(pTextInt); if(p_StrDes->textLength) if(str_len > p_StrDes->textLength) str_len = p_StrDes->textLength; // Draw the text for (ch_ix=0; ch_ix<str_len; ++ch_ix) // For each character in the string { if(longText) { D4D_COOR tmp_Len; tmp_Len = D4D_GetCharWidth(p_StrDes->pFontType->ix_font, *pTextInt); if(tmp_MaxLen - tmp_Len <= 0) { break; } tmp_MaxLen -= tmp_Len; } p_StrDes->x += D4D_LCD_PrintChr(*pTextInt++, p_StrDes); // print the char and automatically update the coordintaion of next char } } if(longText) { ch_ix=0; while(pLongTextEnd[ch_ix]) p_StrDes->x += D4D_LCD_PrintChr(pLongTextEnd[ch_ix++], p_StrDes); // print the char and automatically update the coordintaion of next char if(!(p_StrDes->properties & D4D_FNT_PRTY_TRANSPARENT_MASK)) D4D_FillRectXY(p_StrDes->x, p_StrDes->y, (D4D_COOR)(orig_x + p_StrDes->maxWidth - 1), (D4D_COOR)(p_StrDes->y + D4D_GetFontHeight(p_StrDes->pFontType->ix_font) - 1), p_StrDes->colorBack); } // Draw the Underline option switch(p_StrDes->properties & D4D_FNT_PRTY_UNDERLINE_MASK) { case D4D_FNT_PRTY_UNDERLINE_LINE_MASK: // Draw the full line base_y = (D4D_COOR)(p_StrDes->y + pFontDescriptor->charBaseLine * pFontType->scale.height); base_x = p_StrDes->x; D4D_FillRectXY(orig_x, base_y, (D4D_COOR)(base_x - 1), (D4D_COOR)(base_y + pFontType->scale.height - 1), p_StrDes->colorText); break; case D4D_FNT_PRTY_UNDERLINE_DOT_MASK: // Draw the dot line base_y = (D4D_COOR)(p_StrDes->y + pFontDescriptor->charBaseLine * pFontType->scale.height); ch_ix = 0; for(base_x = orig_x; base_x < p_StrDes->x; base_x += pFontType->scale.height) { if(++ch_ix % 2) D4D_FillRectXY(base_x, base_y, (D4D_COOR)(base_x + pFontType->scale.width - 1), (D4D_COOR)(base_y + pFontType->scale.height - 1), p_StrDes->colorText); } break; default: break; } // Draw the Strike Through option if(p_StrDes->properties & D4D_FNT_PRTY_STRIKETHROUGH_MASK) { Byte line_cnt = (Byte)((p_StrDes->properties & D4D_FNT_PRTY_STRIKETHROUGH_MASK) >> D4D_FNT_PRTY_STRIKETHROUGH_SHIFT); base_y = (D4D_COOR)(p_StrDes->y + (pFontDescriptor->charBaseLine - (pFontDescriptor->charSize / 3)) * pFontType->scale.height); base_x = p_StrDes->x; // Draw Strike Through line as many as specified by parameter while(line_cnt) { D4D_FillRectXY(orig_x, base_y, (D4D_COOR)(base_x - 1), (D4D_COOR)(base_y - 1), p_StrDes->colorText); base_y -=2; line_cnt--; } }
/**************************************************************//*! * * Redraw non client screen area - Header, background, title, etc. * ******************************************************************/ static void D4D_DrawScreenNC(D4D_SCREEN* pScreen, D4D_BOOL active) { D4D_CLR_SCHEME *pScheme = D4D_ScreenGetScheme(pScreen); D4D_COLOR clr; D4D_GEOMETRY contentGeom; D4D_POINT tmpPoint; D4D_SIZE tmpSize; contentGeom.pnt = pScreen->position; contentGeom.sz = pScreen->size; if(pScreen->flags & D4D_SCR_F_BEVEL) { contentGeom.pnt.x += D4D_BEVEL_WIDTH; contentGeom.pnt.y += D4D_BEVEL_WIDTH; contentGeom.sz.cx -= 2*D4D_BEVEL_WIDTH; contentGeom.sz.cy -= 2*D4D_BEVEL_WIDTH; }else if(pScreen->flags & D4D_SCR_F_OUTLINE) { contentGeom.pnt.x++; contentGeom.pnt.y++; contentGeom.sz.cx -= 2; contentGeom.sz.cy -= 2; } if(active) { if(pScreen->flags & D4D_SCR_F_BCKG) { D4D_FillRRect(&contentGeom.pnt, &contentGeom.sz, pScheme->screen.desktop, pScreen->radius); } if(pScreen->flags & D4D_SCR_F_BEVEL) { D4D_Bevel(&(pScreen->position), &(pScreen->size), pScheme->screen.outline, D4D_BEVEL_RAISED, pScreen->radius); }else if(pScreen->flags & D4D_SCR_F_OUTLINE) { D4D_RRect(&(pScreen->position), &(pScreen->size), D4D_LINE_THIN, pScheme->screen.outline, pScreen->radius); } } if(pScreen->flags & D4D_SCR_F_TITLEBAR) { clr = pScheme->screen.title_bar; if(!active) clr = D4D_GetGreyScale(clr); tmpSize = contentGeom.sz; tmpSize.cy = D4D_GetScrHeaderSize(pScreen); if(tmpSize.cy) tmpSize.cy--; D4D_FillRRect(&contentGeom.pnt, &tmpSize, clr, pScreen->radius); } if(pScreen->pIcon != NULL) { tmpPoint = contentGeom.pnt; tmpPoint.x += D4D_SCR_TITLE_OFF_X; tmpPoint.y += (D4D_COOR)((D4D_GetScrHeaderSize(pScreen) - D4D_GetBmpHeight(pScreen->pIcon)) / 2); D4D_DrawRBmp(&tmpPoint, pScreen->pIcon, (D4D_BOOL)!active, pScreen->radius); } if(pScreen->textBuff.pText) { tmpPoint = contentGeom.pnt; tmpPoint.x += D4D_GetScrHeaderTitleOffset(pScreen); tmpPoint.y += (D4D_COOR)((D4D_GetScrHeaderSize(pScreen) - D4D_GetFontHeight(pScreen->textBuff.fontId)) / 2); clr = pScheme->screen.title_text; if(!active) clr = D4D_GetGreyScale(clr); D4D_DrawText(&tmpPoint, &pScreen->textBuff, clr, 0); } if(pScreen->flags & D4D_SCR_F_EXIT) { clr = pScheme->screen.exitBtnFore; if(!active) clr = D4D_GetGreyScale(clr); if(D4D_GetScrHeaderExitBtnCoor(pScreen, &tmpPoint, &tmpSize)) { D4D_RBox(&tmpPoint, &tmpSize, D4D_LINE_THIN, clr, pScheme->screen.exitBtnBckg, pScreen->radius); tmpPoint.x += D4D_SCR_EXITBTN_CROSS_SIZE; tmpPoint.y += D4D_SCR_EXITBTN_CROSS_SIZE; #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE tmpPoint.x += (D4D_COOR)(pScreen->radius / 2); tmpPoint.y += (D4D_COOR)(pScreen->radius / 2); #endif D4D_MoveTo(&tmpPoint); tmpPoint.x += tmpSize.cx - (2 * D4D_SCR_EXITBTN_CROSS_SIZE); tmpPoint.y += tmpSize.cy - (2 * D4D_SCR_EXITBTN_CROSS_SIZE); #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE tmpPoint.x -= (D4D_COOR)(pScreen->radius); tmpPoint.y -= (D4D_COOR)(pScreen->radius); #endif D4D_LineTo(&tmpPoint, D4D_LINE_THIN, clr); tmpPoint.y -= tmpSize.cy - (2 * D4D_SCR_EXITBTN_CROSS_SIZE); #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE tmpPoint.y += (D4D_COOR)(pScreen->radius); #endif D4D_MoveTo(&tmpPoint); tmpPoint.x -= tmpSize.cx - (2 * D4D_SCR_EXITBTN_CROSS_SIZE); tmpPoint.y += tmpSize.cy - (2 * D4D_SCR_EXITBTN_CROSS_SIZE); #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE tmpPoint.x += (D4D_COOR)(pScreen->radius); tmpPoint.y -= (D4D_COOR)(pScreen->radius); #endif D4D_LineTo(&tmpPoint, D4D_LINE_THIN, clr); } } }
static void D4D_TextBoxOnDraw(D4D_MESSAGE* pMsg) { D4D_OBJECT* pThis = pMsg->pObject; D4D_TEXTBOX* pTextBox = D4D_GET_TEXTBOX(pThis); D4D_TXTBX_DATA* pData = pTextBox->pData; D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw; D4D_COLOR clrT, clrB; D4D_INDEX line_cnt; D4D_POINT tmp_point; D4D_SIZE tmp_size; D4D_STRING tmp_txtbuff; D4D_STR_PROPERTIES tmp_strPrties; D4D_TAB tmp_strTab; D4D_TAB* pTab = NULL; D4D_TextBoxValue2Coor(pThis); clrT = D4D_ObjectGetForeFillColor(pThis); clrB = D4D_ObjectGetBckgFillColor(pThis); // draw the rectangle around the text if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE) { D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius); pData->redrawText = D4D_TRUE; } // Draw the frame if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE)) D4D_DrawFrame(pThis, clrT, clrB); if(pData->redrawText) { D4D_INDEX tmp_index = pData->firstShowedCharIx; pData->redrawText = D4D_FALSE; tmp_txtbuff.fontId = pTextBox->textFontId; tmp_txtbuff.str_properties = &tmp_strPrties; tmp_strPrties.font_properties = 0; tmp_strPrties.text_properties = 0; // Draw all lines of textbox tmp_point = _calc.txtGeom.pnt; tmp_size.cx = _calc.txtGeom.sz.cx; tmp_size.cy = D4D_GetFontHeight(pTextBox->textFontId); tmp_txtbuff.pText = pData->pTxtArr; tmp_txtbuff.buffSize = 0; if(pTextBox->pTabTable) { tmp_strTab.pTabTable = pTextBox->pTabTable; tmp_strTab.tabOffset = (D4D_COOR)(_calc.txtGeom.pnt.x - _calc.position.x); pTab = &tmp_strTab; } for(line_cnt = 0; line_cnt < _calc.lineCount; line_cnt++) { tmp_txtbuff.printLen = D4D_TextBoxGetMaxLineChars(tmp_txtbuff.pText, tmp_index, pTab, tmp_size.cx, tmp_txtbuff.fontId); tmp_txtbuff.printOff = tmp_index; tmp_index += tmp_txtbuff.printLen; D4D_DrawTextRectTab(&tmp_point, &tmp_size, &tmp_txtbuff, pTab, clrT, clrB); tmp_point.y += tmp_size.cy; } } }
static void D4D_ConsoleOnDraw(D4D_MESSAGE* pMsg) { D4D_OBJECT* pThis = pMsg->pObject; D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pThis); D4D_CNSL_DATA* pData = pCnsl->pData; D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw; D4D_COLOR clrT, clrB; D4D_INDEX line_cnt, tmp_realLine; D4D_POINT tmp_point; D4D_SIZE tmp_size, tmp_winOff; D4D_STRING tmp_txtbuff; D4D_STR_PROPERTIES tmp_strPrties; D4D_BOOL tmp_font_proporcional = D4D_FALSE; D4D_CnslValue2Coor(pThis); clrT = D4D_ObjectGetForeFillColor(pThis); clrB = D4D_ObjectGetBckgFillColor(pThis); // draw the rectangle around the text if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE) { D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius); pData->flags |= (D4D_CNSL_FLAGS_REDRAWALL | D4D_CNSL_FLAGS_REDRAWLINE | D4D_CNSL_FLAGS_REDRAWCURSOR); } // Draw the frame if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE)) D4D_DrawFrame(pThis, clrT, clrB); tmp_winOff.cx = (D4D_COOR)D4D_ScrlBrGetPosition(D4D_GET_LIST_BOX_SCROLL_BAR_HOR(pThis)); tmp_winOff.cy = (D4D_COOR)D4D_ScrlBrGetPosition(D4D_GET_LIST_BOX_SCROLL_BAR_VER(pThis)); tmp_strPrties.font_properties = 0; tmp_strPrties.text_properties = 0; tmp_txtbuff.fontId = pCnsl->textFontId; tmp_txtbuff.str_properties = &tmp_strPrties; tmp_txtbuff.printOff = 0; if(pData->flags & (D4D_CNSL_FLAGS_REDRAWALL | D4D_CNSL_FLAGS_REDRAWLINE)) { // Draw all lines of console tmp_point = _calc.txtGeom.pnt; tmp_size.cx = _calc.txtGeom.sz.cx; tmp_size.cy = D4D_GetFontHeight(pCnsl->textFontId); if(D4D_GetFont(pCnsl->textFontId)->pFontDescriptor->flags & D4D_FONT_FLAGS_FNT_WIDTH_PROPORTIONAL) tmp_font_proporcional = D4D_TRUE; for(line_cnt = 0; line_cnt < _calc.charArrSize.cy; line_cnt++) { if(!(pData->flags & D4D_CNSL_FLAGS_REDRAWALL)) if(line_cnt != pData->cursorPos.y) { tmp_point.y += tmp_size.cy; continue; } // Compute the real line in memory tmp_realLine = (D4D_INDEX)((pData->lastLineIx + line_cnt + tmp_winOff.cy) % pCnsl->txtArrSize.cy); // found the right pointer of the text to draw in the text array tmp_txtbuff.pText = (D4D_TCHAR*)(pCnsl->pTxtArr + tmp_realLine * (pCnsl->txtArrSize.cx + 1) + tmp_winOff.cx); if((tmp_winOff.cx + _calc.charArrSize.cx) <= pCnsl->txtArrSize.cx) { if(tmp_font_proporcional) tmp_txtbuff.printLen = D4D_CnslFindMaxTextLenght(tmp_txtbuff.pText, pCnsl->textFontId, tmp_winOff.cx, pCnsl->txtArrSize.cx); else tmp_txtbuff.printLen = _calc.charArrSize.cx; tmp_txtbuff.buffSize = 0; } D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB); tmp_point.y += tmp_size.cy; } } // redraw cursor if(((D4D_INDEX_DELTA)(pData->cursorPos.y - tmp_winOff.cy) >= 0) && ((pData->cursorPos.y - tmp_winOff.cy) < _calc.charArrSize.cy) && (pData->cursorPos.x >= tmp_winOff.cx)) //cursor is on screen - check line and also and check the axis X { D4D_BOOL cursorVisible = D4D_FALSE; // Compute the real line in memory tmp_realLine = (D4D_INDEX)((pData->lastLineIx + pData->cursorPos.y) % pCnsl->txtArrSize.cy); // found the right pointer of the text to draw in the text array tmp_txtbuff.pText = (D4D_TCHAR*)(pCnsl->pTxtArr + tmp_realLine * (pCnsl->txtArrSize.cx + 1) + tmp_winOff.cx); // Check if the cursor is visible on the line tmp_txtbuff.printLen = D4D_CnslFindMaxTextLenght(tmp_txtbuff.pText, pCnsl->textFontId, tmp_winOff.cx, pData->cursorPos.x); if(*(tmp_txtbuff.pText + pData->cursorPos.x)) tmp_size.cx = D4D_GetCharWidth(pCnsl->textFontId, *(tmp_txtbuff.pText + pData->cursorPos.x)); else tmp_size.cx = D4D_GetCharWidth(pCnsl->textFontId, ' '); tmp_point.x = D4D_GetTextBuffWidthTab(&tmp_txtbuff, NULL); if(tmp_font_proporcional) { if(tmp_point.x < (D4D_COOR)( _calc.txtGeom.sz.cx - tmp_size.cx)) cursorVisible = D4D_TRUE; } else { if(pData->cursorPos.x < (D4D_INDEX)(_calc.charArrSize.cx + tmp_winOff.cx)) cursorVisible = D4D_TRUE; } if(cursorVisible) { tmp_point.y = (D4D_COOR)((pData->cursorPos.y - tmp_winOff.cy) * D4D_GetFontHeight(pCnsl->textFontId) + _calc.txtGeom.pnt.y);//??+1 tmp_point.x += _calc.txtGeom.pnt.x; tmp_size.cy = (D4D_COOR)((D4D_CNSL_CURSOR_HEIGHT > D4D_GetFontHeight(pCnsl->textFontId))? D4D_CNSL_CURSOR_HEIGHT : D4D_GetFontHeight(pCnsl->textFontId)); // check the state of cursor and selected right color if((!(pData->flags & D4D_CNSL_FLAGS_CURSORSTATE)) || (!tmp_txtbuff.pText[0])) { // draw cursor D4D_COLOR clr; if(pData->flags & D4D_CNSL_FLAGS_CURSORSTATE) clr = clrB; else clr = clrT; tmp_point.y += (D4D_GetFontHeight(pCnsl->textFontId) - D4D_CNSL_CURSOR_HEIGHT - 1); tmp_size.cy = D4D_CNSL_CURSOR_HEIGHT; D4D_FillRect(&tmp_point, &tmp_size, clr); } else { // Draw the original char tmp_txtbuff.printOff = pData->cursorPos.x; tmp_txtbuff.printLen = 1; D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB); } } } pData->flags &= ~(D4D_CNSL_FLAGS_REDRAWALL | D4D_CNSL_FLAGS_REDRAWLINE | D4D_CNSL_FLAGS_REDRAWCURSOR); }
static void D4D_SldrOnDraw(D4D_MESSAGE* pMsg) { D4D_OBJECT* pThis = pMsg->pObject; D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis); D4D_COLOR clrT, clrB; D4D_COLOR clrBar = pSldr->pData->colorBar; D4D_COLOR clrBarBckg = D4D_ObjectGetScheme(pThis)->objectDepend.slider.barBckg; D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw; #ifdef D4D_DEBUG // sanity check D4D_ASSERT(sizeof(_calc) <= D4D_SCRATCHPAD_SIZE); #endif // bar coordinate calculation D4D_SldrValue2Coor(pThis); clrT = D4D_ObjectGetForeColor(pThis, draw); clrB = D4D_ObjectGetBckgColor(pThis, draw); // if slider is disabled draw slider in grey scale if(!D4D_IsEnabled(pThis)) { clrBar = D4D_GetGreyScale(clrBar); clrBarBckg = D4D_GetGreyScale(clrBarBckg); } // when background redraw is needed if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE) { // draw the bitmap if(pSldr->pBmpBkgd != NULL) D4D_DrawRBmp(&_calc.position, pSldr->pBmpBkgd, (D4D_BOOL)!D4D_IsEnabled(pThis), pThis->radius); else D4D_FillRRect(&_calc.position, &pThis->size, D4D_ObjectGetBckgFillColor(pThis), pThis->radius); } // draw focus rectangle D4D_RRect(&_calc.position, &pThis->size, D4D_LINE_THIN, clrT, pThis->radius); // draw first inactive part D4D_FillRRect(&_calc.bar1Geom.pnt, &_calc.bar1Geom.sz, clrBarBckg, _calc.inner_radius); // draw last inactive part of the bar D4D_FillRRect(&_calc.bar3Geom.pnt, &_calc.bar3Geom.sz, clrBarBckg, _calc.inner_radius); // draw active part of the bar if(pThis->initFlags & D4D_SLDR_F_BAR_SCALECOLOR) D4D_FillRRectColorScale(&_calc.bar2Geom.pnt, &_calc.bar2Geom.sz, D4D_COLOR_SLDR_BAR_START, clrBar, _calc.dir, _calc.bar_radius); else D4D_FillRRect(&_calc.bar2Geom.pnt, &_calc.bar2Geom.sz, clrBar, _calc.inner_radius); // Draw the frame if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE)) D4D_DrawFrame(pThis, clrT, clrB); // draw the text if(pSldr->textBuff.pText != NULL) { D4D_SIZE tmp_size; _calc.position.x += pSldr->txtOff.x; _calc.position.y += pSldr->txtOff.y; if(!pSldr->txtOff.x) { if(_calc.isHorizontal) _calc.position.x += (D4D_COOR) ((_calc.contentGeom.sz.cx - (D4D_COOR)(D4D_GetTextWidth(pSldr->textBuff.fontId, pSldr->textBuff.pText))) / 2); else _calc.position.x += (D4D_COOR) (_calc.bar1Geom.pnt.x + 1); } if(!pSldr->txtOff.y) _calc.position.y += (D4D_COOR) (((_calc.contentGeom.sz.cy - D4D_GetFontHeight(pSldr->textBuff.fontId)) / 2) + 1); if(pThis->initFlags & D4D_SLDR_F_TEXT_AUTOCOLOR) clrT = (D4D_COLOR)(~clrBar); tmp_size.cx = D4D_GetTextWidth(pSldr->textBuff.fontId, pSldr->textBuff.pText); tmp_size.cy = D4D_GetFontHeight(pSldr->textBuff.fontId); D4D_DrawTextRect(&_calc.position, &tmp_size, &pSldr->textBuff, clrT, clrB); } }