Progress Circle
Posted: Sat Dec 15, 2007 6:26 am
I was playing around in PB and came up with this.
Feel free to modify, more cosmetics could be made.
Have Fun 
Feel free to modify, more cosmetics could be made.
Code: Select all
;
; Progress Circle by Electrochisso, Use as you wish, PB4
;
Global PCimage,hWnd,gWnd
Procedure ProgressCircleInit(WindowTitle$,MiddleX,MiddleY)
PCimage = CreateImage(#PB_Any,MiddleX*2,MiddleY*2)
hWnd = OpenWindow(#PB_Any,0,0,MiddleX*2,MiddleY*2,WindowTitle$,#PB_Window_WindowCentered)
CreateGadgetList(WindowID(hWnd))
gWnd = ImageGadget(#PB_Any,0,0,MiddleX*2,MiddleY*2,ImageID(PCimage))
EndProcedure
Procedure ProgressCircle(grad,MiddleX,MiddleY,Radius,PCimage,gWnd,IC,Gap,C1,C2,C3,C4,C5,C6)
StartDrawing(ImageOutput(PCimage))
Box(0,0,MiddleX*2,MiddleY*2,C1)
Circle(MiddleX,MiddleY,Radius+1,C2)
LineXY(MiddleX,MiddleY,MiddleX+Sin(grad*(2*3.14159265/360))*Radius,MiddleY+Cos(grad*(2*3.14159265/360))*Radius, C3)
If IC > 0
Circle(MiddleX,MiddleY,Radius-Gap,C4)
EndIf
a.f=(grad/360)*100
DrawText(MiddleX-8,MiddleY-6,RSet(Str(99-a),2,"0"),C5,C6)
StopDrawing()
SetGadgetState(gWnd,ImageID(PCimage))
;Delay(1)
WaitWindowEvent(1)
EndProcedure
If OpenWindow(0,0,0,320,240,"Progress Circle Demo",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ButtonGadget(0,5,5,WindowWidth(0)-10,20,"Press here for Progress Demo 1")
ButtonGadget(1,5,30,WindowWidth(0)-10,20,"Press here for Progress Demo 2")
Else
End
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
If EventGadget() = 0 ;Progress Demo 1
PCwidth=60 : PCheight=60 : InnerCircle=0 : Gap=0
;The order of the colors are: Background, Outer Circle, Dial, Inner Circle, Text Foreground, Text Background
ProgressCircleInit("Progress Demo 1",PCwidth,PCheight)
For Loop = 1 To 200 Step 1 ;Progress Simulation
Count.f = (Loop/200)*360 ;Make the count fit into a max of 360
ProgressCircle(360-Count,PCwidth,PCheight,PCwidth-2,PCimage,gWnd,InnerCircle,Gap,$0000FF,$00FF00,0,$00FFFF,$FF0000,$00FF00)
Next ; You can move anticlockwise by removing the 360- for the Count value
CloseWindow(hWnd)
EndIf
If EventGadget() = 1 ;Progress Demo 2
PCwidth=120 : PCheight=120 : InnerCircle=1 : Gap=10
;The order of the colors are: Background, Outer Circle, Dial, Inner Circle, Text Foreground, Text Background
ProgressCircleInit("Progress Demo 2",PCwidth,PCheight)
For Loop = 1 To 200 Step 1 ;Progress Simulation
Count.f = (Loop/200)*360 ;Make the count fit into a max of 360
ProgressCircle(Count,PCwidth,PCheight,PCwidth-2,PCimage,gWnd,InnerCircle,Gap,$BBBBBB,$B3A84C,$FFFFFF,$0483FB,$FF0000,$99FF99)
Next ; You can move clockwise by placing the 360- before the Count value
CloseWindow(hWnd)
EndIf
EndSelect
Until WindowEvent() = #PB_Event_CloseWindow
EndIf
End
