Procedure.f GetProgressBarColorState(IDGadget) ; si la fonction échoue retourne -1, sinon retourne la position de la barre de progression
If IsGadget (IDGadget) And PBCG = 1 And CountList (PBCG()) > 0
sel = -1 : ForEach PBCG() : If PBCG()\ID = IDGadget : sel = a : EndIf : a = a + 1 : Next
If sel = -1 : ProcedureReturn sel : Else : SelectElement (PBCG(), sel) : EndIf
ProcedureReturn PBCG()\Av
EndIf
EndProcedure
Procedure ResizeProgressBarColor(IDGadget, x, y, Width, Height, Radius) ; Retourne 1 si la fonction a réussi
If IsGadget (IDGadget) And PBCG = 1 And CountList (PBCG()) > 0
sel = -1 : ForEach PBCG() : If PBCG()\ID = IDGadget : sel = a : EndIf : a = a + 1 : Next
If sel = -1 : ProcedureReturn 0 : Else : SelectElement (PBCG(), sel) : EndIf
If Width = -1 : Width = PBCG()\W : EndIf
If Height = -1 : Height = PBCG()\H : EndIf
If Radius = -1 : Radius = PBCG()\R : EndIf
If Width > 4 And Height > 4 And Radius > 0
PBCG()\mem = ReAllocateMemory (PBCG()\mem, width * height * 4 + Width * 4)
PBCG()\W = Width : PBCG()\H = Height : PBCG()\R = Radius
CloseFont (PBCG()\Font)
PBCG()\Font = LoadFont ( #PB_Any , "times new roman" , PBCG()\H / 2)
If PBCG()\V
StartDrawing ( WindowOutput ())
PBCG()\Av = Max
If PBCG()\nbd > 0
t.s = StrF (PBCG()\Av)
t = Left (t, FindString (t, "." , 0) + PBCG()\nbd)
Repeat
If Val ( Right (t, 1)) = 0
t = Left (t, Len (t) - 1)
EndIf
Until Val ( Right (t, 1)) <> 0
Else
t.s = Str (PBCG()\Av)
EndIf
Repeat
DrawingFont ( UseFont (PBCG()\Font))
textl = TextLength (t + PBCG()\S)
If textl > PBCG()\W - 4
b = b + 1
CloseFont (PBCG()\Font)
PBCG()\Font = LoadFont ( #PB_Any , "times new roman" , (PBCG()\H / 2 - b))
If (PBCG()\H / 2 - b) = < 2
ok = 1
EndIf
Else
ok = 1
EndIf
Until Ok = 1
PBCG()\Av = Min
PBCG()\FH = (PBCG()\H / 2 - b) * 1.6
StopDrawing ()
EndIf
ProcedureReturn ResizeImage (PBCG()\Img, Width, Height) & ResizeGadget (IDGadget, x, y, Width, Height) & SetProgressBarColorState(IDGadget, PBCG()\Av)
EndIf
EndIf
EndProcedure
#test = 1
#ProgressBar = 1
#ProgressBar2 = 2
#ProgressBar3 = 3
#text = 4
CreateImage (2, 1, 1)
OpenWindow ( #test , 0, 0, 1000, 150, #PBWIN0 , "TEST PROGRESS - Click On ProgressBar ; )" )
CreateGadgetList ( WindowID ( #test ))
ProgressBarGadget (0, 5, 100, 790, 20, 0, 100, #PB_ProgressBar_Smooth )
SetGadgetState (0, 50)
ProgressBarColorGadget( #ProgressBar , 5, 5, 790, 15, 30, 0, 100, #White , #Green , #Red , #Yellow , 0, #Blue , 1, " %" )
ProgressBarColorGadget( #ProgressBar2 , 5, 25, 790, 25, 30, 0, 100, #White , RGB (229, 126, 63), -1, -1, 0, #Yellow , 0, " %" )
ProgressBarColorGadget( #ProgressBar3 , 5, 55, 790, 20, 30, 20, 90, #White , #Green , -1, -1, 0, 255, 0, "°C" )
TextGadget ( #text , 10, 130, 780, 20, "" , #PB_Text_Center )
ProgressBar4 = ProgressBarColorGadget( #PB_Any , 800, 5, 40, 140, 15, 0, 100, #White , #Blue , RGB (179, 179, 255), #White , 1, #Red , 0, "" )
ProgressBar5 = ProgressBarColorGadget( #PB_Any , 845, 5, 150, 140, 6, 0, 100, #White , #Green , -1, -1, 0, #Red , 0, "" )
SetProgressBarColorState(ProgressBar5, 100)
Repeat
UseWindow ( #test )
Select WaitWindowEvent ()
Case #PB_EventGadget
Select EventGadgetID ()
Case #ProgressBar
a.f = 0
Repeat
a.f = a.f + 0.1
SetProgressBarColorState( #ProgressBar , a)
t$ = StrF (GetProgressBarColorState( #ProgressBar ))
SetGadgetText ( #text , Left (t$, FindString (t$, "." , 0) + 1))
Until a >= 60.5
Case #ProgressBar2
SetProgressBarColorState( #ProgressBar2 , 50)
SetGadgetText ( #text , Str (GetProgressBarColorState( #ProgressBar2 )))
Case #ProgressBar3
ResizeProgressBarColor( #ProgressBar3 , 5, 55, 790, 40, 5)
SetProgressBarColorState( #ProgressBar3 , 50)
SetGadgetText ( #text , Str (GetProgressBarColorState( #ProgressBar3 )))
Case ProgressBar4
For b = 1 To 50
Delay (100)
SetProgressBarColorState(ProgressBar4, b)
SetProgressBarColorState(ProgressBar5, 100 - b)
SetGadgetText ( #text , Str (GetProgressBarColorState(ProgressBar4)))
Next
EndSelect
Case #PB_Event_CloseWindow
quit = 1
EndSelect
Until quit = 1