Simple Progress Bar
Posted: Mon Feb 26, 2018 6:36 pm
Hi all
Edit :Modified # 1
Code: Select all
Procedure _ProgressBar(gadget,x,y,w,h,color)
If h > w
CreateImage(0,w,h,32)
Else
CreateImage(0,h,w,32)
EndIf
StartVectorDrawing(ImageVectorOutput(0))
VectorSourceLinearGradient(-10, 0, 30, 0)
VectorSourceGradientColor(RGBA(Red(Color), Green(Color), Blue(Color), 255), 0.4)
If h > w
AddPathBox(0,0,w,h)
Else
AddPathBox(0,0,h,w)
EndIf
FillPath()
StopVectorDrawing()
cont = ContainerGadget(#PB_Any,x,y,w,h,#PB_Container_Single)
SetGadgetColor(cont,#PB_Gadget_BackColor,$B6B6B6)
CanvasGadget(gadget,-w,1,w,h-2)
StartVectorDrawing(CanvasVectorOutput(gadget))
If w > h
MovePathCursor(w, 0)
RotateCoordinates(0, 0, 90)
Else
MovePathCursor(0,0)
EndIf
DrawVectorImage(ImageID(0))
StopVectorDrawing()
CloseGadgetList()
EndProcedure
flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"My ProgressBar",Flags)
_ProgressBar(0,10,10,200,30,RGB(87, 252, 63))
_ProgressBar(1,10,40,20,200,RGB(251, 201, 62))
w1 = GadgetWidth(0) :h1 = GadgetHeight(0)
w2 = GadgetWidth(1) :h2 = GadgetHeight(1)
ButtonGadget(2,10,265,60,24,"RUN",#PB_Button_Toggle)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Timer
If x < w1
ResizeGadget(0,x-w1,0,w1,h1)
x+1
EndIf
If y < h2
ResizeGadget(1,0,h2-y,w2,h2)
y+1
EndIf
If x >= w1 Or y >= w1
SetGadgetState(2,0)
x = 0 : y = 0
SetGadgetText(2,"RUN")
RemoveWindowTimer(0,100)
EndIf
;
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 2
If GetGadgetState(2) = 1
SetGadgetText(2,"STOP")
AddWindowTimer(0,100,50)
Else
SetGadgetText(2,"RUN")
RemoveWindowTimer(0,100)
EndIf
EndSelect
EndSelect
Until Quit = 1
End