Discussion:
Doing the Delphi 6 Text Editor Tutorial in Lazarus?
Tom Verhoeff
2007-04-04 17:14:17 UTC
Permalink
I have some students who are trying to complete the Delphi 6
Text Editor tutorial using Lazarus. See e.g. Chapter 4 of

<http://www.win.tue.nl/~hemerik/2IP20/Doc/Qs.pdf>

They run into some problems. E.g. Lazarus apparently does not
(yet) have ActionManagers. Hence, also the configuration of
standard actions like Cut/Copy/Paste is not a matter of a few clicks.

How hard is it to do this "yourself" (i.e. not using an ActionManager,
write the necessary code)? Note that TAction and a number of related
facilities are available in Lazarus.

I suggested to them to drop the toolbar and code the actions directly into
the (menu) event handlers. But this still requires that they discover
a few extra things (e.g. concerning Cut/Copy/Paste), and do more work.

Also, the RichEdit component seems to need a workaround (e.g. TMemo,
TSynMemo, TSynEdit).

Does anyone have some (additional) advice?

Thanks,

Tom
--
E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science
PHONE: +31 40 247 41 25 | Technische Universiteit Eindhoven
FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven
http://www.win.tue.nl/~wstomv/ | The Netherlands
Graeme Geldenhuys
2007-04-05 06:50:07 UTC
Permalink
Post by Tom Verhoeff
They run into some problems. E.g. Lazarus apparently does not
(yet) have ActionManagers. Hence, also the configuration of
standard actions like Cut/Copy/Paste is not a matter of a few clicks.
I don't really know what a ActionManager is supposed to do, but under
Lazarus you can do the following. Drop a ActionList on the form.
Double click it. Click on the down arrow next to the New Action
button. Select "New Standard Action" and select from the list. There
are the usual Edit actions (cut, copy, paste), dialog, help and
database actions.
Post by Tom Verhoeff
Also, the RichEdit component seems to need a workaround (e.g. TMemo,
TSynMemo, TSynEdit).
I really don't get this either. Even in the commercial product I
bought, Borland Kylix 3 Enterprise edition, there wasn't a RichEdit
component. I would have expected more from Borland. I'm not a
component writer, but is it really that difficult to write a cross
platform RichEdit component? Maybe it's only possible when you have
250 Microsoft developers at you disposal - I don't know?

I've seen Delphi code that implemented the document editor case study
used in the Gang of Four book (Design Patterns - Elements of Reusable
Object-Oriented Software). It handled text formatting, inserting of
images, etc.. Maybe that could be a start to a new Lazarus RichEdit
component. Let me know and I'll try and find that code again.
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
Gus Wirth
2007-04-05 17:36:24 UTC
Permalink
Post by Graeme Geldenhuys
Post by Tom Verhoeff
They run into some problems. E.g. Lazarus apparently does not
(yet) have ActionManagers. Hence, also the configuration of
standard actions like Cut/Copy/Paste is not a matter of a few clicks.
I don't really know what a ActionManager is supposed to do, but under
Lazarus you can do the following. Drop a ActionList on the form.
Double click it. Click on the down arrow next to the New Action
button. Select "New Standard Action" and select from the list. There
are the usual Edit actions (cut, copy, paste), dialog, help and
database actions.
Post by Tom Verhoeff
Also, the RichEdit component seems to need a workaround (e.g. TMemo,
TSynMemo, TSynEdit).
I really don't get this either. Even in the commercial product I
bought, Borland Kylix 3 Enterprise edition, there wasn't a RichEdit
component. I would have expected more from Borland. I'm not a
component writer, but is it really that difficult to write a cross
platform RichEdit component? Maybe it's only possible when you have
250 Microsoft developers at you disposal - I don't know?
I've seen Delphi code that implemented the document editor case study
used in the Gang of Four book (Design Patterns - Elements of Reusable
Object-Oriented Software). It handled text formatting, inserting of
images, etc.. Maybe that could be a start to a new Lazarus RichEdit
component. Let me know and I'll try and find that code again.
The TRichEdit component is a simple wrapper around a standard Windows
widget, implemented in the riched32.dll. It doesn't show up in Kylix
because there is no equivalent in the QT widget set. The WINE guys
<http://www.winehq.org> have been working on this for years and still
don't have a fully functional replacement.

Gus
Graeme Geldenhuys
2007-04-05 19:13:56 UTC
Permalink
Post by Gus Wirth
The TRichEdit component is a simple wrapper around a standard Windows
widget, implemented in the riched32.dll. It doesn't show up in Kylix
because there is no equivalent in the QT widget set. The WINE guys
I know under Delphi it's a wrapper for that .dll, but why couldn't
Borland just write one from scratch for Kylix? The same goes for
Lazarus. Strangely enough, developers come up with all different
kinds of components, but nobody every bothers to write a RichEdit
component from scratch.

