Difference between revisions of "Paragraph"

From Xojo Documentation

m
 
Line 8: Line 8:
  
 
<dynamicTable id="Properties" class="propertyTable" title="Properties" columns="3">
 
<dynamicTable id="Properties" class="propertyTable" title="Properties" columns="3">
{{Property | name=Alignment | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;Gets the text alignment of the paragraph.  }}
+
{{Property | name=EndPosition | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;End position of the paragraph. }}
{{Property | name=EndPos | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;End position of the paragraph. }}
 
 
{{Property | name=Length | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;Length (in characters) of the paragraph. }}
 
{{Property | name=Length | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;Length (in characters) of the paragraph. }}
{{Property | name=StartPos | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;Starting position of the paragraph. }}
+
{{Property | name=StartPosition | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;Starting position of the paragraph. }}
 +
{{Property | name=TextAlignment | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;Gets the text alignment of the paragraph.  }}
 
</dynamicTable>
 
</dynamicTable>
 
==Class Constants==
 
The following class constants can be used to set the value of the Alignment property.
 
{| class="genericTable"
 
 
! width=25% | Class Constant
 
 
! width=55% | Description
 
|-
 
|AlignDefault
 
 
|Default paragraph alignment.
 
 
|-
 
|AlignLeft
 
 
|Left alignment.
 
 
|-
 
|AlignCenter
 
 
|Center alignment.
 
 
|-
 
|AlignRight
 
 
|Right alignment.
 
 
|-
 
|}
 
  
 
==Notes==
 
==Notes==
Line 49: Line 19:
 
You use the [[StyledText.ParagraphCount|ParagraphCount]] method of the [[StyledText]] class to get the number of paragraphs in the [[StyledText]] object and the [[StyledText.Paragraph|Paragraph]] method of the [[StyledText]] class to refer to a particular paragraph.  
 
You use the [[StyledText.ParagraphCount|ParagraphCount]] method of the [[StyledText]] class to get the number of paragraphs in the [[StyledText]] object and the [[StyledText.Paragraph|Paragraph]] method of the [[StyledText]] class to refer to a particular paragraph.  
  
The '''Paragraph''' has one style attribute, [[Paragraph.Alignment|Alignment]]. It gets the current alignment for the paragraph. The alignment is set by calling the [[StyledText.ParagraphAlignment|ParagraphAlignment]] method of the [[StyledText]] class.
+
The '''Paragraph''' has one style attribute, [[Paragraph.TextAlignment|TextAlignment]]. It gets the current alignment for the paragraph. The alignment is set by calling the [[StyledText.ParagraphAlignment|ParagraphAlignment]] method of the [[StyledText]] class.
  
 
==Examples==
 
==Examples==
Line 55: Line 25:
  
 
<rbcode>
 
<rbcode>
Dim Text As String
+
Var Text As String
Dim st, ln As Integer
+
Var st, ln As Integer
  
 
// define four paragraphs in Text
 
// define four paragraphs in Text
Line 67: Line 37:
  
 
// center the second paragraph
 
// center the second paragraph
TextArea1.StyledText.ParagraphAlignment(1) = Paragraph.AlignCenter
+
TextArea1.StyledText.Paragraph(1).TextAlignment = TextAlignments.Center
  
 
// set the second paragraph in Helvetica, 18 pt bold, red
 
// set the second paragraph in Helvetica, 18 pt bold, red
 
// first get its character positions...
 
// first get its character positions...
st = TextArea1.StyledText.Paragraph(1).StartPos
+
st = TextArea1.StyledText.Paragraph(1).StartPosition
 
ln = TextArea1.StyledText.Paragraph(1).Length
 
ln = TextArea1.StyledText.Paragraph(1).Length
  

Latest revision as of 19:36, 21 June 2019

Class (inherits from Object)

A paragraph of StyledText.

Properties
EndPosition fa-lock-32.png StartPosition
Length TextAlignment

Notes

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.

You use the ParagraphCount method of the StyledText class to get the number of paragraphs in the StyledText object and the Paragraph method of the StyledText class to refer to a particular paragraph.

The Paragraph has one style attribute, TextAlignment. It gets the current alignment for the paragraph. The alignment is set by calling the ParagraphAlignment method of the StyledText class.

Examples

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 Text As String
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

See Also

TextArea, Range, StyledText, StyleRun classes.