int CLCDStreamingText::AddText(LPCTSTR szText) { CLCDText* pText = new CLCDText; pText->Initialize(); pText->SetText(szText); pText->SetOrigin(GetOrigin().x, GetOrigin().y); pText->SetLogicalOrigin(GetLogicalOrigin().x, GetLogicalOrigin().y); pText->SetSize(GetWidth(), GetHeight()); pText->SetBackgroundMode(OPAQUE); LOGFONT lf; GetObject(m_hFont, sizeof(LOGFONT), &lf); pText->SetFont(lf); m_bRecalcExtent = TRUE; m_Objects.push_back(pText); if (NULL == m_pQueueHead) { m_pQueueHead = pText; } // return the zero-based index return (int)(m_Objects.size()-1); }
BOOL CLCDStreamingText::RecalcTextBoxes(CLCDGfx &rGfx) { // check if we need to add another text box LCD_OBJECT_LIST::iterator it = m_Objects.begin(); if (it == m_Objects.end()) return FALSE; CLCDBase* pObject = *it; CLCDText* pText = (CLCDText*)pObject; assert(NULL != pObject); LOGFONT lf; GetObject(m_hFont, sizeof(LOGFONT), &lf); pText->SetFont(lf); // this will re-evaluate the main text object assert(m_Objects.size() == 1); CLCDCollection::OnDraw(rGfx); if (it != m_Objects.end()) { if (pText->GetHExtent().cx > GetWidth()) { pText->SetAlignment(DT_LEFT); // add a gap AddText(m_szGapText); // add another text AddText(m_szText); // add last gap AddText(m_szGapText); } else { pText->SetAlignment(m_nTextAlignment); } } // this will re-evaluate the other text objects CLCDCollection::OnDraw(rGfx); RecalcTextBoxOrigins(); return TRUE; }