cxlookupedit.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,186 行 · 第 1/3 页
PAS
1,186 行
AEditFocused: Boolean): Boolean;
begin
Result := True;
end;
function TcxCustomLookupEditProperties.IsLookupField: Boolean;
begin
Result := False;
end;
procedure TcxCustomLookupEditProperties.PrepareDisplayValue(const AEditValue: TcxEditValue;
var DisplayValue: TcxEditValue; AEditFocused: Boolean);
begin
if IsPickMode or (IsLookupField and not AEditFocused) then
inherited PrepareDisplayValue(AEditValue, DisplayValue, AEditFocused)
else
DisplayValue := GetDisplayLookupText(AEditValue);
end;
function TcxCustomLookupEditProperties.GetLookupGridActiveControl: TWinControl;
begin
Result := GetLookupGridControl;
end;
function TcxCustomLookupEditProperties.GetLookupGridCanResize: Boolean;
begin
Result := True;
end;
function TcxCustomLookupEditProperties.GetLookupGridColumnCount: Integer;
begin
Result := 0;
end;
function TcxCustomLookupEditProperties.GetLookupGridControl: TWinControl;
begin
Result := nil;
end;
function TcxCustomLookupEditProperties.GetLookupGridDataController: TcxCustomDataController;
begin
Result := nil;
end;
function TcxCustomLookupEditProperties.GetLookupGridVisualAreaPreferredWidth: Integer;
begin
Result := 0;
end;
function TcxCustomLookupEditProperties.GetLookupGridNearestPopupHeight(
AHeight: Integer): Integer;
begin
Result := AHeight;
end;
function TcxCustomLookupEditProperties.GetLookupGridPopupHeight(ADropDownRowCount: Integer): Integer;
begin
Result := 0;
end;
function TcxCustomLookupEditProperties.IsLookupGridMouseOverList(const P: TPoint): Boolean;
begin
Result := False;
end;
procedure TcxCustomLookupEditProperties.LookupGridDeinitialize;
begin
end;
procedure TcxCustomLookupEditProperties.LookupGridDroppedDown(const AFindStr: string);
begin
end;
procedure TcxCustomLookupEditProperties.LookupGridInitEvents(AOnClick, AOnFocusedRowChanged: TNotifyEvent;
AOnCloseUp: TcxLookupGridCloseUpEvent);
begin
end;
procedure TcxCustomLookupEditProperties.LookupGridInitialize;
begin
end;
procedure TcxCustomLookupEditProperties.LookupGridInitLookAndFeel(ALookAndFeel: TcxLookAndFeel;
AColor: TColor; AFont: TFont);
begin
end;
procedure TcxCustomLookupEditProperties.LookupGridLockMouseMove;
begin
end;
procedure TcxCustomLookupEditProperties.LookupGridMakeFocusedRowVisible;
begin
end;
procedure TcxCustomLookupEditProperties.LookupGridUnlockMouseMove;
begin
end;
procedure TcxCustomLookupEditProperties.CheckDisplayColumnIndex;
begin
if FDisplayColumnIndex >= GetLookupGridColumnCount then
DisplayColumnIndex := GetLookupGridColumnCount - 1;
end;
procedure TcxCustomLookupEditProperties.DeinitializeDataController;
begin
if DataController <> nil then
DataController.RemoveDataChangedListener(Self, GridDataChanged);
end;
function TcxCustomLookupEditProperties.FindByText(AItemIndex: Integer;
const AText: string; APartialCompare: Boolean): Integer;
begin
Result := DataController.FindRecordIndexByText(0, AItemIndex, AText, APartialCompare, False, True);
end;
function TcxCustomLookupEditProperties.FindLookupText(const AText: string): Boolean;
var
AItemIndex: Integer;
begin
AItemIndex := GetListIndex;
Result := (AItemIndex <> -1) and (DataController <> nil) and
(FindByText(AItemIndex, AText, False) <> -1);
end;
function TcxCustomLookupEditProperties.GetDisplayColumnIndex: Integer;
begin
Result := FDisplayColumnIndex;
end;
function TcxCustomLookupEditProperties.GetDisplayFormatOptions: TcxEditDisplayFormatOptions;
begin
Result := [];
end;
function TcxCustomLookupEditProperties.GetDisplayLookupText(const AKey: TcxEditValue): string;
begin
Result := '';
end;
function TcxCustomLookupEditProperties.GetIncrementalFiltering: Boolean;
begin
Result := IncrementalFiltering;
end;
function TcxCustomLookupEditProperties.GetListIndex: Integer;
begin
Result := DisplayColumnIndex;
if Result >= GetLookupGridColumnCount then
Result := GetLookupGridColumnCount - 1;
end;
class function TcxCustomLookupEditProperties.GetLookupDataClass: TcxInterfacedPersistentClass;
begin
Result := TcxCustomLookupEditLookupData;
end;
function TcxCustomLookupEditProperties.GetNullKey: Variant;
begin
Result := Null;
end;
procedure TcxCustomLookupEditProperties.GridDataChanged(Sender: TObject);
begin
if FInGridDataChanged or IsChangeLocked then Exit;
if IsDataChangedPostponed then Exit;
FInGridDataChanged := True;
try
Changed;
finally
FInGridDataChanged := False;
end;
end;
procedure TcxCustomLookupEditProperties.InitializeDataController;
begin
if DataController <> nil then
DataController.AddDataChangedListener(Self, GridDataChanged);
end;
function TcxCustomLookupEditProperties.IsChangeLocked: Boolean;
begin
Result := FLockCount <> 0;
end;
function TcxCustomLookupEditProperties.IsDataChangedPostponed: Boolean;
begin
Result := (DataController <> nil) and DataController.DataChangedNotifyLocked;
end;
function TcxCustomLookupEditProperties.IsEditValueConversionDependOnFocused: Boolean;
begin
Result := False;
end;
function TcxCustomLookupEditProperties.IsPickMode: Boolean;
begin
Result := False;
end;
function TcxCustomLookupEditProperties.IsPopupKey(Key: Word; Shift: TShiftState): Boolean;
begin
case Key of
VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT:
Result := not (ssAlt in Shift);
VK_HOME, VK_END:
Result := ssCtrl in Shift;
else
Result := False;
end;
end;
procedure TcxCustomLookupEditProperties.LockDataChanged;
begin
if DataController <> nil then
DataController.LockDataChangedNotify;
end;
procedure TcxCustomLookupEditProperties.SetDisplayColumnIndex(Value: Integer);
begin
if Value >= GetLookupGridColumnCount then Value := GetLookupGridColumnCount - 1;
if Value < 0 then Value := 0;
if FDisplayColumnIndex <> Value then
begin
FDisplayColumnIndex := Value;
Changed;
end;
end;
procedure TcxCustomLookupEditProperties.UnlockDataChanged;
begin
if DataController <> nil then
DataController.UnlockDataChangedNotify;
end;
procedure TcxCustomLookupEditProperties.UnlinkLookupGridControlParent;
begin
if GetLookupGridControl <> nil then
GetLookupGridControl.Parent := nil;
end;
function TcxCustomLookupEditProperties.GetDataController: TcxCustomDataController;
begin
Result := GetLookupGridDataController;
end;
function TcxCustomLookupEditProperties.GetDropDownAutoSize: Boolean;
begin
Result := inherited PopupAutoSize;
end;
function TcxCustomLookupEditProperties.GetDropDownHeight: Integer;
begin
Result := inherited PopupHeight;
end;
function TcxCustomLookupEditProperties.GetDropDownSizeable: Boolean;
begin
Result := inherited PopupSizeable;
end;
function TcxCustomLookupEditProperties.GetDropDownWidth: Integer;
begin
Result := inherited PopupWidth;
end;
procedure TcxCustomLookupEditProperties.SetDropDownAutoSize(Value: Boolean);
begin
inherited PopupAutoSize := Value;
end;
procedure TcxCustomLookupEditProperties.SetDropDownHeight(Value: Integer);
begin
inherited PopupHeight := Value;
end;
procedure TcxCustomLookupEditProperties.SetDropDownSizeable(Value: Boolean);
begin
inherited PopupSizeable := Value;
end;
procedure TcxCustomLookupEditProperties.SetDropDownWidth(Value: Integer);
begin
inherited PopupWidth := Value;
end;
{ TcxCustomLookupEdit }
class function TcxCustomLookupEdit.GetPropertiesClass: TcxCustomEditPropertiesClass;
begin
Result := TcxCustomLookupEditProperties;
end;
procedure TcxCustomLookupEdit.PrepareEditValue(const ADisplayValue: TcxEditValue;
out EditValue: TcxEditValue; AEditFocused: Boolean);
begin
if ActiveProperties.IsPickMode then
EditValue := ADisplayValue
else
if ILookupData.GetDisplayText(ILookupData.CurrentKey) = ADisplayValue then
EditValue := ILookupData.CurrentKey
else
if LookupData.LocateText(ADisplayValue) then
EditValue := ILookupData.CurrentKey
else
EditValue := ActiveProperties.GetNullKey;
end;
procedure TcxCustomLookupEdit.AfterPosting;
begin
inherited AfterPosting;
LookupData.EnableChanging;
end;
procedure TcxCustomLookupEdit.BeforePosting;
begin
LookupData.DisableChanging;
inherited BeforePosting;
end;
procedure TcxCustomLookupEdit.DoShowEdit;
begin
inherited DoShowEdit;
ILookupData.TextChanged;
end;
procedure TcxCustomLookupEdit.DropDown;
begin
inherited DropDown;
ILookupData.CurrentKey := EditValue;
end;
procedure TcxCustomLookupEdit.Initialize;
begin
inherited Initialize;
Width := 145;
end;
function TcxCustomLookupEdit.InternalGetEditingValue: TcxEditValue;
begin
PrepareEditValue(Text, Result, InternalFocused);
end;
function TcxCustomLookupEdit.NeedResetInvalidTextWhenPropertiesChanged: Boolean;
begin
Result := False;
end;
procedure TcxCustomLookupEdit.RepositoryItemAssigning;
begin
TcxCustomLookupEditProperties(ActiveProperties).UnlinkLookupGridControlParent;
end;
procedure TcxCustomLookupEdit.SynchronizeDisplayValue;
begin
inherited SynchronizeDisplayValue;
if HasPopupWindow then
ILookupData.CurrentKey := EditValue;
end;
function TcxCustomLookupEdit.GetILookupData: IcxTextEditLookupData;
begin
Result := FLookupData as IcxTextEditLookupData;
end;
function TcxCustomLookupEdit.GetLookupData: TcxCustomLookupEditLookupData;
begin
Result := TcxCustomLookupEditLookupData(FLookupData);
end;
function TcxCustomLookupEdit.GetProperties: TcxCustomLookupEditProperties;
begin
Result := TcxCustomLookupEditProperties(FProperties);
end;
function TcxCustomLookupEdit.GetActiveProperties: TcxCustomLookupEditProperties;
begin
Result := TcxCustomLookupEditProperties(InternalGetActiveProperties);
end;
procedure TcxCustomLookupEdit.SetLookupData(Value: TcxCustomLookupEditLookupData);
begin
FLookupData.Assign(Value);
end;
procedure TcxCustomLookupEdit.SetProperties(Value: TcxCustomLookupEditProperties);
begin
FProperties.Assign(Value);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?