⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cxvgridreg.pas

📁 delphi的的三方控件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{ TcxRTTIInspectorComponentEditor }

procedure TcxRTTIInspectorComponentEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: if Component is TcxRTTIInspector then
         ShowImportDialog(Designer, Component, cxRTTIVGGroupConverterName, False);
    1: GetInspector.RestoreDefaults;
    4: OpenWebPage(DXWebPage);
  end;
end;

function TcxRTTIInspectorComponentEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := 'Import...';
    1: Result := 'Restore default values';
    2: Result := '-';
    3: Result := 'ExpressVerticalGrid ' + cxVGridVersion;
    4: Result := DXWebPage;
  end;
end;

function TcxRTTIInspectorComponentEditor.GetVerbCount: Integer;
begin
  Result := 5;
end;

function TcxRTTIInspectorComponentEditor.GetInspector: TcxCustomRTTIInspector;
begin
  Result := Component as TcxCustomRTTIInspector;
end;

{ TcxDBVerticalGridItemDataBindingFieldNameProperty }

function TcxDBVerticalGridItemDataBindingFieldNameProperty.GetDataSource: TDataSource;
begin
  Result := TcxDBVerticalGridItemDataBinding(GetComponent(0)).DataController.DataSource;
end;

{ TcxOIPropertyEditor }

function TcxOIPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList];
end;

procedure TcxOIPropertyEditor.GetValues(Proc: TGetStrProc);

  function IsValidComponent(AComponent: TComponent): Boolean;
  begin
    Result := (AComponent.Name <> '') and
      IsValidInspectedObject(AComponent, GetComponent(0) as TcxCustomRTTIInspector);
  end;

  procedure FillList(AComponent: TComponent);
  var
    I: Integer;
  begin
     if IsValidComponent(AComponent) then
       Proc(AComponent.Name);
     for i := 0 to AComponent.ComponentCount - 1 do
       FillList(AComponent.Components[I]);
  end;

begin
  FillList(Designer.GetRoot);
end;

function TcxOIPropertyEditor.GetValue: string;
var
  OI: TcxCustomRTTIInspector;
begin
  Result := '';
  OI := TcxCustomRTTIInspector(GetComponent(0));
  if OI.InspectedObject <> nil then
  begin
    if OI.InspectedObject is TComponent then
      Result := OI.InspectedObject.GetNamePath;
  end;
end;


procedure TcxOIPropertyEditor.SetValue(const Value: string);

   function GetValueComponent: TComponent;
   begin
     if CompareText(Value, Designer.GetRoot.Name) = 0 then
       Result := Designer.GetRoot
     else Result := Designer.GetRoot.FindComponent(Value);
     if Result = nil then
       Result := Application.FindComponent(Value);
     if Result = GetComponent(0) then
       Result := nil;
   end;

var
  OI: TcxCustomRTTIInspector;
begin
  OI := TcxCustomRTTIInspector(GetComponent(0));
  if Value = '' then
    OI.InspectedObject := nil
  else
  begin
    if GetValueComponent <> nil then
      OI.InspectedObject := GetValueComponent;
  end;
  Modified;
end;

{$IFDEF DELPHI6}
type
  TcxVerticalGridSelectionEditor = class(TSelectionEditor)
  protected
    ComponentsList: TStringList;
  public
    procedure AddComponent(const Name: string);
    procedure RequiresUnits(Proc: TGetStrProc); override;
  end;

procedure TcxVerticalGridSelectionEditor.RequiresUnits(Proc: TGetStrProc);

  procedure AddPropertiesUnitName(AProperties: TcxCustomEditProperties);
  begin
    if AProperties <> nil then
      Proc(GetTypeData(PTypeinfo(AProperties.ClassType.ClassInfo))^.UnitName);
  end;

  procedure CheckRow(ARow: TcxCustomRow);
  var
    AProperties: TcxCustomRowProperties;
    I: Integer;
  begin
    AProperties := TcxCustomRowAccess(ARow).FProperties;
    if AProperties is TcxCustomEditorRowProperties then
      with TcxCustomEditorRowProperties(AProperties) do
        AddPropertiesUnitName(EditProperties)
    else
      if AProperties is TcxDBMultiEditorRowProperties then
        with TcxDBMultiEditorRowProperties(AProperties) do
          for I := 0 to Editors.Count - 1 do
            AddPropertiesUnitName(Editors[I].EditProperties)
      else
        if AProperties is TcxMultiEditorRowProperties then
          with TcxMultiEditorRowProperties(AProperties) do
            for I := 0 to Editors.Count - 1 do
              AddPropertiesUnitName(Editors[I].EditProperties)
  end;

var
  AComponent: TComponent;
  I, J: Integer;
