unit ListEditor;

interface

uses
  Classes, SysUtils, IWAppForm, IWApplication, IWTypes, IWTMSCC,
  IWCompEdit, Controls, IWBaseControl, IWControl, IWCompLabel, LeftFrame,
  Forms, TopFrame, IWVCLBaseControl, IWBaseHTMLControl, IWAutoFormFill,
  IWTMSCtrls, IWContinuousScroll, IWBaseComponent, IWBaseHTMLComponent,
  IWBaseHTML40Component, IWCompExtCtrls, IWListEditor, IWCompButton,
  IWCompListbox;

type
  TformListEditor1 = class(TIWAppForm)
    FrameTopFrame1: TFrameTopFrame;
    FrameLeftFrame1: TFrameLeftFrame;
    IWLabel4: TIWLabel;
    IWLabel7: TIWLabel;
    TIWListEditor2: TTIWListEditor;
    IWLabel1: TIWLabel;
    IWLabel2: TIWLabel;
    lbEvents: TIWListbox;
    IWLabel3: TIWLabel;
    IWLabel5: TIWLabel;
    btAdd: TIWButton;
    btUpdate: TIWButton;
    btDelete: TIWButton;
    edText: TIWEdit;
    IWLabel6: TIWLabel;
    IWLabel8: TIWLabel;
    IWLabel9: TIWLabel;
    IWLabel10: TIWLabel;
    TIWListEditor1: TTIWListEditor;
    procedure TIWListEditor1AsyncEditEnd(Sender: TObject;
      EventParams: TStringList; Index: Integer; var AValue: string; var AImage;
      var Allow: Boolean);
    procedure TIWListEditor1AsyncEditStart(Sender: TObject;
      EventParams: TStringList; Index: Integer);
    procedure TIWListEditor1AsyncItemClick(Sender: TObject;
      EventParams: TStringList; Index: Integer);
    procedure TIWListEditor1AsyncItemDelete(Sender: TObject;
      EventParams: TStringList; Index: Integer);
    procedure TIWListEditor1AsyncItemInsert(Sender: TObject;
      EventParams: TStringList; var AValue, AImage: string; var Allow: Boolean);
    procedure btAddAsyncClick(Sender: TObject; EventParams: TStringList);
    procedure btUpdateAsyncClick(Sender: TObject; EventParams: TStringList);
    procedure btDeleteAsyncClick(Sender: TObject; EventParams: TStringList);
    procedure IWAppFormCreate(Sender: TObject);
  public
    NewOrder: boolean;
  end;

implementation

{$R *.dfm}

uses
  ServerController;


procedure TformListEditor1.btAddAsyncClick(Sender: TObject;
  EventParams: TStringList);
var
  it : TIWEditListItem;
begin
  if edText.Text <> '' then
  begin
    it := TIWListEditor1.Items.Add();
    it.Caption := edText.Text;
    TIWListEditor1.AsyncItemAdd(it);
  end;
end;

procedure TformListEditor1.btDeleteAsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  if (TIWListEditor1.ItemIndex >= 0)
    and (TIWListEditor1.ItemIndex < TIWListEditor1.Items.Count) then
  begin
    TIWListEditor1.Items[TIWListEditor1.ItemIndex].Free;
    TIWListEditor1.AsyncItemDelete(TIWListEditor1.ItemIndex);
  end;
end;

procedure TformListEditor1.btUpdateAsyncClick(Sender: TObject;
  EventParams: TStringList);
var
  it : TIWEditListItem;
begin
  if (edText.Text <> '') and (TIWListEditor1.ItemIndex >= 0)
    and (TIWListEditor1.ItemIndex < TIWListEditor1.Items.Count) then
  begin
    it := TIWListEditor1.Items[TIWListEditor1.ItemIndex];
    it.Caption := edText.Text;
    TIWListEditor1.AsyncItemUpdate(it);
  end;
end;

procedure TformListEditor1.IWAppFormCreate(Sender: TObject);
var
  it: TIWEditListItem;
begin
  TIWListEditor2.Items.Clear;
  it := TIWListEditor2.Items.Add;
  it.Caption := 'Chrome';
  it.ImageURL := 'files/chrome.png';
  it.Hint := 'Google Chrome';

  it := TIWListEditor2.Items.Add;
  it.Caption := 'FireFox';
  it.ImageURL := 'files/firefox.png';
  it.Hint := 'Mozilla Firefox';

  it := TIWListEditor2.Items.Add;
  it.Caption := 'Internet Explorer';
  it.ImageURL := 'files/ie.png';
  it.Hint := 'Microsoft Internet Explorer';

  it := TIWListEditor2.Items.Add;
  it.Caption := 'Opera';
  it.ImageURL := 'files/opera.png';
  it.Hint := 'Opera';

  it := TIWListEditor2.Items.Add;
  it.Caption := 'Safari';
  it.ImageURL := 'files/safari.png';
  it.Hint := 'Apple Safari';

  TIWListEditor2.ItemIndex := 0;
  TIWListEditor2.Appearance.ItemHeight := 30;
end;

procedure TformListEditor1.TIWListEditor1AsyncEditEnd(Sender: TObject;
  EventParams: TStringList; Index: Integer; var AValue: string; var AImage;
  var Allow: Boolean);
begin
  lbEvents.Items.Insert(0, 'End editing Item ' + IntToStr(Index) + ': '
    + AValue);
end;

procedure TformListEditor1.TIWListEditor1AsyncEditStart(Sender: TObject;
  EventParams: TStringList; Index: Integer);
begin
  lbEvents.Items.Insert(0, 'Start editing Item ' + IntToStr(Index) + ': '
    + TIWListEditor1.Items[Index].Caption);
end;

procedure TformListEditor1.TIWListEditor1AsyncItemClick(Sender: TObject;
  EventParams: TStringList; Index: Integer);
begin
  lbEvents.Items.Insert(0, 'Select Item ' + IntToStr(Index) + ': '
    + TIWListEditor1.Items[Index].Caption);
end;

procedure TformListEditor1.TIWListEditor1AsyncItemDelete(Sender: TObject;
  EventParams: TStringList; Index: Integer);
begin
  lbEvents.Items.Insert(0, 'Delete Item ' + IntToStr(Index) + ': '
    + TIWListEditor1.Items[Index].Caption);
end;

procedure TformListEditor1.TIWListEditor1AsyncItemInsert(Sender: TObject;
  EventParams: TStringList; var AValue, AImage: string; var Allow: Boolean);
begin
  lbEvents.Items.Insert(0, 'Insert new Item: '
    + AValue);
end;

initialization
  TformListEditor1.SetAsMainForm


end.
