unit uNavPaneUtils;

interface

uses
  Forms, ImgList, ActnList, JvPageList, JvNavigationPane, Menus,
  Controls;

procedure PopulateNavPagePane(APanePage : TJvNavPanelPage;
  AMenuItem: TMenuItem; AImageList : TCustomImageList;
  AStyleManager : TJvNavPaneStyleManager); overload;

procedure PopulateNavPagePane(AParentControl : TWinControl;
  AMenuItem: TMenuItem; AImageList : TCustomImageList;
  AStyleManager : TJvNavPaneStyleManager); overload;
  
implementation

uses
  ComCtrls, Classes, Math, TBXDkPanels, StrUtils, SysUtils,
  ExtCtrls, Graphics, Dialogs;


procedure PopulateNavPagePane(APanePage : TJvNavPanelPage;
  AMenuItem: TMenuItem; AImageList : TCustomImageList;
  AStyleManager : TJvNavPaneStyleManager);
var
  APanel : TScrollBox;
  ItemIndex : Integer;
begin
  with TJvNavPanelDivider.Create(APanePage) do
  begin
    Caption := AMenuItem.Caption;
    Parent := APanePage;
    Top := 100;
    Align := alTop;
    Enabled := false;
    Cursor := crDefault;
  end;

  APanel := TScrollBox.Create(APanePage);
  with APanel do
  begin
    Top := 200;
    Align := alTop;
    Font.Style := [];
    BorderStyle := bsNone;
    Parent := APanePage;
    BevelEdges := [];
    BorderStyle := bsNone;
    //ParentColor := True;
    ParentFont := True;
    Color := clRed;
  end;

  for ItemIndex := 0 to (AMenuItem.Count - 1) do
  begin
    if AMenuItem[ItemIndex].Caption <> '-' then
      with TTBXLink.Create(Application) do
      begin
        Parent := APanePage;
        Align := alTop;
        Tag := AMenuItem[ItemIndex].Tag;
        Caption := AMenuItem[ItemIndex].Caption;
        Action := AMenuItem[ItemIndex].Action;
        Images := AImageList;
        ImageIndex := AMenuItem[ItemIndex].ImageIndex;
        {if ItemIndex = 0 then
          Margins.Top := 20
        else
          Margins.Top := 14;
        Margins.Bottom := 14;
        Margins.Left := 10;
        Margins.Right := 10;}
        //Invalidate;
      end;
  end;
end;

procedure PopulateNavPagePane(AParentControl : TWinControl;
  AMenuItem: TMenuItem; AImageList : TCustomImageList;
  AStyleManager : TJvNavPaneStyleManager);
var
  ItemIndex : Integer;
  AHeight : Integer;
begin
  AHeight := 0;
  for ItemIndex := 0 to (AMenuItem.Count - 1) do
  begin
    if AMenuItem[ItemIndex].Caption <> '-' then
      with TTBXLink.Create(Application) do
      begin
        Parent := AParentControl;//APanel;
        Align := alTop;
        ParentFont := True;
        Tag := AMenuItem[ItemIndex].Tag;
        Caption := AMenuItem[ItemIndex].Caption;
        Action := AMenuItem[ItemIndex].Action;
        Images := AImageList;
        ImageIndex := AMenuItem[ItemIndex].ImageIndex;
        if ItemIndex = 0 then
          Margins.Top := 15
        else
          Margins.Top := 8;
        Margins.Bottom := 8;
        Margins.Left := 10;
        Margins.Right := 10;
        Height := 18;
        Invalidate;
        AHeight := AHeight + Margins.Top + Margins.Bottom + Height; 
      end;
  end;
  AParentControl.Height := AHeight;
end;

end.
