Add SetCallBackMainPointer() to draw your own main pointer

This commit is contained in:
2016-08-04 09:45:14 +02:00
parent cd673bd3ff
commit a851b37ef3

View File

@@ -36,7 +36,8 @@ DeclareModule PBMap
Declare DrawingThread(Null) Declare DrawingThread(Null)
Declare SetZoom(Zoom.i, mode.i = #PB_Relative) Declare SetZoom(Zoom.i, mode.i = #PB_Relative)
Declare ZoomToArea() Declare ZoomToArea()
Declare SetCallBackLocation(*CallBackLocation) Declare SetCallBackLocation(CallBackLocation.i)
Declare SetCallBackMainPointer(CallBackMainPointer.i)
Declare LoadGpxFile(file.s); Declare LoadGpxFile(file.s);
Declare AddMarker(Latitude.d,Longitude.d,color.l=-1, CallBackPointer.i = -1) Declare AddMarker(Latitude.d,Longitude.d,color.l=-1, CallBackPointer.i = -1)
Declare Quit() Declare Quit()
@@ -122,6 +123,7 @@ Module PBMap
Drawing.DrawingParameters ; Drawing parameters based on focus point Drawing.DrawingParameters ; Drawing parameters based on focus point
; ;
CallBackLocation.i ; @Procedure(latitude.d,lontitude.d) CallBackLocation.i ; @Procedure(latitude.d,lontitude.d)
CallBackMainPointer.i ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib)
; ;
Position.PixelPosition ; Actual focus point coords in pixels (global) Position.PixelPosition ; Actual focus point coords in pixels (global)
MoveStartingPoint.PixelPosition ; Start mouse position coords when dragging the map MoveStartingPoint.PixelPosition ; Start mouse position coords when dragging the map
@@ -701,7 +703,12 @@ Module PBMap
DrawTiles(@Drawing) DrawTiles(@Drawing)
DrawTrack(@Drawing) DrawTrack(@Drawing)
DrawMarker(@Drawing) DrawMarker(@Drawing)
Pointer(Drawing\CenterX, Drawing\CenterY, #Red) ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib)
If PBMap\CallBackMainPointer > 0
CallFunctionFast(PBMap\CallBackMainPointer, Drawing\CenterX, Drawing\CenterY)
Else
Pointer(Drawing\CenterX, Drawing\CenterY, #Red)
EndIf
StopVectorDrawing() StopVectorDrawing()
;Redraw ;Redraw
; If something was not correctly drawn, redraw after a while ; If something was not correctly drawn, redraw after a while
@@ -817,6 +824,10 @@ Module PBMap
PBMap\CallBackLocation = CallBackLocation PBMap\CallBackLocation = CallBackLocation
EndProcedure EndProcedure
Procedure SetCallBackMainPointer(CallBackMainPointer.i)
PBMap\CallBackMainPointer = CallBackMainPointer
EndProcedure
Procedure.d GetLatitude() Procedure.d GetLatitude()
Protected Value.d Protected Value.d
LockMutex(PBMap\Drawing\Mutex) LockMutex(PBMap\Drawing\Mutex)
@@ -841,9 +852,6 @@ Module PBMap
ProcedureReturn Value ProcedureReturn Value
EndProcedure EndProcedure
Procedure RefreshMapGadget()
SignalSemaphore(PBMap\Drawing\Semaphore)
EndProcedure
Procedure Event(Event.l) Procedure Event(Event.l)
Protected Gadget.i Protected Gadget.i
@@ -982,6 +990,11 @@ CompilerIf #PB_Compiler_IsMainFile
FillPath(#PB_Path_Preserve):VectorSourceColor(RGBA(0, 0, 0, 255)):StrokePath(1) FillPath(#PB_Path_Preserve):VectorSourceColor(RGBA(0, 0, 0, 255)):StrokePath(1)
EndProcedure EndProcedure
Procedure MainPointer(x.i, y.i)
VectorSourceColor(RGBA(255, 255,255, 255)):AddPathCircle(x, y,32):StrokePath(1)
VectorSourceColor(RGBA(0,0,0, 255)):AddPathCircle(x, y,29):StrokePath(2)
EndProcedure
Procedure ResizeAll() Procedure ResizeAll()
ResizeGadget(#Map,10,10,WindowWidth(#Window_0)-198,WindowHeight(#Window_0)-59) ResizeGadget(#Map,10,10,WindowWidth(#Window_0)-198,WindowHeight(#Window_0)-59)
ResizeGadget(#Text_1,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Text_1,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
@@ -1029,6 +1042,7 @@ CompilerIf #PB_Compiler_IsMainFile
PBMap::InitPBMap() PBMap::InitPBMap()
PBMap::MapGadget(#Map, 10, 10, 512, 512) PBMap::MapGadget(#Map, 10, 10, 512, 512)
PBMap::SetCallBackLocation(@UpdateLocation()) PBMap::SetCallBackLocation(@UpdateLocation())
PBMap::SetCallBackMainPointer(@MainPointer()) ;To change the Main Pointer
PBMap::SetLocation(49.04599, 2.03347, 17) PBMap::SetLocation(49.04599, 2.03347, 17)
PBMap::AddMarker(49.0446828398, 2.0349812508, -1, @MyPointer()) PBMap::AddMarker(49.0446828398, 2.0349812508, -1, @MyPointer())
@@ -1068,8 +1082,8 @@ CompilerIf #PB_Compiler_IsMainFile
CompilerEndIf CompilerEndIf
; IDE Options = PureBasic 5.50 (Windows - x86) ; IDE Options = PureBasic 5.50 (Windows - x86)
; CursorPosition = 860 ; CursorPosition = 994
; FirstLine = 847 ; FirstLine = 969
; Folding = --------- ; Folding = ---------
; EnableThread ; EnableThread
; EnableXP ; EnableXP