{********************************************************************}
{ IntraWeb script editor property editor                             }
{ for Delphi & C++Builder                                            }
{                                                                    }
{ written by : TMS Software                                          }
{               copyright © 2002 - 2005                              }
{               Email : info@tmssoftware.com                         }
{               Web : http://www.tmssoftware.com                     }
{********************************************************************}
unit IWScriptEdit;

interface
{$I TMSDEFS.INC}
uses
  Classes, AdvMemo, Dialogs, uScriptEdit, Forms, Controls, IWTMSCtrls,
  IWWebGrid, IWTMSCal, IWOutlookBar, IWSideNavBar, IWExchangeBar,
{$IFDEF DELPHI6_LVL}
  DesignIntf, DesignEditors
{$ELSE}
  DsgnIntf
{$ENDIF}
  ;


type
  TIWScriptEventProperty = class(TClassProperty)
  public
    function GetAttributes:TPropertyAttributes; override;
    procedure Edit; override;
  end;

  TIWScriptStringEventProperty = class(TClassProperty)
  public
    function GetAttributes:TPropertyAttributes; override;
    procedure Edit; override;
  end;


procedure Register;

implementation

procedure Register;
begin
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'ButtonClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'CellClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'CheckClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'ComboChange',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'DynCheckClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'DynComboChange',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'DynEditChange',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'DynEditDone',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'EditDone',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'GridKeyDown',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'HoverRow',TIWScriptEventProperty);  
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'ImageClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'NodeClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'PopupEditOk',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWGridClientEvents,'PopupEditCancel',TIWScriptEventProperty);

  RegisterPropertyEditor(TypeInfo(TStringList),TIWCalendarClientEvents,'DateClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWCalendarClientEvents,'NextMonthClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWCalendarClientEvents,'NextYearClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWCalendarClientEvents,'PrevMonthClick',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWCalendarClientEvents,'PrevYearClick',TIWScriptEventProperty);

  RegisterPropertyEditor(TypeInfo(TStringList),TIWDSClientEvents,'YearChange',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWDSClientEvents,'MonthChange',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWDSClientEvents,'DayChange',TIWScriptEventProperty);


  RegisterPropertyEditor(TypeInfo(TStringList),TIWDatePickerClientEvents,'OnExit',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TIWDatePickerClientEvents,'OnEnter',TIWScriptEventProperty);

  RegisterPropertyEditor(TypeInfo(TStringList),TTIWClientCode,'Code',TIWScriptEventProperty);

  RegisterPropertyEditor(TypeInfo(string), TIWOutlookItem, 'Script',TIWScriptStringEventProperty);
  RegisterPropertyEditor(TypeInfo(string), TIWOutlookPanel, 'Script',TIWScriptStringEventProperty);

  RegisterPropertyEditor(TypeInfo(string), TSideNavBarItem, 'Script',TIWScriptStringEventProperty);

  RegisterPropertyEditor(TypeInfo(string), TExchangeBarItem, 'Script',TIWScriptStringEventProperty);

  RegisterPropertyEditor(TypeInfo(TStringList),TSideNavBarClientEvents,'',TIWScriptEventProperty);
  RegisterPropertyEditor(TypeInfo(TStringList),TExchangeBarClientEvents,'',TIWScriptEventProperty);  
end;


{ TIWScriptEventProperty }

procedure TIWScriptEventProperty.Edit;
var
  SE: TTMSScriptEdit;
  func: string;
begin
  SE := TTMSScriptEdit.Create(Application);

  try
    if GetComponent(0) is TSideNavBarClientEvents then
    begin
      func := (GetComponent(0) as TSideNavBarClientEvents).GetJSFunction(Self.GetName);
      SE.Func.Caption := func;
    end;

    if GetComponent(0) is TExchangeBarClientEvents then
    begin
      func := (GetComponent(0) as TExchangeBarClientEvents).GetJSFunction(Self.GetName);
      SE.Func.Caption := func;
    end;

    if GetComponent(0) is TIWGridClientEvents then
    begin
      func := (GetComponent(0) as TIWGridClientEvents).GetJSFunction(Self.GetName);
      SE.Func.Caption := func;
    end;

    if GetComponent(0) is TIWCalendarClientEvents then
    begin
      func := (GetComponent(0) as TIWCalendarClientEvents).GetJSFunction(Self.GetName);
      SE.Func.Caption := func;
    end;

    if GetComponent(0) is TIWDatePickerClientEvents then
    begin
      func := (GetComponent(0) as TIWDatePickerClientEvents).GetJSFunction(Self.GetName);
      SE.Func.Caption := func;
    end;

    if GetComponent(0) is TIWDSClientEvents then
    begin
      func := (GetComponent(0) as TIWDSClientEvents).GetJSFunction(Self.GetName);
      SE.Func.Caption := func;
    end;


    SE.AdvMemo1.Lines.Assign(TStrings(GetOrdValue));
    if SE.ShowModal = mrOk then
      SetOrdValue(longint(SE.AdvMemo1.Lines));
  finally
    SE.Free;
  end;
end;

function TIWScriptEventProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;


{ TIWScriptEventProperty }

procedure TIWScriptStringEventProperty.Edit;
var
  SE: TTMSScriptEdit;

begin
  SE := TTMSScriptEdit.Create(Application);

  try
    SE.AdvMemo1.Lines.Text := GetStrValue;
    if SE.ShowModal = mrOk then
      SetStrValue(SE.AdvMemo1.Lines.Text);
  finally
    SE.Free;
  end;
end;

function TIWScriptStringEventProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;


end.




