Recent

Author Topic: New RichEdit component for Lazarus  (Read 31228 times)

typo

  • Hero Member
  • *****
  • Posts: 3051
New RichEdit component for Lazarus
« on: November 24, 2011, 10:51:53 pm »
The name is lzRichEdit and it can load, edit and save RTF files. Download it from the link:

http://lazarus-br.googlecode.com/files/lazarus-br-28-10-2011.zip

This is a package with several files. Search for lzRichEdit and install it.

w click

  • Full Member
  • ***
  • Posts: 180
Re: New RichEdit component for Lazarus
« Reply #1 on: November 25, 2011, 08:34:18 am »
Does it allow you to expand the distance between lines?

Shebuka

  • Sr. Member
  • ****
  • Posts: 427
Re: New RichEdit component for Lazarus
« Reply #2 on: November 25, 2011, 09:53:07 am »
Does it support colorization and weblink highlight?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: New RichEdit component for Lazarus
« Reply #3 on: November 25, 2011, 01:57:44 pm »
You can set line spacing and URL autodetection like this:

Code: [Select]
const
  MAX_TAB_STOPS     = 32;
  PFM_LINESPACING                     = $00000100;
  ENM_LINK                            = $04000000;
  EM_AUTOURLDETECT                    = WM_USER + 91;

type
  PARAFORMAT2 = record
    cbSize: UINT;
    dwMask: DWORD;
    wNumbering: Word;
    wReserved: Word;
    dxStartIndent: Longint;
    dxRightIndent: Longint;
    dxOffset: Longint;
    wAlignment: Word;
    cTabCount: Smallint;
    rgxTabs: array [0..MAX_TAB_STOPS - 1] of Longint;
    dySpaceBefore: Longint;     { Vertical spacing before para }
    dySpaceAfter: Longint;      { Vertical spacing after para }
    dyLineSpacing: Longint;     { Line spacing depending on Rule }
    sStyle: Smallint;           { Style handle }
    bLineSpacingRule: Byte;     { Rule for line spacing (see tom.doc) }
    bCRC: Byte;                 { Reserved for CRC for rapid searching }
    wShadingWeight: Word;       { Shading in hundredths of a per cent }
    wShadingStyle: Word;        { Nibble 0: style, 1: cfpat, 2: cbpat }
    wNumberingStart: Word;      { Starting value for numbering }
    wNumberingStyle: Word;      { Alignment, roman/arabic, (), ), ., etc. }
    wNumberingTab: Word;        { Space bet 1st indent and 1st-line text }
    wBorderSpace: Word;         { Space between border and text (twips) }
    wBorderWidth: Word;         { Border pen width (twips) }
    wBorders: Word;             { Byte 0: bits specify which borders }
end;

procedure RE_SetLineSpacing(ARichEdit: TlzRichEdit; lineSpacing: Byte);
var
  pf2: ParaFormat2;
begin
  FillChar(pf2, SizeOf(pf2), 0);
  pf2.cbSize := SizeOf(PARAFORMAT2);
  pf2.dwMask := PFM_LINESPACING;
  pf2.bLineSpacingRule := lineSpacing;
  SendMessage(ARichEdit.Handle, EM_SETPARAFORMAT, 0, Longint(@pf2));
end;

procedure InitRichEditURLDetection(RE: TlzRichEdit);
var
  mask: Word;
begin
  mask := SendMessage(RE.Handle, EM_GETEVENTMASK, 0, 0);
  SendMessage(RE.Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK);
  SendMessage(RE.Handle, EM_AUTOURLDETECT, Integer(True), 0);
end;

procedure TForm1.MenuItem27Click(Sender: TObject);
begin
  RE_SetLineSpacing(lzrichedit1, 1);
  InitRichEditURLDetection(lzrichedit1);
end;             
« Last Edit: November 25, 2011, 05:45:54 pm by typo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: New RichEdit component for Lazarus
« Reply #4 on: November 26, 2011, 01:17:19 am »
Here is the direct link for an updated file (not tested though):

http://lazarus-br.googlecode.com/files/lzRichEdit.zip
« Last Edit: November 26, 2011, 01:25:14 am by typo »

rqn

  • New member
  • *
  • Posts: 9
Re: New RichEdit component for Lazarus
« Reply #5 on: November 26, 2011, 06:07:06 pm »
Hi !

