cxwwgridconverter.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,078 行 · 第 1/3 页
PAS
1,078 行
GetFontWidth(GetClassProperty(nil, 'Font') as TFont);
end;
end;
DropDownWidth := GetIntegerProperty(AComponent, 'DropDownWidth', DropDownWidth);
if DropDownWidth = 0 then
begin
for I := 0 to ListColumns.Count - 1 do
DropDownWidth := DropDownWidth + ListColumns[I].Width;
end;
DropDownRows := GetIntegerProperty(AComponent, 'DropDownCount', DropDownRows);
if GetEnumProperty(AComponent, 'ButtonStyle') = 'cbsCustom' then
ButtonGlyph.Assign(GetClassProperty(AComponent, 'ButtonGlyph') as TBitmap);
ReadOnly := GetBooleanProperty(AComponent, 'ReadOnly', ReadOnly);
PopupAlignment := ConvertAlignment(GetEnumProperty(AComponent, 'DropDownAlignment'));
AString := GetEnumProperty(AComponent, 'Style');
if AString = 'csDropDown' then
DropDownListStyle := lsEditList
else
DropDownListStyle := lsFixedList;
ImmediateDropDown := GetBooleanProperty(AComponent, 'AutoDropDown', ImmediateDropDown);
AWWSeqSearchOptions := TStringList.Create;
try
EnablePropertyException;
try
GetSetProperty(AComponent, 'SeqSearchOptions', AWWSeqSearchOptions);
AWWSeqSearchOptions.Sort;
IncrementalFiltering := AWWSeqSearchOptions.Find('ssoEnabled', I);
ListOptions.CaseInsensitive := not AWWSeqSearchOptions.Find('ssoCaseSensitive', I);
except
on EcxUnknownProperty do;
end;
finally
AWWSeqSearchOptions.Free;
DisablePropertyException;
end;
AWWOptions := TStringList.Create;
try
EnablePropertyException;
try
GetSetProperty(AComponent, 'Options', AWWOptions);
AWWOptions.Sort;
if AWWOptions.Find('loColLines', I) then
begin
if AWWOptions.Find('loRowLines', I) then
ListOptions.GridLines := glBoth
else
ListOptions.GridLines := glVertical;
end
else
begin
if AWWOptions.Find('loRowLines', I) then
ListOptions.GridLines := glHorizontal
else
ListOptions.GridLines := glNone;
end;
ListOptions.ShowHeader := AWWOptions.Find('loTitles', I);
except
on EcxUnknownProperty do;
end;
finally
AWWOptions.Free;
DisablePropertyException;
end;
end;
end;
end;
procedure TcxWWGridConverter.ImportWWLookupComboDlg(AcxColumn: TcxGridDBBandedColumn;
AComponent: TComponent);
var
AListDataSource: TDataSource;
AListTable: TObject;
AIndex: Integer;
ASelected: TStringList;
I: Integer;
AListFieldName: string;
AListFieldWidth: string;
AListFieldCaption: string;
AcxLookupColumn: TcxLookupDBGridColumn;
AString: string;
AWWSeqSearchOptions: TStringList;
AWWGridOptions: TStringList;
begin
AcxColumn.PropertiesClass := TcxLookupComboBoxProperties;
with TcxLookupComboBoxProperties(AcxColumn.Properties) do
begin
AListTable := GetClassProperty(AComponent, 'LookupTable');
if AListTable <> nil then
begin
AListDataSource := TDataSource.Create(cxGridView);
AListDataSource.DataSet := AListTable as TDataSet;
ListSource := AListDataSource;
KeyFieldNames := GetStringProperty(AComponent, 'LookupField', '');
ASelected := GetClassProperty(AComponent, 'Selected') as TStringList;
if ASelected <> nil then
begin
for I := 0 to ASelected.Count - 1 do
begin
AIndex := ExtractData(ASelected[I], AListFieldName, 1, #9);
AIndex := ExtractData(ASelected[I], AListFieldWidth, AIndex, #9);
ExtractData(ASelected[I], AListFieldCaption, AIndex, #9);
AcxLookupColumn := ListColumns.Add;
AcxLookupColumn.FieldName := AListFieldName;
AcxLookupColumn.Caption := AListFieldCaption;
AcxLookupColumn.Width := StrToInt(AListFieldWidth) *
GetFontWidth(GetClassProperty(nil, 'Font') as TFont);
end;
end;
DropDownWidth := 0;
for I := 0 to ListColumns.Count - 1 do
DropDownWidth := DropDownWidth + ListColumns[I].Width;
if GetEnumProperty(AComponent, 'ButtonStyle') = 'cbsCustom' then
ButtonGlyph.Assign(GetClassProperty(AComponent, 'ButtonGlyph') as TBitmap);
ReadOnly := GetBooleanProperty(AComponent, 'ReadOnly', ReadOnly);
AString := GetEnumProperty(AComponent, 'Style');
if AString = 'csDropDown' then
DropDownListStyle := lsEditList
else
DropDownListStyle := lsFixedList;
ImmediateDropDown := GetBooleanProperty(AComponent, 'AutoDropDown', ImmediateDropDown);
AWWSeqSearchOptions := TStringList.Create;
try
EnablePropertyException;
try
GetSetProperty(AComponent, 'SeqSearchOptions', AWWSeqSearchOptions);
AWWSeqSearchOptions.Sort;
IncrementalFiltering := AWWSeqSearchOptions.Find('ssoEnabled', I);
ListOptions.CaseInsensitive := not AWWSeqSearchOptions.Find('ssoCaseSensitive', I);
except
on EcxUnknownProperty do;
end;
finally
AWWSeqSearchOptions.Free;
DisablePropertyException;
end;
AWWGridOptions := TStringList.Create;
try
EnablePropertyException;
try
GetSetProperty(AComponent, 'GridOptions', AWWGridOptions);
AWWGridOptions.Sort;
if AWWGridOptions.Find('dgColLines', I) then
begin
if AWWGridOptions.Find('dgRowLines', I) then
ListOptions.GridLines := glBoth
else
ListOptions.GridLines := glVertical;
end
else
begin
if AWWGridOptions.Find('dgRowLines', I) then
ListOptions.GridLines := glHorizontal
else
ListOptions.GridLines := glNone;
end;
ListOptions.ShowHeader := AWWGridOptions.Find('dgTitles', I);
except
on EcxUnknownProperty do;
end;
finally
AWWGridOptions.Free;
DisablePropertyException;
end;
end;
end;
end;
procedure TcxWWGridConverter.ImportWWMonthCalendar(AcxColumn: TcxGridDBBandedColumn; AComponent: TComponent);
var
AWWOptions: TStringList;
ADateButtons: TDateButtons;
I: Integer;
begin
AcxColumn.PropertiesClass := TcxDateEditProperties;
with TcxDateEditProperties(AcxColumn.Properties) do
begin
AWWOptions := TStringList.Create;
try
EnablePropertyException;
try
GetSetProperty(AComponent, 'Options', AWWOptions);
ADateButtons := [btnClear];
if not AWWOptions.Find('mdoNoToday', I) then
Include(ADateButtons, btnToday);
DateButtons := ADateButtons;
except
on EcxUnknownProperty do;
end;
finally
AWWOptions.Free;
DisablePropertyException;
end;
DateOnError := deToday;
end;
end;
procedure TcxWWGridConverter.ImportWWOptions;
var
AOptions: TStringList;
I: Integer;
begin
AOptions := TStringList.Create;
try
EnablePropertyException;
try
GetSetProperty(nil, 'Options', AOptions);
AOptions.Sort;
with cxGridView do
begin
OptionsBehavior.AlwaysShowEditor := AOptions.Find('dgAlwaysShowEditor', I);
OptionsData.Editing := AOptions.Find('dgEditing', I);
OptionsView.Header := AOptions.Find('dgTitles', I);
OptionsView.Indicator := AOptions.Find('dgIndicator', I);
OptionsCustomize.ColumnHorzSizing := AOptions.Find('dgColumnResize', I);
if AOptions.Find('dgColLines', I) then
begin
if AOptions.Find('dgRowLines', I) then
OptionsView.GridLines := glBoth
else
OptionsView.GridLines := glVertical;
end
else
begin
if AOptions.Find('dgRowLines', I) then
OptionsView.GridLines := glHorizontal
else
OptionsView.GridLines := glNone;
end;
OptionsBehavior.FocusCellOnTab := AOptions.Find('dgTabs', I);
OptionsSelection.CellSelect := not AOptions.Find('dgRowSelect', I);
OptionsSelection.HideSelection := not AOptions.Find('dgAlwaysShowSelection', I);
OptionsData.DeletingConfirmation := AOptions.Find('dgConfirmDelete', I);
OptionsData.CancelOnExit := AOptions.Find('dgCancelOnExit', I);
OptionsSelection.MultiSelect := AOptions.Find('dgMultiSelect', I);
OptionsView.Footer := AOptions.Find('dgShowFooter', I);
OptionsBehavior.FocusCellOnCycle := not AOptions.Find('dgTabExitsOnLastCol', I);
end;
AOptions.Clear;
GetSetProperty(nil, 'KeyOptions', AOptions);
AOptions.Sort;
with cxGridView do
begin
OptionsBehavior.GoToNextCellOnEnter := AOptions.Find('dgEnterToTab', I);
OptionsData.Deleting := AOptions.Find('dgAllowDelete', I);
OptionsData.Inserting := AOptions.Find('dgAllowInsert', I);
end;
except
on EcxUnknownProperty do;
end;
finally
AOptions.Free;
DisablePropertyException;
end;
end;
procedure TcxWWGridConverter.ImportWWRadioGroup(AcxColumn: TcxGridDBBandedColumn; AComponent: TComponent);
var
AWWItems: TStringList;
AWWValues: TStringList;
AcxItem: TcxImageComboBoxItem;
I: Integer;
begin
AcxColumn.PropertiesClass := TcxImageComboBoxProperties;
with TcxImageComboBoxProperties(AcxColumn.Properties) do
begin
AWWItems := GetClassProperty(AComponent, 'Items') as TStringList;
AWWValues := GetClassProperty(AComponent, 'Values') as TStringList;
if (AWWItems <> nil) and (AWWValues <> nil) then
begin
for I := 0 to AWWItems.Count - 1 do
begin
AcxItem := Items.Add as TcxImageComboBoxItem;
AcxItem.Description := AWWItems[I];
if I < AWWValues.Count then
AcxItem.Value := AWWValues[I];
end;
end;
ReadOnly := GetBooleanProperty(AComponent, 'ReadOnly', ReadOnly);
Images := GetClassProperty(AComponent, 'GlyphImages') as TImageList;
ShowDescriptions := GetBooleanProperty(AComponent, 'ShowText', ShowDescriptions);
end;
AcxColumn.Options.ShowEditButtons := isebAlways;
end;
procedure TcxWWGridConverter.ImportWWSpinEdit(AcxColumn: TcxGridDBBandedColumn; AComponent: TComponent);
begin
AcxColumn.PropertiesClass := TcxSpinEditProperties;
with TcxSpinEditProperties(AcxColumn.Properties) do
begin
AutoSelect := GetBooleanProperty(AComponent, 'AutoSelect', AutoSelect);
ReadOnly := GetBooleanProperty(AComponent, 'ReadOnly', ReadOnly);
MaxValue := GetFloatProperty(AComponent, 'MaxValue', MaxValue);
MinValue := GetFloatProperty(AComponent, 'MinValue', MinValue);
Increment := GetFloatProperty(AComponent, 'Increment', Increment);
end;
end;
procedure TcxWWGridConverter.ImportWWTextEdit(AcxColumn: TcxGridDBBandedColumn; AComponent: TComponent);
begin
AcxColumn.PropertiesClass := TcxTextEditProperties;
with TcxTextEditProperties(AcxColumn.Properties) do
begin
AutoSelect := GetBooleanProperty(AComponent, 'AutoSelect', AutoSelect);
ReadOnly := GetBooleanProperty(AComponent, 'ReadOnly', ReadOnly);
CharCase := GetCharCase(GetEnumProperty(AComponent, 'CharCase'));
MaxLength := GetIntegerProperty(AComponent, 'MaxLength', MaxLength);
end;
end;
function TcxWWGridConverter.IsColumnDefault(const AFieldName: string): string;
var
AControlType: TStringList;
ADataFieldName: string;
I: Integer;
begin
Result := '';
AControlType := GetClassProperty(nil, 'ControlType') as TStringList;
if AControlType <> nil then
begin
for I := 0 to AControlType.Count - 1 do
begin
ExtractData(AControlType[I], ADataFieldName, 1, ';');
if ADataFieldName = AFieldName then
begin
Result := AControlType[I];
Break;
end;
end;
end;
end;
function TcxWWGridConverter.Pass(const AData: string; AStartIndex: Integer;
AFieldCount: Integer; ASeparator: Char): Integer;
var
ACount: Integer;
begin
Result := AStartIndex;
ACount := 0;
while Result <= Length(AData) do
begin
if AData[Result] = ASeparator then
begin
Inc(ACount);
if ACount = AFieldCount then
begin
Inc(Result);
Break;
end;
end;
Inc(Result);
end;
end;
initialization
ConverterFactory(cxGridGroupConverterName).RegisterConverter('WW InfoPower Grid Converter', TcxWWGridConverter);
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?