Code: Select all
For i = 0 To 3
If CreateImage(i,32,32,24)
If StartDrawing(ImageOutput(i))
If i = 0 : Box(0,0,32,32,RGB(255,0,0))
ElseIf i = 1 : Box(0,0,32,32,RGB(0,255,0))
ElseIf i = 2 : Box(0,0,32,32,RGB(0,0,255))
ElseIf i = 3 : Box(0,0,32,32,RGB(255,0,255))
EndIf
StopDrawing()
EndIf
EndIf
Next i
Structure MPos
x.d
y.d
EndStructure
Global TreeMouse.MPos
Global ItemState.b = #False
Runtime Procedure QtSignalHandler()
If GetGadgetState(1) = 1 And TreeMouse\x < 13 ;Test
MessageRequester("", "Hallo!")
If ItemState = #False
SetGadgetItemImage(1, 1, ImageID(3))
ItemState = #True
Else
SetGadgetItemImage(1, 1, ImageID(1))
ItemState = #False
EndIf
EndIf
EndProcedure
Procedure MouseFrame(win, *mRet.MPos, mx, my, mw, mh)
Protected mxx, myy
*mRet\x = 0 : *mRet\y = 0
mxx = WindowMouseX(win) : myy = WindowMouseY(win)
If (mxx > mx And mxx < (mw+mx)) And (myy > my And myy < (mh+my))
*mRet\x = 100 / mw * (mxx-mx)
*mRet\y = 100 / mh * (myy-my)
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 320, 250, "FrameGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 300, 50, "Original Text")
TreeGadget(1, 10, 80, 300, 140)
AddGadgetItem(1, -1, "Text 1", ImageID(0),0)
AddGadgetItem(1, -1, "Text 2", ImageID(1),0)
AddGadgetItem(1, -1, "Text 3", ImageID(2),0)
; show the TreeGadget object's content
Debug QtScript("dump(gadget(1).clicked)")
Debug QtScript(~"gadget(1).clicked.connect(function() { runtime.call(\"QtSignalHandler()\"); })")
; modify the gadget text
QtScript(~"gadget(0).text = \"Click on the green box.\"")
Repeat
MouseFrame(0, @TreeMouse, 10, 80, 300, 140)
Debug "X: " + StrD(TreeMouse\x)
;Debug "Y: " + StrD(TreeMouse\y)
Until WindowEvent() = #PB_Event_CloseWindow
EndIf