cxpropertiesconverters.pas

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

PAS
923
字号
        if AButtons.Find('ptbCopy', I) then
          Include(AMenuItems, pmiCopy);
        if AButtons.Find('ptbPaste', I) then
          Include(AMenuItems, pmiPaste);
        if AButtons.Find('ptbDelete', I) then
          Include(AMenuItems, pmiDelete);
        if AButtons.Find('ptbLoad', I) then
          Include(AMenuItems, pmiLoad);
        if AButtons.Find('ptbSave', I) then
          Include(AMenuItems, pmiSave);
        if AButtons.Find('ptbCustom', I) then
          Include(AMenuItems, pmiCustom);
        PopupMenuLayout.MenuItems := AMenuItems;
      finally
        AButtons.Free;
      end;
    end;
  end;
  inherited DoImport;
end;

function TcxImagePropertiesConverter.GetDestination: TcxImageProperties;
begin
  Result := inherited Destination as TcxImageProperties;
end;

{ TcxImageComboBoxPropertiesConverter }

procedure TcxImageComboBoxPropertiesConverter.DoImport;
var
  AObject: TObject;
  AItem: TcxImageComboBoxItem;
  AdxImageIndexes: TObject;
  AdxValues: TObject;
  AdxDescriptions: TObject;
  I: Integer;
begin
  with Destination do
  begin
    Alignment.Horz := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    Alignment.Vert := ConvertVertAlignment(GetEnumProperty(Source, 'VertAlignment'));
    ButtonGlyph.Assign(GetClassProperty(Source, 'ButtonGlyph') as TBitmap);
    DropDownRows := GetIntegerProperty(Source, 'DropDownRows', DropDownRows);
    AObject := GetClassProperty(Source, 'Images');
    if AObject <> nil then
      Images := AObject as TCustomImageList
    else
      Images := nil;
    AObject := GetClassProperty(Source, 'LargeImages');
    if AObject <> nil then
      LargeImages := AObject as TCustomImageList
    else
      LargeImages := nil;
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
    MultiLineText := GetBooleanProperty(Source,'MultiLineText', MultiLineText);
    ShowDescriptions := GetBooleanProperty(Source, 'ShowDescription', ShowDescriptions);
    AdxImageIndexes := GetClassProperty(Source, 'ImageIndexes');
    AdxValues := GetClassProperty(Source, 'Values');
    AdxDescriptions := GetClassProperty(Source, 'Descriptions');
    if (AdxImageIndexes <> nil) and (AdxValues <> nil) and
      (AdxDescriptions <> nil) then
    begin
      if (AdxImageIndexes is TStrings) and (AdxValues is TStrings) and
        (AdxDescriptions is TStrings) then
      begin
        for I := 0 to TStrings(AdxImageIndexes).Count - 1 do
        begin
          AItem := Items.Add as TcxImageComboBoxItem;
          AItem.ImageIndex := StrToInt(TStrings(AdxImageIndexes)[I]);
          if I < TStrings(AdxDescriptions).Count then
            AItem.Description := TStrings(AdxDescriptions)[I];
          if I < TStrings(AdxValues).Count then
            AItem.Value := TStrings(AdxValues)[I];
        end;
      end;
    end;
  end;
  inherited DoImport;
end;

function TcxImageComboBoxPropertiesConverter.GetDestination: TcxImageComboBoxProperties;
begin
  Result := inherited Destination as TcxImageComboBoxProperties;
end;

{ TcxLookupComboBoxPropertiesConverter }

procedure TcxLookupComboBoxPropertiesConverter.DoImport;
begin
  with Destination do
  begin
    Alignment.Horz := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    Alignment.Vert := ConvertVertAlignment(GetEnumProperty(Source, 'VertAlignment'));
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
    CharCase := ConvertCharCase(GetEnumProperty(Source, 'CharCase'));
    ClearKey := GetIntegerProperty(Source, 'ClearKey', ClearKey);
    ImmediateDropDown := GetBooleanProperty(Source, 'ImmediateDropDown', ImmediateDropDown);
    OEMConvert := GetBooleanProperty(Source, 'OEMConvert', OEMConvert);
    MaxLength := GetIntegerProperty(Source, 'MaxLength', MaxLength);
    ButtonGlyph.Assign(GetClassProperty(Source, 'ButtonGlyph') as TBitmap);
    DropDownRows := GetIntegerProperty(Source, 'DropDownRows', DropDownRows);
    DropDownWidth := GetIntegerProperty(Source, 'DropDownWidth', DropDownWidth);
    ListFieldNames := GetStringProperty(Source, 'ListFieldName', ListFieldNames);
    PopupAlignment := ConvertAlignment(GetEnumProperty(Source, 'PopupAlignment'));
    ListOptions.ShowHeader := False;
  end;
  inherited DoImport;
