(************************************************************************
*    This File is Part of the AHM Triton Tools                          *
*    for Borland Delphi and C++ Builder.                                *
*************************************************************************
* Copyright © 1995-1999 Alexander H. Mehlhorn (AHM) and Tritontools.com *
* All Rights reserved.                                                  *
*                                                                       *
*    For more Information contact us at                                 *
*    E-Mail : support@tritontools.com                                   *
*    URL : http://www.tritontools.com                                   *
*                                                                       *
*    AHM is copyright by Alexander H. Mehlhorn                          *
*    All Parts of this Collection were developed,                       *
*    designed and implemented by AHM                                    *
*                                                                       *
*    Under no Circumstances may you distribute this file                *
*    in this or any other format. This File is supplied                 *
*    as Evaluation of Source only. No Delphi Components may be developed*
*    using extracts or subsets of this code without expressed permission*
*    by AHM.                                                            *
*                                                                       *
*************************************************************************)
unit AHMStdReg;

interface
{$I ahm.inc}
uses Classes,DesignIntf,
  AHMTAnimator,
  AHMStdClass,
  AHMSControls,
  AHMTLookupEdit,
  AHMTLookupMenu,
  AHMTFileLookup,
  AHMTRealSpinEdit,
  AHMTSpinEdit,
  AHMTStickyLabel,
  AHMTAutoCombo,
  AHMTCommandLabel,
  AHMTFontControls,
  AHMTColorCombo,
  AHMTOfficeEdit,
  AHMTInformationLabel,
  AHMTVersionLabel,
  AHMTDBIndexLookup,
  AHMTDBLookupEdit,
  AHMTDBOfficeEdit,
  AHMTDBSpinEdit,
  AHMTClipBoard,
  AHMTExplorerTree,
  AHMTExplorerView,
  AHMTFileCtrls,
  AHMTFileLabel,
  AHMTFormDivider,
  AHMTIconCtrls,
  AHMTDBStickyLabel,
  AHMTDBCommandLabel,
  AHMTDBLookupMenu,
  AHMTPrinterCombo,
  AHMTAutoStores
  {$IFDEF AHMINPRISE3}
  ,AHMTDBAscii
  ,AHMTLanguageCombo
  ,AHMTFolderLookup
  {$ENDIF}, DesignEditors;
type TAHMAboutStandardControl = class(TPropertyEditor)
     public
       procedure Edit; override;
       function GetValue: string; override;
       function GetAttributes: TPropertyAttributes; override;
     end;
    TAHMROInfoProperty = class(TStringProperty)
    public
      function GetAttributes : TPropertyAttributes; Override;
    end;
    TAHMDBStringProperty = class(TStringProperty)
    public
      function GetAttributes: TPropertyAttributes; override;
      procedure GetValueList(List: TStrings); virtual;
      procedure GetValues(Proc: TGetStrProc); override;
    end;
    TAHMDataFieldProperty = class(TAHMDBStringProperty)
    public
      function GetDataSourcePropName: string; virtual;
      procedure GetValueList(List: TStrings); override;
    end;
    TAHMItemDataFieldProperty = class(TAHMDBStringProperty)
    public
      function GetDataSourcePropName: string; virtual;
      procedure GetValueList(List: TStrings); override;
    end;
{    TAHMROCaptionProperty = class(TCaptionProperty)
    public
      function GetAttributes : TPropertyAttributes; Override;
    end;}
    {$IFDEF AHMINPRISE3}
    TAHMDBAsciiConfigEditor = class(TDefaultEditor)
    public
      procedure ExecuteVerb(Index : Integer); override;
      function GetVerb(Index : Integer): string; override;
      function GetVerbCount : Integer; override;
      procedure Edit; override;
    end;
    {$ENDIF}

procedure Register;
implementation
{$R AHMStandard.res}
uses Forms,Dialogs,SysUtils,TypInfo,DB,Controls;

procedure Register;
begin
  RegisterPropertyEditor(TypeInfo(TAHMAboutSControlStr),TComponent,'About',TAHMAboutStandardControl);
  RegisterComponents('AHM Standard',[TAHMCommandLabel,TAHMStickyLabel,TAHMVersionLabel,TAHMInformationLabel,
                                     TAHMLookupEdit,TAHMLookupMenu,TAHMFileLookup,{$IFDEF AHMINPRISE3} TAHMFolderLookup,{$ENDIF}
                                     TAHMRealSpinEdit,TAHMOfficeEdit,TAHMSpinEdit,TAHMSpinButton,
                                     TAHMAutoCombo,TAHMColorCombo,TAHMFontCombo,TAHMFontBox,
                                     TAHMFormDivider,TAHMAnimator]);
  RegisterComponents('AHM Data-Aware',[{$IFDEF AHMINPRISE3}TAHMDBAscii,{$ENDIF}TAHMDBIndexLookup,TAHMDBLookupEdit,
                                        TAHMDBOfficeEdit,TAHMDBSpinEdit,TAHMDBStickyLabel,TAHMDBCommandLabel,TAHMDBLookupMenu]);
  RegisterComponents('AHM Standard 2',[{$IFDEF AHMINPRISE3}TAHMLanguageCombo,{$ENDIF}TAHMFileCombo,TAHMDriveCombo,
                                  TAHMFolderListbox,TAHMIconCombo, TAHMIconListbox,TAHMExplorerView,
                                  TAHMExplorerTree,TAHMFileLabel,TAHMPrinterCombo,TAHMClipboard,TAHMControlStore,
                                  TAHMStoreEdit,TAHMStoreCheckbox,TAHMStoreCombobox,TAHMStoreRadioButton,TAHMStoreMemo]);
  {$IFDEF AHMINPRISE3}
  RegisterPropertyEditor(TypeInfo(string),TCollectionItem,'DataField',TAHMItemDataFieldProperty);
  RegisterComponentEditor(TAHMDBAscii,TAHMDBAsciiConfigEditor);
  {$ENDIF}
  RegisterPropertyEditor(TypeInfo(TROInfo),TAHMInformationLabel,'CaptionValue',TAHMROInfoProperty);
