{***************************************************************************}
{ TMS IntraWeb Component Pack Pro                                           }
{ for Delphi & C++Builder                                                   }
{                                                                           }
{ written by TMS Software                                                   }
{            copyright © 2002 - 2009                                        }
{            Email : info@tmssoftware.com                                   }
{            Web : http://www.tmssoftware.com                               }
{                                                                           }
{ The source code is given as is. The author is not responsible             }
{ for any possible damage done due to the use of this code.                 }
{ The component can be freely used in any application. The complete         }
{ source code remains property of the author and may not be distributed,    }
{ published, given or sold in any form as such. No parts of the source      }
{ code can be included in any other component or application without        }
{ written authorization of the author.                                      }
{***************************************************************************}

unit IWAdvWebGridDE;

{$I TMSDEFS.INC}

interface

uses
  Classes, IWAdvWebGrid, IWWebGrid, Forms, IWDBAdvWebGrid
{$IFNDEF LINUX}
  , IWHTMLDE, IWTMSImgDE, IWTMSImg, IWGridGallery, IWTMSBase
{$ENDIF}
{$IFDEF TMSIW72}
  , IWColor, IWDsnColor
{$ENDIF}  

{$IFDEF DELPHI6_LVL}
  , DesignIntf, DesignEditors
{$ELSE}
  , DsgnIntf
{$ENDIF}
  ;


type
  TIWAdvWebGridEditor = class(TDefaultEditor)
  protected
{$IFNDEF DELPHI6_LVL}
    procedure EditProperty(PropertyEditor: TPropertyEditor;
      var Continue, FreeEditor: Boolean); override;
{$ELSE}
    procedure EditProperty(const PropertyEditor: IProperty; var Continue: Boolean); override;
{$ENDIF}
  public
    function GetVerb(index:integer):string; override;
    function GetVerbCount:integer; override;
    procedure ExecuteVerb(Index:integer); override;

  end;

procedure Register;

implementation

uses
  SysUtils, Dialogs;

{$IFDEF DELPHI6_LVL}
procedure TIWAdvWebGridEditor.EditProperty(const PropertyEditor: IProperty; var Continue: Boolean);
{$ELSE}
procedure TIWAdvWebGridEditor.EditProperty(PropertyEditor: TPropertyEditor;
  var Continue, FreeEditor: Boolean);
{$ENDIF}
var
  PropName: string;
begin
  PropName := PropertyEditor.GetName;
  if (CompareText(PropName, 'COLUMNS') = 0) then
  begin
    PropertyEditor.Edit;
    Continue := False;
  end;
end;


procedure TIWAdvWebGridEditor.ExecuteVerb(Index: integer);
var
  compiler: string;
  Gallery: TGridGallery;
begin
  case Index of
  0:begin
    {$IFDEF VER130}
    {$IFDEF BCB}
    compiler := 'C++Builder 5';
    {$ELSE}
    compiler := 'Delphi 5';
    {$ENDIF}
    {$ENDIF}
    {$IFDEF VER140}
      {$IFDEF BCB}
      compiler := 'C++Builder 6';
      {$ELSE}
      compiler := 'Delphi 6';
      {$ENDIF}
    {$ENDIF}

    {$IFDEF VER150}
      compiler := 'Delphi 7';
    {$ENDIF}

    {$IFDEF VER170}
      compiler := 'Delphi 2005';
    {$ENDIF}

    {$IFDEF VER180}
      compiler := 'Delphi 2006';
    {$ENDIF}

    {$IFDEF VER185}
      compiler := 'Delphi 2007';
    {$ENDIF}

    {$IFDEF VER200}
      compiler := 'Delphi 2009';
    {$ENDIF}

    {$IFDEF LINUX}
    {$IFDEF VER140}
      compiler := 'Kylix 2';
    {$ENDIF}
    {$IFDEF VER150}
      compiler := 'Kylix 3';
    {$ENDIF}
    {$ENDIF}

    MessageDlg(Component.ClassName+' version '+(Component as TTIWCustomAdvWeBGrid).GetVersionString+' for '+compiler+#13#10'© 2002 - 2009 by TMS software',
               mtinformation,[mbok],0);
    end;
  1:begin
      ForceDirectories(GetProgramFiles + '\tmssoftware\TMSIWPRO\Preferences\Grids\');
      Gallery := TGridGallery.Create(Application);
      Gallery.Component := Component;
      Gallery.FilePath := GetProgramFiles + '\tmssoftware\TMSIWPRO\Preferences\Grids\';
      Gallery.FillList;
      Gallery.ShowModal;
      Gallery.Free;
      Designer.Modified;
    end;
  end;
end;

function TIWAdvWebGridEditor.GetVerb(index: integer): string;
begin
  case index of
  0:Result := '&About';
  1:Result := '&Gallery';
  end;
end;

function TIWAdvWebGridEditor.GetVerbCount: integer;
begin
  Result := 2;
end;



procedure Register;
begin
  {$IFDEF VER170}
  ForceDemandLoadState(dlDisable);
  EnableDemandLoadReport(false);
  {$ENDIF}

{$IFNDEF LINUX}
  RegisterPropertyEditor(TypeInfo(string), TTIWWebGridColumn, 'Template', TIWHTMLStringProperty);
  RegisterPropertyEditor(TypeInfo(string), TTIWWebGridColumn, 'Title', TIWHTMLStringProperty);
  RegisterPropertyEditor(TypeInfo(string), TTIWWebGridColumn, 'SubTitle', TIWHTMLStringProperty);
  RegisterPropertyEditor(TypeInfo(string), TTIWWebGridColumn, 'DetailTemplate', TIWHTMLStringProperty);
  RegisterPropertyEditor(TypeInfo(string), TTIWAdvWebGridController, 'Caption', TIWHTMLStringProperty);
{$ENDIF}

{$IFDEF TMSIW72}

  RegisterPropertyEditor(TypeInfo(TIWColor), TTIWRGBorders, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TTIWAdvWebGridBands, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TIWGridBackground, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TTIWWebGridRowHeader, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TTIWWebGridScroll, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TTIWWebGridColumn, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TTIWAdvWebGridController, '', TIWColorEditor);

{$ENDIF}

  RegisterComponentEditor(TTIWAdvWebGrid,TIWAdvWebGridEditor);
  RegisterComponentEditor(TTIWAdvDetailWebGrid,TIWAdvWebGridEditor);

{$IFNDEF LINUX}
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvWebGridController, 'ImgPrev', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvWebGridController, 'ImgNext', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvWebGridController, 'ImgFirst', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvWebGridController, 'ImgLast', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TIWGridNode,'NodeOpen', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TIWGridNode,'NodeClosed', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TIWGridBackground,'Picture', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWCustomWebGrid, 'CheckTruePicture', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWCustomWebGrid, 'CheckFalsePicture', TTIWAdvImageProperty);
{$ENDIF}
end;

end.
