Richedit justify and numbering style bugs and fixes

Moderator: Rathinagiri

Post Reply
User avatar
kcarmody
Posts: 152
Joined: Tue Oct 07, 2014 11:13 am
Contact:

Richedit justify and numbering style bugs and fixes

Post by kcarmody »

I have been using HMG rich edit controls heavily for the past few months and have discovered two bugs and fixes for them.

The first bug is that the justify alignment does not work, e.g.

Win.RichEditBox.ParaAlignment := RTF_JUSTIFY

has no effect and does not actually justify the text. After some searching, I found out that you must turn on "advanced typography" to get this to work. The following should be added to InitRichEditBox() in c_richeditbox.c:

SendMessage( hWndControl, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY );

"Advanced typography" sounds like it should be enable a big set of advanced features, but in fact the feature set it enables is quite small, and justification is the main one.

The second bug is that paragraph numbering styles that you get and set with the ParaNumberingStyle property do not match the constants in i_richeditbox.ch, e.g.

Win.RichEditBox.ParaNumberingStyle := RTF_PERIOD

actually sets the numbering style to two parentheses instead of a period. This is due to a mismatch between c_richeditbox.c lines 837-845 and 940-953, and i_richeditbox.ch lines 151-157. In the C code, numbering style 0 and PFNS_PAREN have the same effect, a right parenthesis after the number. So the first case is unnecessary, and the cases should start with PFNS_PAREN, which should be mapped to case 1.

However, I do not think the C code should be modified, as this would break existing applications that use it. Instead, I suggest adding some additional constants to i_richeditbox.ch that reflect the actual values in the C code, e.g.

#define RTF_PAREN_2 3 // Follows the number with a right parenthesis.

I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;

Kevin
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Richedit justify and numbering style bugs and fixes

Post by serge_girard »

Thanks Kevin !

Serge
There's nothing you can do that can't be done...
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: Richedit justify and numbering style bugs and fixes

Post by EduardoLuis »

Hi Kevin:

My first words are: EXCELLENT job.-
I've download and apply new libraries, and it works absolutely fine.-
A suggestion to all users:
1) First rename both original files to individualitate as OLD
2) Copy both libraries each on it's root (INCLUDE and SOURCES)
3) Re Build libraries twice: one choosing ANSI option, and when it finish choose UNICODE
After that, chances take place and you'll enjoy both improvements.

Again Kevin, Excellent Job, and thanks to share with us.-
With regards.
Eduardo
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Richedit justify and numbering style bugs and fixes

Post by esgici »

kcarmody wrote:I have been using HMG rich edit controls heavily for the past few months ...

I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg
...
Hello Mr. Carmody

You are welcome aboard of HMG_Forum :)

Thanks a lot for your valuable participation.

And surely we will benefit by your huge experience and knowledge :arrow:

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Richedit justify and numbering style bugs and fixes

Post by danielmaximiliano »

Gracias / Thanks Kevin....
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Richedit justify and numbering style bugs and fixes

Post by Pablo César »

Wow ! Thank you Kevin for you fix of it and sharing with us.

Have you are welcome to our community ! :D

Nice work in AksharaPad !

Image
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
kcarmody
Posts: 152
Joined: Tue Oct 07, 2014 11:13 am
Contact:

Re: Richedit justify and numbering style bugs and fixes

Post by kcarmody »

Thank you everyone for your kind words -- including Pablo for noticing my HMG project AksharaPad -- but it looks now like I was wrong about the second bug. There is no mismatch between the constants in i_richeditbox.ch lines 151-157 and the code in c_richeditbox.c lines 837-845 and 940-953. So the second bug I reported does not exist.

However it is still true that RTF_NONE and RTF_PAREN (style numbers 1 and 2) produce the same effect, a right parenthesis. So RTF_NONE is not necessary and is misnamed. The numbering style which eliminates punctuation is RTF_NONUMBER.

I've posted a new version of i_richeditbox.ch, with the proposed additions of RTF_PAREN_2 etc. removed, to my site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;

Kevin
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Richedit justify and numbering style bugs and fixes

Post by srvet_claudio »

kcarmody wrote:I have been using HMG rich edit controls heavily for the past few months and have discovered two bugs and fixes for them.

The first bug is that the justify alignment does not work, e.g.

Win.RichEditBox.ParaAlignment := RTF_JUSTIFY

has no effect and does not actually justify the text. After some searching, I found out that you must turn on "advanced typography" to get this to work. The following should be added to InitRichEditBox() in c_richeditbox.c:

SendMessage( hWndControl, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY );

"Advanced typography" sounds like it should be enable a big set of advanced features, but in fact the feature set it enables is quite small, and justification is the main one.

The second bug is that paragraph numbering styles that you get and set with the ParaNumberingStyle property do not match the constants in i_richeditbox.ch, e.g.

Win.RichEditBox.ParaNumberingStyle := RTF_PERIOD

actually sets the numbering style to two parentheses instead of a period. This is due to a mismatch between c_richeditbox.c lines 837-845 and 940-953, and i_richeditbox.ch lines 151-157. In the C code, numbering style 0 and PFNS_PAREN have the same effect, a right parenthesis after the number. So the first case is unnecessary, and the cases should start with PFNS_PAREN, which should be mapped to case 1.

However, I do not think the C code should be modified, as this would break existing applications that use it. Instead, I suggest adding some additional constants to i_richeditbox.ch that reflect the actual values in the C code, e.g.

#define RTF_PAREN_2 3 // Follows the number with a right parenthesis.

I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;" onclick="window.open(this.href);return false;

Kevin
Thanks Kevin for report the bug and fix.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Richedit justify and numbering style bugs and fixes

Post by Javier Tovar »

Muy bien Kevin, Gracias por ver los errores y contribuir en su corrección.
Bienvenido a HMG.
Saludos desde México.
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Richedit justify and numbering style bugs and fixes

Post by bpd2000 »

Hi Mr. Kevin
Welcome from India
Than you for your contribution
BPD
Convert Dream into Reality through HMG
Post Reply