/**************************************************************//*! * * 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--; } }
* ******************************************************************************/ #include "d4d.h" #include "common_files/d4d_private.h" //Internal API void D4D_MenuOnMessage(D4D_MESSAGE* pMsg); D4D_STRING* D4D_MenuGetTextBuffer(D4D_OBJECT* pThis); static void D4D_MenuOnInit(D4D_MESSAGE* pMsg); static D4D_MENU_INDEX D4D_GetItemsCount(D4D_MENU* pMenu); const D4D_OBJECT_SYS_FUNCTION d4d_menuSysFunc = { D4D_DEFSTR("Menu"), D4D_MenuOnMessage, NULL, D4D_MenuGetTextBuffer }; // temporary structure for menu temporary value calculation typedef struct { D4D_POINT position; D4D_GEOMETRY contentGeom; D4D_COOR titleBar_y; D4D_SIZE maxIcon; D4D_MENU_INDEX posCnt; D4D_COOR textOff; D4D_TCHAR index_txt[8];
* * @date Feb-19-2013 * * @brief D4D driver progress_bar object c file * ******************************************************************************/ #include "d4d.h" #include "common_files/d4d_private.h" //Internal API void D4D_PrgrsBarOnMessage(D4D_MESSAGE* pMsg); const D4D_OBJECT_SYS_FUNCTION d4d_progress_barSysFunc = { D4D_DEFSTR("Progress Bar"), D4D_PrgrsBarOnMessage, NULL, NULL }; // temporary structure for bar coordinate calculation typedef struct { D4D_POINT position; D4D_GEOMETRY contentGeom; D4D_POINT barXY; D4D_SIZE barSize; D4D_COOR resultC1; D4D_COOR resultC2; D4D_COOR inner_radius;
* @date Oct-14-2013 * * @brief D4D driver check box object c file * ******************************************************************************/ #include "d4d.h" #include "common_files/d4d_private.h" //Internal API void D4D_CheckBoxOnMessage(D4D_MESSAGE* pMsg); D4D_STRING* D4D_CheckBoxGetTextBuffer(D4D_OBJECT* pThis); const D4D_OBJECT_SYS_FUNCTION d4d_checkBoxSysFunc = { D4D_DEFSTR("Check Box"), D4D_CheckBoxOnMessage, NULL, D4D_CheckBoxGetTextBuffer }; typedef struct { D4D_POINT position; D4D_GEOMETRY contentGeom; D4D_GEOMETRY BmpGeom; D4D_GEOMETRY TxtGeom; D4D_COOR iconRadius; } D4D_CHECKBOX_TMP_VAL; #define _calc (*((D4D_CHECKBOX_TMP_VAL*)d4d_scratchPad))
* * @brief D4D driver label object c file * ******************************************************************************/ #include "d4d.h" #include "common_files/d4d_private.h" // Internal API void D4D_LabelOnMessage(D4D_MESSAGE* pMsg); D4D_STRING* D4D_LabelGetTextBuffer(D4D_OBJECT* pThis); const D4D_OBJECT_SYS_FUNCTION d4d_labelSysFunc = { D4D_DEFSTR("Label"), D4D_LabelOnMessage, NULL, D4D_LabelGetTextBuffer }; typedef struct { D4D_POINT position; D4D_GEOMETRY contentGeom; } D4D_LBL_TMP_VAL; #define _calc (*((D4D_LBL_TMP_VAL*)d4d_scratchPad)) static void D4D_LblValue2Coor(D4D_OBJECT* pThis)
/* Bitmap dimension (W x H) */ 0x00, 0x0C, 0x00, 0x06, /* Color mode */ 0x80, 0x07, /* Data */ 0x00, 0x00, 0x0B, 0x01, 0x01, 0x08, 0x00, 0x00, 0x01, 0x01, 0x01, 0x06, 0x00, 0x00, 0x03, 0x01, 0x01, 0x04, 0x00, 0x00, 0x05, 0x01, 0x01, 0x02, 0x00, 0x00, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x03 }; const D4D_OBJECT_SYS_FUNCTION d4d_comboBoxSysFunc = { D4D_DEFSTR("Combo Box"), D4D_ComboBoxOnMessage, NULL, NULL }; const D4D_MARGIN comboBox_marginDefault = { D4D_BEVEL_WIDTH, D4D_BEVEL_WIDTH, D4D_BEVEL_WIDTH, D4D_BEVEL_WIDTH }; // temporary structure for comboBox temporary value calculation typedef struct
D4D_STRING* D4D_TextBoxGetTextBuffer(D4D_OBJECT* pThis); static D4D_BOOL D4D_TextBoxScrollBarSetup(D4D_OBJECT* pObject); static D4D_INDEX D4D_TextBoxGetMaxLineChars(D4D_TCHAR* pText, D4D_INDEX offset, D4D_TAB* pTab, D4D_COOR len, D4D_FONT fnt); static D4D_BOOL D4D_TextBoxGetWordSpec(D4D_TXTBX_WORD_DESC* wordDesc); static D4D_BOOL D4D_TextBoxGetCharsToLine(D4D_TXTBX_WORD_DESC* wordDesc); static D4D_INDEX D4D_TextBoxGetLineCount(D4D_OBJECT* pThis); static D4D_INDEX D4D_TextBoxFindLineStartChar(D4D_OBJECT* pThis, D4D_INDEX line); static void D4D_TextBoxOnInit(D4D_OBJECT* pObject); const D4D_OBJECT_SYS_FUNCTION d4d_textboxSysFunc = { D4D_DEFSTR("Text Box"), D4D_TextBoxOnMessage, NULL, NULL }; typedef struct { D4D_POINT position; D4D_GEOMETRY contentGeom; D4D_GEOMETRY txtGeom; D4D_INDEX lineCount; } D4D_TXTBX_TMP_VAL; #define _calc (*((D4D_TXTBX_TMP_VAL*)d4d_scratchPad))
// Internal API void D4D_ConsoleOnMessage(D4D_MESSAGE* pMsg); static void D4D_CnslNewLine(D4D_OBJECT_PTR pObj, D4D_BOOL returnCarrier); static D4D_BOOL D4D_CnslPutCharInt(D4D_OBJECT_PTR pObj, D4D_TCHAR ch); static void D4D_CnslUpdateScrollbars(D4D_OBJECT* pThis); static void D4D_CnslOnInit(D4D_MESSAGE* pMsg); static void D4D_ConsoleTimeTick(D4D_MESSAGE* pMsg); static D4D_INDEX D4D_CnslFindMaxTextLenght(D4D_TCHAR* pText, D4D_FONT font, D4D_INDEX startOffset, D4D_INDEX maxLenght); const D4D_OBJECT_SYS_FUNCTION d4d_consoleSysFunc = { D4D_DEFSTR("Console"), D4D_ConsoleOnMessage, NULL, NULL }; typedef struct { D4D_POINT position; D4D_SIZE size; D4D_GEOMETRY txtGeom; D4D_SIZE lineSize; D4D_SIZE charArrSize; } D4D_CNSL_TMP_VAL; #define _calc (*((D4D_CNSL_TMP_VAL*)d4d_scratchPad))
* * @brief D4D driver icon object c file * ******************************************************************************/ #include "d4d.h" #include "common_files/d4d_private.h" //Internal API void D4D_IconOnMessage(D4D_MESSAGE* pMsg); D4D_STRING* D4D_IconGetTextBuffer(D4D_OBJECT* pThis); D4D_ICON_INDEX D4D_IconGetBmpCount(D4D_OBJECT_PTR pThis); const D4D_OBJECT_SYS_FUNCTION d4d_iconSysFunc = { D4D_DEFSTR("Icon"), D4D_IconOnMessage, NULL, D4D_IconGetTextBuffer }; // temporary structure for icon coordinate calculation typedef struct { D4D_POINT position; D4D_POINT txtPos; D4D_GEOMETRY contentGeom; } D4D_ICON_TMP_VAL; #define _calc (*((D4D_ICON_TMP_VAL*)d4d_scratchPad))
// Internal API static void D4D_ScrlBrOnMessage(D4D_MESSAGE* pMsg); static void D4D_ScrlBrOnKeyDown(D4D_MESSAGE* pMsg); #if defined(D4D_LLD_TCH) || defined(D4D_LLD_MOUSE) static void D4D_ScrlBrOnTouch(D4D_MESSAGE* pMsg, D4D_POINT* point); #endif static void D4D_ScrlBrDrawArrow(D4D_POINT* ppt, D4D_COOR size, D4D_DIRECTION dir, D4D_COLOR color); const D4D_OBJECT_SYS_FUNCTION d4d_scroll_barSysFunc = { D4D_DEFSTR("Scroll Bar"), D4D_ScrlBrOnMessage, NULL, NULL }; typedef struct { D4D_POINT position; D4D_GEOMETRY contentGeom; D4D_POINT scrollPos; D4D_SIZE scrollSize; D4D_POINT refreshPos; D4D_SIZE refreshSize; D4D_COOR scrollRadius; } D4D_SCRLBAR_TMP_VAL;
* @date Jan-14-2014 * * @brief D4D driver slider object c file * ******************************************************************************/ #include "d4d.h" #include "common_files/d4d_private.h" //Internal API void D4D_SldrOnMessage(D4D_MESSAGE* pMsg); D4D_STRING* D4D_SldrGetTextBuffer(D4D_OBJECT* pThis); const D4D_OBJECT_SYS_FUNCTION d4d_sliderSysFunc = { D4D_DEFSTR("Slider"), D4D_SldrOnMessage, NULL, D4D_SldrGetTextBuffer }; // temporary structure for bar coordinate calculation typedef struct { D4D_POINT position; D4D_GEOMETRY contentGeom; D4D_GEOMETRY bar1Geom; D4D_GEOMETRY bar2Geom; D4D_GEOMETRY bar3Geom; D4D_DIRECTION dir; D4D_BOOL isHorizontal;