I discovered your RichEdit component last week. Very good work ! It is very useful and I like the ability to format paragraphs and insert images (TRichMemo can't do it).

But... I'd like found a similar procedure (TRichMemo) :
procedure  SetRangeParams(TextStart, TextLength: Integer;
    ModifyMask: TTextModifyMask; const FontName: String;
    FontSize: Integer; FontColor: TColor;
    AddFontStyle, RemoveFontStyle: TFontStyles);

The Add/RemoveFontStyle parameter lets you change an attribute (eg bold) of the selection without changing the others : eg a sentence with words in red, others underlined will be formatted in bold but the red and underlined remain unchanged.
Well, this sentence :
The method loads RTF encoded data from the specified stream
becomes :
The method loads RTF encoded data from the specified stream

I tried changing one character at a time, using GettextAttributes, but it is very slow.

Congratulations again for your component !

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: New RichEdit component for Lazarus
« Reply #6 on: November 26, 2011, 07:18:28 pm »
Is this component work on linux (GTK, QT) too?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: New RichEdit component for Lazarus
« Reply #7 on: November 26, 2011, 07:46:48 pm »
AFAIK, it is intended to do so.

ElsonJ

  • New member
  • *
  • Posts: 7
Re: New RichEdit component for Lazarus
« Reply #8 on: November 27, 2011, 06:36:54 am »
Is this component work on linux (GTK, QT) too?

GTK Only...

ElsonJ

  • New member
  • *
  • Posts: 7
Re: New RichEdit component for Lazarus
« Reply #9 on: November 27, 2011, 06:44:35 am »
Hi !

I discovered your RichEdit component last week. Very good work ! It is very useful and I like the ability to format paragraphs and insert images (TRichMemo can't do it).

But... I'd like found a similar procedure (TRichMemo) :
procedure  SetRangeParams(TextStart, TextLength: Integer;
    ModifyMask: TTextModifyMask; const FontName: String;
    FontSize: Integer; FontColor: TColor;
    AddFontStyle, RemoveFontStyle: TFontStyles);

The Add/RemoveFontStyle parameter lets you change an attribute (eg bold) of the selection without changing the others : eg a sentence with words in red, others underlined will be formatted in bold but the red and underlined remain unchanged.
Well, this sentence :
The method loads RTF encoded data from the specified stream
becomes :
The method loads RTF encoded data from the specified stream

I tried changing one character at a time, using GettextAttributes, but it is very slow.

Congratulations again for your component !

You can make changes using SelAttributes.

The component has been changed recently (26th November) and a lot has changed, now you can only change the text characteristics SelAttributes.

Automatic translation.
« Last Edit: November 27, 2011, 06:54:16 am by ElsonJ »

rqn

  • New member
  • *
  • Posts: 9
Re: New RichEdit component for Lazarus
« Reply #10 on: November 27, 2011, 09:23:53 am »
Well.. it doesn't work.

I understand it use EM_SETCHARFORMAT message (I'm working with windows). Only the formatting attributes specified by the dwMask member should  change (found here : http://msdn.microsoft.com/en-us/library/windows/desktop/bb774230%28v=VS.85%29.aspx). But, in fact, it seems not work.
I take a look in the demo, and I did the same :
         lzRichEdit1.SelAttributes.Style := lzRichEdit1.SelAttributes.Style + [fsBold]
But the format of a single word of the selection, formatted in italic (for example), is amended and italic is lost.

An idea ?
« Last Edit: November 29, 2011, 09:50:52 am by rqn »

JSN

  • Jr. Member
  • **
  • Posts: 53
Re: New RichEdit component for Lazarus
« Reply #11 on: January 31, 2016, 01:42:01 am »
The name is lzRichEdit and it can load, edit and save RTF files. Download it from the link:

http://lazarus-br.googlecode.com/files/lazarus-br-28-10-2011.zip

This is a package with several files. Search for lzRichEdit and install it.

I tried to install the included package for lzRichEdit, Lazarus Win32 1.4.4, and it failed. Error indicated there was no Register procedure. Has anyone been able to install this lzRichEdit successfully, and then have the capability to paste images into the Richedit at runtime?

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: New RichEdit component for Lazarus
« Reply #12 on: January 31, 2016, 03:18:28 am »
try RichMemo. I could probably help you with pasting images into RichMemo.

JSN

  • Jr. Member
  • **
  • Posts: 53
Re: New RichEdit component for Lazarus
« Reply #13 on: January 31, 2016, 03:45:40 am »
try RichMemo. I could probably help you with pasting images into RichMemo.

I have installed another package, also named lzRichEdit (RichBox). Any help you could offer in pasting images (jpg, png or bmp) into any RichEdit component would be greatly appreciated.

msch

  • New Member
  • *
  • Posts: 10
Re: New RichEdit component for Lazarus
« Reply #14 on: June 06, 2017, 11:08:15 am »

Well I had some problems compiling under windows due to missing Gtk units, so I decided to remove the Gtk parts form my packages and it compiled. In the attachment you see the used package configuration.

Greetings // Martin

 

TinyPortal © 2005-2018