I've been testing TextBlock::SetStyleProperties() with mixed success. I can change the justification and slant of text with success:
DgnTextStylePtr textStyle = DgnTextStyle::Create(L"",*ISessionMgr::GetActiveDgnFile()); UInt32 justification = 7; //TextElementJustification::CenterMiddle; textStyle->SetProperty(TextStyleProperty::TextStyle_Justification, justification); textStyle->SetProperty(TextStyleProperty::TextStyle_Italics, true); textStyle->SetProperty(TextStyleProperty::TextStyle_Slant, 10.*fc_piover180); TextStylePropertyMaskPtr stylePropMask = TextStylePropertyMask::CreatePropMask(); stylePropMask->SetPropertyFlag(TextStyleProperty::TextStyle_Justification, true); // works stylePropMask->SetPropertyFlag(TextStyleProperty::TextStyle_Italics, true); // works stylePropMask->SetPropertyFlag(TextStyleProperty::TextStyle_Slant, true); // works CaretPtr startCaret = textBlock->CreateStartCaret(); CaretPtr endCaret = textBlock->CreateEndCaret(); textBlock->SetStyleProperties(*textStyle, *stylePropMask, *startCaret, *endCaret); textBlock->PerformLayout(); ITextEdit::ReplaceStatus rStatus = editor->ReplaceTextPart(eeh, *textPartId, *textBlock); // every time you replace, you get another ? eeh.ReplaceInModel(elemRef);
but when I try to change the color, nothing seems to change:
DgnTextStylePtr textStyle = DgnTextStyle::Create(L"",*ISessionMgr::GetActiveDgnFile()); UInt32 color = 3; textStyle->SetProperty(TextStyleProperty::TextStyle_Color, color); TextStylePropertyMaskPtr stylePropMask = TextStylePropertyMask::CreatePropMask(); stylePropMask->SetPropertyFlag(TextStyleProperty::TextStyle_Color, true); // not works CaretPtr startCaret = textBlock->CreateStartCaret(); CaretPtr endCaret = textBlock->CreateEndCaret(); textBlock->SetStyleProperties(*textStyle, *stylePropMask, *startCaret, *endCaret); textBlock->PerformLayout(); ITextEdit::ReplaceStatus rStatus = editor->ReplaceTextPart(eeh, *textPartId, *textBlock); // every time you replace, you get another ? eeh.ReplaceInModel(elemRef);
Am I missing something?
Bruce
Bruce,
Try this:
DgnTextStylePtr textStyle = DgnTextStyle::Create(L"",*ISessionMgr::GetActiveDgnFile()); UInt32 color = 3; // Color flag textStyle->SetProperty (TextStyleProperty::TextStyle_ColorFlag, true); // Color flag textStyle->SetProperty(TextStyleProperty::TextStyle_Color, color); TextStylePropertyMaskPtr stylePropMask = TextStylePropertyMask::CreatePropMask(); // Color flag stylePropMask->SetPropertyFlag (TextStyleProperty::TextStyle_ColorFlag, true); // Color flag stylePropMask->SetPropertyFlag(TextStyleProperty::TextStyle_Color, true); CaretPtr startCaret = textBlock->CreateStartCaret(); CaretPtr endCaret = textBlock->CreateEndCaret(); textBlock->SetStyleProperties(*textStyle, *stylePropMask, *startCaret, *endCaret); textBlock->PerformLayout(); ITextEdit::ReplaceStatus rStatus = editor->ReplaceTextPart(eeh, *textPartId, *textBlock); // every time you replace, you get another ? eeh.ReplaceInModel(elemRef);
Thanks,
Ashrafali
Answer Verified By: Bruce Reeves SRNS