//  RegisterPropertyEditor(TypeInfo(TCaption),TAHMInformationLabel,'Caption',TAHMROCaptionProperty);
end;

{function TAHMROCaptionProperty.GetAttributes : TPropertyAttributes;
begin
  Result := inherited GetAttributes + [paReadonly];
end;}

function TAHMROInfoProperty.GetAttributes : TPropertyAttributes;
begin
  Result := inherited GetAttributes + [paReadonly];
end;


procedure TAHMAboutStandardControl.Edit;
begin
  ShowStandardsAbout;
end;

function TAHMAboutStandardControl.GetValue: string;
begin
  FmtStr(Result, '(%s)', ['AHM Standard Controls']);
end;

function TAHMAboutStandardControl.GetAttributes: TPropertyAttributes;
begin
  Result := [paMultiSelect,paDialog,paReadOnly];
end;

function TAHMDataFieldProperty.GetDataSourcePropName: string;
begin
  Result := 'DataSource';
end;

procedure TAHMDataFieldProperty.GetValueList(List: TStrings);
var Instance: TPersistent;
    PropInfo: PPropInfo;
    DataSource: TDataSource;
begin
  Instance := GetComponent(0);
  PropInfo := TypInfo.GetPropInfo(Instance.ClassInfo, GetDataSourcePropName);
  if (PropInfo <> nil) and (PropInfo^.PropType^.Kind = tkClass) then
  begin
    DataSource := TObject(GetOrdProp(Instance, PropInfo)) as TDataSource;
    if (DataSource <> nil) and (DataSource.DataSet <> nil) then
      DataSource.DataSet.GetFieldNames(List);
  end;
end;

function TAHMItemDataFieldProperty.GetDataSourcePropName: string;
begin
  Result := 'DataSource';
end;

function TAHMDBStringProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paSortList, paMultiSelect];
end;

procedure TAHMDBStringProperty.GetValueList(List: TStrings);
begin
end;


procedure TAHMDBStringProperty.GetValues(Proc: TGetStrProc);
var
  I: Integer;
  Values: TStringList;
begin
  Values := TStringList.Create;
  try
    GetValueList(Values);
    for I := 0 to Values.Count - 1 do Proc(Values[I]);
  finally
    Values.Free;
  end;
end;

{$IFDEF AHMINPRISE3}
procedure TAHMItemDataFieldProperty.GetValueList(List: TStrings);
var
  Instance: TPersistent;
  PropInfo: PPropInfo;
  DataSource: TDataSource;
begin
  Instance := (GetComponent(0) as TAHMADField).Owner;
  PropInfo := TypInfo.GetPropInfo(Instance.ClassInfo, GetDataSourcePropName);
  if (PropInfo <> nil) and (PropInfo^.PropType^.Kind = tkClass) then
  begin
    DataSource := TObject(GetOrdProp(Instance, PropInfo)) as TDataSource;
    if (DataSource <> nil) and (DataSource.DataSet <> nil) then
      DataSource.DataSet.GetFieldNames(List);
  end;
end;

procedure TAHMDBAsciiConfigEditor.ExecuteVerb(Index: Integer);
begin
  if (Index< 0) and (Index>1) then Exit;
  if index=0 then Edit;
end;

function TAHMDBAsciiConfigEditor.GetVerb(Index: Integer): String;
begin
  if index=0 then  Result := '&Insert All Fields';
end;

function TAHMDBAsciiConfigEditor.GetVerbCount: Integer;
begin
  Result:=1;
end;

procedure TAHMDBAsciiConfigEditor.Edit;
begin
  if (Component is TAHMDBAscii) then
  if not(TAHMDBAscii(Component).InsertAllFields) then
    showmessage(Component.name+' has not a ACTIVE dataset assigned against it.');
end;


{$ELSE}
procedure TAHMItemDataFieldProperty.GetValueList(List: TStrings);
var
  Instance: TComponent;
  PropInfo: PPropInfo;
  DataSource: TDataSource;
begin
  Instance := GetComponent(0);
  PropInfo := TypInfo.GetPropInfo(Instance.ClassInfo, GetDataSourcePropName);
  if (PropInfo <> nil) and (PropInfo^.PropType^.Kind = tkClass) then
  begin
    DataSource := TObject(GetOrdProp(Instance, PropInfo)) as TDataSource;
    if (DataSource <> nil) and (DataSource.DataSet <> nil) then
      DataSource.DataSet.GetFieldNames(List);
  end;
end;
{$ENDIF}




end.
