This example demonstrates displaying and modifying multi-line justification. The justification defines the location of the multi-line relative to the vertices.
The AboutMLineJustify() function requires a value of the Mline::MlineJustification enumerator and returns a string containing the comment about the passed multi-line justification as an OdString value. The function declares a variable of the OdString type and uses the format() method to convert the justification code. Then this function checks the passed justification code using the switch statement to select the comment which must be attached to the result string.
The AboutMLineJustify() function has the following implementation:
OdString AboutMLineJustify(Mline::MlineJustification mode)
{
OdString sAbout;
sAbout.format(L"[%d-", mode);
switch(mode)
{
case Mline::kTop: sAbout += L"Top"; break;
case Mline::kZero: sAbout += L"Zero"; break;
case Mline::kBottom: sAbout += L"Bottom"; break;
default: sAbout += L"?";
}
return (sAbout += L"]");
}
The EntryMLineJustify() function requires a reference to a variable of a 16-bit Integer type in which the selected multi-line justification must be saved as an argument and returns True if the user selects the justification or False if the user cancels entry. The functions organize a loop that displays the list of available justifications, and then, inquires about the number as an Integer value. The justifications can take the following values:
After entry, the function checks whether the value is in the range [0 to 2]. If the entry is incorrect or out of range, the function displays the error message and repeats the loop. If the entry is correct, the function returns True as a resulting value and the selected number through its own argument in the calling function. If the user selects [3], the function cancels entry and returns False as a resulting value.
The EntryMLineJustify() function has the following implementation:
bool EntryMLineJustify(OdInt16& refMode)
{
OdInt16 mode;
do {
wcout << L"\n0. Top"
<< L"\n1. Zero"
<< L"\n2. Bottom"
<< L"\n3. Quit"
<< L"\nEntry the justification:>";
wcin >> mode;
if(!wcin.fail() && wcin.peek() == 10)
if(mode >= 0 && mode <= 2)
{
refMode = mode;
return true;
}
else if(mode == 3) return false;
else wcout << L"Error: Undefined justification\n";
else { wcin.clear(); wcout << L"Error: Invalid entered value\n"; wcin.sync(); }
}
while(1);
}
The testing function has the following implementation:
void DemoBase(OdDbDatabase* pDb)
{
OdInt16 type;
EntryMLineJustify(type);
wcout << L"Justification is set to: " << AboutMLineJustify((Mline::MlineJustification) type);
}
Testing gives the following results:
0. Top
1. Zero
2. Bottom
3. Quit
Entry the justification:>2
Justification is set to: [2-Bottom]
Specific Multi-Line Properties
Example of Working with the Multi-Line Object
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|