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

interface

{$I TMSDEFS.INC}

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

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

  TTMSFMXNavBarPanelEditor = 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 TTMSFMXNavBarEditor.ExecuteVerb(Index: Integer);
var
  NavBarPanel: TTMSFMXNavBarPanel;
begin
  inherited;
  case Index of
  0:
    begin
      NavBarPanel := TTMSFMXNavBarPanel(Designer.CreateComponent(TTMSFMXNavBarPanel,Component,23,0,100,100));
      NavBarPanel.Parent := TTMSFMXNavBar(Component);
      NavBarPanel.NavBar := TTMSFMXNavBar(Component);
      NavBarPanel.Caption := NavBarPanel.Name;
      TTMSFMXNavBar(component).ActivePanel:= NavBarPanel;
    end;
  1: TTMSFMXNavBar(Component).SelectPreviousPanel;
  2: TTMSFMXNavBar(Component).SelectNextPanel;
  end;
end;

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

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

{ TTMSFMXPageEditor }


{$IFDEF WIN32}
procedure TTMSFMXNavBarPanelEditor.ExecuteVerb(Index: Integer);
var
  NavBarPanel: TTMSFMXNavBarPanel;
  p: TFmxObject;
begin
  inherited;
  p := TFMXObject(Component).Parent;
  if p is TTMSFMXNavBar then
  begin
    case Index of
    0:
      begin
        NavBarPanel := TTMSFMXNavBarPanel(Designer.CreateComponent(TTMSFMXNavBarPanel, p,23,0,100,100));
        NavBarPanel.Parent := p;
        NavBarPanel.NavBar := TTMSFMXNavBar(p);
        NavBarPanel.Caption := NavBarPanel.Name;
        TTMSFMXNavBar(p).ActivePanel:= NavBarPanel;
      end;
    1: TTMSFMXNavBar(p).SelectPreviousPanel;
    2: TTMSFMXNavBar(p).SelectNextPanel;
    3:
      begin
      TTMSFMXNavBarPanel(Component).NavBar := nil;
      Component.Free;
      end;
    end;
  end;
end;

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

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