That's why I'm asking if it's such an impossible thing that nobody can
do, except the hordes of Microsoft employees.
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
Hess, Philip J
2007-04-05 19:41:11 UTC
Permalink
Do you want to (a) create RTF files programmatically and/or display RTF files from your program or do you want to (b) allow your users to have a simple rich-text editor in your program. You can do (a) now in a cross-platform way with the FPC rtfpars unit and an external word processor.


-----Original Message-----
From: Graeme Geldenhuys [mailto:***@gmail.com]
Sent: Thursday, April 05, 2007 3:14 PM
To: ***@miraclec.com
Subject: Re: [lazarus] Doing the Delphi 6 Text Editor Tutorial in Lazarus?
Post by Gus Wirth
The TRichEdit component is a simple wrapper around a standard Windows
widget, implemented in the riched32.dll. It doesn't show up in Kylix
because there is no equivalent in the QT widget set. The WINE guys
I know under Delphi it's a wrapper for that .dll, but why couldn't
Borland just write one from scratch for Kylix? The same goes for
Lazarus. Strangely enough, developers come up with all different
kinds of components, but nobody every bothers to write a RichEdit
component from scratch.

That's why I'm asking if it's such an impossible thing that nobody can
do, except the hordes of Microsoft employees.
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'

_________________________________________________________________
To unsubscribe: mail lazarus-***@miraclec.com with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
Graeme Geldenhuys
2007-04-05 20:55:06 UTC
Permalink
Post by Hess, Philip J
Do you want to (a) create RTF files programmatically and/or display RTF files from your program or do you want to (b) allow your users to have a simple rich-text editor in your program. You can do (a) now in a cross-platform way with the FPC rtfpars unit and an external word processor.
At one stage (long ago when I worked with Kylix) I needed something
like (b). A richtext component, but have no need for it in my current
projects.

Though I can see some uses for it in Lazarus.

* Editing FPDoc documentation using 'lazde' and having a richedit
component for the descriptions would be nice. The richedit component
could have a swapable backend for saving to different formats like the
xml needed in the documentation. No need for anybody wanting to
create documentation to learn the fpdoc formatting tags. Just type,
highlight text and click whatever formatting you want to apply (like
all other word processors).
* Help Viewer for when Lazarus one day has a cross platform help
file (like .chm or .hlp).

You get the idea...
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
Hess, Philip J
2007-04-05 21:50:32 UTC
Permalink
TRichEdit has/had 3 basic problems:

(1) Borland never supported Rich Edit 2 (RICHED20.DLL), only the original Rich Edit 1 (RICHED32.DLL). Rich Edit 2 has been part of Windows since the late 90's but Borland never supported it, not even in Delphi 2006.

(2) Microsoft never fixed the bugs in RICHED20.DLL and doesn't appear to have made any improvements to it in years.

(3) Even RICHED20.DLL only supports a fairly limited set of RTF control words.

By hacking Delphi's ComCtrls.pas it is possible to enable support for RICHED20.DLL in TRichEdit, although this doesn't solve (2) or (3).

Any Rich Edit control built from scratch would have the same problem of (3), that is, what subset of RTF to support? One problem with a control like this is that people want to use it like a word processor, which it's not. One person's useful control word is the next person's useless baggage.

Ideally you could wrap a smallish word processor like AbiWord and use it in Lazarus. Then you would automatically have support for most of the RTF spec.

Note that OS X has its own Help Viewer, so a Rich Edit control wouldn't be useful for viewing help on Macs, except in a non-standard way.



-----Original Message-----
From: Graeme Geldenhuys [mailto:***@gmail.com]
Sent: Thursday, April 05, 2007 4:55 PM
To: ***@miraclec.com
Subject: Re: [lazarus] Doing the Delphi 6 Text Editor Tutorial in Lazarus?
Post by Hess, Philip J
Do you want to (a) create RTF files programmatically and/or display RTF files from your program or do you want to (b) allow your users to have a simple rich-text editor in your program. You can do (a) now in a cross-platform way with the FPC rtfpars unit and an external word processor.
At one stage (long ago when I worked with Kylix) I needed something
like (b). A richtext component, but have no need for it in my current
projects.

Though I can see some uses for it in Lazarus.

* Editing FPDoc documentation using 'lazde' and having a richedit
component for the descriptions would be nice. The richedit component
could have a swapable backend for saving to different formats like the
xml needed in the documentation. No need for anybody wanting to
create documentation to learn the fpdoc formatting tags. Just type,
highlight text and click whatever formatting you want to apply (like
all other word processors).
* Help Viewer for when Lazarus one day has a cross platform help
file (like .chm or .hlp).

