Rich Edit Full Justification

Share your advanced PureBasic knowledge/code with the community.
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Rich Edit Full Justification

Post by mdp »

Code updated for 5.20+

Greetings,
I managed to find out how to full justify text in a RichEdit gadget. (Actually, I found it pretty difficult to find the info around). It's a single line:

Code: Select all

SendMessage_(GadgetID(#re),#EM_SETTYPOGRAPHYOPTIONS,1,1)
where #re indicates your EditorGadget and that '1', the parameter, is short for the const #TO_ADVANCEDTYPOGRAPHY (not defined in PB).
I normally insert a rich text formatted string with SetGadgetText(); to justify, the RTF keyword is '\qj '. Without the previous line, that keyword is unrecognised.

Well... I think I started looking for it in 2004 :)
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

Thanks mdp!

I was looking just that kind of thinks around for my editor.
I am very poor in the knowledge of RTF keywords, but I was looking for that.
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: Rich Edit Full Justification

Post by Thorsten1867 »

mdp wrote:I normally insert a rich text formatted string with SetGadgetText(); to justify, the RTF keyword is '\qj '
How must this string look like?
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Post by mdp »

The RTF formatted string may be a RTF-Header plus a plain or formatted text.
To get a RTF-Header, you can save a quodlibet file in RTF format from WordPad and peek inside, say, with Notepad.
To give you some examples:
A RTF-Header could be:

Code: Select all

re_head.s="{\rtf1\ansi\deff0{\fonttbl"
re_head + "{\f0\froman\fprq1\fcharset0 Times New Roman;}}"
re_head + "{\colortbl ;\red32\green64\blue128; \red0\green127\blue255;}};
re_head + "\li80\ri80\fi400\qj\sb90\fs32\fc0 "
Where:
\li, \ri, \fi -> indents (left, right, first line)
\sb -> paragraph spacing
\fs -> font size (2x the values we may be used to)
\fc -> font color index, according to the specified table
\qj, \ql, \qc, \qr -> alignment
(etc.)
You can concatenate keywords without spaces; when text follows, add a space (es. '\ri300\li300 Hi there.\par ').
In text formatting:
\b .. \b0 is for bold, \i .. \i0 for italics, \par and \line etc.
I learnt from WordPad's output but it's easy to find the syntax around.
Post Reply