acldbreg.pas

来自「delphi编程控件」· PAS 代码 · 共 1,263 行 · 第 1/3 页

PAS
1,263
字号
unit acldbreg;
(*
 COPYRIGHT (c) RSD Software 1997 - 98
 All Rights Reserved.
*)

{$I aclver.inc}
interface
uses   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DsgnIntf, DBTables, DB {$IFNDEF DELPHI3_0} , MaskProp {$ENDIF};

procedure Register;

implementation

uses  adbcombo, adbimctr, adbtempl, adbtmple, adbgrid, adbpanel,
  aimctrls, asimpred, aimpredt, refer, adbgrfed, adbgrded, adefctrl,
  adbmaker, afilter, filtcomp, AutoDB, AutoFind, aincsrch, afforms,
  audbstrs, adbpaned, adbpnfed, adbpnped, filtered, MacroEd, TypInfo,
  afformed, adbdate, referred, adbtimct, aqtyper, amaskped
  {$IFDEF DELPHI3_0}, adbrich {$ENDIF}, abtnedit;

{TAutoRepositoryEditor}
type
  TAutoRepositoryEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure TAutoRepositoryEditor.ExecuteVerb(Index: Integer);
begin
  if(TAutoRepository(Component).Designer <> Nil) then
    TFAutoRepositoryEditor(TAutoRepository(Component).DesignerForm).Show
  else ShowAutoRepositoryEditor(TAutoRepository(Component));
  TAutoRepository(Component).Designer := Designer;
end;

function TAutoRepositoryEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := LoadStr(ACDB_REPOSITORYCAPTION);
  end;
end;

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

{TAutoDBGridEditor}
type
TAutoDBGridEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure TAutoDBGridEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: if ShowAutoGridLayoutEditor(TAutoDBGrid(Component).GridLayout) then
        Designer.Modified;
  end;
end;

function TAutoDBGridEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := LoadStr(ACDB_GRIDEDITOR);
  end;
end;

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

{TAutoDBPanelEditor}
type
TAutoDBPanelEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure TAutoDBPanelEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: if ShowAutoPanelLayoutEditor(TAutoDBPanel(Component).PanelLayout) then
        Designer.Modified;
  end;
end;

function TAutoDBPanelEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := LoadStr(ACDB_PANELEDITOR);
  end;
end;

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


{TAutoRepositoryPropertyEditor}
type
TAutoRepositoryPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoRepositoryPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TAutoDefDataSets.ClassName]);
end;

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

procedure TAutoRepositoryPropertyEditor.Edit;
begin
  if(TAutoRepository(GetComponent(0)).Designer <> Nil) then
    TFAutoRepositoryEditor(TAutoRepository(GetComponent(0)).DesignerForm).Show
  else ShowAutoRepositoryEditor(TAutoRepository(GetComponent(0)));
  TAutoRepository(GetComponent(0)).Designer := Designer;
end;


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

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

procedure TAutoGridLayoutPropertyEditor.Edit;
Var
  GridLayout : TAutoGridLayout;
begin
  GridLayout := TAutoGridLayout(GetOrdValue);
  if (ShowAutoGridLayoutEditor(GridLayout)) then
    Modified;
end;

{ TAutoGridLayoutFieldsPropertyEditor }
type
TAutoGridLayoutFieldsPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoGridLayoutFieldsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TAutoGridFields.ClassName]);
end;

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

procedure TAutoGridLayoutFieldsPropertyEditor.Edit;
Var
  GridLayout : TAutoGridLayout;
begin
  GridLayout := TAutoGridFields(GetOrdValue).GridLayout;
  if (ShowAutoGridFieldsEditor(GridLayout)) then
    Modified;
end;

{ TAutoGridLayoutGroupsPropertyEditor }
type
TAutoGridLayoutGroupsPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoGridLayoutGroupsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TAutoGridGroups.ClassName]);
end;

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

procedure TAutoGridLayoutGroupsPropertyEditor.Edit;
Var
  GridLayout : TAutoGridLayout;
