How to display coloured emoticons embedded in text in Purebasic Gadgets?

Windows specific forum
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

How to display coloured emoticons embedded in text in Purebasic Gadgets?

Post by sverson »

How can I display coloured emoticons embedded in the text in Purebasic?
For me it only works in black and white in all gadgets.

Image

I have hundreds of comments with emoticons in a database and want to display them correctly (in colour!).
This should also work somehow with the ListIconGadget. Not only LibreOffice Calc but also the DB Browser for SQLite (https://sqlitebrowser.org/) can do this - and of course MS Word.

I am happy to receive suggestions :)
sverson
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: How to display coloured emoticons embedded in text in Purebasic Gadgets?

Post by idle »

you can in scintilla on windows 10 11 with
ScintillaSendMessage(0,#SCI_SETTECHNOLOGY, #SC_TECHNOLOGY_DIRECTWRITE)

Code: Select all


Procedure.s _Chr(v.i) ;return a proper surrogate pair for unicode values outside the BMP (Basic Multilingual Plane)
  
  Protected chr.q
  If v < $10000
    ProcedureReturn Chr(v)
  Else
    chr = (v&$3FF)<<16 | (v-$10000)>>10 | $DC00D800
    ProcedureReturn PeekS(@chr, 2, #PB_Unicode)
  EndIf
  
EndProcedure

If OpenWindow(0, 0, 0, 600, 200, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
    
  ScintillaGadget(0, 10, 10, 580, 180, 0)
    
  ScintillaSendMessage(0,#SCI_SETTECHNOLOGY, #SC_TECHNOLOGY_DIRECTWRITE) ;<---this does the job
  
  ; Output set to red color
  ScintillaSendMessage(0, #SCI_STYLESETFORE, 0, RGB(255, 0, 0))
  ScintillaSendMessage(Gadget, #SCI_STYLESETFONT,#STYLE_DEFAULT, @"Segoe UI")      
  ScintillaSendMessage(Gadget, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 18)                     
    
  ; Set the initial text to the ScintillaGadget
  *Text=UTF8("This is a simple ScintillaGadget with text..." + _Chr($1f60e))
  ScintillaSendMessage(0, #SCI_SETTEXT, 0, *Text)
  FreeMemory(*Text) ; The buffer made by UTF8() has to be freed, to avoid memory leak
  
  ; Adding a second line of text with linebreak before
  Text$ = Chr(10) + "Second line"
  *Text=UTF8(Text$)
  ScintillaSendMessage(0, #SCI_APPENDTEXT, Len(Text$), *Text)
  FreeMemory(*Text)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf


sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

Re: How to display coloured emoticons embedded in text in Purebasic Gadgets?

Post by sverson »

Thx idle.

So scintilla is the only way to handle this issue?
If so, I would have to create some kind of ListIconGadget from ScintillaGadgets.
That's going to be a pretty big deal when you have to process 11 columns and thousands of rows. 🤔

I assume this solution will be pretty slow. The "DB Browser for SQLite" (Windows) is not slow at all but still can display coloured enoticons within text.

🙂 sverson
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: How to display coloured emoticons embedded in text in Purebasic Gadgets?

Post by idle »

Yes currently scintilla is the only gadget that supports it. if you want a searchable structure
you can either use a webgadget and html table or embed pngs or icons in a DS and map by name or a trie
see here https://www.purebasic.fr/english/viewtopic.php?t=84306
there's a link to create icons
Post Reply