cxcustomdata.pas

来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,436 行 · 第 1/5 页

PAS
1,436
字号
    procedure SetTextStored(Value: Boolean);
    procedure SetValueTypeClass(Value: TcxValueTypeClass);
  protected
    procedure BeginRecreateData;
    procedure Changed;
    procedure ClearData;
    procedure CreateData;
    procedure EndRecreateData;
    procedure Reassign(ASource: TcxCustomDataField); virtual;
    procedure RemoveNotification(AComponent: TComponent); virtual;
    property FieldList: TcxCustomDataFieldList read FFieldList;
    property NeedConversion: Boolean read FNeedConversion write FNeedConversion;
    property Notifier: TComponent read GetNotifier;
    property TextStored: Boolean read GetTextStored write SetTextStored;
    property ValueDef: TcxValueDef read GetValueDef;
  public
    constructor Create(AFieldList: TcxCustomDataFieldList); virtual;
    destructor Destroy; override;
    function CanModify(AEditValueSource: TcxDataEditValueSource): Boolean; virtual;
    function IsUnbound: Boolean; virtual;
    function IsValueDefInternal: Boolean; virtual;
    property DataController: TcxCustomDataController read GetDataController;
    property Index: Integer read GetIndex write SetIndex;
    property IsInternal: Boolean read FIsInternal write SetIsInternal;
    property Item: TObject read FItem write FItem;
    property ReferenceField: TcxCustomDataField read FReferenceField write SetReferenceField;
    property ValueTypeClass: TcxValueTypeClass read GetValueTypeClass write SetValueTypeClass;
  end;

  TcxCustomDataFieldClass = class of TcxCustomDataField;

  { TcxCustomDataFieldList }

  TcxCustomDataFieldList = class
  private
    FDataController: TcxCustomDataController;
    FFieldDestroyed: Boolean;
    FInternalCount: Integer;
    FItems: TList;
    function GetCount: Integer;
    function GetItem(Index: Integer): TcxCustomDataField;
    function GetItemCount: Integer;
  protected
    procedure Add(AField: TcxCustomDataField);
    procedure Clear;
    procedure RemoveField(AField: TcxCustomDataField);
    procedure RemoveNotification(AComponent: TComponent); virtual;
    procedure Update;
  public
    constructor Create(ADataController: TcxCustomDataController); virtual;
    destructor Destroy; override;
    function FieldByItem(AItem: TObject): TcxCustomDataField;
    procedure ReassignFields(ADestroyedField: TcxCustomDataField);
    property Count: Integer read GetCount;
    property DataController: TcxCustomDataController read FDataController;
    property ItemCount: Integer read GetItemCount;
    property Items[Index: Integer]: TcxCustomDataField read GetItem; default;
  end;

  { Master-Detail }

  TcxDetailInfoObject = class
    LinkObject: TObject;
    HasChildren: Boolean;
    HasChildrenAssigned: Boolean;
  public
    destructor Destroy; override;
  end;

  TcxDetailObject = class
  private
    FActiveRelationIndex: Integer;
    FInfoObjects: TList;
    FExpanded: Boolean;
    function GetInfoObject(Index: Integer): TcxDetailInfoObject;
    function GetInfoObjectCount: Integer;
    function GetIsEmpty: Boolean;
    function GetLinkObject(Index: Integer): TObject;
    function GetLinkObjectCount: Integer;
    procedure SetInfoObject(Index: Integer; Value: TcxDetailInfoObject);
    procedure SetLinkObject(Index: Integer; Value: TObject);
  protected
    procedure CorrectCount(ARelations: TcxCustomDataRelationList);
  public
    constructor Create;
    destructor Destroy; override;
    procedure Clear;
    function ClearHasChildrenFlag: Boolean;
    procedure ClearInfoObject(AIndex: Integer);
    property ActiveRelationIndex: Integer read FActiveRelationIndex write FActiveRelationIndex;
    property Expanded: Boolean read FExpanded write FExpanded;
    property InfoObjectCount: Integer read GetInfoObjectCount;
    property InfoObjects[Index: Integer]: TcxDetailInfoObject read GetInfoObject write SetInfoObject;
    property IsEmpty: Boolean read GetIsEmpty;
    property LinkObjectCount: Integer read GetLinkObjectCount;
    property LinkObjects[Index: Integer]: TObject read GetLinkObject write SetLinkObject;
  end;

  { TcxCustomDataRelation }

  TcxCustomDataRelation = class
  private
    FDetailDataController: TcxCustomDataController;
    FItem: TObject;
    FRelationList: TcxCustomDataRelationList;
    function GetDataController: TcxCustomDataController;
    function GetIndex: Integer;
  protected
    procedure Changed;
    procedure RemoveDataField(ADataField: TcxCustomDataField); virtual;
  public
    constructor Create(ARelationList: TcxCustomDataRelationList; AItem: TObject); virtual;
    destructor Destroy; override;
    procedure Assign(ASource: TcxCustomDataRelation); virtual;
    property DataController: TcxCustomDataController read GetDataController;
    property DetailDataController: TcxCustomDataController read FDetailDataController;
    property Index: Integer read GetIndex;
    property Item: TObject read FItem;
    property RelationList: TcxCustomDataRelationList read FRelationList;
  end;

  TcxCustomDataRelationClass = class of TcxCustomDataRelation;

  { TcxCustomDataRelationList }

  TcxCustomDataRelationList = class
  private
    FDataController: TcxCustomDataController;
    FDataField: TcxCustomDataField;
    FItems: TList;
    FLockCount: Integer;
    procedure AddItem(AItem: TcxCustomDataRelation);
    function GetCount: Integer;
    function GetItem(Index: Integer): TcxCustomDataRelation;
    procedure RemoveItem(AItem: TcxCustomDataRelation);
  protected
    procedure Changed(ARelation: TcxCustomDataRelation);
    function GetValueAsDetailObject(ARecordIndex: Integer): TcxDetailObject;
    procedure RemoveDataField(ADataField: TcxCustomDataField);
    procedure Update(ARelation: TcxCustomDataRelation);

    property DataController: TcxCustomDataController read FDataController;
    property LockCount: Integer read FLockCount;
  public
    constructor Create(ADataController: TcxCustomDataController);
    destructor Destroy; override;
    function Add(AItem: TObject): TcxCustomDataRelation;
    procedure Assign(ASource: TcxCustomDataRelationList);
    procedure BeginUpdate;
    procedure Clear;
    function ClearDetailObject(ARecordIndex, ARelationIndex: Integer): Boolean;
    procedure EndUpdate;
    function FindByItem(AItem: TObject): TcxCustomDataRelation;
    function GetDetailObject(ARecordIndex: Integer): TcxDetailObject;
    function IsDetailObjectExist(ARecordIndex, ARelationIndex: Integer): Boolean;
    function IsEmpty: Boolean;
    procedure Move(ACurIndex, ANewIndex: Integer);
    procedure RemoveByItem(AItem: TObject);

    property Count: Integer read GetCount;
    property Items[Index: Integer]: TcxCustomDataRelation read GetItem; default;
  end;

  { TcxCustomDataController }

  { TcxSortingFieldList }

  TcxDataSortOrder = (soNone, soAscending, soDescending);

  TcxDataSortInfo = record
    Field: TcxCustomDataField;
    SortOrder: TcxDataSortOrder;
  end;
  PcxDataSortInfo = ^TcxDataSortInfo;

  TcxNoParamsEvent = procedure of object;

  TcxSortingFieldList = class
  private
    FItems: TList;              
    FOnChanged: TcxNoParamsEvent;
    function GetCount: Integer;
    function GetItem(Index: Integer): TcxDataSortInfo;
  protected
    procedure Add(AField: TcxCustomDataField; ASortOrder: TcxDataSortOrder);
    procedure Changed;
    procedure Delete(Index: Integer);
    function Find(AField: TcxCustomDataField): Integer;
    procedure Insert(Index: Integer; AField: TcxCustomDataField; ASortOrder: TcxDataSortOrder);
    procedure Move(ACurIndex, ANewIndex: Integer);
    procedure Remove(AField: TcxCustomDataField);
    procedure SetSortOrder(Index: Integer; ASortOrder: TcxDataSortOrder);
  public
    constructor Create;
    destructor Destroy; override;
    procedure AppendFrom(AList: TcxSortingFieldList);
    procedure ChangeSorting(AField: TcxCustomDataField; ASortOrder: TcxDataSortOrder); virtual;
    procedure CheckField(AField: TcxCustomDataField);
    procedure Clear;
    function SortIndexByField(AField: TcxCustomDataField): Integer;
    function SortOrderByField(AField: TcxCustomDataField): TcxDataSortOrder;
    property Count: Integer read GetCount;
    property Items[Index: Integer]: TcxDataSortInfo read GetItem; default;
    property OnChanged: TcxNoParamsEvent read FOnChanged write FOnChanged;
  end;

  TcxGroupingFieldList = class(TcxSortingFieldList)
  public
    procedure ChangeGrouping(AField: TcxCustomDataField; AGroupIndex: Integer);
    procedure ChangeSorting(AField: TcxCustomDataField; ASortOrder: TcxDataSortOrder); override;
    function GroupIndexByField(AField: TcxCustomDataField): Integer;
    procedure UpdateSorting(ASortingFieldList: TcxSortingFieldList);
  end;

  { TcxDataGroups }

  TcxDataGroupInfo = class
    RowIndex: Integer;
    Expanded: Boolean;
    Level: Integer;
    BeginRecordListIndex: Integer;
    EndRecordListIndex: Integer;
    SummaryValues: Variant;
  end;

  TcxGroupsRowInfo = record
    Expanded: Boolean;
    Level: Integer;
    RecordListIndex: Integer;
  end;

  TcxDataGroups = class
  private
    FFields: TList;
    FItems: TList;

    function GetField(Index: Integer): TcxCustomDataField;
    function GetFieldCount: Integer;
    function GetItem(Index: Integer): TcxDataGroupInfo;
    function GetItemCount: Integer;
    function GetRowCount: Integer;
    function GetRowInfo(ARowIndex: Integer): TcxGroupsRowInfo;
    function GetTopVisibleItem(ARowIndex: Integer; var ACurIndex: Integer): TcxDataGroupInfo;
  protected
    procedure Add(const ADataGroupInfo: TcxDataGroupInfo);
    procedure AddField(AField: TcxCustomDataField);
    function AddEmpty: TcxDataGroupInfo;
    procedure Clear;
    function Find(ARowIndex: Integer; var AItem: TcxDataGroupInfo): Integer;
    function FindByIndex(ARecordListIndex, ALevel: Integer): Integer;
    function IsVisible(AIndex: Integer): Boolean;
    function MakeVisible(AIndex: Integer; AExpand: Boolean): Boolean;

    property FieldCount: Integer read GetFieldCount;
    property Fields[Index: Integer]: TcxCustomDataField read GetField;
  public
    constructor Create;
    destructor Destroy; override;
    procedure ChangeExpanding(ARowIndex: Integer; AExpanded, ARecursive: Boolean);
    procedure FullExpanding(AExpanded: Boolean);
    function GetChildCount(AIndex: Integer): Integer;
    function GetChildIndex(AParentIndex, AIndex: Integer): Integer;
    function GetChildRecordListIndex(AParentIndex, AIndex: Integer): Integer;
    function GetDataRecordListIndex(AInfo: TcxDataGroupInfo): Integer;
    function GetFirstLevelCount: Integer;
    function GetFirstLevelIndex(AIndex: Integer): Integer;
    function GetIndexByRowIndex(ARowIndex: Integer): Integer;
    function GetIndexByRowIndexLevel(ARowIndex, ALevel: Integer): Integer;
    function GetLevel(AIndex: Integer): Integer;
    function GetParentIndex(AChildIndex: Integer): Integer;
    procedure Rebuild;
    procedure SetItem(AIndex: Integer; AItem: TcxDataGroupInfo);

    property Count: Integer read GetItemCount;
    property Items[Index: Integer]: TcxDataGroupInfo read GetItem; default;
    property LevelCount: Integer read GetFieldCount;
    property RowInfo[RowIndex: Integer]: TcxGroupsRowInfo read GetRowInfo;
    property RowCount: Integer read GetRowCount;
  end;

  { TcxCustomDataControllerInfo }

  TcxDataControllerInfoChange = (dcicLoad, dcicGrouping, dcicSorting,
    dcicFocusedRow, dcicView, dcicExpanding, dcicResetFocusedRow, dcicSelection,
    dcicSummary, dcicFocusedRecord);
  TcxDataControllerInfoChanges = set of TcxDataControllerInfoChange;

  TcxRowInfo = record

⌨️ 快捷键说明

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