end;

function TcxLookupComboBoxPropertiesConverter.GetDestination: TcxLookupComboBoxProperties;
begin
  Result := inherited Destination as TcxLookupComboBoxProperties;
end;

{ TcxMaskEditPropertiesConverter }

procedure TcxMaskEditPropertiesConverter.DoImport;
begin
  with Destination do
  begin
    Alignment.Horz := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    Alignment.Vert := ConvertVertAlignment(GetEnumProperty(Source, 'VertAlignment'));
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
    CharCase := ConvertCharCase(GetEnumProperty(Source, 'CharCase'));
    EditMask := GetStringProperty(Source, 'EditMask', EditMask);
    IgnoreMaskBlank := GetBooleanProperty(Source, 'IgnoreMaskBlank', IgnoreMaskBlank);
    MaskKind := emkStandard;
    MaxLength := GetIntegerProperty(Source, 'MaxLength', MaxLength);
    OEMConvert := GetBooleanProperty(Source, 'OEMConvert', OEMConvert);
  end;
  inherited DoImport;
end;

function TcxMaskEditPropertiesConverter.GetDestination: TcxMaskEditProperties;
begin
  Result := inherited Destination as TcxMaskEditProperties;
end;

{ TcxMemoPropertiesConverter }

procedure TcxMemoPropertiesConverter.DoImport;
begin
  with Destination do
  begin
    Alignment := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
    CharCase := ConvertCharCase(GetEnumProperty(Source, 'CharCase'));
    MaxLength := GetIntegerProperty(Source, 'MaxLength', MaxLength);
    OEMConvert := GetBooleanProperty(Source, 'OEMConvert', OEMConvert);
    ScrollBars := ConvertScrollStyle(GetEnumProperty(Source, 'ScrollBars'));
    WantReturns := GetBooleanProperty(Source, 'WantReturns', WantReturns);
    WantTabs := GetBooleanProperty(Source, 'WantTabs', WantTabs);
    WordWrap := GetBooleanProperty(Source, 'WordWrap', WordWrap);
  end;
  inherited DoImport;
end;

function TcxMemoPropertiesConverter.GetDestination: TcxMemoProperties;
begin
  Result := inherited Destination as TcxMemoProperties;
end;

{ TcxMRUEditPropertiesConverter }

procedure TcxMRUEditPropertiesConverter.DoImport;
var
  AObject: TObject;
  AItems: TStringList;
  I: Integer;
begin
  with Destination do
  begin
    AItems := GetClassProperty(Source, 'Items') as TStringList;
    if AItems <> nil then
      for I := 0 to AItems.Count - 1 do
        LookupItems.Add(AItems[I]);
    Alignment.Horz := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    Alignment.Vert := ConvertVertAlignment(GetEnumProperty(Source, 'VertAlignment'));
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
    AObject := GetClassProperty(Source, 'ButtonGlyph');
    ButtonGlyph.Assign(AObject as TBitmap);
    DropDownRows := GetIntegerProperty(Source, 'DropDownRows', DropDownRows);
    ImmediateDropDown := GetBooleanProperty(Source, 'ImmediateDropDown', ImmediateDropDown);
    MaxItemCount := GetIntegerProperty(Source, 'MaxItemCount', MaxItemCount);
    ShowEllipsis := GetBooleanProperty(Source, 'ShowEllipsis', ShowEllipsis);
  end;
  inherited DoImport;
end;

function TcxMRUEditPropertiesConverter.GetDestination: TcxMRUEditProperties;
begin
  Result := inherited Destination as TcxMRUEditProperties;
end;

{ TcxPopupEditPropertiesConverter }

procedure TcxPopupEditPropertiesConverter.DoImport;
var
  AObject: TObject;
  APanelStyle: string;
