{ 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; 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; begin Inst := GetComponent(0); Providers := TStringList.Create; try if Inst is TMapView then MV := TMapView(Inst) else if Inst is TMapLayer then MV := TMapLayer(Inst).MapView else Exit; MV.Engine.GetMapProviders(Providers); if not (Inst is TMapView) then Proc(NONE); Providers.Sort; for S in Providers do 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.