You get the idea...
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'

_________________________________________________________________
To unsubscribe: mail lazarus-***@miraclec.com with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
Felipe Monteiro de Carvalho
2007-04-05 20:37:57 UTC
Permalink
Post by Graeme Geldenhuys
That's why I'm asking if it's such an impossible thing that nobody can
do, except the hordes of Microsoft employees.
It´s not at all impossible. It just happens that so far noone was
interrested enougth on this to actually implement it, or pay someone
else to do it.

I, for example, never needed a rich text component.
--
Felipe Monteiro de Carvalho
Graeme Geldenhuys
2007-04-05 20:59:00 UTC
Permalink
On 4/5/07, Felipe Monteiro de Carvalho
Post by Felipe Monteiro de Carvalho
It´s not at all impossible. It just happens that so far noone was
interrested enougth on this to actually implement it, or pay someone
else to do it.
I didn't really think it being impossible, but like you say. Most
probably everybody had the same idea, wait for somebody else to
implement it.

Either way, I'll see if I can find that code I spoke of, based on the
GoF case study. Maybe that will give someone a starting point or some
inspiration.
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
Carlos German Tejero
2007-04-05 20:50:38 UTC
Permalink
wxWidgets have a RichText control (
http://www.wxwidgets.org/manuals/stable/wx_wxrichtextctrl.html#wxrichtextctrl)
and in linux it's implemented over GTK.
wxWidgets, it's a good widgetset for Lazarus, i think (support Win32, Mac OS
X, GTK+, X11, Motif and WinCE).
Post by Graeme Geldenhuys
Post by Gus Wirth
The TRichEdit component is a simple wrapper around a standard Windows
widget, implemented in the riched32.dll. It doesn't show up in Kylix
because there is no equivalent in the QT widget set. The WINE guys
I know under Delphi it's a wrapper for that .dll, but why couldn't
Borland just write one from scratch for Kylix? The same goes for
Lazarus. Strangely enough, developers come up with all different
kinds of components, but nobody every bothers to write a RichEdit
component from scratch.
That's why I'm asking if it's such an impossible thing that nobody can
do, except the hordes of Microsoft employees.
--
Graeme Geldenhuys
There's no place like S34° 03.168' E018° 49.342'
_________________________________________________________________
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
--
Carlos Germán Tejero
Felipe Monteiro de Carvalho
2007-04-05 20:56:40 UTC
Permalink
Post by Carlos German Tejero
wxWidgets, it's a good widgetset for Lazarus,
Not really. There are no pascal bindings yet.
--
Felipe Monteiro de Carvalho
Graeme Geldenhuys
2007-04-05 21:01:26 UTC
Permalink
On 4/5/07, Felipe Monteiro de Carvalho
Post by Felipe Monteiro de Carvalho
Post by Carlos German Tejero
wxWidgets, it's a good widgetset for Lazarus,
Not really. There are no pascal bindings yet.
The other problem being that it would be something like four layers of
frameworks which can't be good for maintenance or performance.
Native Compontents (GTK, GDI) -> wxWidgets -> Pascal Bindings -> LCL
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
Hess, Philip J
2007-04-05 21:15:07 UTC
Permalink
If you substitute Qt for wxWidgets you have the layers of the Qt widgetset, which seems pretty fast. Certainly a lot faster than, say, the GTK2 widgetset, which only has 3 layers. I'm not sure that the number of layers affects performance that much in this case. There's probably something else going on.

The advantage of wxWidgets is that Lazarus would need only 1 widgetset in order to use any of the backends that wxWidgets supports, similar to the way the Qt widgetset supports the backends that Qt supports.


-----Original Message-----
From: Graeme Geldenhuys [mailto:***@gmail.com]
Sent: Thursday, April 05, 2007 5:01 PM
To: ***@miraclec.com
Subject: Re: [lazarus] Doing the Delphi 6 Text Editor Tutorial in Lazarus?

On 4/5/07, Felipe Monteiro de Carvalho
Post by Felipe Monteiro de Carvalho
Post by Carlos German Tejero
wxWidgets, it's a good widgetset for Lazarus,
Not really. There are no pascal bindings yet.
The other problem being that it would be something like four layers of
frameworks which can't be good for maintenance or performance.
Native Compontents (GTK, GDI) -> wxWidgets -> Pascal Bindings -> LCL
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'

_________________________________________________________________
To unsubscribe: mail lazarus-***@miraclec.com with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
mramirez
2007-04-09 16:10:35 UTC
Permalink
Post by Graeme Geldenhuys
kinds of components, but nobody every bothers to write a RichEdit
component from scratch.
I started to do something like that, in Delphi, and I didn 't get any far due
to my job workload.