begin
  with Destination do
  begin
    Alignment.Horz := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    Alignment.Vert := ConvertVertAlignment(GetEnumProperty(Source, 'VertAlignment'));
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
    CharCase := ConvertCharCase(GetEnumProperty(Source, 'CharCase'));
    MaxLength := GetIntegerProperty(Source, 'MaxLength', MaxLength);
    OEMConvert := GetBooleanProperty(Source, 'OEMConvert', OEMConvert);
    PopupAutoSize := GetBooleanProperty(Source, 'PopupAutoSize', PopupAutoSize);
    PopupClientEdge := GetBooleanProperty(Source, 'PopupFormClientEdge', PopupClientEdge);
    AObject := GetClassProperty(Source, 'PopupControl');
    if AObject <> nil then
      PopupControl := AObject as TControl
    else
      PopupControl := nil;
    PopupHeight := GetIntegerProperty(Source, 'PopupHeight', PopupHeight);
    PopupMinHeight := GetIntegerProperty(Source, 'PopupMinHeight', PopupMinHeight);
    PopupMinWidth := GetIntegerProperty(Source, 'PopupMinWidth', PopupMinWidth);
    PopupWidth := GetIntegerProperty(Source, 'PopupWidth', PopupWidth);
    PopupSizeable := GetBooleanProperty(Source, 'PopupFormSizeable', PopupSizeable);
    APanelStyle := GetEnumProperty(Source, 'PopupFormBorderStyle');
    PopupSysPanelStyle := APanelStyle = 'pbsSysPanel';
  end;
  inherited DoImport;
end;

function TcxPopupEditPropertiesConverter.GetDestination: TcxPopupEditProperties;
begin
  Result := inherited Destination as TcxPopupEditProperties;
end;

{ TcxSpinEditPropertiesConverter }

procedure TcxSpinEditPropertiesConverter.DoImport;
begin
  with Destination do
  begin
    Alignment.Horz := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    Alignment.Vert := ConvertVertAlignment(GetEnumProperty(Source, 'VertAlignment'));
    Increment := GetFloatProperty(Source, 'Increment', Increment);
    MaxValue := GetFloatProperty(Source, 'MaxValue', MaxValue);
    MinValue := GetFloatProperty(Source, 'MinValue', MinValue);
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
  end;
  inherited DoImport;
end;

function TcxSpinEditPropertiesConverter.GetDestination: TcxSpinEditProperties;
begin
  Result := inherited Destination as TcxSpinEditProperties;
end;

{ TcxTextEditPropertiesConverter }

procedure TcxTextEditPropertiesConverter.DoImport;
begin
  with Destination do
  begin
    Alignment.Horz := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    Alignment.Vert := ConvertVertAlignment(GetEnumProperty(Source, 'VertAlignment'));
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
    CharCase := ConvertCharCase(GetEnumProperty(Source, 'CharCase'));
    MaxLength := GetIntegerProperty(Source, 'MaxLength', MaxLength);
    OEMConvert := GetBooleanProperty(Source, 'OEMConvert', OEMConvert);
  end;
  inherited DoImport;
end;

function TcxTextEditPropertiesConverter.GetDestination: TcxTextEditProperties;
begin
  Result := inherited Destination as TcxTextEditProperties;
end;

{ TcxTimeEditPropertiesConverter }

procedure TcxTimeEditPropertiesConverter.DoImport;
begin
  with Destination do
  begin
    Alignment.Horz := ConvertAlignment(GetEnumProperty(Source, 'Alignment'));
    Alignment.Vert := ConvertVertAlignment(GetEnumProperty(Source, 'VertAlignment'));
    ReadOnly := GetBooleanProperty(Source, 'ReadOnly', ReadOnly);
    TimeFormat := ConvertTimeFormat(GetEnumProperty(Source, 'TimeEditFormat'));
  end;
  inherited DoImport;
end;

function TcxTimeEditPropertiesConverter.ConvertTimeFormat(const AFormat: string): TcxTimeEditTimeFormat;
begin
  if AFormat = 'tfHour' then
    Result := tfHour
  else if AFormat = 'tfHourMin' then
    Result := tfHourMin
  else if AFormat = 'tfHourMinSec' then
    Result := tfHourMinSec
  else
    Result := tfHour;
end;

function TcxTimeEditPropertiesConverter.GetDestination: TcxTimeEditProperties;
begin
  Result := inherited Destination as TcxTimeEditProperties;
end;

end.

⌨️ 快捷键说明

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