Take a look into my code example which demonstrates how to toggle between
different styles in the ListIconGadget and TextGadget:
Code: Select all
ImportC ""
SetControlFontStyle(ControlRef.L, *ControlFontStyleRec)
SetControlVisibility(ControlRef.L, IsVisible.L, DoDraw.L)
EndImport
#kControlUseFaceMask = $0002
; ----- Font style constants
#Bold = 1
#Italic = 2
#Bold_Italic = 3
#Underline = 4
#Bold_Underline = 5
#Italic_Underline = 6
#Bold_Italic_Underline = 7
Structure RGBColor
Red.U
Green.U
Blue.U
EndStructure
Structure ControlFontStyleRec
Flags.W
Font.W
Size.W
Style.W
Mode.W
Just.W
ForeColor.RGBColor
BackColor.RGBColor
EndStructure
Procedure ChangeFontStyle(Style.W)
Protected FontStyle.ControlFontStyleRec
FontStyle\Flags = #kControlUseFaceMask
FontStyle\Style = Style
SetControlFontStyle(GadgetID(1), @FontStyle)
SetControlFontStyle(GadgetID(2), @FontStyle)
SetControlVisibility(GadgetID(2), #True, #True)
EndProcedure
OpenWindow(0, 200, 100, 480, 435, "Change font styles")
TextGadget(0, 195, 15, 100, 18, "ListIconGadget")
ListIconGadget(1, 5, 32, 470, 100, "Name", 135)
AddGadgetColumn(1, 1, "Address", 314)
AddGadgetItem(1, -1, "Harry Rannit" + #LF$ + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(1, -1, "Ginger Brokeit"+ #LF$ + "130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(1, -1, "Didi Foundit"+ #LF$ + "321 Logo Drive, Mouse House, Downtown")
TextGadget(2, 195, 152, 80, 18, "TextGadget", #PB_Text_Border)
Frame3DGadget(3, 130, 190, 210, 225, "Font styles:")
ButtonGadget(4, 140, 210, 190, 18, "Standard")
ButtonGadget(5, 140, 235, 190, 18, "Bold")
ButtonGadget(6, 140, 260, 190, 18, "Italic")
ButtonGadget(7, 140, 285, 190, 18, "Bold + Italic")
ButtonGadget(8, 140, 310, 190, 18, "Underlined")
ButtonGadget(9, 140, 335, 190, 18, "Bold + Underlined")
ButtonGadget(10, 140, 360, 190, 18, "Italic + Underlined")
ButtonGadget(11, 140, 385, 190, 18, "Bold + Italic + Underlined")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventType() = #PB_EventType_LeftClick
GadgetNumber = EventGadget()
If GadgetNumber >= 4 And GadgetNumber <= 11
ChangeFontStyle(GadgetNumber - 4)
EndIf
EndIf
EndSelect
ForEver