📄 jfedit.pas
字号:
SetDispText;
if Assigned(FOnSelectReturn) then
FOnSelectReturn(Self);
end;
end;
procedure TJFEdit.StartTimer;
begin
if ((FJFEditKind = JFbkDropDown) or
(FJFEditKind = JFbkDropDownTree)) and
Focused and FJFDDNumSelect then
FTimer.Resume;
end;
procedure TJFEdit.StopTimer;
begin
FTimer.Suspend;
end;
procedure TJFEdit.SetJFDDNumSelect(const Value: Boolean);
begin
FJFDDNumSelect := Value;
end;
procedure TJFEdit.SetJFLimitSpace(const Value: Boolean);
begin
FJFLimitSpace := Value;
end;
procedure TJFEdit.SetJFSRFocusMove(const Value: Boolean);
begin
FJFSRFocusMove := Value;
end;
procedure TJFEdit.SetJFEnterToSearch(const Value: Boolean);
begin
FJFEnterToSearch := Value;
end;
procedure TJFEdit.SetJFPacketRecords(const Value: Integer);
begin
FJFPacketRecords := Value;
end;
procedure TJFEdit.SelectValue(AFieldName: string; AValue: Variant);
var
iLst: Integer;
iLoop : Integer;
begin
if (JFEditKind <> jfbkDropDown) and (JFEditKind <> jfbkDropDownTree) then
Exit;
Clear;
for iLst := 0 to FJFDropDownList.Count - 1 do
begin
for iLoop := 0 to Length(PJFFieldValues(FJFDropDownList.Items[iLst])^) - 1 do
begin
if AnsiSameText(AFieldName, PJFFieldValues(FJFDropDownList.Items[iLst])^[iLoop].FieldName) then
begin
if PJFFieldValues(FJFDropDownList.Items[iLst])^[iLoop].Value = AValue then
begin
JFSelectIndex := iLst;
Exit;
end;
end;
end;
end;
end;
procedure TJFEdit.SetJFClearDefIndex(const Value: Integer);
begin
FJFClearDefIndex := Value;
end;
procedure TJFEdit.JFButtonClick;
begin
if FJFEdtBtn.Visible then
FJFEdtBtn.FButton.Click;
end;
procedure TJFEdit.SetJFSearchUseLocate(const Value: Boolean);
begin
FJFSearchUseLocate := Value;
end;
function TJFEdit.GetFullSortValue: string;
procedure GetParentValue(AItemID: string);
var
iLoop : Integer;
begin
if Trim(AItemID) = '' then
Exit;
for iLoop := 0 to JFDropDownList.Count - 1 do
begin
if Trim(JFDropDownList.GetFieldValue(JFDDTItemID, '', iLoop)) = Trim(AItemID) then
begin
Result := JFDropDownList.GetFieldValue(JFDispFieldName, '', iLoop) + Result;
GetParentValue(JFDropDownList.GetFieldValue(JFDDTParentID, '', iLoop));
Break;
end;
end;
end;
begin
Result := '';
if IsSelectEmpty then
Exit;
if JFEditKind <> JFbkDropDownTree then
Exit;
Result := JFSelectResult.GetFieldValue(JFDispFieldName, '');
GetParentValue(JFSelectResult.GetFieldValue(JFDDTParentID, ''));
end;
{ TJFEdtBtn }
constructor TJFEdtBtn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FButton := TSpeedButton.Create(Self);
FButton.Parent := Self;
Color := clBtnFace;
end;
destructor TJFEdtBtn.Destroy;
begin
FButton.Free;
inherited Destroy;
end;
procedure TJFEdtBtn.ResizeButton;
begin
FButton.Left := 0;
FButton.Top := 0;
FButton.Width := Width;
FButton.Height:= Height;
end;
procedure TJFEdtBtn.WMSize(var MSG: TMessage);
begin
inherited;
REsizeButton;
end;
{ TEdtSearchFieldItem }
procedure TEdtSearchFieldItem.Assign(Source: TPersistent);
begin
if Source is TEdtSearchFieldItem then
begin
if Assigned(Collection) then Collection.BeginUpdate;
try
FieldName := TEdtSearchFieldItem(Source).FieldName;
FieldType := TEdtSearchFieldItem(Source).FieldType;
Operation := TEdtSearchFieldItem(Source).Operation;
finally
if Assigned(Collection) then Collection.EndUpdate;
end;
end
else
inherited Assign(Source);
end;
constructor TEdtSearchFieldItem.Create(Collection: TCollection);
begin
inherited Create(Collection);
FFieldName := '';
FFieldType := JFsftString;
FOperation := '=';
FFullBlur := True;
end;
procedure TEdtSearchFieldItem.SetFieldName(const Value: string);
begin
FFieldName := Value;
end;
procedure TEdtSearchFieldItem.SetFieldType(
const Value: TJFSearchFieldType);
begin
FFieldType := Value;
end;
procedure TEdtSearchFieldItem.SetFullBlur(const Value: Boolean);
begin
FFullBlur := Value;
end;
procedure TEdtSearchFieldItem.SetOperation(const Value: string);
begin
if (not SameText(Value, 'Like')) and
(not SameText(Value, '=')) and
(not SameText(Value, '>')) and
(not SameText(Value, '>=')) and
(not SameText(Value, '<')) and
(not SameText(Value, '<=')) then
Exit;
FOperation := Value;
end;
{ TEdtSearchFields }
function TEdtSearchFields.Add: TEdtSearchFieldItem;
begin
Result := TEdtSearchFieldItem(inherited Add);
end;
procedure TEdtSearchFields.Assign(Source: TPersistent);
var
I: Integer;
begin
if Source is TEdtSearchFields then
begin
BeginUpdate;
try
Clear;
for I := 0 to TEdtSearchFields(Source).Count - 1 do
Add.Assign(TEdtSearchFields(Source).Items[I]);
finally
EndUpdate;
end;
Exit;
end;
end;
constructor TEdtSearchFields.Create(AOwner: TPersistent;EdtSearchFieldClass: TEdtSearchFieldClass);
begin
inherited Create(EdtSearchFieldClass);
FOwner := AOwner;
end;
function TEdtSearchFields.GetOwner: TPersistent;
begin
Result := FOwner;
end;
function TEdtSearchFields.GetSearchField(
Index: Integer): TEdtSearchFieldItem;
begin
Result := TEdtSearchFieldItem(inherited Items[Index]);
end;
procedure TEdtSearchFields.SetSearchField(Index: Integer;
const Value: TEdtSearchFieldItem);
begin
Items[Index].Assign(Value);
end;
{ TEdtDispFieldItem }
procedure TEdtDispFieldItem.Assign(Source: TPersistent);
begin
if Source is TEdtDispFieldItem then
begin
if Assigned(Collection) then Collection.BeginUpdate;
try
FieldName := TEdtDispFieldItem(Source).FieldName;
Alignment := TEdtDispFieldItem(Source).Alignment;
DispWidth := TEdtDispFieldItem(Source).DispWidth;
ColumnTitle := TEdtDispFieldItem(Source).ColumnTitle;
finally
if Assigned(Collection) then Collection.EndUpdate;
end;
end
else
inherited Assign(Source);
end;
constructor TEdtDispFieldItem.Create(Collection: TCollection);
begin
inherited Create(Collection);
FDispWidth := 50;
FAlignment := taLeftJustify;
end;
procedure TEdtDispFieldItem.SetAlignment(const Value: TAlignment);
begin
FAlignment := Value;
end;
procedure TEdtDispFieldItem.SetColumnTitle(const Value: string);
begin
FColumnTitle := Value;
end;
procedure TEdtDispFieldItem.SetDispWidth(const Value: Integer);
begin
FDispWidth := Value;
end;
procedure TEdtDispFieldItem.SetFieldName(const Value: string);
begin
FFieldName := Value;
end;
{ TEdtDispFields }
function TEdtDispFields.Add: TEdtDispFieldItem;
begin
Result := TEdtDispFieldItem(inherited Add);
end;
procedure TEdtDispFields.Assign(Source: TPersistent);
var
I: Integer;
begin
if Source is TEdtDispFields then
begin
BeginUpdate;
try
Clear;
for I := 0 to TEdtDispFields(Source).Count - 1 do
Add.Assign(TEdtDispFields(Source).Items[I]);
finally
EndUpdate;
end;
Exit;
end;
end;
constructor TEdtDispFields.Create(AOwner: TPersistent; EdtDispFieldClass: TEdtDispFieldClass);
begin
inherited Create(EdtDispFieldClass);
FOwner := AOwner;
end;
function TEdtDispFields.GetDispField(Index: Integer): TEdtDispFieldItem;
begin
Result := TEdtDispFieldItem(inherited Items[Index]);
end;
function TEdtDispFields.GetOwner: TPersistent;
begin
Result := FOwner;
end;
procedure TEdtDispFields.SetDispField(Index: Integer;
const Value: TEdtDispFieldItem);
begin
Items[Index].Assign(Value);
end;
{ TEdtExecParamitem }
procedure TEdtExecParamitem.Assign(Source: TPersistent);
begin
if Source is TEdtExecParamitem then
begin
if Assigned(Collection) then Collection.BeginUpdate;
try
Value := TEdtExecParamitem(Source).Value;
finally
if Assigned(Collection) then Collection.EndUpdate;
end;
end
else
inherited Assign(Source);
end;
constructor TEdtExecParamitem.Create(Collection: TCollection);
begin
inherited Create(Collection);
end;
procedure TEdtExecParamitem.SetValue(const Value: Variant);
begin
FValue := Value;
end;
{ TEdtExecParams }
function TEdtExecParams.Add: TEdtExecParamitem;
begin
Result := TEdtExecParamitem(inherited Add);
end;
procedure TEdtExecParams.Assign(Source: TPersistent);
var
I: Integer;
begin
if Source is TEdtExecParams then
begin
BeginUpdate;
try
Clear;
for I := 0 to TEdtExecParams(Source).Count - 1 do
Add.Assign(TEdtExecParams(Source).Items[I]);
finally
EndUpdate;
end;
Exit;
end;
end;
constructor TEdtExecParams.Create(AOwner: TPersistent;EdtExecParamClass: TEdtExecParamClass);
begin
inherited Create(EdtExecParamClass);
FOwner := AOwner;
end;
function TEdtExecParams.GetExecParam(Index: Integer): TEdtExecParamitem;
begin
Result := TEdtExecParamitem(inherited Items[Index]);
end;
function TEdtExecParams.GetOwner: TPersistent;
begin
Result := FOwner;
end;
procedure TEdtExecParams.SetExecParam(Index: Integer;
const Value: TEdtExecParamitem);
begin
Items[Index].Assign(Value);
end;
{ TJFEditThread }
constructor TJFEditThread.Create(JFEdit: TJFEdit);
begin
inherited Create(True);
FreeOnTerminate := True;
FJFEdit := JFEdit;
end;
procedure TJFEditThread.Execute;
begin
while not Terminated do
begin
try
Sleep(300);
//Synchronize(InputKeys);
InputKeys;
except
end;
end;
end;
procedure TJFEditThread.InputKeys;
var
Index: Integer;
begin
with FJFEdit do
begin
Index := StrToIntDef(FInputKeys, -1) - 1;
if FInputKeys = '' then
Exit;
try
JFSelectIndex := Index;
finally
FInputKeys := '';
Self.Suspend;
end;
end;
end;
initialization
finalization
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -