unit uNavPaneUtils;

interface

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

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

uses
  ComCtrls, Classes, Math, SpTBXDkPanels, StrUtils, SysUtils,
  ExtCtrls, Graphics, Dialogs, JvLinkLabel, JvLabel, StdCtrls;


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 ((not AMenuItem[ItemIndex].IsLine)  // que no sea una línea separadora
         and (AMenuItem[ItemIndex].Tag <> -999) // Si TAG = -999 indica que se ignora este item
         and (AMenuItem[ItemIndex].Count = 0) // que no sea el padre de un submenú
         and (AMenuItem[ItemIndex].Visible)) // y que sea visible
    then
      with TJvLabel.Create(AParentControl) do
      begin
        Parent := AParentControl;//APanel;
        ParentFont := True;
        Align := alTop;
        Tag := AMenuItem[ItemIndex].Tag;
        Caption := AMenuItem[ItemIndex].Caption;
        Action := AMenuItem[ItemIndex].Action;

        HotTrack := True;
        HotTrackFont.Style := [fsUnderline];

        Images := AImageList;
        ImageIndex := AMenuItem[ItemIndex].ImageIndex;

        Height := AImageList.Height;

        Margins.Top := 0;
        Margins.Bottom := 6;
        Margins.Left := 10;
        Margins.Right := 10;
        AlignWithMargins := True;

        AutoSize := True;
        Layout := tlCenter;
        Transparent := True;

        AHeight := AHeight + Margins.Top + Margins.Bottom + Height;
      end;

{      with TSpTBXLabel.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 := 6;
        Margins.Bottom := 6;
        Margins.Left := 10;
        Margins.Right := 10;
        AlignWithMargins := True;
        Height := 18;
        Color := clRed;
        Invalidate;
        AHeight := AHeight + Margins.Top + Margins.Bottom + Height;
      end;}
  end;
  AParentControl.Height := AHeight;
end;

end.
