Difference between revisions of "lzRichEdit"

From Lazarus wiki
Jump to navigationJump to search
m (Fix heading levels)
 
(30 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Translate}}
+
== About ==
= About =
 
  
This component was created to try to solve or at least alleviate the lack
+
This component was created to solve or at least alleviate the lack of RichText component.
a Rich Text Editor component, this component runs on two platforms
+
Component runs on two platforms: Linux (GTK2) / Windows, and has different ways to work on both OS'es.  
Linux (GTK2) / Windows, and has different ways to work on both OSs. The
 
rich text control in Windows is provided by a library (API) and so is
 
much faster than Linux. Linux file reading rich text
 
is made by the FPC RTFPars TRTFParser ie the class, with some
 
changes to support images, this class is just slower to treat
 
rich complex text files, the Linux version only supports formatting
 
text, paragraph and pictures and everything Windows supports what Ole and the APIWindows can offer.
 
The two most important properties are the lzRichEdit Paragraph and
 
SelAttributes, one takes care of the attributes of the paragraph and the other attributes of
 
text.
 
  
= Author =
+
* Control in Windows is provided by OS API. Win version supports all features that Win32 API has.
 +
* Linux file reading is made by FPC TRTFParser class, with some changes to support images, this class is slower on complex files. Linux version supports only text formatting.
  
Elson Junio (elsonjunio@yahoo.com.br)
+
The two most important properties are Paragraph and SelAttributes, one takes care of the attributes of the paragraph and the other attributes of text.
  
= Platforms =
+
Screenshot:
  
'''Linux''' (Gtk2) and '''Windows'''.
+
[[Image: lzRichEdit.png]]
  
= License =
+
== Author ==
 +
 
 +
Elson Junio (elsonjunio@yahoo.com.br).
 +
 
 +
Antônio Galvão.
 +
 
 +
== Platforms ==
 +
 
 +
'''Linux''' (Gtk2) and '''Win32'''.
 +
 
 +
== License ==
 
modified LGPL.
 
modified LGPL.
  
= Download =
+
== Download ==
  
 
The latest version is available here:
 
The latest version is available here:
http://www.lazarusbrasil.org/lzRichEdit.zip
+
http://sourceforge.net/projects/lazarusfiles/files/lzRichEdit.zip/download
 +
 
 +
SVN:
 +
https://lazarus-br.googlecode.com/svn/trunk/package/lzRichEdit
 +
 
 +
== Installation ==
  
= Installation =
 
 
* Download the package
 
* Download the package
 
* Open the package, and install it, rebuilding the IDE
 
* Open the package, and install it, rebuilding the IDE
 
* TlzRichEdit is added to 'Common Controls' component page.
 
* TlzRichEdit is added to 'Common Controls' component page.
  
= Details =
+
== Methods ==
 
 
[[Image: lzRichEdit.png]]
 
  
== Methods ==
 
 
=== CopyToClipboard ===
 
=== CopyToClipboard ===
 
Copies RTF text to clipboard.
 
Copies RTF text to clipboard.
 
=== CutToClipboard ===
 
=== CutToClipboard ===
 
Cuts RTF text to clipboard.
 
Cuts RTF text to clipboard.
 +
=== PasteFromClipboard ===
 +
Pastes RTF text from clipboard.
 
=== FindText ===
 
=== FindText ===
 
Finds text in the control contents.
 
Finds text in the control contents.
 +
 +
=== GetFirstVisibleLine ===
 +
Gets the first visible line.
 +
 +
=== GetRTFSelection ===
 +
Gets the selected RTF text to a provided stream.
 +
 +
=== PutRTFSelection ===
 +
Puts the contents of a source RTF stream in the caret position.
 +
 
=== GetWordAtPoint ===
 
=== GetWordAtPoint ===
 
Gets the word at the (x,y) position.
 
Gets the word at the (x,y) position.
 
=== GetWordAtPos ===
 
=== GetWordAtPos ===
 
Gets the word at the text position.
 
Gets the word at the text position.
=== PasteFromClipboard ===
+
=== GetZoomState ===
Pastes RTF text from clipboard.
+
Gets the zoom state of the RichEdit.
 +
=== SetZoomState ===
 +
Sets the zoom state of the RichEdit.
 
=== LoadFromFile ===
 
=== LoadFromFile ===
 
Loads a file.
 
Loads a file.
Line 59: Line 74:
 
=== Print ===
 
=== Print ===
 
Prints the contents of the control.
 
Prints the contents of the control.
 +
 
=== Undo ===
 
=== Undo ===
 
Undo modifications.
 
Undo modifications.
 
=== Redo ===
 
=== Redo ===
 
Redo modifications.
 
