Recent

Author Topic: lzRichEdit: Windows/Linux rich text implementation  (Read 41999 times)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #45 on: November 26, 2014, 11:04:35 pm »
Of course it is about selected text, there is no way to get formatted text without selection, but you can lost focus and hide selection.

More 2 new methods:

GetRTFSelection
PutRTFSelection

Usage:
Code: [Select]
var
  str :TMemoryStream;
begin
  lzRichEdit1.SelStart := 0;
  lzRichEdit1.SelLength := Length(lzRichEdit1.Text);
  str := TMemoryStream.Create;
  try
    lzRichEdit1.GetRTFSelection(str);
    str.Position := 0;
    lzRichEdit2.PutRTFSelection(str);
  finally
    str.Free;
  end;
  lzRichEdit1.SelLength := 0;
end;
« Last Edit: November 27, 2014, 12:48:36 am by typo »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #46 on: November 27, 2014, 01:32:00 am »
Of course it is about selected text, there is no way to get formatted text without selection, but you can lost focus and hide selection.

can elaborate on "get formatted text without selection"? what exactly do you mean?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #47 on: November 27, 2014, 01:59:35 am »
AFAIK, Windows RichEdit does not allow getting formatted text of a range of text other than for a canvas, which is only the image of the text and not the text info.

For instance:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb788026%28v=vs.85%29.aspx

One needs that the text be selected to get partial text formatting info.
« Last Edit: November 27, 2014, 03:27:27 am by typo »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #48 on: November 27, 2014, 05:15:03 am »
One needs that the text be selected to get partial text formatting info.
well, you referred to this functionality as "a joke" on the mailing list, but this is exactly what RichMemo allows

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #49 on: November 27, 2014, 12:57:11 pm »
How do you get this?

I referred to this, not as a joke, but as a limitation, maybe an error of approach, because it is impossible on Windows RichEdit.

I think if you need selected text in order to obtain some info, you need to let the user -- or the programmer, as a workaround -- select this text in his/her app.

I think Windows RichEdit is a control for the user  -- in fact, the client  -- and not for the programmers.

More 2 methods added:

ScrollLine
Scrolls for a given delta line position.

ScrollToCaret
Scrolls to the caret.

The ZIP file provided by the link on the wiki is updated.
http://wiki.lazarus.freepascal.org/lzRichEdit#Download

The demo project also demonstrates how to use lzRichEdit in a chat app.
« Last Edit: November 27, 2014, 04:33:18 pm by typo »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #50 on: November 27, 2014, 04:58:51 pm »
How do you get this?
Straightforward, change and restore the selection once you got character formatting. But if your API is selection driven you should keep so

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #51 on: November 27, 2014, 05:34:41 pm »
I think that selection is for the user -- or, at most, for the application developer as a workaround.

An edit control should provide ways to manage the text on the control without selection. If it does not do that, selection is applicable as a workaround. This is what I think.

Microsoft does what it does because it hates programmers other than from Microsoft itself. Selection should never be used from inside an app.
« Last Edit: November 27, 2014, 06:04:58 pm by typo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #52 on: November 28, 2014, 06:02:16 pm »
Now I guess lzRichEdit is better than Delphi RichEdit.

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #53 on: November 28, 2014, 07:13:29 pm »
@typo i stopped testing because of the bug in the savedialog who seems to be this one

Quote
from time to time debuger crashes when clossing the app and in session several documntes where loaded but did not figure this out yet to spot exactly when it happens
[ http://forum.lazarus.freepascal.org/index.php/topic,26425.msg163291.html#msg163291 ]

your work is very good thank you
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #54 on: November 28, 2014, 07:19:48 pm »
You are welcome for any other report. Thanks.

ekimtrah

  • Newbie
  • Posts: 5
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #55 on: December 06, 2014, 06:01:01 am »
I am very interested in this component, the feature I like most is Get/SetZoomState, which should make it much more useful than RichMemo. I presume it will zoom all text on the lzRichEdit.

The trouble is that I cannot compile the package. I am on Lubuntu 14.04 64 bit, with Lazarus version 1.0.10+dfsg-1 from the Ubuntu repos, and when I try to compile the package lazrichedit.lpk I get the error
Code: [Select]
interfaces/win32/win32wsrichbox.pas(42,3) Fatal: Can not find unit Windows used by Win32WSRichBox.It seems to be trying to compile Windows specific code, however this is Linux, is there perhaps a compiler directive missing somewhere ?

I did try to install later versions of Lazarus according to the Wiki instructions but it still wanted to install 1.0.10, so I did not go ahead. I tried downloading the Deb files and installed them but the ide had path errors when it started up.
Thanks,
Michael.

Nana

  • New member
  • *
  • Posts: 7
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #56 on: December 06, 2014, 12:53:47 pm »
Nice component for creating a little word aplication in a buisness program.

i'am a beginner in programming.
Is it possible to insert a logo (load and insert bitmap) and text with adress and date during runtime for creating buisness letter templates or bulk letters and how does this work.

Is it possible to have tabulators, headline,footline  for pagenumbers for example for documents with several pages and a printpreview window.


Best regrads

Nana


typo

  • Hero Member
  • *****
  • Posts: 3051
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #57 on: December 06, 2014, 02:54:23 pm »
@ekimtrah
Win32WSRichBox is Windows specific code, Linux should use gtk2wsrichbox. You should never have problems with Win32WSRichBox, since Linux can not find it. Anyway, if youi find some Windows in some uses clause outside this file, please try to put compiler directives around it or simply take it out. There is no Windows specific code outside this file.
BTW, you could help me with this component in Linux, please have a look and see if you can help.

@Nana
You could have an example of what you may expect from lzRichEdit by seeing what windows WordPad can do.
« Last Edit: December 06, 2014, 05:11:13 pm by typo »

ekimtrah

  • Newbie
  • Posts: 5
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #58 on: December 07, 2014, 01:13:39 am »
@typo, I could not find Windows in any uses clause outside the file win32wsrichbox.pas.

The word win32wsrichbox is in the file lazrichedit.pas, without a Windows compiler directive. It is also in the file richbox_package.pas but in this case it is inside a Windows compiler directive. Both of these files have the line "This file was automatically created by Lazarus. Do not edit!", so I supposed their contents are defined somewhere else. Is the one in the lazrichedit.pas file the problem ?
Thanks for the quick reply,
Michael.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: lzRichEdit: Windows/Linux rich text implementation
« Reply #59 on: December 07, 2014, 02:26:31 am »
This is the uses clause of richbox_package.pas:

Code: [Select]
uses
    RichBox, WSRichBoxFactory, WSRichBox,
{$IFDEF LCLWIN32}Win32WSRichBox,Win32WSRichBoxFactory,{$ENDIF}
{$IFDEF LCLGTK2}Gtk2WSRichBox, Gtk2WSRichBoxFactory, Gtk2RTFTool,{$ENDIF}
  LazarusPackageIntf; 

 

TinyPortal © 2005-2018