RichMemo

From Lazarus wiki
Revision as of 11:55, 4 September 2010 by Chronos (talk | contribs)
Jump to navigationJump to search

Template:Translate

About

TRichMemo is a component to replace Delphi TRichEdit component. It's designed in cross-platform way, so implementation is possible for the following platforms: Win32, MacOSX, Linux. Since, being a cross-platform is the primary, most of windows RichEdit features are replaced, making RichMemo not compatible with Delphi's VCL or RX RichEdits.

Its main caracteristics are :

  • Text highlight
  • Import/Export RichText (not yet implemented)
  • System based Unicode edit support

Planned: (patches are welcomed)

  • Adding images into text
  • Embedding LCL Controls?

The download contains the component, an installation package and a demo application, that illustrates the features of the component along with some instrumentation for evaluating the chart on a given system.

Screenshot

RichMemo macosx screenshot. Thanks to Dominique Louis

Bug reporting

Please add your Bugreports/Feature requests in Lazarus CCR project of the Lazarus bug tracker.

Author

Dmitry 'skalogryz' Boyarintsev

License

modified LGPL (same as the FPC RTL and the Lazarus LCL). You can contact the author if the modified LGPL doesn't work with your project licensing.

Download

Releases can be found at Sourceforge Lazarus-CCR project

The latest trunk is available here: https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/richmemo


note: Currently it's recommended to use the svn version. [1]

Change Log

  • Version 1.0.0 22th Jun 2009
  • Version 0.8.0 Jun 2009

Dependencies / System Requirements

  • Lazarus 0.9.27

Status: 'Beta'

Issues:

Tested only on:

  • XP 32-bit, Vista 32-bit,Vista 64-bit, Win7 32-bit
  • Intel 10.5.7 Leopard

Installation

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

RichMemoPalette.PNG

TRichMemo

methods

SetTextAttributes

<delphi>procedure SetTextAttributes(TextStart, TextLen: Integer; AFont: TFont);</delphi>

  • TextStart : Integer - the first character to be modified
  • TextLen : Integer - number of characters to be modified
  • AFont : TFont - a font that should be applied to the part of the text


<delphi>procedure SetTextAttributes(TextStart, TextLen: Integer; const TextParams: TFontParams);</delphi>

  • TextStart : Integer - the first character to be modified
  • TextLen : Integer - number of characters to be modified
  • TextParams : TFontParams - font parameters to be set


SetTextureAttributes methods are changing specified text range style. Font parameters is passed in both methods, by AFont parameter (LCL TFont object) or by TFontParams (declared at RichMemo).

Setting text attributes does not change current selection. If it's necessary to modify the style of currently selected text, you should SelStart and SelLength as a text range values:

<delphi>RichMemo1.SetTextAttributes(RichMemo1.SelStart, RichMemo1.SelLength, FontDialog1.Font);</delphi>

GetTextAttributes

<delphi>function GetTextAttributes(TextStart: Integer; var TextParams: TFontParams): Boolean; virtual;</delphi>

  • TextStart : Integer - the character position to be queried for font parameters
  • var TextParams : TFontParams - output value, filled with charachter's font attributes. If the method fails and returns false, record's field values is undefined.

Fill font params of the character, at TextStart position. Method returns True if textstart is valid character position, and False overwise.

GetStyleRange

<delphi>function GetStyleRange(CharPos: Integer; var RangeStart, RangeLen: Integer): Boolean; virtual;</delphi>

Returns a range of characters that share the same font parameters, i.e. all characters in the range has the same font name, size, color and styles.

  • CharPos : Integer - a character that belongs to the style range. It's not necessary for this position to be at the begging on the style range. It can be in the middle on in the end of the style range. The first character position is returned by RangeStart parameter.
  • var RangeStart : Integer - the first character in the range
  • var RangeLen : Integer - number of characthers in the range

The method returns true if successed. the method returns false, if CharPos is incorrect value or some other error.


SetRangeColor

<delphi>procedure SetRangeColor(TextStart, TextLength: Integer; FontColor: TColor);</delphi>

The method sets color of characters in the specified range to the FontColor. Other font parameters (name, size, styles) are left unchanged.

  • TextStart: Integer - the first character in the range
  • TextLength: Integer - number of characters in the range
  • FontColor: TColor - color that should be set
SetRangeParams

<delphi>procedure SetRangeParams(TextStart, TextLength: Integer;

   ModifyMask: TTextModifyMask; const FontName: String; 
   FontSize: Integer; FontColor: TColor; 
   AddFontStyle, RemoveFontStyle: TFontStyles);</delphi>

The method changes font parameters in the specified range.

LoadRichText

<delphi>function LoadRichText(Source: TStream): Boolean; virtual;</delphi>

  • Source: TStream - a stream to read richtext data from

The method loads RTF enocded data from the specified stream. Returns true if success, and false otherwise. If source is nil, the method returns false

The content of TRichMemo is completely replaced by the content on the source stream. Current text selection is reset.

SaveRichText

<delphi>function SaveRichText(Dest: TStream): Boolean; virtual;</delphi>

  • Source: TStream - a stream to read richtext data from

The method saves RTF enocded data to the specified stream. Returns true if success, and false otherwise. If source is nil, the method returns false

Current state of TRichMemo is unchanged after the method returns

properties

HideSelection

<delphi>property HideSelection: Boolean default false</delphi>

Read/Write property. If True RichMemo selection is hidden if the control is not focused. If False, the selection is shown all the time.