{*************************************************************************}
{                                                                         }
{ 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.TMSPageSliderDE;

interface

{$I TMSDEFS.INC}

uses
  FMX.TMSPageSlider, FMX.Types
  {$IFDEF WIN32}
    ,DesignEditors
  {$ENDIF}
  ;

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

  TTMSFMXPageEditor = class(TDefaultEditor)
  public
    function GetVerb(Index: Integer):string; override;
    function GetVerbCount: Integer; override;
    procedure ExecuteVerb(Index: Integer); override;
  end;
  {$ENDIF}

implementation


{ TTMSFMXPageSliderEditor }
{$IFDEF WIN32}
procedure TTMSFMXPageSliderEditor.ExecuteVerb(Index: Integer);
var
  AdvPage: TTMSFMXPage;
begin
  inherited;
  case Index of
  0:
    begin
      AdvPage := TTMSFMXPage(Designer.CreateComponent(TTMSFMXPage,Component,23,0,100,100));
      AdvPage.Parent := TTMSFMXPageSlider(Component);
      AdvPage.PageSlider := TTMSFMXPageSlider(Component);
      AdvPage.Header := AdvPage.Name;
      TTMSFMXPageSlider(component).ActivePage:= AdvPage;
    end;
  1: TTMSFMXPageSlider(Component).SelectNextPage(false);
  2: TTMSFMXPageSlider(Component).SelectNextPage(True);
  end;
end;

function TTMSFMXPageSliderEditor.GetVerb(Index: Integer): string;
begin
  case Index of
  0: Result := 'New Page';
  1: Result := 'Previous Page';
  2: Result := 'Next Page';
  end;
end;

function TTMSFMXPageSliderEditor.GetVerbCount: Integer;
begin
  Result := 3;
end;
{$ENDIF}

{ TTMSFMXPageEditor }


{$IFDEF WIN32}
procedure TTMSFMXPageEditor.ExecuteVerb(Index: Integer);
var
  AdvPage: TTMSFMXPage;
  p: TFmxObject;
begin
  inherited;
  p := TFMXObject(Component).Parent;
  if p is TTMSFMXPageSlider then
  begin
    case Index of
    0:
      begin
        AdvPage := TTMSFMXPage(Designer.CreateComponent(TTMSFMXPage, p,23,0,100,100));
        AdvPage.Parent := p;
        AdvPage.PageSlider := TTMSFMXPageSlider(p);
        AdvPage.Header := AdvPage.Name;
        TTMSFMXPageSlider(p).ActivePage:= AdvPage;
      end;
    1: TTMSFMXPageSlider(p).SelectNextPage(false);
    2: TTMSFMXPageSlider(p).SelectNextPage(true);
    3:
      begin
      TTMSFMXPage(Component).PageSlider := nil;
      Component.Free;
      end;
    end;
  end;
end;

function TTMSFMXPageEditor.GetVerb(Index: Integer): string;
begin
  case Index of
  0: Result := 'New Page';
  1: Result := 'Previous Page';
  2: Result := 'Next Page';
  3: Result := 'Delete Page';
  end;
end;

function TTMSFMXPageEditor.GetVerbCount: Integer;
begin
  Result := 4;
end;
  {$ENDIF}
end.
