cxgridreg.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,332 行 · 第 1/3 页
PAS
1,332 行
protected
function GetInstance: TPersistent; override;
end;
function TcxGridChartPieDiagramEventsProperty.GetInstance: TPersistent;
begin
Result := TcxGridChartView(GetComponent(0)).DiagramPie;
end;
{ TcxGridLevelGridViewProperty }
type
TcxGridLevelGridViewProperty = class(TComponentProperty)
private
function GetLevel: TcxGridLevel;
protected
property Level: TcxGridLevel read GetLevel;
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
end;
function TcxGridLevelGridViewProperty.GetLevel: TcxGridLevel;
begin
Result := TcxGridLevel(GetComponent(0));
end;
function TcxGridLevelGridViewProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes - [paMultiSelect];
end;
procedure TcxGridLevelGridViewProperty.GetValues(Proc: TGetStrProc);
var
AViewList: TcxGridLevelViewList;
I: Integer;
begin
AViewList := TcxGridLevelViewList.Create(Level);
try
for I := 0 to AViewList.ViewNames.Count - 1 do
Proc(AViewList.ViewNames[I]);
finally
AViewList.Free;
end;
end;
{ TcxGridLevelImageIndexProperty }
type
TcxGridLevelImageIndexProperty = class(TImageIndexProperty)
public
function GetImages: TCustomImageList; override;
end;
function TcxGridLevelImageIndexProperty.GetImages: TCustomImageList;
begin
Result := TcxCustomGrid(TcxGridLevel(GetComponent(0)).Control).LevelTabs.Images;
end;
{ TcxCustomGridTableItemPropertiesProperty }
type
TcxCustomGridTableItemPropertiesProperty = class(TClassProperty)
protected
function HasSubProperties: Boolean;
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
end;
function TcxCustomGridTableItemPropertiesProperty.HasSubProperties: Boolean;
var
I: Integer;
begin
for I := 0 to PropCount - 1 do
begin
Result := TcxCustomGridTableItem(GetComponent(I)).Properties <> nil;
if not Result then Exit;
end;
Result := True;
end;
function TcxCustomGridTableItemPropertiesProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes;
if not HasSubProperties then
Exclude(Result, paSubProperties);
Result := Result - [paReadOnly] +
[paValueList, paSortList, paRevertable{$IFDEF DELPHI6}, paVolatileSubProperties{$ENDIF}];
end;
function TcxCustomGridTableItemPropertiesProperty.GetValue: string;
begin
if HasSubProperties then
Result := GetRegisteredEditProperties.GetDescriptionByClass(
TcxCustomGridTableItem(GetComponent(0)).Properties.ClassType)
else
Result := '';
end;
procedure TcxCustomGridTableItemPropertiesProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
begin
for I := 0 to GetRegisteredEditProperties.Count - 1 do
Proc(GetRegisteredEditProperties.Descriptions[I]);
end;
procedure TcxCustomGridTableItemPropertiesProperty.SetValue(const Value: string);
var
APropertiesClass: TcxCustomEditPropertiesClass;
I: Integer;
begin
APropertiesClass := TcxCustomEditPropertiesClass(GetRegisteredEditProperties.FindByClassName(Value));
if APropertiesClass = nil then
APropertiesClass := TcxCustomEditPropertiesClass(GetRegisteredEditProperties.FindByDescription(Value));
{$IFNDEF DELPHI7}
if GetValue <> Value then
ObjectInspectorCollapseProperty;
{$ENDIF}
for I := 0 to PropCount - 1 do
TcxCustomGridTableItem(GetComponent(I)).PropertiesClass := APropertiesClass;
Modified;
end;
{$IFNDEF NONDB}
type
TcxDBDataSummaryItemFieldNameProperty = class(TFieldNameProperty)
public
function GetDataSource: TDataSource; override;
end;
function TcxDBDataSummaryItemFieldNameProperty.GetDataSource: TDataSource;
begin
Result := (GetComponent(0) as TcxDBDataSummaryItem).DataController.DataSource;
end;
type
TcxGridItemDBDataBindingFieldNameProperty = class(TFieldNameProperty)
public
function GetDataSource: TDataSource; override;
end;
function TcxGridItemDBDataBindingFieldNameProperty.GetDataSource: TDataSource;
begin
Result := TcxGridItemDBDataBinding(GetComponent(0)).DataController.DataSource;
end;
type
TMasterKeyFieldNamesProperty = class(TFieldNameProperty)
function GetDataSource: TDataSource; override;
end;
function TMasterKeyFieldNamesProperty.GetDataSource: TDataSource;
var
AIDataController: IcxCustomGridDataController;
AParentLevel: TcxGridLevel;
begin
Result := nil;
if Supports(GetComponent(0), IcxCustomGridDataController, AIDataController) then
begin
AParentLevel := AIDataController.GridView.Level as TcxGridLevel;
if AParentLevel <> nil then
AParentLevel := AParentLevel.Parent;
if (AParentLevel <> nil) and (AParentLevel.GridView <> nil) and
(AParentLevel.GridView.DataController is TcxDBDataController) then
Result := TcxDBDataController(AParentLevel.GridView.DataController).DataSource;
end;
end;
{ TcxGridDBChartItemDataBindingFieldNameProperty }
type
TcxGridDBChartItemDataBindingFieldNameProperty = class(TFieldNameProperty)
public
function GetDataSource: TDataSource; override;
procedure GetValueList(AList: TStrings); override;
end;
function TcxGridDBChartItemDataBindingFieldNameProperty.GetDataSource: TDataSource;
begin
Result := TcxGridDBChartItemDataBinding(GetComponent(0)).DataController.DataSource;
end;
procedure TcxGridDBChartItemDataBindingFieldNameProperty.GetValueList(AList: TStrings);
var
I, J: Integer;
AField: TField;
AValueTypeClass: TcxValueTypeClass;
begin
inherited;
for I := AList.Count - 1 downto 0 do
begin
AField := GetDataSource.DataSet.FindField(AList[I]);
if AField = nil then
AList.Delete(I)
else
begin
AValueTypeClass := GetValueTypeClassByField(AField);
for J := 0 to PropCount - 1 do
if not (GetComponent(J) as TcxGridDBChartItemDataBinding).IsValueTypeClassValid(AValueTypeClass) then
begin
AList.Delete(I);
Break;
end;
end;
end;
end;
{$ENDIF}
{ TcxCustomGridBandIndexProperty }
const
sNoBand = '<none>';
sIndexCaptionSeparator = ' - ';
type
TcxCustomGridBandIndexProperty = class(TIntegerProperty)
private
function GetGridView: TcxGridBandedTableView;
protected
function GetGridViewForComponent(AIndex: Integer): TcxGridBandedTableView; virtual; abstract;
function GetValueForBandIndex(AIndex: Integer): string;
function IsSameGridView: Boolean;
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
property GridView: TcxGridBandedTableView read GetGridView;
end;
function TcxCustomGridBandIndexProperty.GetGridView: TcxGridBandedTableView;
begin
Result := GetGridViewForComponent(0);
end;
function TcxCustomGridBandIndexProperty.GetValueForBandIndex(AIndex: Integer): string;
begin
if AIndex = -1 then
Result := sNoBand
else
begin
Result := IntToStr(AIndex);
if GridView.Bands[AIndex].Caption <> '' then
Result := Result + sIndexCaptionSeparator + GridView.Bands[AIndex].Caption;
end;
end;
function TcxCustomGridBandIndexProperty.IsSameGridView: Boolean;
var
I: Integer;
begin
Result := True;
for I := 1 to PropCount - 1 do
begin
Result := GetGridViewForComponent(I) = GridView;
if not Result then Break;
end;
end;
function TcxCustomGridBandIndexProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes;
if IsSameGridView then Include(Result, paValueList);
end;
function TcxCustomGridBandIndexProperty.GetValue: string;
begin
if IsSameGridView or (GetOrdValue = -1) then
Result := GetValueForBandIndex(GetOrdValue)
else
Result := inherited GetValue;
end;
procedure TcxCustomGridBandIndexProperty.GetValues(Proc: TGetStrProc);
begin
Proc(GetValueForBandIndex(-1));
end;
procedure TcxCustomGridBandIndexProperty.SetValue(const Value: string);
var
P: Integer;
begin
if Value = sNoBand then
SetOrdValue(-1)
else
begin
P := Pos(sIndexCaptionSeparator, Value);
if P = 0 then
inherited SetValue(Value)
else
inherited SetValue(Copy(Value, 1, P - 1));
end;
end;
{ TcxGridBandedColumnBandIndexProperty }
type
TcxGridBandedColumnBandIndexProperty = class(TcxCustomGridBandIndexProperty)
protected
function GetGridViewForComponent(AIndex: Integer): TcxGridBandedTableView; override;
public
procedure GetValues(Proc: TGetStrProc); override;
end;
function TcxGridBandedColumnBandIndexProperty.GetGridViewForComponent(AIndex: Integer): TcxGridBandedTableView;
begin
Result := TcxGridBandedColumnPosition(GetComponent(AIndex)).GridView;
end;
procedure TcxGridBandedColumnBandIndexProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
begin
inherited;
for I := 0 to GridView.Bands.BottomItemCount - 1 do
Proc(GetValueForBandIndex(GridView.Bands.BottomItems[I].Index));
end;
{ TcxGridBandBandIndexProperty }
type
TcxGridBandBandIndexProperty = class(TcxCustomGridBandIndexProperty)
protected
function GetGridViewForComponent(AIndex: Integer): TcxGridBandedTableView; override;
public
procedure GetValues(Proc: TGetStrProc); override;
end;
function TcxGridBandBandIndexProperty.GetGridViewForComponent(AIndex: Integer): TcxGridBandedTableView;
begin
Result := TcxGridBandPosition(GetComponent(AIndex)).GridView;
end;
procedure TcxGridBandBandIndexProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
function IsBandSelected(ABandIndex: Integer): Boolean;
var
ABand: TcxGridBand;
I: Integer;
begin
ABand := GridView.Bands[ABandIndex];
for I := 0 to PropCount - 1 do
begin
Result := TcxGridBandPosition(GetComponent(I)).Band = ABand;
if Result then Exit;
end;
Result := False;
end;
begin
inherited;
for I := 0 to GridView.Bands.Count - 1 do
if not IsBandSelected(I) then
Proc(GetValueForBandIndex(I));
end;
{ TcxCustomGridTableItemProperty }
type
TcxCustomGridTableItemProperty = class(TComponentProperty)
protected
function GetGridView: TcxCustomGridView;
procedure GetGridViewItemNames(AGridView: TcxCustomGridView; Proc: TGetStrProc); virtual;
function InternalGetGridView(APersistent: TPersistent): TcxCustomGridView; virtual; abstract;
public
procedure GetValues(Proc: TGetStrProc); override;
end;
procedure TcxCustomGridTableItemProperty.GetValues(Proc: TGetStrProc);
var
AGridView: TcxCustomGridView;
begin
AGridView := GetGridView;
if AGridView <> nil then
GetGridViewItemNames(AGridView, Proc);
end;
function TcxCustomGridTableItemProperty.GetGridView: TcxCustomGridView;
var
I: Integer;
begin
Result := InternalGetGridView(GetComponent(0));
for I := 1 to PropCount - 1 do
if InternalGetGridView(GetComponent(I)) <> Result then
begin
Result := nil;
Break;
end;
end;
procedure TcxCustomGridTableItemProperty.GetGridViewItemNames(AGridView: TcxCustomGridView;
Proc: TGetStrProc);
var
I: Integer;
begin
if AGridView is TcxCustomGridTableView then
with AGridView as TcxCustomGridTableView do
for I := 0 to ItemCount - 1 do
Proc(Designer.GetComponentName(Items[I]));
end;
{ TcxGridIncSearchItemProperty }
type
TcxGridIncSearchItemProperty = class(TcxCustomGridTableItemProperty)
protected
function InternalGetGridView(APersistent: TPersistent): TcxCustomGridView; override;
end;
function TcxGridIncSearchItemProperty.InternalGetGridView(APersistent: TPersistent):
TcxCustomGridView;
begin
Result := TcxCustomGridTableOptionsBehavior(APersistent).GridView;
end;
{ TcxGridPreviewColumnProperty }
type
TcxGridPreviewColumnProperty = class(TcxCustomGridTableItemProperty)
protected
function InternalGetGridView(APersistent: TPersistent): TcxCustomGridView; override;
end;
function TcxGridPreviewColumnProperty.InternalGetGridView(APersistent: TPersistent):
TcxCustomGridView;
begin
Result := TcxGridPreview(APersistent).GridView;
end;
{ TcxGridTableSummaryItemColumnProperty }
type
TcxGridTableSummaryItemColumnProperty = class(TcxCustomGridTableItemProperty)
protected
function InternalGetGridView(APersistent: TPersistent): TcxCustomGridView; override;
end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?