LazMapViewer: Add MarkerDragPlugin.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9687 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
cc5dd7eb5e
commit
0d5bec125e
@ -144,15 +144,20 @@ type
|
|||||||
TMarkerClickPlugin = class(TMvMarkerPlugin)
|
TMarkerClickPlugin = class(TMvMarkerPlugin)
|
||||||
private
|
private
|
||||||
FCursor: TCursor;
|
FCursor: TCursor;
|
||||||
FSavedCursor: TCursor;
|
|
||||||
FShift: TShiftState;
|
FShift: TShiftState;
|
||||||
FOnCanClick: TMarkerCanClickEvent;
|
FOnCanClick: TMarkerCanClickEvent;
|
||||||
FOnMarkerClick: TMarkerClickEvent;
|
FOnMarkerClick: TMarkerClickEvent;
|
||||||
protected
|
protected
|
||||||
|
FMouseDown: Boolean;
|
||||||
|
FMousePoint: TPoint;
|
||||||
|
FOrigGpsPoint: TGPSPoint;
|
||||||
|
FSavedCursor: TCursor;
|
||||||
procedure MouseDown(AMapView: TMapView; {%H-}Button: TMouseButton;
|
procedure MouseDown(AMapView: TMapView; {%H-}Button: TMouseButton;
|
||||||
AShift: TShiftState; X,Y: Integer; var Handled: Boolean); override;
|
AShift: TShiftState; X,Y: Integer; var Handled: Boolean); override;
|
||||||
procedure MouseMove(AMapView: TMapView; {%H-}AShift: TShiftState;
|
procedure MouseMove(AMapView: TMapView; {%H-}AShift: TShiftState;
|
||||||
X,Y: Integer; var Handled: Boolean); override;
|
X,Y: Integer; var Handled: Boolean); override;
|
||||||
|
procedure MouseUp(AMapView: TMapView; {%H-}Button: TMouseButton;
|
||||||
|
AShift: TShiftState; X,Y: Integer; var Handled: Boolean); override;
|
||||||
procedure SetMapView(AValue: TMapView); override;
|
procedure SetMapView(AValue: TMapView); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
@ -164,6 +169,25 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TMarkerDragPlugin }
|
||||||
|
|
||||||
|
TMarkerDragPlugin = class(TMarkerClickPlugin)
|
||||||
|
private
|
||||||
|
FDragCursor: TCursor;
|
||||||
|
protected
|
||||||
|
procedure MouseDown(AMapView: TMapView; {%H-}Button: TMouseButton;
|
||||||
|
AShift: TShiftState; X,Y: Integer; var Handled: Boolean); override;
|
||||||
|
procedure MouseMove(AMapView: TMapView; {%H-}AShift: TShiftState;
|
||||||
|
X,Y: Integer; var Handled: Boolean); override;
|
||||||
|
procedure MouseUp(AMapView: TMapView; {%H-}Button: TMouseButton;
|
||||||
|
AShift: TShiftState; X,Y: Integer; var Handled: Boolean); override;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
published
|
||||||
|
property DragCursor: TCursor read FDragCursor write FDragCursor default crSizeAll;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TMarkerHintPlugin }
|
{ TMarkerHintPlugin }
|
||||||
|
|
||||||
TMarkerCreateHintWindowEvent = procedure(AMapView: TMapView;
|
TMarkerCreateHintWindowEvent = procedure(AMapView: TMapView;
|
||||||
@ -951,23 +975,25 @@ end;
|
|||||||
procedure TMarkerClickPlugin.MouseDown(AMapView: TMapView; Button: TMouseButton;
|
procedure TMarkerClickPlugin.MouseDown(AMapView: TMapView; Button: TMouseButton;
|
||||||
AShift: TShiftState; X, Y: Integer; var Handled: Boolean);
|
AShift: TShiftState; X, Y: Integer; var Handled: Boolean);
|
||||||
var
|
var
|
||||||
gpsPoint: TGPSPoint;
|
|
||||||
canClick: Boolean;
|
canClick: Boolean;
|
||||||
begin
|
begin
|
||||||
if Handled then
|
if Handled then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
gpsPoint := FindNearestMarker(AMapView, X, Y);
|
FOrigGPSPoint := FindNearestMarker(AMapView, X, Y);
|
||||||
if Assigned(gpsPoint) and Assigned(FOnMarkerClick) and (AShift = FShift) then
|
if Assigned(FOrigGPSPoint) and (AShift = FShift) then
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnCanClick) then
|
if Assigned(FOnCanClick) then
|
||||||
begin
|
begin
|
||||||
canClick := true;
|
canClick := true;
|
||||||
FOnCanClick(AMapView, gpsPoint, canClick);
|
FOnCanClick(AMapView, FOrigGPSPoint, canClick);
|
||||||
if not canClick then
|
if not canClick then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
FOnMarkerClick(AMapView, gpsPoint);
|
if Assigned(FOnMarkerClick) then
|
||||||
|
FOnMarkerClick(AMapView, FOrigGPSPoint);
|
||||||
|
FMouseDown := true;
|
||||||
|
FMousePoint := Point(X, Y);
|
||||||
Handled := true;
|
Handled := true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -991,6 +1017,12 @@ begin
|
|||||||
AMapView.Cursor := IfThen(canClick, FCursor, FSavedCursor);
|
AMapView.Cursor := IfThen(canClick, FCursor, FSavedCursor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMarkerClickPlugin.MouseUp(AMapView: TMapView; Button: TMouseButton;
|
||||||
|
AShift: TShiftState; X, Y: Integer; var Handled: Boolean);
|
||||||
|
begin
|
||||||
|
FMouseDown := false;
|
||||||
|
end;
|
||||||
|
|
||||||
{ Store the original MapView cursor. Is used when the mouse is not over a
|
{ Store the original MapView cursor. Is used when the mouse is not over a
|
||||||
clickable point. If no MapView is assigned to the plugin it is assumed that
|
clickable point. If no MapView is assigned to the plugin it is assumed that
|
||||||
the MapView has the default cursor. }
|
the MapView has the default cursor. }
|
||||||
@ -1004,6 +1036,47 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TMarkerDragPlugin }
|
||||||
|
|
||||||
|
constructor TMarkerDragPlugin.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
FDragCursor := crSizeAll;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMarkerDragPlugin.MouseDown(AMapView: TMapView; {%H-}Button: TMouseButton;
|
||||||
|
AShift: TShiftState; X,Y: Integer; var Handled: Boolean);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if FMouseDown then
|
||||||
|
Handled := true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMarkerDragPlugin.MouseMove(AMapView: TMapView;
|
||||||
|
{%H-}AShift: TShiftState; X,Y: Integer; var Handled: Boolean);
|
||||||
|
var
|
||||||
|
P: TRealPoint;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
|
||||||
|
if FMouseDown then
|
||||||
|
begin
|
||||||
|
AMapView.Cursor := FDragCursor;
|
||||||
|
P := AMapView.ScreenToLatLon(Point(X, Y));
|
||||||
|
FOrigGPSPoint.MoveTo(P.Lon, P.Lat);
|
||||||
|
Update;
|
||||||
|
Handled := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMarkerDragPlugin.MouseUp(AMapView: TMapView; {%H-}Button: TMouseButton;
|
||||||
|
AShift: TShiftState; X,Y: Integer; var Handled: Boolean);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
AMapView.Cursor := FSavedCursor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TMarkerHintPlugin }
|
{ TMarkerHintPlugin }
|
||||||
|
|
||||||
constructor TMarkerHintPlugin.Create(AOwner: TComponent);
|
constructor TMarkerHintPlugin.Create(AOwner: TComponent);
|
||||||
@ -1386,8 +1459,9 @@ initialization
|
|||||||
RegisterPluginClass(TTileInfoPlugin, 'Tile info');
|
RegisterPluginClass(TTileInfoPlugin, 'Tile info');
|
||||||
RegisterPluginClass(TLegalNoticePlugin, 'Legal notice');
|
RegisterPluginClass(TLegalNoticePlugin, 'Legal notice');
|
||||||
RegisterPluginClass(TLinkedMapsPlugin, 'Linked maps');
|
RegisterPluginClass(TLinkedMapsPlugin, 'Linked maps');
|
||||||
RegisterPluginClass(TMarkerClickPlugin, 'Marker click');
|
|
||||||
RegisterPluginClass(TMarkerHintPlugin, 'Marker hint');
|
RegisterPluginClass(TMarkerHintPlugin, 'Marker hint');
|
||||||
|
RegisterPluginClass(TMarkerClickPlugin, 'Marker click');
|
||||||
|
RegisterPluginClass(TMarkerDragPlugin, 'Marker drag');
|
||||||
RegisterPluginClass(TDraggableMarkerPlugin, 'Draggable marker');
|
RegisterPluginClass(TDraggableMarkerPlugin, 'Draggable marker');
|
||||||
RegisterPluginClass(TUserDefinedPlugin, 'User-defined');
|
RegisterPluginClass(TUserDefinedPlugin, 'User-defined');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user