StringGadget Centered Hal & Val cross platform
Posted: Tue Jun 11, 2019 5:27 am
It should be cross platform
Using only native commands
Tested with Windows only
Edit : Modified #1
Using only native commands
Tested with Windows only
Code: Select all
Global sh,cw,ch
Procedure type()
Text$ = GetGadgetText(1)
StartDrawing(WindowOutput(0))
DrawingFont(FontID(0))
w = TextWidth(text$)
StopDrawing()
ResizeGadget(1,cw/2-w/2,ch/2-sh/2-2,w,sh)
EndProcedure
LoadFont(0,"Tahoma",24)
OpenWindow(0, 0, 0, 600, 400, "StringGadget ", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(0,#White)
StartDrawing(WindowOutput(0))
DrawingFont(FontID(0))
sh = TextHeight("Q")+2
sw = TextWidth(" ")
StopDrawing()
ContainerGadget(0,10,10,580,60,#PB_Container_Flat)
SetGadgetColor(0,#PB_Gadget_BackColor,$FFFFFF)
cw = GadgetWidth(0)
ch = GadgetHeight(0)
StringGadget(1, cw/2,10,sw,sh," ",#PB_String_BorderLess)
SetGadgetFont(1,FontID(0))
SetGadgetColor(1,#PB_Gadget_FrontColor,$0000FF)
CloseGadgetList()
SetGadgetFont(1,FontID(0))
SetActiveGadget(1)
BindGadgetEvent(1,@type())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
EndSelect
EndSelect
Until Quit = 1