📄 jvqdyncontrolenginevcl.pas
字号:
{$ENDIF HAS_UNIT_VARIANTS}
SysUtils,
JvQDynControlEngineTools, JvQConsts, JvQJCLUtils;
var
IntDynControlEngineVCL: TJvDynControlEngine = nil;
//=== { TJvDynControlVCLMaskEdit } ===========================================
procedure TJvDynControlVCLMaskEdit.ControlSetDefaultProperties;
begin
end;
procedure TJvDynControlVCLMaskEdit.ControlSetReadOnly(Value: Boolean);
begin
ReadOnly := Value;
end;
procedure TJvDynControlVCLMaskEdit.ControlSetCaption(const Value: string);
begin
end;
procedure TJvDynControlVCLMaskEdit.ControlSetTabOrder(Value: Integer);
begin
TabOrder := Value;
end;
procedure TJvDynControlVCLMaskEdit.ControlSetOnEnter(Value: TNotifyEvent);
begin
OnEnter := Value;
end;
procedure TJvDynControlVCLMaskEdit.ControlSetOnExit(Value: TNotifyEvent);
begin
OnExit := Value;
end;
procedure TJvDynControlVCLMaskEdit.ControlSetOnChange(Value: TNotifyEvent);
begin
OnChange := Value;
end;
procedure TJvDynControlVCLMaskEdit.ControlSetOnClick(Value: TNotifyEvent);
begin
end;
procedure TJvDynControlVCLMaskEdit.ControlSetHint(const Value: string);
begin
Hint := Value;
end;
procedure TJvDynControlVCLMaskEdit.ControlSetValue(Value: Variant);
begin
Text := Value;
end;
function TJvDynControlVCLMaskEdit.ControlGetValue: Variant;
begin
Result := Text;
end;
procedure TJvDynControlVCLMaskEdit.ControlSetPasswordChar(Value: Char);
begin
if Value = #0 then
EchoMode := emNormal
else
EchoMode := emPassword;
end;
procedure TJvDynControlVCLMaskEdit.ControlSetEditMask(const Value: string);
begin
EditMask := Value;
end;
//=== { TJvDynControlVCLButtonEdit } =========================================
constructor TJvDynControlVCLButtonEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEditControl := TMaskEdit.Create(AOwner);
FEditControl.Parent := Self;
FButton := TBitBtn.Create(AOwner);
FButton.Parent := Self;
FButton.Align := alRight;
FButton.Caption := '...';
Height := FEditControl.Height;
FButton.Width := Height;
FEditControl.Align := alClient;
BevelInner := bvNone;
BevelOuter := bvNone;
end;
destructor TJvDynControlVCLButtonEdit.Destroy;
begin
FreeAndNil(FEditControl);
FreeAndNil(FButton);
inherited Destroy;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetDefaultProperties;
begin
Self.Caption := ' ';
end;
procedure TJvDynControlVCLButtonEdit.ControlSetReadOnly(Value: Boolean);
begin
FEditControl.ReadOnly := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetCaption(const Value: string);
begin
end;
procedure TJvDynControlVCLButtonEdit.ControlSetTabOrder(Value: Integer);
begin
TabOrder := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetOnEnter(Value: TNotifyEvent);
begin
OnEnter := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetOnExit(Value: TNotifyEvent);
begin
OnExit := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetOnChange(Value: TNotifyEvent);
begin
FEditControl.OnChange := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetOnClick(Value: TNotifyEvent);
begin
FEditControl.OnClick := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetHint(const Value: string);
begin
Hint := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetValue(Value: Variant);
begin
FEditControl.Text := Value;
end;
function TJvDynControlVCLButtonEdit.ControlGetValue: Variant;
begin
Result := FEditControl.Text;
end;
type
TMaskEditAccessProtected = class(TMaskEdit);
procedure TJvDynControlVCLButtonEdit.ControlSetPasswordChar(Value: Char);
begin
if Value = #0 then
TMaskEditAccessProtected(FEditControl).EchoMode := emNormal
else
TMaskEditAccessProtected(FEditControl).EchoMode := emPassword;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetEditMask(const Value: string);
begin
FEditControl.EditMask := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetOnButtonClick(Value: TNotifyEvent);
begin
FButton.OnClick:= Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetButtonCaption(const Value: string);
begin
FButton.Caption := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetGlyph(Value: TBitmap);
begin
FButton.Glyph.Assign(Value);
end;
procedure TJvDynControlVCLButtonEdit.ControlSetNumGlyphs(Value: Integer);
begin
FButton.NumGlyphs := Value;
end;
procedure TJvDynControlVCLButtonEdit.ControlSetLayout(Value: TButtonLayout);
begin
FButton.Layout := Value;
end;
//=== { TJvDynControlVCLFileNameEdit } =======================================
constructor TJvDynControlVCLFileNameEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEditControl := TMaskEdit.Create(AOwner);
FEditControl.Parent := Self;
FButton := TBitBtn.Create(AOwner);
FButton.Parent := Self;
FButton.Align := alRight;
FButton.OnClick := DefaultOnButtonClick;
FButton.Caption := '...';
Height := FEditControl.Height;
FButton.Width := Height;
FEditControl.Align := alClient;
FDialogOptions := [ofHideReadOnly,ofEnableSizing];
BevelInner := bvNone;
BevelOuter := bvNone;
FDialogKind := jdkOpen;
end;
destructor TJvDynControlVCLFileNameEdit.Destroy;
begin
FreeAndNil(FEditControl);
FreeAndNil(FButton);
inherited Destroy;
end;
procedure TJvDynControlVCLFileNameEdit.DefaultOnButtonClick(Sender: TObject);
begin
case FDialogKind of
jdkOpen:
with TOpenDialog.Create(Self) do
try
Options := FDialogOptions;
Title := FDialogTitle;
Filter := FFilter;
FilterIndex := FFilterIndex;
InitialDir := FInitialDir;
DefaultExt := FDefaultExt;
FileName := ControlGetValue;
if Execute then
ControlSetValue(FileName);
finally
Free;
end;
jdkOpenPicture:
with TOpenPictureDialog.Create(Self) do
try
Options := FDialogOptions;
Title := FDialogTitle;
Filter := FFilter;
FilterIndex := FFilterIndex;
InitialDir := FInitialDir;
DefaultExt := FDefaultExt;
FileName := ControlGetValue;
if Execute then
ControlSetValue(FileName);
finally
Free;
end;
jdkSave:
with TSaveDialog.Create(Self) do
try
Options := FDialogOptions;
Title := FDialogTitle;
Filter := FFilter;
FilterIndex := FFilterIndex;
InitialDir := FInitialDir;
DefaultExt := FDefaultExt;
FileName := ControlGetValue;
if Execute then
ControlSetValue(FileName);
finally
Free;
end;
jdkSavePicture:
with TSavePictureDialog.Create(Self) do
try
Options := FDialogOptions;
Title := FDialogTitle;
Filter := FFilter;
FilterIndex := FFilterIndex;
InitialDir := FInitialDir;
DefaultExt := FDefaultExt;
FileName := ControlGetValue;
if Execute then
ControlSetValue(FileName);
finally
Free;
end;
end;
if FEditControl.CanFocus then
FEditControl.SetFocus;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetDefaultProperties;
begin
Caption := ' ';
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetReadOnly(Value: Boolean);
begin
FEditControl.ReadOnly := Value;
FButton.Enabled := not Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetCaption(const Value: string);
begin
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetTabOrder(Value: Integer);
begin
TabOrder := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetOnEnter(Value: TNotifyEvent);
begin
FEditControl.OnEnter := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetOnExit(Value: TNotifyEvent);
begin
FEditControl.OnExit := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetOnChange(Value: TNotifyEvent);
begin
FEditControl.OnChange := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetOnClick(Value: TNotifyEvent);
begin
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetHint(const Value: string);
begin
Hint := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetValue(Value: Variant);
begin
FEditControl.Text := Value;
end;
function TJvDynControlVCLFileNameEdit.ControlGetValue: Variant;
begin
Result := FEditControl.Text;
end;
// IJvDynControlFileName
procedure TJvDynControlVCLFileNameEdit.ControlSetInitialDir(const Value: string);
begin
FInitialDir := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetDefaultExt(const Value: string);
begin
FDefaultExt := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetDialogTitle(const Value: string);
begin
FDialogTitle := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetDialogOptions(Value: TOpenOptions);
begin
FDialogOptions := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetFilter(const Value: string);
begin
FFilter := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetFilterIndex(Value: Integer);
begin
FFilterIndex := Value;
end;
procedure TJvDynControlVCLFileNameEdit.ControlSetDialogKind(Value: TJvDynControlFileNameDialogKind);
begin
FDialogKind := Value;
end;
//=== { TJvDynControlVCLDirectoryEdit } ======================================
constructor TJvDynControlVCLDirectoryEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEditControl := TMaskEdit.Create(AOwner);
FEditControl.Parent := Self;
FButton := TBitBtn.Create(AOwner);
FButton.Parent := Self;
FButton.Align := alRight;
FButton.OnClick := DefaultOnButtonClick;
FButton.Caption := '...';
Height := FEditControl.Height;
FButton.Width := Height;
FEditControl.Align := alClient;
BevelInner := bvNone;
BevelOuter := bvNone;
end;
destructor TJvDynControlVCLDirectoryEdit.Destroy;
begin
FreeAndNil(FEditControl);
FreeAndNil(FButton);
inherited Destroy;
end;
procedure TJvDynControlVCLDirectoryEdit.DefaultOnButtonClick(Sender: TObject);
var
Dir: WideString;
begin
Dir := ControlGetValue;
if Dir = '' then
if FInitialDir <> '' then
Dir := FInitialDir
else
Dir := PathDelim;
if not DirectoryExists(Dir) then
Dir := PathDelim;
{$IFDEF MSWINDOWS}
if SelectDirectory('', '', Dir) then
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
if SelectDirectory('', '/', Dir, False) then
{$ENDIF UNIX}
ControlSetValue(Dir);
if FEditControl.CanFocus then
FEditControl.SetFocus;
end;
procedure TJvDynControlVCLDirectoryEdit.ControlSetDefaultProperties;
begin
Self.Caption := ' ';
end;
procedure TJvDynControlVCLDirectoryEdit.ControlSetReadOnly(Value: Boolean);
begin
FEditControl.ReadOnly := Value;
FButton.Enabled := not Value;
end;
procedure TJvDynControlVCLDirectoryEdit.ControlSetCaption(const Value: string);
begin
end;
procedure TJvDynControlVCLDirectoryEdit.ControlSetTabOrder(Value: Integer);
begin
TabOrder := Value;
end;
procedure TJvDynControlVCLDirectoryEdit.ControlSetOnEnter(Value: TNotifyEvent);
begin
FEditControl.OnEnter := Value;
end;
procedure TJvDynControlVCLDirectoryEdit.ControlSetOnExit(Value: TNotifyEvent);
begin
FEditControl.OnExit := Value;
end;
procedure TJvDynControlVCLDirectoryEdit.ControlSetOnChange(Value: TNotifyEvent);
begin
FEditControl.OnChange := Value;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -