How do you make the font bold type??????
I don't see anyway of manipulating the font in any of the gadgets.
Fonts in the EditorGadget
-
- User
- Posts: 14
- Joined: Mon Jul 20, 2009 9:29 pm
- Location: Santa Barbara California US
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re:
Here it is necessary for me, how to do this?netmaestro wrote:I assumed something more involved of course, as setting font, size, etc. for selected range.

http://www.purebasic.fr/english/viewtop ... 50#p522021
If there are examples of better offer.
Re: Fonts in the EditorGadget
You can use rtf (Rich Text Format). Wiki: https://en.wikipedia.org/wiki/Rich_Text_Format
Windows Only
Update... 
Windows Only
Code: Select all
;-TOP
; *****************************************************************************
; AddTextRTF by mk-soft, v1.05, 27.03.2018
CompilerIf #PB_Compiler_Version < 550
Procedure UTF8(Text.s)
Protected *mem = AllocateMemory(StringByteLength(Text, #PB_UTF8) + 1)
If *mem
PokeS(*mem, Text, -1, #PB_UTF8)
EndIf
ProcedureReturn *mem
EndProcedure
CompilerEndIf
Procedure AddTextRTF(Gadget, Text.s , NewLine=#False)
If Left(Text, 5) <> "{\rtf"
Text = "{\rtf " + Text + "}"
EndIf
If NewLine
Text = Left(Text, Len(text) - 1) + "\line}"
EndIf
CompilerIf #PB_Compiler_Unicode
Protected hEdit = GadgetID(Gadget)
Protected ndx = GetWindowTextLength_(hEdit)
Protected *szBuffer = UTF8(Text)
SendMessage_(hEdit, #EM_SETSEL, ndx, ndx)
SendMessage_(hEdit, #EM_REPLACESEL, 0, *szBuffer)
FreeMemory(*szBuffer)
CompilerElse
AddGadgetItem(Gadget, -1 , Text)
CompilerEndIf
EndProcedure
; *****************************************************************************
;-
Define.s rtf1, rtf2
;rtf1 = "{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard This is some {\b bold} text.\par}"
rtf1 = "This is some {\b bold} text."
rtf2 = "{\rtf1\ansi\deff0 {\fonttbl {\f0 Courier;}}"
rtf2 + "{\colortbl;\red0\green0\blue255;\red255\green0\blue;}"
rtf2 + "This line is the Default color\line"
rtf2 + "\cf2"
rtf2 + "\tab This line is red And has a tab before it\line"
rtf2 + "\cf1"
rtf2 + "\b This line is the blue color And bold"
rtf2 + "}"
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 8, 8, 306, 133)
AddTextRTF(0, rtf1, 1)
AddTextRTF(0, rtf2, 1)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Fonts in the EditorGadget
You can try with these, thanks to: Srod & netmaestro.
Code: Select all
; Srod: http://www.purebasic.fr/english/viewtopic.php?p=164184#164184
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 270, 160, "TextGadget", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
TextGadget(0, 10, 10, 250, 20, "TextGadget Standard (Left)")
font = SendMessage_(GadgetID(0), #WM_GETFONT, 0, 0)
GetObject_(font, SizeOf(LOGFONT), lg.LOGFONT)
lg\lfWeight = #FW_BOLD
font = CreateFontIndirect_(lg)
SendMessage_(GadgetID(0), #WM_SETFONT, font, 1)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
DeleteObject_(font)
Code: Select all
; netmaestro: http://www.purebasic.fr/english/viewtopic.php?p=164013#164013
If OpenWindow(0, 0, 0, 270, 160, "TextGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(0, 10, 10, 250, 20, "TextGadget Standard (Left) [BOLD]")
TextGadget(1, 10, 70, 250, 20, "TextGadget Center", #PB_Text_Center)
TextGadget(2, 10, 40, 250, 20, "TextGadget Right", #PB_Text_Right)
TextGadget(3, 10, 100, 250, 20, "TextGadget Border", #PB_Text_Border)
TextGadget(4, 10, 130, 250, 20, "TextGadget Center + Border", #PB_Text_Center | #PB_Text_Border)
SetGadgetFont(0, GetStockObject_(#BOLD_FONTTYPE))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
