Page 1 of 1

Rich Edit Full Justification

Posted: Tue Jan 03, 2006 7:01 pm
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 :)

Posted: Tue Jan 03, 2006 9:46 pm
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.

Re: Rich Edit Full Justification

Posted: Wed Jan 04, 2006 11:44 pm
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?

Posted: Thu Jan 05, 2006 8:08 pm
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.