
Code: Alles auswählen
; target OS all (windows erfordert XP-Style enabled!)
; Version: 4.0 ++ (ich bekomme mit 4.20 einen IMA ???)
; Id, x, y, w, h, text.s, flags = wie bei ButtonGadget auch!
; fcolor = FrontColor, bcolor = BackColor, fontid = FontID()
Procedure ButtonColorGadget(Id, x, y, w, h, text.s, fcolor, bcolor, flags = 0, fontid = #PB_Font_Default)
Protected img
img = CreateImage(#PB_Any, w, h)
If StartDrawing(ImageOutput(img))
DrawingFont(fontid)
Box(0, 0, w, h, bcolor)
DrawText(w / 2 - TextWidth(text) / 2, h / 2 - TextHeight(text) / 2, text, fcolor, bcolor)
StopDrawing()
ProcedureReturn ButtonImageGadget(Id, x, y, w, h, ImageID(img), flags)
EndIf
EndProcedure
; Beispiel
Define btnBlack, btnWhite
OpenWindow(0, 100, 100, 340, 100, "ColorButton", #PB_Window_SystemMenu)
ButtonColorGadget(1, 10, 10, 150, 30, "toogle", #Black, #Red, #PB_Button_Toggle)
ButtonColorGadget(2, 10, 50, 150, 30, "courier", #Blue, #Yellow, 0, LoadFont(0, "courier", 10))
btnBlack = ButtonColorGadget(#PB_Any, 170, 10, 150, 30, "black / white", #Black, #White)
btnWhite = ButtonColorGadget(#PB_Any, 170, 50, 150, 30, "white / black", #White, #Black)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Debug "red / black"
Case 2
Debug "blue / yellow"
Case btnBlack
Debug "black / white"
Case btnWhite
Debug "white / black"
EndSelect
EndSelect
ForEver