FrameGadgetCustom()
Posted: Sun Oct 08, 2017 1:17 am
Here's a little procedure that creates a customised FrameGadget(), by letting you change the text color and font for it.
Credit: Based on code from Rashad here: http://www.purebasic.fr/english/viewtop ... 85#p513085
Credit: Based on code from Rashad here: http://www.purebasic.fr/english/viewtop ... 85#p513085
Code: Select all
Procedure FrameGadgetCustom(gad,x,y,w,h,text$,color,fontid=0)
If fontid
SetGadgetFont(#PB_Default,fontid)
EndIf
tmp=TextGadget(#PB_Any,0,0,0,0,text$)
tmpw=GadgetWidth(tmp,#PB_Gadget_RequiredSize)
tmph=GadgetHeight(tmp,#PB_Gadget_RequiredSize)
FreeGadget(tmp)
FrameGadget(gad,x,y,w,h," ")
gadnum=TextGadget(#PB_Any,x+10,y,tmpw+1,tmph,text$)
SetGadgetColor(gadnum,#PB_Gadget_FrontColor,color)
If fontid
SetGadgetFont(#PB_Default,#PB_Default)
EndIf
ProcedureReturn gadnum
EndProcedure
OpenWindow(0,200,200,420,150,"Window",#PB_Window_SystemMenu)
PanelGadget(0,10,10,210,130)
AddGadgetItem(0,-1,"Panel")
FrameGadgetCustom(1,10,10,180,85,"Blue",#Blue,FontID(LoadFont(#PB_Any,"Broadway",20)))
CloseGadgetList()
FrameGadgetCustom(2,230,23,180,118,"Red",#Red)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow