📄 jvdsgneditors.pas
字号:
if TFrmSelectDateTimeDlg.SelectDateTime(D, dstTime) then
begin
SetFloatValue(Frac(D)); // (p3) only return the time portion
Designer.Modified;
end;
end;
function TJvTimeExProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
{$ENDIF VCL}
//=== { TJvDefaultImageIndexProperty } =======================================
{$IFDEF COMPILER6_UP}
function TJvDefaultImageIndexProperty.ImageList: TCustomImageList;
const
cImageList = 'ImageList';
cImages = 'Images';
begin
if TypInfo.GetPropInfo(GetComponent(0), cImageList) <> nil then
Result := TCustomImageList(TypInfo.GetObjectProp(GetComponent(0), cImageList))
else
if TypInfo.GetPropInfo(GetComponent(0), cImages) <> nil then
Result := TCustomImageList(TypInfo.GetObjectProp(GetComponent(0), cImages))
else
Result := nil;
end;
function TJvDefaultImageIndexProperty.GetAttributes: TPropertyAttributes;
begin
{$IFDEF VCL}
Result := [paValueList, paMultiSelect, paRevertable];
{$ENDIF VCL}
{$IFDEF VisualCLX}
Result := [paRevertable, paDialog];
{$ENDIF VisualCLX}
end;
{$IFDEF VCL}
function TJvDefaultImageIndexProperty.GetValue: string;
begin
Result := IntToStr(GetOrdValue);
end;
procedure TJvDefaultImageIndexProperty.SetValue(const Value: string);
var
XValue: Integer;
begin
try
XValue := StrToInt(Value);
SetOrdValue(XValue);
except
inherited SetValue(Value);
end;
end;
procedure TJvDefaultImageIndexProperty.GetValues(Proc: TGetStrProc);
var
Tmp: TCustomImageList;
I: Integer;
begin
Tmp := ImageList;
if Assigned(Tmp) then
for I := 0 to Tmp.Count - 1 do
Proc(IntToStr(I));
end;
procedure TJvDefaultImageIndexProperty.ListMeasureWidth(const Value: string; ACanvas: TCanvas; var AWidth: Integer);
var
Tmp: TCustomImageList;
begin
Tmp := ImageList;
if Assigned(Tmp) then
AWidth := Tmp.Width + ACanvas.TextHeight(Value) + 4;
end;
procedure TJvDefaultImageIndexProperty.ListMeasureHeight(const Value: string; ACanvas: TCanvas; var AHeight: Integer);
var
Tmp: TCustomImageList;
begin
Tmp := ImageList;
if Assigned(Tmp) then
AHeight := Max(Tmp.Height + 2, ACanvas.TextHeight(Value) + 2);
end;
procedure TJvDefaultImageIndexProperty.ListDrawValue(const Value: string; ACanvas:
TCanvas; const ARect: TRect; ASelected: Boolean);
var
Tmp: TCustomImageList;
R: TRect;
begin
DefaultPropertyListDrawValue(Value, ACanvas, ARect, ASelected);
Tmp := ImageList;
if Tmp <> nil then
begin
R := ARect;
ACanvas.FillRect(ARect);
Tmp.Draw(ACanvas, ARect.Left, ARect.Top, StrToInt(Value));
OffsetRect(R, Tmp.Width + 2, 0);
DrawText(ACanvas.Handle, PChar(Value), -1, R, 0);
end;
end;
procedure TJvDefaultImageIndexProperty.PropDrawName(ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean);
begin
DefaultPropertyDrawName(Self, ACanvas, ARect);
end;
procedure TJvDefaultImageIndexProperty.PropDrawValue(ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean);
var
Tmp: TCustomImageList;
begin
Tmp := ImageList;
if (GetVisualValue <> '') and Assigned(Tmp) then
ListDrawValue(GetVisualValue, ACanvas, ARect, ASelected)
else
DefaultPropertyDrawValue(Self, ACanvas, ARect);
end;
{$ENDIF VCL}
{$ENDIF COMPILER6_UP}
{$IFDEF COMPILER5}
function TJvDefaultImageIndexProperty.ImageList: TCustomImageList;
const
cImageList = 'ImageList';
cImages = 'Images';
begin
if TypInfo.GetPropInfo(GetComponent(0), cImageList) <> nil then
Result := TCustomImageList(TypInfo.GetObjectProp(GetComponent(0), cImageList))
else
if TypInfo.GetPropInfo(GetComponent(0), cImages) <> nil then
Result := TCustomImageList(TypInfo.GetObjectProp(GetComponent(0), cImages))
else
Result := nil;
end;
function TJvDefaultImageIndexProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paMultiSelect, paRevertable];
end;
function TJvDefaultImageIndexProperty.GetValue: string;
begin
Result := IntToStr(GetOrdValue);
end;
procedure TJvDefaultImageIndexProperty.SetValue(const Value: string);
var
XValue: Integer;
begin
try
XValue := StrToInt(Value);
SetOrdValue(XValue);
except
inherited SetValue(Value);
end;
end;
procedure TJvDefaultImageIndexProperty.GetValues(Proc: TGetStrProc);
var
Tmp: TCustomImageList;
I: Integer;
begin
Tmp := ImageList;
if Assigned(Tmp) then
for I := 0 to Tmp.Count - 1 do
Proc(IntToStr(I));
end;
procedure TJvDefaultImageIndexProperty.ListDrawValue(const Value: string;
ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
var
Tmp: TCustomImageList;
R: TRect;
begin
inherited ListDrawValue(Value, ACanvas, ARect, ASelected);
Tmp := ImageList;
if Tmp <> nil then
begin
R := ARect;
ACanvas.FillRect(ARect);
Tmp.Draw(ACanvas, ARect.Left, ARect.Top, StrToInt(Value));
OffsetRect(R, Tmp.Width + 2, 0);
DrawText(ACanvas.Handle, PChar(Value), -1, R, 0);
end;
end;
procedure TJvDefaultImageIndexProperty.ListMeasureHeight(const Value: string;
ACanvas: TCanvas; var AHeight: Integer);
var
Tmp: TCustomImageList;
begin
Tmp := ImageList;
if Assigned(Tmp) then
AHeight := Max(Tmp.Height + 2, ACanvas.TextHeight(Value) + 2);
end;
procedure TJvDefaultImageIndexProperty.ListMeasureWidth(const Value: string;
ACanvas: TCanvas; var AWidth: Integer);
var
Tmp: TCustomImageList;
begin
Tmp := ImageList;
if Assigned(Tmp) then
AWidth := Tmp.Width + ACanvas.TextHeight(Value) + 4;
end;
procedure TJvDefaultImageIndexProperty.PropDrawValue(ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean);
begin
// if GetVisualValue <> '' then
// ListDrawValue(GetVisualValue, ACanvas, ARect, True)
// else
inherited PropDrawValue(ACanvas, ARect, ASelected);
end;
{$ENDIF COMPILER5}
{$IFDEF VisualCLX}
procedure TJvDefaultImageIndexProperty.Edit;
var
SelectedIndex: Integer;
Tmp: TImageList;
begin
if ImageList <> nil then
begin
Tmp := TImageList.Create(Application);
Tmp.Assign(ImageList);
SelectedIndex := StrToInt(GetValue);
if EditImageIndex(Tmp, SelectedIndex) then
begin
SetValue(IntToStr(SelectedIndex));
ImageList.Assign(Tmp);
end;
Tmp.Free;
end;
end;
{$ENDIF VisualCLX}
//=== { TJvShortCutProperty } ================================================
function TJvShortCutProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paMultiSelect, paRevertable];
end;
function TJvShortCutProperty.GetValue: string;
begin
try
Result := ShortCutToText(GetOrdValue);
if Result = '' then
Result := RsNone;
except
Result := inherited GetValue;
end;
end;
procedure TJvShortCutProperty.GetValues(Proc: TGetStrProc);
var
Key: Word;
Shift: TShiftState;
begin
Proc(RsNone);
Shift := [ssCtrl];
for Key := Ord('A') to Ord('Z') do
Proc(ShortCutToText(ShortCut(Key, Shift)));
Shift := [ssAlt, ssCtrl];
for Key := Ord('A') to Ord('Z') do
Proc(ShortCutToText(ShortCut(Key, Shift)));
Shift := [];
for Key := VK_F1 to VK_F10 do
Proc(ShortCutToText(ShortCut(Key, Shift)));
Shift := [ssCtrl];
for Key := VK_F1 to VK_F10 do
Proc(ShortCutToText(ShortCut(Key, Shift)));
Shift := [ssShift];
for Key := VK_F1 to VK_F10 do
Proc(ShortCutToText(ShortCut(Key, Shift)));
Shift := [ssShift, ssCtrl];
for Key := VK_F1 to VK_F10 do
Proc(ShortCutToText(ShortCut(Key, Shift)));
Shift := [ssShift, ssAlt, ssCtrl];
for Key := VK_F1 to VK_F10 do
Proc(ShortCutToText(ShortCut(Key, Shift)));
Proc(ShortCutToText(ShortCut(VK_INSERT, [])));
Proc(ShortCutToText(ShortCut(VK_INSERT, [ssShift])));
Proc(ShortCutToText(ShortCut(VK_INSERT, [ssCtrl])));
Proc(ShortCutToText(ShortCut(VK_DELETE, [])));
Proc(ShortCutToText(ShortCut(VK_DELETE, [ssShift])));
Proc(ShortCutToText(ShortCut(VK_DELETE, [ssCtrl])));
Proc(ShortCutToText(ShortCut(VK_BACK, [ssAlt])));
Proc(ShortCutToText(ShortCut(VK_BACK, [ssAlt, ssShift])));
end;
procedure TJvShortCutProperty.SetValue(const Value: string);
begin
try
SetOrdValue(TextToShortCut(Value));
except
inherited SetValue(Value);
end;
end;
//=== { TJvNosortEnumProperty } ==============================================
function TJvNosortEnumProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes - [paSortList];
end;
procedure TJvFilenameProperty.OnDialogShow(Sender: TObject);
begin
{$IFDEF VCL}
SetDlgItemText(GetParent(TOpenDialog(Sender).Handle), chx1, PChar(RsStripFilePath));
{$ENDIF VCL}
end;
//=== { TJvExeNameProperty } =================================================
function TJvExeNameProperty.GetFilter: string;
begin
Result := RsExecutableFilesExeExeAllFiles;
end;
//=== { TJvIntegerProperty } =================================================
function TJvIntegerProperty.GetValue: string;
begin
Result := ValueName(GetOrdValue);
if Result = '' then
Result := IntToStr(GetOrdValue);
end;
procedure TJvIntegerProperty.SetValue(const Value: string);
var
L: Longint;
begin
L := StrToValue(Value);
if L = 0 then
L := StrToInt(Value);
inherited SetValue(IntToStr(L));
end;
//=== { TJvFloatProperty } ===================================================
function TJvFloatProperty.GetValue: string;
const
Precisions: array [TFloatType] of Integer = (7, 15, 18, 18, 18);
begin
Result := ValueName(GetFloatValue);
if Result = '' then
Result := FloatToStrF(GetFloatValue, ffGeneral,
Precisions[GetTypeData(GetPropType)^.FloatType], 0);
end;
procedure TJvFloatProperty.SetValue(const Value: string);
var
L: Longint;
begin
L := StrToValue(Value);
if L <> 0 then
SetFloatValue(L)
else
SetFloatValue(StrToFloat(Value));
end;
procedure TJvImageListEditor.SaveAsBitmap(ImageList: TImageList);
var
Bitmap: TBitmap;
SaveDlg: TOpenDialog;
I: Integer;
begin
if ImageList.Count > 0 then
begin
SaveDlg := TSavePictureDialog.Create(Application);
with SaveDlg do
try
Options := [ofHideReadOnly, ofOverwritePrompt];
DefaultExt := GraphicExtension(TBitmap);
Filter := GraphicFilter(TBitmap);
if Execute then
begin
Bitmap := TBitmap.Create;
try
with Bitmap do
begin
Width := ImageList.Width * ImageList.Count;
Height := ImageList.Height;
if ImageList.BkColor <> clNone then
Canvas.Brush.Color := ImageList.BkColor
else
Canvas.Brush.Color := clWindow;
Canvas.FillRect(Bounds(0, 0, Width, Height));
for I := 0 to ImageList.Count - 1 do
ImageList.Draw(Canvas, ImageList.Width * I, 0, I);
{$IFDEF VCL}
HandleType := bmDIB;
if PixelFormat in [pf15bit, pf16bit] then
{$ENDIF VCL}
{$IFDEF VisualCLX}
if PixelFormat = pf16bit then
{$ENDIF VisualCLX}
try
PixelFormat := pf24bit;
except
end;
end;
Bitmap.SaveToFile(FileName);
finally
Bitmap.Free;
end;
end;
finally
Free;
end;
end
else
Beep;
end;
procedure TJvImageListEditor.ExecuteVerb(Index: Integer);
begin
if Designer <> nil then
case Index of
0:
if EditImageList(Component as TImageList) then
Designer.Modified;
1:
SaveAsBitmap(TImageList(Component));
end;
end;
function TJvImageListEditor.GetVerb(Index: Integer): string;
begin
case Index of
0:
Result := SImageListEditor;
1:
Result := RsSaveImageList;
else
Result := '';
end;
end;
function TJvImageListEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
//=== { TJvWeekDayProperty } =================================================
function TJvWeekDayProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList];
end;
//=== { TJvComponentFormProperty } ===========================================
procedure TJvComponentFormProperty.GetValues(Proc: TGetStrProc);
var
Form: TComponent;
begin
inherited GetValues(Proc);
Form := Designer.{$IFDEF COMPILER6_UP} Root {$ELSE} Form {$ENDIF};
if (Form is GetTypeData(GetPropType)^.ClassType) and (Form.Name <> '') then
Proc(Form.Name);
end;
procedure TJvComponentFormProperty.SetValue(const Value: string);
var
Component: TComponent;
Form: TComponent;
begin
Component := Designer.GetComponent(Value);
Form := Designer.{$IFDEF COMPILER6_UP} Root {$ELSE} Form {$ENDIF};
if ((Component = nil) or not (Component is GetTypeData(GetPropType)^.ClassType)) and
(CompareText(Form.Name, Value) = 0) then
begin
if not (Form is GetTypeData(GetPropType)^.ClassType) then
raise EPropertyError.CreateRes(@SInvalidPropertyValue);
SetOrdValue(Longint(Form));
end
else
inherited SetValue(Value);
end;
//=== { TJvPersistentProperty } ==============================================
{$IFDEF COMPILER5}
function TJvPersistentProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paSubProperties, paReadOnly];
end;
function TJvPersistentProperty.GetEditLimit: Integer;
begin
Result := 127;
end;
procedure TJvPersistentProperty.GetProperties(Proc: TGetPropEditProc);
var
I: Integer;
J: Integer;
JvPersistents: TDesignerSelectionList;
begin
JvPersistents := TDesignerSelectionList.Create;
for I := 0 to PropCount - 1 do
begin
J := GetOrdValueAt(I);
if J <> 0 then
JvPersistents.Add(TJvPersistent(GetOrdValueAt(I)));
end;
if JvPersistents.Count > 0 then
GetComponentProperties(JvPersistents, tkAny, Designer, Proc);
end;
{$ENDIF COMPILER5}
//=== { TJvStringsEditor } ===================================================
function TJvStringsEditor.GetEditPropertyName: string;
begin
Result := 'Strings';
end;
//=== { TJvItemsEditor } =====================================================
function TJvItemsEditor.GetEditPropertyName: string;
begin
Result := 'Items';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -