Assigning RTF (styled) text to EditorGadget directly

Just starting out? Need help? Post your questions and find answers here.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Assigning RTF (styled) text to EditorGadget directly

Post by ts-soft »

Armoured wrote: But why not to have a basic command to make this? :?:
EditorGadget is not designed to work with RTF. It's only for plain text.
The code to convert is useless on macos or linux.

// edit
It's better not using of string to hold the ascii string. I think this one
should better in this case:

Code: Select all

Procedure SetASCIIText(Gadget, Text.s)
  Protected *mem, result
  
  If Text
    *mem = AllocateMemory(StringByteLength(Text, #PB_Ascii) + 1)
    If *mem
      PokeS(*mem, Text, -1, #PB_Ascii)
      result = SendMessage_(GadgetID(Gadget), #WM_SETTEXT, 0, *mem)
      FreeMemory(*mem)
    EndIf
  EndIf
  
  ProcedureReturn result
EndProcedure

OpenWindow(0, 200, 200, 400, 200,"Memory Put", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget)
EditorGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), #PB_Editor_ReadOnly)
SendMessage_(GadgetID(0), #EM_LIMITTEXT, -1, 0)

a.s="{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red255\green0\blue0;\red0\green0\blue0;}"
a.s=a.s+"{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 Hello, this is \cf1\b\fs32 RTF\cf2\b0\fs20 direct!\cf0\par}"

SetASCIIText(0, a)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Last edited by ts-soft on Sat Apr 10, 2010 10:42 pm, edited 1 time in total.
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Re: Assigning RTF (styled) text to EditorGadget directly

Post by Armoured »

ts-soft wrote:EditorGadget is not designed to work with RTF. It's only for plain text.
If EditorGadget on Windows can read and display correctly RTF then the EditorGadget on Windows support RTF.
ts-soft wrote:The code to convert is useless on macos or linux.
The MDIGadget and other commands works only on Windows and are here...
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Assigning RTF (styled) text to EditorGadget directly

Post by ts-soft »

Armoured wrote: If EditorGadget on Windows can read and display correctly RTF then the EditorGadget on Windows support RTF.
RTF is not supported without API. No command implemented, only the used control is a RichText control.
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Re: Assigning RTF (styled) text to EditorGadget directly

Post by Armoured »

ts-soft wrote: RTF is not supported without API.
If EditorGadget on Windows can read and display correctly RTF then the EditorGadget on Windows support RTF.
ts-soft wrote:No command implemented, only the used control is a RichText control.
RTF is like Latex, a scripting language, for the layouts of the pages.
EditorGadget on Windows, in my opinion, must display RTF text without problems in unicode or not.
With the appropriate documentation is possible to create commands to edit RTF text in the EditorGadget else there is WordPad :)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Assigning RTF (styled) text to EditorGadget directly

Post by RASHAD »

Hi Armoured
You had a long run with ts-soft
Editor Gadget is a very sophisticated gadget,the team was very tied with it for compatibility with Mac & Linux
If you want to deal with it with MS way search the forum you will get at least 30 snippets for Freak,srod,Falco
and others

You will love it for sure ( Under Windows )

Good Luck Mate
Egypt my love
Post Reply