Redo modifications.
 +
 +
=== ScrollLine ===
 +
Scrolls for a given delta line position.
 +
 +
=== ScrollToCaret ===
 +
Scrolls to the caret.
 +
 
=== SelectAll ===
 
=== SelectAll ===
 
Selects all text.
 
Selects all text.
  
== Paragraph ==
+
== Properties ==
 +
 
 +
=== Paragraph ===
 
It is possible to change the current paragraph attributes (it is guided by
 
It is possible to change the current paragraph attributes (it is guided by
 
SelStart) property.
 
SelStart) property.
=== Alignment: TRichEditAlignment ===
+
===== Alignment: TRichEditAlignment =====
 
Sets / gets the alignment of the paragraph or selected text.
 
Sets / gets the alignment of the paragraph or selected text.
==== traLeft ====
+
===== traLeft =====
 
Paragraph aligned to left.
 
Paragraph aligned to left.
==== traRight ====
+
===== traRight =====
 
Paragraph aligned to right.
 
Paragraph aligned to right.
==== traCenter ====
+
===== traCenter =====
 
Paragraph centered.
 
Paragraph centered.
==== traJustify ====
+
===== traJustify =====
 
Paragraph justified.
 
Paragraph justified.
  
=== FirstIndent: Longint ===
+
===== FirstIndent: Longint =====
 
Sets / gets the indentation of the first line of a paragraph, FirstIndent works
 
Sets / gets the indentation of the first line of a paragraph, FirstIndent works
 
differently on Linux and Windows. Under Windows it has a relationship
 
differently on Linux and Windows. Under Windows it has a relationship
Line 88: Line 113:
 
LeftIndent and FirstIndent and its value must be positive for Causing the retreat of
 
LeftIndent and FirstIndent and its value must be positive for Causing the retreat of
 
line.
 
line.
=== LeftIndent: Longint ===
+
===== LeftIndent: Longint =====
 
Sets / gets the paragraph indentation left.
 
Sets / gets the paragraph indentation left.
=== RightIndent: Longint ===  
+
===== RightIndent: Longint =====  
 
Sets / gets the distance from the text in the paragraph right corner of the control.
 
Sets / gets the distance from the text in the paragraph right corner of the control.
=== Numbering: TnumberingStyle ===
+
===== Numbering: TnumberingStyle =====
 
Inserts \ checks in paragraph marker, only one paragraph at a time.
 
Inserts \ checks in paragraph marker, only one paragraph at a time.
  
== SelAttributes ==
+
=== SelAttributes ===
 +
 
 
It is possible to change and get attribute values of the selected text.
 
It is possible to change and get attribute values of the selected text.
=== Color: TColor ===
+
===== Color: TColor =====
 
Used to set / get the color of the selected text.
 
Used to set / get the color of the selected text.
=== BackColor: TColor ===
+
===== BackColor: TColor =====
 
Used to set / get the background color of the selected text.
 
Used to set / get the background color of the selected text.
=== Name: TFontName ===
+
===== Name: TFontName =====
 
Used to set / get the font of the selected text.
 
Used to set / get the font of the selected text.
=== Size: Integer ===
+
===== Size: Integer =====
 
Used to set / get the font size of the selected text.
 
Used to set / get the font size of the selected text.
=== Style: TFontStyles ===
+
===== Style: TFontStyles =====
 
Used to set / recer the font style of the selected text (Linux / Windows).
 
Used to set / recer the font style of the selected text (Linux / Windows).
  
== CaretCoordinates ==
+
=== CaretCoordinates ===
=== Column :Integer ===
+
 
 +
===== Column :Integer =====
 
Reads the caret column position.
 
Reads the caret column position.
=== Line :Integer ===
+
===== Line :Integer =====
 
Reads the caret line position.
 
Reads the caret line position.
== CaretPoint ==
+
 
=== X :Integer ===
+
=== CaretPoint ===
 +
 
 +
===== X :Integer =====
 
Reads the X pixels position of the caret.
 
Reads the X pixels position of the caret.
=== Y :Integer ===
+
===== Y :Integer =====
 
Reads the Y pixels position of the caret.
 
Reads the Y pixels position of the caret.
  
== Support for images: ==
+
=== ScrollPoint ===
The image support is left up to 3 units, RichOleBox, RichOle,
+
 
GTKTextImage, These units are in the sample folder and can be placed
+
===== X :Integer =====
along with the source code of your program.
+
Reads and writes the X scrolling position.
 +
===== Y :Integer =====
 +
Reads and writes the Y scrolling position.
 +
 
 +
=== DefaultExtension ===
 +
 
 +
===== string =====
 +