And It was a single line editor, not the whole multiline.

The main problem with this component is that it shows not just
text in different colors or styles (bold, underlines, etc),
but also in different sizes and it suppouse to show pictures,
which makes development difficult.

Cheers !!!

maramirezc
mramirez
2007-04-09 16:02:18 UTC
Permalink
Post by Graeme Geldenhuys
I don't really know what a ActionManager is supposed to do, but under
An "Action Manager" is replacement for an "ActionList",
with some additional "goodies" like an improved component editor,
and a runtime "add actions to toolbar" dialog,
like the "Customize..." option in M$ Office applications...

The freeware RX Components included this component, before Delphi did.
I don't know if CodeGear remake this component or actually took
the RX source code. It's very useful, altought It can be very easy
to build.
Post by Graeme Geldenhuys
platform RichEdit component? Maybe it's only possible when you have
I started to do something similar, and NO, It's NOT AS DIFFICULT,
AS IT DOES, but It takes time for a lone developer to do it.

Cheers.

maramirezc
John Meyer
2007-04-10 01:29:08 UTC
Permalink
Post by Hess, Philip J
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
Okay, I was trying to find the beginning of this thread so I could find
this D6 Text Editor Tutorial, but when I click on the link, I get
"archives/index content was not found". Is something wrong here?
Razvan Adrian Bogdan
2007-04-19 10:40:54 UTC
Permalink
Isn't RichView supposed to be better than RichEdit ?
http://wiki.lazarus.freepascal.org/index.php/RichView

Razvan
Razvan Adrian Bogdan
2007-04-19 10:41:48 UTC
Permalink
BTW: Skype uses RichView too :)

Marc Weustink
2007-04-05 09:55:29 UTC
Permalink
Post by Tom Verhoeff
I have some students who are trying to complete the Delphi 6
Text Editor tutorial using Lazarus. See e.g. Chapter 4 of
<http://www.win.tue.nl/~hemerik/2IP20/Doc/Qs.pdf>
They run into some problems. E.g. Lazarus apparently does not
(yet) have ActionManagers. Hence, also the configuration of
standard actions like Cut/Copy/Paste is not a matter of a few clicks.
How hard is it to do this "yourself" (i.e. not using an ActionManager,
write the necessary code)? Note that TAction and a number of related
facilities are available in Lazarus.
Yes, actionmanagers at one time were introduced in Delphi. I've never
taken the time to figure out what I can do with them and why they are
usefull. So, if someone can give a brief clue, they might get added to
Lazarus someday.

Marc
Sergei Gorelkin
2007-04-05 13:23:31 UTC
Permalink
Post by Tom Verhoeff
I have some students who are trying to complete the Delphi 6
Text Editor tutorial using Lazarus. See e.g. Chapter 4 of
<http://www.win.tue.nl/~hemerik/2IP20/Doc/Qs.pdf>
They run into some problems. E.g. Lazarus apparently does not
(yet) have ActionManagers. Hence, also the configuration of
standard actions like Cut/Copy/Paste is not a matter of a few clicks.
How hard is it to do this "yourself" (i.e. not using an ActionManager,
write the necessary code)? Note that TAction and a number of related
facilities are available in Lazarus.
Typically, in Delphi you would do it like this (without TActionManager):

1. Drop an TActionList onto form
2. Add a standard action from StdAcnts unit (e.g. TEditCut) to it
3. Drop a TMainMenu and add a menu item to it
4. Assign the Action property of menu item to necessary TAction.
5. Optionally, drop a TToolBar, add button and assign it to the same
TAction.

These steps do not require any coding.
The same may be done with Lazarus. However, the problem is that its
StdActns unit is currently just a skeleton, it has no functionality.

MW> Yes, actionmanagers at one time were introduced in Delphi. I've never
MW> taken the time to figure out what I can do with them and why they are
MW> usefull. So, if someone can give a brief clue, they might get added to
MW> Lazarus someday.

The ActionManagers look like an attempt to mimic MSOffice 2000 user
interface (the same look, the ability to customize menus and toolbars
at runtime, and the ability to hide rarely used commands).
On the other hand, they represent much more elaborated design than it
was before. Briefly, you drag an action to menu bar and it's
automatically rendered as menu item, then you drag the same action to
the toolbar and it's rendered as a button. The whole thing was designed
to custom paint its UI and support visual styles
(at least partially, as ColorMaps). With proper implementation, this
component could easily be completely cross-platform. However,
regarding its actual implementation I have a feeling that everything
possible and impossible was done so that nobody could ever use it with CLX.
--
Best regards,
Sergei
Loading...