Use LMB CMB and RMB to see how changes the mouse buttons.
I hope you enjoy this.
Greetings!!
Code: Select all
DeclareModule gvl
Global.i font= LoadFont(#PB_Any,"Arial",8,#PB_Font_HighQuality)
Declare vPathRoundBox(x.i,y.i,w.i,h.i,ti.l,cr.d=-1)
Declare vPathPildora(x.i,y.i,w.i,h.i,ti.l)
Declare vDrawMouse(x.i,y.i,w.i,h.i,ti.l,tisel.l,boton.b=0,linea.b=4, mode.b=0, fill.b=0)
Declare vClock(x.i,y.i,w.i, hora.s="", mdate.i=-1, ti.l=$ff000000, tisel.l=$ff0000ff, linea.b=2, borde.l=$ffffffff)
EndDeclareModule
Module gvl
Procedure vPathRoundBox(x.i,y.i,w.i,h.i,ti.l,cr.d=-1)
; Protected.d cr
VectorSourceColor(ti)
If cr=-1
cr= w*0.25
If w>h
cr= h*0.25
EndIf
EndIf
AddPathCircle(cr+x,cr+y,cr,180,270);lt
AddPathCircle(w-cr+x,cr+y,cr,270,0, #PB_Path_Connected);rt
AddPathCircle(w-cr+x,h-cr+y,cr,0,90, #PB_Path_Connected);rb
AddPathCircle(cr+x,h-cr+y,cr,90,180, #PB_Path_Connected);lb
AddPathLine(x,cr+y)
EndProcedure
Procedure vPathPildora(x.i,y.i,w.i,h.i,ti.l)
Protected.i cy
VectorSourceColor(ti)
If w>h
cy= h*0.5
AddPathCircle(cx+x,cy+y,cy,90,270);, #PB_Path_CounterClockwise)
AddPathCircle(w-cy+x,cy+y,cy,270,90, #PB_Path_Connected)
AddPathLine((cx*2)+x,cy*2+y)
Else
cy= w*0.5
AddPathCircle(cx+x,cy+y,cy,180,0);, #PB_Path_CounterClockwise)
AddPathCircle(cx+x,h-cy+y,cy,0,180, #PB_Path_Connected)
AddPathLine(x-cy,cy+y)
EndIf
EndProcedure
Procedure vDrawMouse(x.i,y.i,w.i,h.i,ti.l,tisel.l,boton.b=0,linea.b=4, mode.b=0, fill.b=0)
Protected.d pw= w/21
Protected.d ph= w/21
Protected.l b1,b2,b3
vPathRoundBox(x,y, w,h, RGBA(Red(ti),Green(ti),Blue(ti),50) )
If fill
FillPath()
Else
StrokePath(linea)
EndIf
vPathRoundBox(x,y, w,h, ti )
StrokePath(linea)
Select boton
Case 0
b1= ti
b2= ti
b3= ti
Case 1
b1= tisel
b2= ti
b3= ti
Case 2
b1= ti
b2= tisel
b3= ti
Case 3
b1= ti
b2= ti
b3= tisel
EndSelect
If mode= 0
vPathRoundBox(x+pw*2,y+ph*2, pw*6,ph*8, b1 )
StrokePath(linea)
vPathRoundBox(x+pw*9.5,y+ph*2, pw*2,ph*8, b2 )
StrokePath(linea)
vPathRoundBox(x+pw*13,y+ph*2, pw*6,ph*8, b3 )
StrokePath(linea)
Else
Select boton
Case 0
vPathRoundBox(x+pw*2,y+ph*2, pw*6,ph*8, b1 )
StrokePath(linea)
vPathRoundBox(x+pw*9.5,y+ph*2, pw*2,ph*8, b2 )
StrokePath(linea)
vPathRoundBox(x+pw*13,y+ph*2, pw*6,ph*8, b3 )
StrokePath(linea)
Case 1
vPathRoundBox(x+pw*2,y+ph*2, pw*6,ph*8, b1 )
FillPath()
vPathRoundBox(x+pw*9.5,y+ph*2, pw*2,ph*8, b2 )
StrokePath(linea)
vPathRoundBox(x+pw*13,y+ph*2, pw*6,ph*8, b3 )
StrokePath(linea)
Case 2
vPathRoundBox(x+pw*2,y+ph*2, pw*6,ph*8, b1 )
StrokePath(linea)
vPathRoundBox(x+pw*9.5,y+ph*2, pw*2,ph*8, b2 )
FillPath()
vPathRoundBox(x+pw*13,y+ph*2, pw*6,ph*8, b3 )
StrokePath(linea)
Case 3
vPathRoundBox(x+pw*2,y+ph*2, pw*6,ph*8, b1 )
StrokePath(linea)
vPathRoundBox(x+pw*9.5,y+ph*2, pw*2,ph*8, b2 )
StrokePath(linea)
vPathRoundBox(x+pw*13,y+ph*2, pw*6,ph*8, b3 )
FillPath()
EndSelect
EndIf
EndProcedure
Procedure vClock(x.i,y.i,w.i, hora.s="", mdate.i=-1, ti.l=$ff000000, tisel.l=$ff0000ff, linea.b=2, borde.l=$ffffffff)
Protected.d mw= w/2
Protected.d xc= x+mw
Protected.d yc= y+mw
Protected.d nx,ny,a
Protected.a h= Val(Mid(hora,1,2))
Protected.a m= Val(Mid(hora,4,2))
Protected.a s= Val(Mid(hora,7,2))
If mdate>-1
h=Hour(mdate)
m=Minute(mdate)
s=Second(mdate)
hora= FormatDate("%hh:%ii:%ss",mdate)
EndIf
; VectorSourceColor(ti)
; MovePathCursor(xc,yc)
; AddPathCircle(xc,yc,mw)
; StrokePath(linea)
vPathRoundBox(x,y,w,w,ti)
StrokePath(linea)
For p=0 To 360 Step 30
a= Radian((p)-90)
nx= xc+(Cos(a)*(mw*0.90))
ny= yc+(Sin(a)*(mw*0.90))
MovePathCursor(nx,ny)
nx= xc+(Cos(a)*mw)
ny= yc+(Sin(a)*mw)
AddPathLine(nx,ny)
StrokePath(linea)
Next p
VectorSourceColor(tisel)
;hora
a= Radian((h*30)-90)
nx= xc+(Cos(a)*(mw*0.65))
ny= yc+(Sin(a)*(mw*0.65))
MovePathCursor(xc,yc)
AddPathLine(nx,ny)
StrokePath(linea+2)
VectorSourceColor(ti)
;minuto
a= Radian((m*6)-90)
nx= xc+(Cos(a)*(mw*0.75))
ny= yc+(Sin(a)*(mw*0.65))
MovePathCursor(xc,yc)
AddPathLine(nx,ny)
StrokePath(linea+1)
;segundo
If Len(hora)>5
a= Radian((s*6)-90)
nx= xc+(Cos(a)*(mw*0.85))
ny= yc+(Sin(a)*(mw*0.65))
MovePathCursor(xc,yc)
AddPathLine(nx,ny)
StrokePath(1)
EndIf
VectorSourceColor(borde)
VectorFont(FontID(font), w*0.2)
MovePathCursor(xc-(VectorTextWidth(hora)/2),y+w*0.7)
AddPathText(hora)
StrokePath(3)
VectorSourceColor(tisel)
MovePathCursor(xc-(VectorTextWidth(hora)/2),y+w*0.7)
AddPathText(hora)
FillPath()
EndProcedure
EndModule
CompilerIf #PB_Compiler_IsMainFile
;----DEMO By minimy 2021
OpenWindow(0,0,0,1200,650,"opss!!",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
gadget= CanvasGadget(#PB_Any,0,0,WindowWidth(0),WindowHeight(0))
StartVectorDrawing(CanvasVectorOutput(gadget))
;fondo
VectorSourceColor(RGBA(255,255,255,255))
VectorSourceColor($ffeeeeee)
FillVectorOutput()
gvl::vPathPildora(400,10, 200,50, RGBA(200,0,0,255) )
FillPath()
gvl::vPathPildora(400,70, 200,50, RGBA(200,0,0,255) )
StrokePath(4)
gvl::vPathPildora(400,130, 200,50, RGBA(200,0,0,255) )
DashPath(4,16)
gvl::vPathPildora(450,200, 50,200, RGBA(200,0,0,255) )
FillPath()
gvl::vPathPildora(520,200, 50,200, RGBA(200,0,0,255) )
StrokePath(4)
gvl::vPathPildora(590,200, 50,200, RGBA(200,0,0,255) )
DashPath(4,16)
gvl::vClock(10,420,80,"",Date()-10, $ff000000,$ff0000ff, 2,#True)
gvl::vClock(120,420,180,"15:40")
gvl::vDrawMouse(640,70, 100,150, RGBA(0,0,255,255), RGBA(255,0,0,255) ,0, 1)
gvl::vDrawMouse(780,70, 100,150, RGBA(0,0,255,255), RGBA(255,0,0,255) ,2, 1, 0, 1)
gvl::vDrawMouse(640,270, 100,150, RGBA(0,0,255,255), RGBA(255,0,0,255) ,1, 1, 1)
gvl::vDrawMouse(780,270, 200,300, RGBA(0,0,255,255), RGBA(255,0,0,255) ,3, 1, 1, 1)
StopVectorDrawing()
Repeat
Event= WindowEvent()
Select Event
Case #PB_Event_Timer
Case #PB_Event_Gadget
EventGadget= EventGadget()
EventType= EventType()
If EventGadget= gadget
Select EventType
Case #PB_EventType_LeftButtonDown
btn=1
d=1
Case #PB_EventType_LeftButtonUp
btn=0
d=1
Case #PB_EventType_MiddleButtonDown
btn=2
d=1
Case #PB_EventType_MiddleButtonUp
btn=0
d=1
Case #PB_EventType_RightButtonDown
btn=3
d=1
Case #PB_EventType_RightButtonUp
btn=0
d=1
EndSelect
If d
StartVectorDrawing(CanvasVectorOutput(gadget))
VectorSourceColor($ffffffff)
AddPathBox(640,70, 100,150)
FillPath()
gvl::vDrawMouse(640,70, 100,150, RGBA(0,0,255,255), RGBA(255,0,0,255) ,btn, 1,1)
VectorSourceColor($ffffffff)
AddPathBox(780,270, 200,300)
FillPath()
gvl::vDrawMouse(780,270, 200,300, RGBA(0,0,255,255), RGBA(255,0,0,255) ,btn, 1, 1, 1)
StopVectorDrawing()
EndIf
EndIf
Case #PB_Event_CloseWindow
Break
Default
EndSelect
Delay(5)
ForEver
CompilerEndIf