{*************************************************************************}
{                                                                         }
{ written by TMS Software                                                 }
{           copyright ©  2013                                             }
{           Email : info@tmssoftware.com                                  }
{           Web : http://www.tmssoftware.com                              }
{                                                                         }
{ The source code is given as is. The author is not responsible           }
{ for any possible damage done due to the use of this code.               }
{ The component can be freely used in any application. The complete       }
{ source code remains property of the author and may not be distributed,  }
{ published, given or sold in any form as such. No parts of the source    }
{ code can be included in any other component or application without      }
{ written authorization of the author.                                    }
{*************************************************************************}

unit FMX.TMSTileListDE;

interface

{$I TMSDEFS.INC}

uses
  Classes, FMX.TMSTileList, FMX.Dialogs, FMX.Types
  {$IFDEF WIN32}
  ,DesignIntf ,DesignEditors
  {$ENDIF}
  ;

{$IFDEF WIN32}
type
  TTMSFMXTileListEditor = class(TDefaultEditor)
  public
    function GetVerb(Index: Integer):string; override;
    function GetVerbCount: Integer; override;
    procedure ExecuteVerb(Index: Integer); override;
  end;

  TStyleTextProperty = class(TStringProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValues(Proc:TGetStrProc); override;
  end;
{$ENDIF}

implementation

{ TTMSFMXTileListEditor }

{$IFDEF WIN32}
procedure TTMSFMXTileListEditor.ExecuteVerb(Index: Integer);
var
  tl: TTMSFMXTileList;
begin
  inherited;
  tl := nil;
  if Component is TTMSFMXTileList then
    tl := Component as TTMSFMXTileList;

  if Assigned(tl) then
  begin
    case Index of
      0: tl.Tiles.Add;
      1: tl.Tiles.Add.Empty := True;
      2: tl.Tiles.AddTransparent;
      3: tl.Tiles.Clear;
      4: tl.Styles.Add;
      5: tl.Styles.Clear;
    end;
  end;
end;

function TTMSFMXTileListEditor.GetVerb(Index: Integer): string;
begin
  case Index of
  0: Result := 'Add new tile';
  1: Result := 'Add empty tile';
  2: Result := 'Add transparent tile';
  3: Result := 'Clear tiles';
  4: Result := 'Add custom tile style';
  5: Result := 'Clear custom tile styles';
  end;
end;

function TTMSFMXTileListEditor.GetVerbCount: Integer;
begin
  Result := 6;
end;

{ TStyleTextProperty }

function TStyleTextProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paSortList, paValueEditable];
end;

procedure TStyleTextProperty.GetValues(Proc: TGetStrProc);
var
  p: TPersistent;
  comp: TTMSFMXTileList;
  i: integer;
begin
  p := GetComponent(0);
  comp := nil;

  if Assigned(p) and (p is TTMSFMXTile) then
    comp := (p as TTMSFMXTile).TileList;

  if Assigned(comp) then
  begin
    for I := 0 to comp.Styles.Count - 1 do
      Proc(comp.Styles[I].StyleName);
  end;
end;

{$ENDIF}

end.
