Esempio n. 1
0
void JMChattControl::DrawMultiLineText(Canvas* pCanvas, String strText, Rectangle rtArea, Color colorText, Color colorBack)
{
	AppLog("3333DrawMultiLineText");
	result r = E_SUCCESS;

	EnrichedText* pEnrichedText = null;
	TextElement* pTextElement1 = null;
	pEnrichedText = new EnrichedText();
	r = pEnrichedText->Construct(Dimension(rtArea.width, rtArea.height));
    if (IsFailed(r)) {
		return;
    }
    pEnrichedText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
    pEnrichedText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
    pEnrichedText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
    pEnrichedText->SetTextAbbreviationEnabled(false);

	// Create a TextElement and set attributes.
	pTextElement1 = new TextElement();
	r = pTextElement1->Construct(strText);
	if (IsFailed(r)) {
		return;
	}
	pTextElement1->SetTextColor(colorText);
    pTextElement1->SetFont(__stScreenInfo.fontText);
    // Add the TextElement to the EnrichedText
    pEnrichedText->Add(*pTextElement1);
    pCanvas->SetBackgroundColor(colorBack);



    // Draw the EnrichedText at the specified Point
    pCanvas->DrawText(Point(rtArea.x, rtArea.y), *pEnrichedText);
    // Clean up
    pEnrichedText->RemoveAllTextElements(true);
    delete pEnrichedText;
}