diff --git a/components/lazmapviewer/source/addons/plugins/mvplugins.pas b/components/lazmapviewer/source/addons/plugins/mvplugins.pas index 30e31cca8..3c28bd3c6 100644 --- a/components/lazmapviewer/source/addons/plugins/mvplugins.pas +++ b/components/lazmapviewer/source/addons/plugins/mvplugins.pas @@ -127,6 +127,10 @@ type end; type + TMvPluginGPSItemsModifiedEvent = procedure (Sender: TObject; AMapView: TMapView; + ChangedList: TGPSObjectList; ActualObjs: TGPSObjList; Adding: Boolean; + var Handled: Boolean) of Object; + TMvPluginNotifyEvent = procedure (Sender : TObject; AMapView: TMapView; var Handled: Boolean) of Object; @@ -139,9 +143,8 @@ type TMvPluginMouseWheelEvent = procedure (Sender: TObject; AMapView: TMapView; AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint; var Handled: Boolean) of object; - TMvPluginGPSItemsModifiedEvent = procedure (Sender: TObject; AMapView: TMapView; - ChangedList: TGPSObjectList; ActualObjs: TGPSObjList; Adding: Boolean; - var Handled: Boolean) of Object; + TMvPluginZoomChangingEvent = procedure (Sender: TObject; AMapView: TMapView; + NewZoom: Integer; var Allow, Handled: Boolean) of object; { TUserDefinedPlugin } @@ -159,6 +162,7 @@ type FMouseUpEvent : TMvPluginMouseEvent; FMouseWheelEvent : TMvPluginMouseWheelEvent; FZoomChangeEvent : TMvPluginNotifyEvent; + FZoomChangingEvent : TMvPluginZoomChangingEvent; protected procedure AfterDrawObjects(AMapView: TMapView; var Handled: Boolean); override; procedure AfterPaint(AMapView: TMapView; var Handled: Boolean); override; @@ -177,6 +181,7 @@ type procedure MouseWheel(AMapView: TMapView; AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint; var Handled: Boolean); override; procedure ZoomChange(AMapView: TMapView; var Handled: Boolean); override; + procedure ZoomChanging(AMapView: TMapView; NewZoom: Integer; var Allow, Handled: Boolean); override; public published property OnAfterDrawObjects : TMvPluginNotifyEvent read FAfterDrawObjectsEvent write FAfterDrawObjectsEvent; @@ -191,6 +196,7 @@ type property OnMouseUp : TMvPluginMouseEvent read FMouseUpEvent write FMouseUpEvent; property OnMouseWheel : TMvPluginMouseWheelEvent read FMouseWheelEvent write FMouseWheelEvent; property OnZoomChange : TMvPluginNotifyEvent read FZoomChangeEvent write FZoomChangeEvent; + property OnZoomChanging: TMvPluginZoomChangingEvent read FZoomChangingEvent write FZoomChangingEvent; // inherited property Enabled; @@ -657,11 +663,19 @@ begin FCenterMoveEvent(Self, AMapView, Handled); end; +procedure TUserDefinedPlugin.GPSItemsModified(AMapView: TMapView; + ChangedList: TGPSObjectList; ActualObjs: TGPSObjList; Adding: Boolean; + var Handled: Boolean); +begin + if Assigned(FGPSItemsModifiedEvent) then + FGPSItemsModifiedEvent(Self, AMapView, ChangedList, ActualObjs, Adding, Handled); +end; + procedure TUserDefinedPlugin.MouseDown(AMapView: TMapView; Button: TMouseButton; Shift: TShiftState; X, Y: Integer; var Handled: Boolean); begin if Assigned(FMouseDownEvent) then - FMouseDownEvent(Self,AMapView, Button, Shift, X,Y, Handled); + FMouseDownEvent(Self, AMapView, Button, Shift, X,Y, Handled); end; procedure TUserDefinedPlugin.MouseEnter(AMapView: TMapView; var Handled: Boolean); @@ -703,12 +717,11 @@ begin FZoomChangeEvent(Self, AMapView, Handled); end; -procedure TUserDefinedPlugin.GPSItemsModified(AMapView: TMapView; - ChangedList: TGPSObjectList; ActualObjs: TGPSObjList; Adding: Boolean; - var Handled: Boolean); +procedure TUserDefinedPlugin.ZoomChanging(AMapView: TMapView; NewZoom: Integer; + var Allow, Handled: Boolean); begin - if Assigned(FGPSItemsModifiedEvent) then - FGPSItemsModifiedEvent(Self,AMapView, ChangedList, ActualObjs, Adding, Handled); + if Assigned(FZoomChangingEvent) then + FZoomChangingEvent(Self, AMapView, NewZoom, Allow, Handled); end; diff --git a/components/lazmapviewer/source/mvmapviewer.pas b/components/lazmapviewer/source/mvmapviewer.pas index e6a757752..cf2d5d560 100644 --- a/components/lazmapviewer/source/mvmapviewer.pas +++ b/components/lazmapviewer/source/mvmapviewer.pas @@ -456,6 +456,7 @@ type function MouseWheel(AMapView: TMapView; AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean; virtual; function ZoomChange(AMapView: TMapView): Boolean; virtual; + function ZoomChanging(AMapView: TMapView; NewZoom: Integer; var Allow: Boolean): Boolean; virtual; public end; @@ -497,6 +498,7 @@ type FZoomMin: Integer; FOnCenterMove: TNotifyEvent; FOnZoomChange: TNotifyEvent; + FOnZoomChanging: TZoomChangingEvent; FBeforeDrawObjectsEvent: TNotifyEvent; FAfterDrawObjectsEvent: TNotifyEvent; FAfterPaintEvent: TNotifyEvent; @@ -522,7 +524,7 @@ type function GetOnCenterMoving: TCenterMovingEvent; function GetOnChange: TNotifyEvent; // function GetOnZoomChange: TNotifyEvent; - function GetOnZoomChanging: TZoomChangingEvent; +// function GetOnZoomChanging: TZoomChangingEvent; function GetUseThreads: boolean; function GetZoom: integer; function GetZoomToCursor: Boolean; @@ -551,7 +553,7 @@ type procedure SetOnCenterMoving(AValue: TCenterMovingEvent); procedure SetOnChange(AValue: TNotifyEvent); // procedure SetOnZoomChange(AValue: TNotifyEvent); - procedure SetOnZoomChanging(AValue: TZoomChangingEvent); +// procedure SetOnZoomChanging(AValue: TZoomChangingEvent); procedure SetOptions(AValue: TMapViewOptions); procedure SetPluginManager(AValue: TMvCustomPluginManager); procedure SetPOIImage(const AValue: TCustomBitmap); @@ -580,6 +582,7 @@ type MousePos: TPoint): Boolean; override; procedure DoOnResize; override; procedure DoZoomChange(Sender: TObject); + procedure DoZoomChanging(Sender: TObject; NewZoom: Integer; var Allow: Boolean); function FindObjsAtScreenPt(X, Y: Integer; ATolerance: Integer; AVisibleOnly: Boolean): TGPSObjArray; function IsActive: Boolean; inline; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; @@ -695,8 +698,8 @@ type property OnBeforeDrawObjects: TNotifyEvent read FBeforeDrawObjectsEvent write FBeforeDrawObjectsEvent; property OnCenterMove: TNotifyEvent read {Get}FOnCenterMove write {Set}FOnCenterMove; property OnCenterMoving: TCenterMovingEvent read GetOnCenterMoving write SetOnCenterMoving; - property OnZoomChange: TNotifyEvent read {Get}FOnZoomChange write {Set}FOnZoomChange; - property OnZoomChanging: TZoomChangingEvent read GetOnZoomChanging write SetOnZoomChanging; + property OnZoomChange: TNotifyEvent read FOnZoomChange write FOnZoomChange; + property OnZoomChanging: TZoomChangingEvent read FOnZoomChanging write FOnZoomChanging; property OnChange: TNotifyEvent read GetOnChange write SetOnChange; property OnDrawGpsPoint: TDrawGpsPointEvent read FOnDrawGpsPoint write FOnDrawGpsPoint; property OnEditSelectionCompleted: TNotifyEvent read FOnEditSelectionCompleted write FOnEditSelectionCompleted; @@ -2218,6 +2221,13 @@ begin FOnZoomChange(Self); end; +procedure TMapView.DoZoomChanging(Sender: TObject; NewZoom: Integer; var Allow: Boolean); +begin + GetPluginManager.ZoomChanging(Self, NewZoom, Allow); + if Assigned(FOnZoomChanging) then + FOnZoomChanging(Self, NewZoom, Allow); +end; + function TMapView.GetOnChange: TNotifyEvent; begin Result := Engine.OnChange; @@ -2228,12 +2238,12 @@ function TMapView.GetOnZoomChange: TNotifyEvent; begin Result := Engine.OnZoomChange; end; -} function TMapView.GetOnZoomChanging: TZoomChangingEvent; begin Result := Engine.OnZoomChanging; end; +} function TMapView.GetUseThreads: boolean; begin @@ -2410,12 +2420,12 @@ begin FOnZoomChange := AValue; Engine.OnZoomChange := @DoZoomChangeHandler; end; - } + procedure TMapView.SetOnZoomChanging(AValue: TZoomChangingEvent); begin Engine.OnZoomChanging := AValue; end; - + } procedure TMapView.SetOptions(AValue: TMapViewOptions); begin if FOptions = AValue then Exit; @@ -3317,6 +3327,7 @@ begin FEngine.OnEraseBackground := @DoEraseBackground; FEngine.OnTileDownloaded := @DoTileDownloaded; FEngine.OnZoomChange := @DoZoomChange; + FEngine.OnZoomChanging := @DoZoomChanging; FEngine.DrawPreviewTiles := True; FEngine.DrawTitleInGuiThread := false; FEngine.DownloadEngine := FBuiltinDownloadEngine; @@ -4469,5 +4480,12 @@ begin Result := false; end; +function TMvCustomPluginManager.ZoomChanging(AMapView: TMapView; + NewZoom: Integer; var Allow: Boolean): Boolean; +begin + Unused(AMapView, NewZoom, Allow); + Result := False; +end; + end. diff --git a/components/lazmapviewer/source/mvplugincore.pas b/components/lazmapviewer/source/mvplugincore.pas index 8b6bc0075..03fd46252 100644 --- a/components/lazmapviewer/source/mvplugincore.pas +++ b/components/lazmapviewer/source/mvplugincore.pas @@ -62,7 +62,7 @@ type procedure MouseWheel(AMapView: TMapView; AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint; var Handled: Boolean); virtual; procedure ZoomChange(AMapView: TMapView; var Handled: Boolean); virtual; - // procedure ZoomChanging(AMapView: TMapView; NewZoom: Integer; var Allow, Handled: Boolean); virtual; + procedure ZoomChanging(AMapView: TMapView; NewZoom: Integer; var Allow, Handled: Boolean); virtual; protected property MapView: TMapView read FMapView write SetMapView; property Enabled: Boolean read FEnabled write SetEnabled default true; @@ -196,7 +196,7 @@ type function MouseWheel(AMapView: TMapView; AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean; override; function ZoomChange(AMapView: TMapView): Boolean; override; -// procedure ZoomChanging(AMapView: TMapView; NewZoom: Integer; var Allow: Boolean; AMapEvent); override; + function ZoomChanging(AMapView: TMapView; NewZoom: Integer; var Allow: Boolean): Boolean; override; public constructor Create(AOwner: TComponent); override; @@ -424,12 +424,12 @@ begin Unused(AMapView, Handled); end; -{ procedure TMvCustomPlugin.ZoomChanging(AMapView: TMapView; NewZoom: Integer; var Allow, Handled: Boolean); begin + Unused(AMapView, Handled); + Unused(NewZoom, Allow); end; -} { TMvDrawPlugin } @@ -931,24 +931,20 @@ begin end; end; - (* -procedure TMvPluginManager.ZoomChanging(AMapView: TMapView; NewZoom: Integer; - var Allow: Boolean; AMapEvent: TNotifyEvent); +function TMvPluginManager.ZoomChanging(AMapView: TMapView; NewZoom: Integer; + var Allow: Boolean): Boolean; var i: Integer; - handled: Boolean; - plugin: TMvPlugin; + plugin: TMvCustomPlugin; begin - handled := false; + Result := false; for i := 0 to FPluginList.Count-1 do begin plugin := Item[i]; if HandlePlugin(plugin, AMapView) then - plugin.ZoomChanging(AMapView, NewZoom, Allow, handled); + plugin.ZoomChanging(AMapView, NewZoom, Allow, Result); end; - if not handled then - inherited ZoomChanging(AMapView, NewZoom, Allow, AMapEvent); -end; *) +end; { Plugin registration }