unit AdvTreeView;

interface

uses
  Classes, SysUtils, IWAppForm, IWApplication, IWTypes, IWTMSCC,
  IWCompEdit, Controls, IWBaseControl, IWControl, IWCompLabel, LeftFrame,
  Forms, TopFrame, IWVCLBaseControl, IWBaseHTMLControl, IWAutoFormFill,
  IWTMSCtrls, IWAdvTreeView, IWCompListbox, AdvTreeNodes, IWCompButton;

type
  TformAdvTreeView = class(TIWAppForm)
    FrameTopFrame1: TFrameTopFrame;
    FrameLeftFrame1: TFrameLeftFrame;
    IWLabel4: TIWLabel;
    IWLabel7: TIWLabel;
    TIWAdvTreeView1: TTIWAdvTreeView;
    IWListbox1: TIWListbox;
    IWLabel1: TIWLabel;
    IWButton1: TIWButton;
    IWEdit1: TIWEdit;
    IWButton2: TIWButton;
    IWEdit2: TIWEdit;
    IWButton3: TIWButton;
    procedure TIWAdvTreeView1AsyncItemClick(Sender: TObject;
      EventParams: TStringList; Node: TAdvTreeNode);
    procedure IWAppFormCreate(Sender: TObject);
    procedure IWButton1AsyncClick(Sender: TObject; EventParams: TStringList);
    procedure IWButton2AsyncClick(Sender: TObject; EventParams: TStringList);
    procedure IWButton3AsyncClick(Sender: TObject; EventParams: TStringList);
  public
  end;

implementation

{$R *.dfm}

uses
  ServerController;


procedure TformAdvTreeView.IWAppFormCreate(Sender: TObject);
var
  N, NC, NCC: TAdvTreeNode;
begin
  FrameTopFrame1.Align := alTop;
  FrameLeftFrame1.Align := alLeft;

  TIWAdvTreeView1.Items.Clear;

  N := TIWAdvTreeView1.Items.Add('Folder 1');
  N.Hint := 'Folder 1';
  N.ImageURL := '/files/folder.gif';
  N.ImageCollapsedURL := '/files/folder-closed.gif';
  N.Tag := 1;
  N.IsExpanded := False;

  NC := N.AddChild('File A');
  NC.Hint := 'File A';
  NC.ImageURL := '/files/file.png';
  NC.Tag := 2;

  NC := N.AddChild('File B');
  NC.Hint := 'File B';
  NC.ImageURL := '/files/file.png';
  NC.Tag := 3;

  N := TIWAdvTreeView1.Items.Add('Folder 2');
  N.Hint := 'Folder 2';
  N.ImageURL := '/files/folder.gif';
  N.ImageCollapsedURL := '/files/folder-closed.gif';
  N.Tag := 4;
  N.IsExpanded := True;

  NC := N.AddChild('Subfolder 1');
  NC.Hint := 'Subfolder 1';
  NC.ImageURL := '/files/folder.gif';
  NC.ImageCollapsedURL := '/files/folder-closed.gif';
  NC.Tag := 5;

  NCC := NC.AddChild('File C');
  NCC.Hint := 'File C';
  NCC.ImageURL := '/files/file.png';
  NCC.Tag := 6;

  N := TIWAdvTreeView1.Items.Add('Options');
  N.Hint := 'Options';
  N.ImageURL := '/files/options.png';
  N.Tag := 7;
  N.IsExpanded := True;

  NC := N.AddChild('Operating System');
  NC.Hint := 'Select your current operating system.';
  NC.ImageURL := '/files/pc.gif';
  NC.Tag := 8;

  NCC := NC.AddChild('Windows XP');
  NCC.Hint := 'Windows XP';
  NCC.ImageURL := '/files/windows.png';
  NCC.Tag := 9;
  NCC.NodeType := ntRadioButton;

  NCC := NC.AddChild('Windows Vista');
  NCC.Hint := 'Windows Vista';
  NCC.ImageURL := '/files/windowsvista.png';
  NCC.Tag := 10;
  NCC.NodeType := ntRadioButton;

  NCC := NC.AddChild('Windows 7');
  NCC.Hint := 'Windows 7';
  NCC.ImageURL := '/files/windows7.png';
  NCC.Tag := 11;
  NCC.Checked := True;
  NCC.NodeType := ntRadioButton;

  NC := N.AddChild('Browsers');
  NC.Hint := 'Select the currently installed browsers.';
  NC.ImageURL := '/files/world.png';
  NC.Tag := 12;

  NCC := NC.AddChild('Chrome');
  NCC.Hint := 'Google Chrome';
  NCC.ImageURL := '/files/chrome.png';
  NCC.Tag := 13;
  NCC.Checked := True;
  NCC.NodeType := ntCheckBox;

  NCC := NC.AddChild('FireFox');
  NCC.Hint := 'Mozilla FireFox';
  NCC.ImageURL := '/files/firefox.png';
  NCC.Tag := 14;
  NCC.NodeType := ntCheckBox;

  NCC := NC.AddChild('Internet Explorer');
  NCC.Hint := 'Microsoft Internet Explorer';
  NCC.ImageURL := '/files/ie.png';
  NCC.Tag := 15;
  NCC.Checked := True;
  NCC.NodeType := ntCheckBox;

  NCC := NC.AddChild('Opera');
  NCC.Hint := 'Opera';
  NCC.ImageURL := '/files/opera.png';
  NCC.Tag := 16;
  NCC.NodeType := ntCheckBox;

  NCC := NC.AddChild('Safari');
  NCC.Hint := 'Apple Safari';
  NCC.ImageURL := '/files/safari.png';
  NCC.Tag := 17;
  NCC.NodeType := ntCheckBox;

  N := TIWAdvTreeView1.Items.Add('TMS Software');
  N.Hint := 'Link to the TMS Software site';
  N.ImageUrl := '/files/tms.png';
  N.URL := 'http://www.tmssoftware.com/';
  N.Tag := 18;

end;

procedure TformAdvTreeView.IWButton1AsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  if not (IWEdit1.Text = '') then
  begin
    TIWAdvTreeView1.Items.Add(IWEdit1.Text);
    TIWAdvTreeView1.Invalidate;
  end;
end;

procedure TformAdvTreeView.IWButton2AsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  if (not (IWEdit2.Text = '')) and (not (TIWAdvTreeView1.SelectedNode = nil)) then
  begin
    TIWAdvTreeView1.SelectedNode.Text := IWEdit2.Text;
    TIWAdvTreeView1.Invalidate;
  end;
end;

procedure TformAdvTreeView.IWButton3AsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  if (not (TIWAdvTreeView1.SelectedNode = nil)) then
  begin
    TIWAdvTreeView1.SelectedNode.Free;
    TIWAdvTreeView1.Invalidate;
  end;
end;

procedure TformAdvTreeView.TIWAdvTreeView1AsyncItemClick(Sender: TObject;
  EventParams: TStringList; Node: TAdvTreeNode);
var
  msg: string;
begin
  msg := Node.Text;
  if (Node.NodeType = ntCheckBox) or (Node.NodeType = ntRadioButton) then
  begin
    if (Node.Checked) then
      msg := msg + ' (Checked)'
    else
      msg := msg + ' (Unchecked)';
  end;

  if (Node.HasChildren) then
  begin
    if (Node.IsExpanded) then
      msg := msg + ' (Expanded)'
    else
      msg := msg + ' (Collapsed)';
  end;

  IWListBox1.Items.Add(msg);
end;

initialization
  TformAdvTreeView.SetAsMainForm


end.