begin
  Proc(UnitNamePrefix + 'cxStyles');
  Proc(UnitNamePrefix + 'cxGraphics');
  Proc(UnitNamePrefix + 'cxEdit');
  ComponentsList := TStringList.Create;
  try
    Designer.GetComponentNames(GetTypeData(PTypeInfo(TcxCustomVerticalGrid.ClassInfo)), AddComponent);
    for I := 0 to ComponentsList.Count - 1 do
    begin
      AComponent := Designer.GetComponent(ComponentsList[I]);
      if AComponent is TcxCustomVerticalGrid then
        with TcxCustomVerticalGrid(AComponent) do
          for J := 0 to Rows.Count - 1 do CheckRow(Rows[J]);
    end;
  finally
    ComponentsList.Free;
  end;
end;

procedure TcxVerticalGridSelectionEditor.AddComponent(const Name: string);
begin
  ComponentsList.Add(Name);
end;
{$ENDIF}

procedure Register;
begin
{$IFDEF DELPHI9}
  ForceDemandLoadState(dlDisable);
{$ENDIF}  

  RegisterComponents('Dev Express', [TcxVerticalGrid,
    TcxVirtualVerticalGrid, TcxDBVerticalGrid, TcxRTTIInspector]);
  //rows
  RegisterClasses([TcxCustomVerticalGrid, TcxCategoryRow, TcxEditorRow,
    TcxMultiEditorRow, TcxVerticalGridStyleSheet]);
  RegisterNoIcon([TcxCategoryRow, TcxEditorRow, TcxMultiEditorRow,
    TcxVerticalGridStyleSheet]);
  //row properties
  RegisterClasses([TcxCaptionRowProperties, TcxEditorRowProperties,
    TcxMultiEditorRowProperties]);
  RegisterPropertyEditor(TypeInfo(string), TcxCustomEditorRowProperties, 'EditPropertiesClassName', nil);
  RegisterPropertyEditor(TypeInfo(TcxCustomEditProperties), TcxCustomEditorRowProperties, 'EditProperties', TcxInplaceEditContainerPropertiesProperty);
  RegisterPropertyEditor(TypeInfo(TImageIndex), TcxCustomRowProperties, 'ImageIndex', TcxCustomRowPropertiesImageIndexProperty);
  RegisterPropertyEditor(TypeInfo(TNotifyEvent), TcxCustomVerticalGrid,
    'StylesEvents', TcxVerticalGridStylesEventsProperty);
  RegisterPropertyEditor(TypeInfo(TNotifyEvent), TcxCustomEditorRow,
    'PropertiesEvents', TcxEditorRowPropertiesEventsProperty);
  RegisterPropertyEditor(TypeInfo(TNotifyEvent), TcxCustomEditorRow,
    'EditPropertiesEvents', TcxEditPropertiesEventsProperty);
  RegisterPropertyEditor(TypeInfo(TNotifyEvent), TcxCollectionItemEditorRowProperties,
    'EditPropertiesEvents', TcxCollectionItemEditPropertiesEventsProperty);

  RegisterComponentEditor(TcxVerticalGrid, TcxVerticalGridComponentEditor);
  RegisterComponentEditor(TcxVirtualVerticalGrid, TcxVerticalGridComponentEditor);
  RegisterPropertyEditor(TypeInfo(string), TcxDBVerticalGridItemDataBinding, 'FieldName', TcxDBVerticalGridItemDataBindingFieldNameProperty);
  RegisterPropertyEditor(TypeInfo(string), TcxDBVerticalGridItemDataBinding, 'FieldName', TcxDBVerticalGridItemDataBindingFieldNameProperty);
  //DB
  RegisterClasses([TcxDBEditorRow, TcxDBMultiEditorRow]);
  RegisterNoIcon([TcxDBEditorRow, TcxDBMultiEditorRow]);
  RegisterClasses([TcxDBEditorRowProperties, TcxDBMultiEditorRowProperties]);
  RegisterComponentEditor(TcxDBVerticalGrid, TcxVerticalGridComponentEditor);
  RegisterPropertyEditor(TypeInfo(string), TcxDBVerticalGridItemDataBinding, 'FieldName', TcxDBVerticalGridItemDataBindingFieldNameProperty);
  //RTTI
  RegisterComponentEditor(TcxCustomRTTIInspector, TcxRTTIInspectorComponentEditor);
  RegisterPropertyEditor(TypeInfo(TPersistent), TcxCustomRTTIInspector, 'InspectedObject',
    TcxOIPropertyEditor);
{$IFDEF DELPHI6}
  RegisterSelectionEditor(TcxCustomVerticalGrid, TcxVerticalGridSelectionEditor);
{$ENDIF}
end;

initialization
  RegisterStyleSheetClass(TcxVerticalGridStyleSheet);

finalization
  UnRegisterStyleSheetClass(TcxVerticalGridStyleSheet);

end.

⌨️ 快捷键说明

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