BruceSteers wrote: ↑Saturday 27th January 2024 12:43am
and with gambas button images are placed to the left of the text not above or below
you'll have to make a custom button/function to do that
Here is a function that does that trick.
It makes a picture that consists of the icon and Paints the text below the icon. then sets the button picture as the picture with text.
Note: do not set Button1.Text as it is now in the image
EDIT: fixed
Public Sub Form_Open()
' make Button1.Picture a picture with text below it.
MakePictureText(Button1, Picture["icon:/32/alarm"], "Alarm call")
End
'' Make a picture with text below it. can be used on any object that has a .Text and a .Picture property.
Public Sub MakePictureText(Obj As Object, Pic As Picture, Text As String)
Dim hIcon As Picture = Pic.Stretch(Obj.Height - Obj.Font.Height - 6) ' stretch the icon to button height lss font height less margin.
Dim p As Picture = New Picture(Obj.W, Obj.H, True) ' make a new picture (use transparent arg to fix qt bug)
Obj.Text = "" ' make sure Obj has not got text
' use Paint.class to draw the icon and text to the picture
Paint.Begin(p)
Paint.DrawPicture(hIcon, (Obj.W - hIcon.W) / 2, 4, hIcon.Width, hIcon.Height)
Paint.DrawText(Text, 0, hIcon.Height + 3, Obj.Width, Obj.Font.Height, Align.Center)
Paint.End
Obj.Picture = p ' set the object picture to new pic
End