From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
A paragraph of StyledText.
Use the Paragraph class to refer to a paragraph of text within a block of StyledText. A paragraph is defined as all the text between two paragraph separators. A separator can be the EndOfLine function or the correct separator character for the platform on which the application is running. Completely empty paragraphs (e.g., blank lines) do not count as paragraphs.
The following example sets a paragraph's alignment to Centered. It then gets the starting position and length of the paragraph via the Paragraph class and applies several style attributes to the whole paragraph. The TextArea that displays the styled text must have the MultiLine and Styled properties set to True.
Var st, ln As Integer
// define four paragraphs in Text
Text = "This is the text that we are going to save " _
+ "into our file from the TextArea." + EndOfLine _
+ "Isn't that interesting?" + EndOfLine _
+ "Man, I sure do love using Xojo to take care of my projects." + EndOfLine _
+ "That's because the Xojo staff is just so awesome!"
TextArea1.StyledText.Text = text // four paragraphs in Text
// center the second paragraph
TextArea1.StyledText.Paragraph(1).TextAlignment = TextAlignments.Center
// set the second paragraph in Helvetica, 18 pt bold, red
// first get its character positions...
st = TextArea1.StyledText.Paragraph(1).StartPosition
ln = TextArea1.StyledText.Paragraph(1).Length
// next apply attributes...
TextArea1.StyledText.Bold(st, ln) = True
TextArea1.StyledText.Font(st, ln) = "Helvetica"
TextArea1.StyledText.Size(st, ln) = 18
TextArea1.StyledText.TextColor(st, ln) = &cFF0000 // red