FastReport_FMX_2.8.12/Source/FMX.frxCustomEditors.pas

175 lines
4.7 KiB
ObjectPascal
Raw Permalink Normal View History

2024-01-10 21:50:38 +01:00
{******************************************}
{ }
{ FastReport v4.0 }
{ Property editors for Designer }
{ }
{ Copyright (c) 1998-2008 }
{ by Alexander Tzyganenko, }
{ Fast Reports Inc. }
{ }
{******************************************}
unit FMX.frxCustomEditors;
interface
{$I frx.inc}
uses
System.Classes, System.SysUtils, System.UITypes, System.Types, FMX.Types, FMX.Controls, FMX.Forms, FMX.Menus,
FMX.Dialogs, FMX.frxClass, FMX.frxDMPClass, FMX.frxDsgnIntf
, System.Variants;
type
TfrxViewEditor = class(TfrxComponentEditor)
public
procedure GetMenuItems(OnClickEvent: TNotifyEvent); override;
function Execute(Tag: Integer; Checked: Boolean): Boolean; override;
end;
TfrxCustomMemoEditor = class(TfrxViewEditor)
public
procedure GetMenuItems(OnClickEvent: TNotifyEvent); override;
function Execute(Tag: Integer; Checked: Boolean): Boolean; override;
end;
implementation
uses FMX.frxEditMemo, FMX.frxEditFormat, FMX.frxRes;
{ TfrxViewEditor }
function TfrxViewEditor.Execute(Tag: Integer; Checked: Boolean): Boolean;
var
i: Integer;
c: TfrxComponent;
v: TfrxView;
begin
Result := False;
for i := 0 to Designer.SelectedObjects.Count - 1 do
begin
c := Designer.SelectedObjects[i];
if (c is TfrxView) and not (rfDontModify in c.Restrictions) and (Tag in [50..53]) then
begin
v := TfrxView(c);
case Tag of
50: if Checked then
v.ShiftMode := smAlways else
v.ShiftMode := smDontShift;
51: if Checked then
v.ShiftMode := smWhenOverlapped else
v.ShiftMode := smDontShift;
52: v.Visible := Checked;
53: v.Printable := Checked;
end;
Result := True;
end;
end;
end;
procedure TfrxViewEditor.GetMenuItems(OnClickEvent: TNotifyEvent);
var
v: TfrxView;
begin
inherited;
v := TfrxView(Component);
AddItem(frxResources.Get('mvShift'), 50, v.ShiftMode = smAlways);
AddItem(frxResources.Get('mvShiftOver'), 51, v.ShiftMode = smWhenOverlapped);
AddItem(frxResources.Get('mvVisible'), 52, v.Visible);
AddItem(frxResources.Get('mvPrintable'), 53, v.Printable);
end;
{ TfrxCustomMemoEditor }
function TfrxCustomMemoEditor.Execute(Tag: Integer; Checked: Boolean): Boolean;
var
i: Integer;
c: TfrxComponent;
m: TfrxCustomMemoView;
DisplayFormat: TfrxFormat;
function EditFormat: Boolean;
begin
with TfrxFormatEditorForm.Create(Designer) do
begin
Format.Assign(TfrxCustomMemoView(Component).DisplayFormat);
FormShow(Self);
Result := ShowModal = mrOk;
if Result then
DisplayFormat.Assign(Format);
Free;
end;
end;
begin
Result := inherited Execute(Tag, Checked);
DisplayFormat := TfrxFormat.Create;
try
if Tag = 1 then
if not EditFormat then Exit;
for i := 0 to Designer.SelectedObjects.Count - 1 do
begin
c := Designer.SelectedObjects[i];
if (c is TfrxCustomMemoView) and not (rfDontModify in c.Restrictions) then
begin
m := TfrxCustomMemoView(c);
case Tag of
1: m.DisplayFormat := DisplayFormat;
2: m.Memo.Clear;
3: m.AutoWidth := Checked;
4: m.WordWrap := Checked;
5: m.SuppressRepeated := Checked;
6: m.HideZeros := Checked;
7: m.AllowExpressions := Checked;
8: m.AllowHTMLTags := Checked;
40: if Checked then
m.StretchMode := smActualHeight else
m.StretchMode := smDontStretch;
41: if Checked then
m.StretchMode := smMaxHeight else
m.StretchMode := smDontStretch;
end;
Result := True;
end;
end;
finally
DisplayFormat.Free;
end;
end;
procedure TfrxCustomMemoEditor.GetMenuItems(OnClickEvent: TNotifyEvent);
var
m: TfrxCustomMemoView;
begin
inherited;
m := TfrxCustomMemoView(Component);
AddItem(frxResources.Get('mvFormat'), 1);
AddItem(frxResources.Get('mvClear'), 2);
AddItem('-', -1);
AddItem(frxResources.Get('mvAutoWidth'), 3, m.AutoWidth);
AddItem(frxResources.Get('mvWWrap'), 4, m.WordWrap);
AddItem(frxResources.Get('mvSuppress'), 5, m.SuppressRepeated);
AddItem(frxResources.Get('mvHideZ'), 6, m.HideZeros);
AddItem(frxResources.Get('mvExpr'), 7, m.AllowExpressions);
if not (m is TfrxDMPMemoView) then
AddItem(frxResources.Get('mvHTML'), 8, m.AllowHTMLTags);
AddItem('-', -1);
AddItem(frxResources.Get('mvStretch'), 40, m.StretchMode = smActualHeight);
AddItem(frxResources.Get('mvStretchToMax'), 41, m.StretchMode = smMaxHeight);
end;
end.