Provides a way to set a file extension different than ".RTF" which can be correctly opened.
 +
 
 +
== Graphic support ==
 +
The images support is left up to 3 units:
 +
 
 +
* RichOleBox
 +
* RichOle
 +
* GTKTextImage
 +
 
 +
These units are in the sample folder and can be placed along with the source code of your program.
 +
 
 +
== More information ==
  
= More information =
 
 
For more information, see the Example Project or contact the author.
 
For more information, see the Example Project or contact the author.
  
 +
[[Category:Lazarus]]
 
[[Category:Components]]
 
[[Category:Components]]

Latest revision as of 08:40, 27 August 2021

About

This component was created to solve or at least alleviate the lack of RichText component. Component runs on two platforms: Linux (GTK2) / Windows, and has different ways to work on both OS'es.

  • Control in Windows is provided by OS API. Win version supports all features that Win32 API has.
  • Linux file reading is made by FPC TRTFParser class, with some changes to support images, this class is slower on complex files. Linux version supports only text formatting.

The two most important properties are Paragraph and SelAttributes, one takes care of the attributes of the paragraph and the other attributes of text.

Screenshot:

lzRichEdit.png

Author

Elson Junio (elsonjunio@yahoo.com.br).

Antônio Galvão.

Platforms

Linux (Gtk2) and Win32.

License

modified LGPL.

Download

The latest version is available here: http://sourceforge.net/projects/lazarusfiles/files/lzRichEdit.zip/download

SVN: https://lazarus-br.googlecode.com/svn/trunk/package/lzRichEdit

Installation

  • Download the package
  • Open the package, and install it, rebuilding the IDE
  • TlzRichEdit is added to 'Common Controls' component page.

Methods

CopyToClipboard

Copies RTF text to clipboard.

CutToClipboard

Cuts RTF text to clipboard.

PasteFromClipboard

Pastes RTF text from clipboard.

FindText

Finds text in the control contents.

GetFirstVisibleLine

Gets the first visible line.

GetRTFSelection

Gets the selected RTF text to a provided stream.

PutRTFSelection

Puts the contents of a source RTF stream in the caret position.

GetWordAtPoint

Gets the word at the (x,y) position.

GetWordAtPos

Gets the word at the text position.

GetZoomState

Gets the zoom state of the RichEdit.

SetZoomState

Sets the zoom state of the RichEdit.

LoadFromFile

Loads a file.

SaveToFile

Saves a file.

Print

Prints the contents of the control.

Undo

Undo modifications.

Redo

Redo modifications.

ScrollLine

Scrolls for a given delta line position.

ScrollToCaret

Scrolls to the caret.

SelectAll

Selects all text.

Properties

Paragraph

It is possible to change the current paragraph attributes (it is guided by SelStart) property.

Alignment: TRichEditAlignment

Sets / gets the alignment of the paragraph or selected text.

traLeft

Paragraph aligned to left.

traRight

Paragraph aligned to right.

traCenter

Paragraph centered.

traJustify

Paragraph justified.

FirstIndent: Longint

Sets / gets the indentation of the first line of a paragraph, FirstIndent works differently on Linux and Windows. Under Windows it has a relationship LeftIndent proportional to its value and shouldnt be negative if you want your effect is the recoil of the line, Otherwise the line is advanced. Linux does not the relationship between LeftIndent and FirstIndent and its value must be positive for Causing the retreat of line.

LeftIndent: Longint

Sets / gets the paragraph indentation left.

RightIndent: Longint

Sets / gets the distance from the text in the paragraph right corner of the control.

Numbering: TnumberingStyle

Inserts \ checks in paragraph marker, only one paragraph at a time.

SelAttributes

It is possible to change and get attribute values of the selected text.

Color: TColor

Used to set / get the color of the selected text.

BackColor: TColor

Used to set / get the background color of the selected text.

Name: TFontName

Used to set / get the font of the selected text.

Size: Integer

Used to set / get the font size of the selected text.

Style: TFontStyles

Used to set / recer the font style of the selected text (Linux / Windows).

CaretCoordinates

Column :Integer

Reads the caret column position.

Line :Integer

Reads the caret line position.

CaretPoint

X :Integer

Reads the X pixels position of the caret.

Y :Integer

Reads the Y pixels position of the caret.

ScrollPoint

X :Integer

Reads and writes the X scrolling position.

Y :Integer

Reads and writes the Y scrolling position.

DefaultExtension

string

Provides a way to set a file extension different than ".RTF" which can be correctly opened.

Graphic support

The images support is left up to 3 units:

  • RichOleBox
  • RichOle
  • GTKTextImage

These units are in the sample folder and can be placed along with the source code of your program.

More information

For more information, see the Example Project or contact the author.