
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9232 8e941d3f-bd1b-0410-a28a-d453659cc2b4
110 lines
2.4 KiB
ObjectPascal
110 lines
2.4 KiB
ObjectPascal
{
|
|
Property editors for LazMapViewer
|
|
Copyright (C) 2019 user alpine at Lazarus forum https://forum.lazarus.freepascal.org
|
|
|
|
License: modified LGPL with linking exception (like RTL, FCL and LCL)
|
|
|
|
See the file COPYING.modifiedLGPL.txt, included in the Lazarus distribution,
|
|
for details about the license.
|
|
|
|
See also: https://wiki.lazarus.freepascal.org/FPC_modified_LGPL
|
|
}
|
|
unit
|
|
mvMapViewerPropEdits;
|
|
|
|
{$mode ObjFPC}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, PropEdits, mvMapProvider;
|
|
|
|
type
|
|
{ TMapProviderPropertyEditor }
|
|
|
|
TMapProviderPropertyEditor = class(TStringPropertyEditor)
|
|
public
|
|
function GetAttributes: TPropertyAttributes; override;
|
|
procedure GetValues(Proc: TGetStrProc); override;
|
|
function GetValue: AnsiString; override;
|
|
procedure SetValue(const NewValue: AnsiString); override;
|
|
end;
|
|
|
|
procedure Register;
|
|
|
|
implementation
|
|
|
|
uses
|
|
mvMapViewer;
|
|
|
|
const
|
|
NONE = '(none)';
|
|
|
|
{ TMapProviderPropertyEditor }
|
|
|
|
function TMapProviderPropertyEditor.GetAttributes: TPropertyAttributes;
|
|
begin
|
|
Result := [paValueList, paPickList, paRevertable];
|
|
end;
|
|
|
|
procedure TMapProviderPropertyEditor.GetValues(Proc: TGetStrProc);
|
|
var
|
|
Providers: TStringList;
|
|
S: String;
|
|
Inst: TPersistent;
|
|
MV: TMapView;
|
|
Filter: Boolean = False;
|
|
PT: TProjectionType;
|
|
begin
|
|
Inst := GetComponent(0);
|
|
Providers := TStringList.Create;
|
|
try
|
|
if Inst is TMapView then
|
|
MV := TMapView(Inst)
|
|
else if Inst is TMapLayer then
|
|
begin
|
|
MV := TMapLayer(Inst).MapView;
|
|
Filter := True;
|
|
PT := MV.Engine.MapProjectionType;
|
|
end
|
|
else
|
|
Exit;
|
|
MV.Engine.GetMapProviders(Providers);
|
|
//if not (Inst is TMapView) then
|
|
Proc(NONE);
|
|
Providers.Sort;
|
|
for S in Providers do
|
|
// TODO: When filtered it is not clear what is the full list.
|
|
//if not Filter or (PT = MV.Engine.MapProviderByName(S).ProjectionType) then
|
|
Proc(S);
|
|
finally
|
|
Providers.Free;
|
|
end;
|
|
end;
|
|
|
|
function TMapProviderPropertyEditor.GetValue: AnsiString;
|
|
begin
|
|
Result := inherited GetValue;
|
|
if Result = '' then
|
|
Result := NONE;
|
|
end;
|
|
|
|
procedure TMapProviderPropertyEditor.SetValue(const NewValue: AnsiString);
|
|
begin
|
|
if NewValue = NONE
|
|
then inherited SetValue('')
|
|
else inherited SetValue(NewValue);
|
|
end;
|
|
|
|
procedure Register;
|
|
begin
|
|
RegisterPropertyEditor(TypeInfo(String),
|
|
TMapView,'MapProvider',TMapProviderPropertyEditor);
|
|
RegisterPropertyEditor(TypeInfo(String),
|
|
TMapLayer,'MapProvider',TMapProviderPropertyEditor);
|
|
end;
|
|
|
|
|
|
end.
|
|
|