begin
  GridLayout := TAutoGridGroups(GetOrdValue).GridLayout;
  if (ShowAutoGridLayoutEditor(GridLayout)) then
    Modified;
end;

{TAutoFilterFormFieldsPropertyEditor}
type
TAutoFilterFormFieldsPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoFilterFormFieldsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TAutoFilterFields.ClassName]);
end;

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

procedure TAutoFilterFormFieldsPropertyEditor.Edit;
Var
  FilterForm : TCustomAutoFilterForm;
begin
  FilterForm := GetComponent(0) as TCustomAutoFilterForm;
  if (ShowAutoFilterFieldsEditor(FilterForm)) then
    Modified;
end;


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

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

procedure TAutoPanelLayoutPropertyEditor.Edit;
Var
  PanelLayout : TAutoPanelLayout;
begin
  PanelLayout := TAutoPanelLayout(GetOrdValue);
  if (ShowAutoPanelLayoutEditor(PanelLayout)) then
    Modified;
end;

{TAutoPanelLayoutFieldsPropertyEditor}
type
TAutoPanelLayoutFieldsPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoPanelLayoutFieldsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TAutoPanelFields.ClassName]);
end;

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

procedure TAutoPanelLayoutFieldsPropertyEditor.Edit;
Var
  PanelLayout : TAutoPanelLayout;
begin
  PanelLayout := TAutoPanelFields(GetOrdValue).PanelLayout;
  if (ShowAutoPanelFieldsEditor(PanelLayout)) then
    Modified;
end;

{TAutoPanelLayoutPagesPropertyEditor}
type
TAutoPanelLayoutPagesPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoPanelLayoutPagesPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TAutoPanelPages.ClassName]);
end;

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

procedure TAutoPanelLayoutPagesPropertyEditor.Edit;
Var
  PanelLayout : TAutoPanelLayout;
begin
  PanelLayout := TAutoPanelPages(GetOrdValue).PanelLayout;
  if (ShowAutoPanelPagesEditor(PanelLayout)) then
    Modified;
end;

{ TDBStringProperty }

type
  TDBStringProperty = class(TStringProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValueList(List: TStrings); virtual;
    procedure GetValues(Proc: TGetStrProc); override;
  end;

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

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

procedure TDBStringProperty.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;

type
  TDBComboBoxDatabaseNameProperty = class(TDBStringProperty)
  public
    procedure GetValueList(List: TStrings); override;
  end;

procedure TDBComboBoxDatabaseNameProperty.GetValueList(List: TStrings);
begin
  (GetComponent(0) as TAutoCustomDBComboBox).Query.DBSession.GetDatabaseNames(List);
end;

type
  TDBComboBoxTableNameProperty = class(TDBStringProperty)
  public
    procedure GetValueList(List: TStrings); override;
  end;

procedure TDBComboBoxTableNameProperty.GetValueList(List: TStrings);
var
  Query : TQuery;
begin
  Query := (GetComponent(0) as TAutoCustomDBComboBox).Query;
  Query.DBSession.GetTableNames(Query.DatabaseName, '', False, False, List);
end;

{ TDataFieldProperty }

type
  TDBComboBoxFieldNameProperty = class(TDBStringProperty)
  public
    procedure GetValueList(List: TStrings); override;
  end;

procedure TDBComboBoxFieldNameProperty.GetValueList(List: TStrings);
var
  Component: TAutoCustomDBComboBox;
  Table : TTable;
begin
  Component := (GetComponent(0) as TAutoCustomDBComboBox);
  Table := TTable.Create(Nil);
  Table.DataBaseName := Component.DataBaseName;
  Table.TableName := Component.TableName;
  Table.GetFieldNames(List);
  Table.Free;
end;

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

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

procedure TAutoDBDefSpinImageItemsProperties.Edit;
Var
  DefControl : TAutoDBDefSpinImage;
  SpinImage : TAutoCustomSpinImage;
begin
  SpinImage := TAutoCustomSpinImage.Create(Nil);
  DefControl := GetComponent(0) as TAutoDBDefSpinImage;
  with SpinImage do begin
    SetBounds(0, 0, 0, 0);
    Parent := Designer.Form;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?