From 853503a11f048da82c22aea719005ab1a1b68c30 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 4 Jan 2025 21:12:05 +0000 Subject: [PATCH] LazMapViewer: Rename TPluginManager.Item[] to .Items[]. Add properties .Count, .MapViewCount and .MapViews[]. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9563 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../source/addons/plugins/mvplugins.pas | 8 +-- .../lazmapviewer/source/mvplugincore.pas | 63 ++++++++++++------- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/components/lazmapviewer/source/addons/plugins/mvplugins.pas b/components/lazmapviewer/source/addons/plugins/mvplugins.pas index 7685d6cf3..8cfdf889d 100644 --- a/components/lazmapviewer/source/addons/plugins/mvplugins.pas +++ b/components/lazmapviewer/source/addons/plugins/mvplugins.pas @@ -289,9 +289,9 @@ begin exit; inc(FLocked); try - for i := 0 to PluginManager.MapList.Count-1 do + for i := 0 to PluginManager.MapViewCount-1 do begin - map := TMapView(PluginManager.MapList[i]); + map := PluginManager.MapViews[i]; if AMapView <> map then map.Center := AMapView.Center; end; @@ -310,9 +310,9 @@ begin exit; inc(FLocked); try - for i := 0 to PluginManager.MapList.Count-1 do + for i := 0 to PluginManager.MapViewCount-1 do begin - map := TMapView(PluginManager.MapList[i]); + map := PluginManager.MapViews[i]; if AMapView <> map then begin zoomToCrs := map.ZoomToCursor; diff --git a/components/lazmapviewer/source/mvplugincore.pas b/components/lazmapviewer/source/mvplugincore.pas index 9af9f28fb..9394b6729 100644 --- a/components/lazmapviewer/source/mvplugincore.pas +++ b/components/lazmapviewer/source/mvplugincore.pas @@ -216,7 +216,10 @@ type private FPluginList: TMvPluginList; FMapList: TFPList; - function GetItem(AIndex: Integer): TMvCustomPlugin; + function GetCount: Integer; + function GetItems(AIndex: Integer): TMvCustomPlugin; + function GetMapViewCount: Integer; + function GetMapViews(AIndex: Integer): TMapView; protected procedure AddMapView(AMapView: TMapView); override; function HandlePlugin(APlugin: TMvCustomPlugin; AMapView: TMapView): Boolean; @@ -255,8 +258,11 @@ type destructor Destroy; override; procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override; procedure SetChildOrder(Child: TComponent; Order: Integer); override; - property Item[AIndex: Integer]: TMvCustomPlugin read GetItem; default; - property MapList: TFPList read FMapList; + property Count: Integer read GetCount; + property Items[AIndex: Integer]: TMvCustomPlugin read GetItems; default; + property MapViews[AIndex: Integer]: TMapView read GetMapViews; + property MapViewCount: Integer read GetMapViewCount; +// property MapList: TFPList read FMapList; published property PluginList: TMvPluginList read FPluginList; end; @@ -888,7 +894,7 @@ begin Result := False; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.AfterDrawObjects(AMapView, Result); end; @@ -902,7 +908,7 @@ begin Result := False; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.AfterPaint(AMapView, Result); end; @@ -916,7 +922,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.BeforeDrawObjects(AMapView, Result); end; @@ -930,7 +936,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.CenterMove(AMapView, Result); end; @@ -945,7 +951,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.CenterMoving(AMapView, NewCenter, Allow, Result); end; @@ -960,7 +966,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.DrawGPSPoint(AMapView, ADrawingEngine, APoint, Result); end; @@ -975,7 +981,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.DrawMissingTile(AMapView, ADrawingEngine, ATileID, ARect, Result); end; @@ -988,17 +994,32 @@ var begin for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if plugin.Owner = Root then Proc(plugin); end; end; -function TMvPluginManager.GetItem(AIndex: Integer): TMvCustomPlugin; +function TMvPluginManager.GetCount: Integer; +begin + Result := FPluginList.Count; +end; + +function TMvPluginManager.GetItems(AIndex: Integer): TMvCustomPlugin; begin Result := TMvCustomPlugin(FPluginList.Items[AIndex]); end; +function TMvPluginManager.GetMapViewCount: Integer; +begin + Result := FMapList.Count; +end; + +function TMvPluginManager.GetMapViews(AIndex: Integer): TMapView; +begin + Result := TMapView(FMapList[AIndex]); +end; + function TMvPluginManager.GPSItemsModified(AMapView: TMapView; ModifiedList: TGPSObjectList; ActualObjs: TGPSObjList; Adding: Boolean): Boolean; var @@ -1008,7 +1029,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.GPSItemsModified(AMapView, ModifiedList, ActualObjs, Adding, Result); end; @@ -1037,7 +1058,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.MouseDown(AMapView, AButton, AShift, X, Y, Result); end; @@ -1051,7 +1072,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.MouseEnter(AMapView, Result); end; @@ -1065,7 +1086,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.MouseLeave(AMapView, Result); end; @@ -1080,7 +1101,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.MouseMove(AMapView, AShift, X, Y, Result); end; @@ -1095,7 +1116,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.MouseUp(AMapView, AButton, AShift, X, Y, Result); end; @@ -1110,7 +1131,7 @@ begin Result := False; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.MouseWheel(AMapView, AShift, AWheelDelta, AMousePos, Result); end; @@ -1160,7 +1181,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.ZoomChange(AMapView, Result); end; @@ -1175,7 +1196,7 @@ begin Result := false; for i := 0 to FPluginList.Count-1 do begin - plugin := Item[i]; + plugin := Items[i]; if HandlePlugin(plugin, AMapView) then plugin.ZoomChanging(AMapView, NewZoom, Allow, Result); end;