📄 rm_desgn.pas
字号:
var
i, j, k: Integer;
t: TRMView;
begin
j := 0; k := 0;
FLeftTop := Point(10000, 10000);
FRightBottom := -1;
MRFlag := False;
if SelNum > 1 then {find right-bottom element}
begin
for i := 0 to Objects.Count - 1 do
begin
t := Objects[i];
if t.Selected then
begin
t.OriginalRect := Rect(t.x, t.y, t.dx, t.dy);
if (t.x + t.dx > j) or ((t.x + t.dx = j) and (t.y + t.dy > k)) then
begin
j := t.x + t.dx;
k := t.y + t.dy;
FRightBottom := i;
end;
if t.x < FLeftTop.x then FLeftTop.x := t.x;
if t.y < FLeftTop.y then FLeftTop.y := t.y;
end;
end;
t := Objects[FRightBottom];
OldRect := Rect(FLeftTop.x, FLeftTop.y, t.x + t.dx, t.y + t.dy);
OldRect1 := OldRect;
MRFlag := True;
end;
end;
procedure TRMDesignerPage.MDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i: Integer;
f, v: Boolean;
t: TRMView;
Rgn: HRGN;
p: TPoint;
begin
FWasCtrl := ssCtrl in Shift;
if FDFlag then
begin
FDFlag := False;
Exit;
end;
if (Button = mbRight) and FDown and FRFlag then
DrawFocusRect(OldRect);
FRFlag := False;
DrawPage(dmSelection);
FDown := True;
if Button = mbLeft then
begin
if (ssCtrl in Shift) or (Cursor = crCross) then
begin
FRFlag := True;
if Cursor = crCross then
begin
if FDesigner.PageType = ptReport then
DrawFocusRect(OldRect);
RoundCoord(x, y);
OldRect1 := OldRect;
end;
OldRect := Rect(x, y, x, y);
FDesigner.Unselect;
SelNum := 0;
FRightBottom := -1;
MRFlag := False;
FirstSelected := nil;
Exit;
end
else if Cursor = crPencil then
begin
with FDesigner do
begin
if GridAlign then
begin
if not FindNearestEdge(x, y) then
begin
x := Round(x / GridSizeX) * GridSizeX;
y := Round(y / GridSizeY) * GridSizeY;
end;
end;
end;
OldRect := Rect(x, y, x, y);
FDesigner.Unselect;
SelNum := 0;
FRightBottom := -1;
MRFlag := False;
FirstSelected := nil;
FLastX := x;
FLastY := y;
Exit;
end;
end;
if Cursor = crDefault then
begin
f := False;
for i := Objects.Count - 1 downto 0 do
begin
t := Objects[i];
Rgn := t.GetClipRgn(rtNormal);
v := PtInRegion(Rgn, X, Y);
DeleteObject(Rgn);
if v then
begin
if ssShift in Shift then
begin
t.Selected := not t.Selected;
if t.Selected then Inc(SelNum) else Dec(SelNum);
end
else if not t.Selected then
begin
FDesigner.Unselect;
SelNum := 1;
t.Selected := True;
end;
if SelNum = 0 then
FirstSelected := nil
else if SelNum = 1 then
FirstSelected := t
else if FirstSelected <> nil then
begin
if not FirstSelected.Selected then
FirstSelected := nil;
end;
f := True;
Break;
end;
end;
if not f then
begin
FDesigner.Unselect;
SelNum := 0;
FirstSelected := nil;
if Button = mbLeft then
begin
FRFlag := True;
OldRect := Rect(x, y, x, y);
Exit;
end;
end;
GetMultipleSelected;
end;
if SelNum = 0 then
begin // reset multiple selection
FRightBottom := -1;
MRFlag := False;
end;
FLastX := x;
FLastY := y;
FMoved := False;
FirstChange := True;
FFirstBandMove := True;
if Button = mbRight then
begin
DrawPage(dmSelection);
FDown := False;
GetCursorPos(p);
FDesigner.SelectionChanged;
FDesigner.Popup1.Popup(p.X, p.Y);
end
else if FDesigner.FShapeMode = smFrame then
DrawPage(dmShape);
end;
const
CON_RMBandNames: array[0..22] of string = (
'Report title', 'Report summary', 'Page header', 'Page footer',
'Master header', 'Master data', 'Master footer', 'Detail header',
'Detail data', 'Detail footer', 'Subdetail header', 'Subdetail data',
'Subdetail footer', 'Overlay', 'Column header', 'Column footer',
'Group header', 'Group footer', 'Cross header', 'Cross data',
'Cross footer', 'Child', 'None');
procedure TRMDesignerPage.MUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
i, k, dx, dy: Integer;
t: TRMView;
ObjectInserted: Boolean;
procedure AddObject(ot: Byte);
begin
Objects.Add(RMCreateObject(ot, ''));
t := Objects.Last;
end;
procedure CreateSection;
var
s: string;
FRMBandTypesForm: TRMBandTypesForm;
function IsSubreport(PageN: Integer): Boolean;
var
i, j: Integer;
t: TRMView;
begin
Result := False;
with CurReport do
begin
for i := 0 to Pages.Count - 1 do
begin
for j := 0 to Pages[i].Objects.Count - 1 do
begin
t := Pages[i].Objects[j];
if t.Typ = gtSubReport then
begin
if TRMSubReportView(t).SubPage = PageN then
begin
Result := True;
Exit;
end;
end;
end;
end;
end;
end;
begin
FRMBandTypesForm := TRMBandTypesForm.Create(nil);
FRMBandTypesForm.IsSubreport := IsSubreport(FDesigner.CurPage);
ObjectInserted := FRMBandTypesForm.ShowModal = mrOk;
if ObjectInserted then
begin
Objects.Add(TRMBandView.Create);
t := Objects.Last;
TRMBandView(t).BandType := FRMBandTypesForm.SelectedTyp;
s := CON_RMBandNames[Integer(FRMBandTypesForm.SelectedTyp)];
if Pos(' ', s) <> 0 then
begin
s[Pos(' ', s) + 1] := UpCase(s[Pos(' ', s) + 1]);
Delete(s, Pos(' ', s), 1);
end;
THackView(t).BaseName := s;
SendBandsToDown;
end;
FRMBandTypesForm.Free;
end;
procedure CreateSubReport;
begin
Objects.Add(TRMSubReportView.Create);
t := Objects.Last;
TRMSubReportView(t).SubPage := CurReport.Pages.Count;
CurReport.Pages.Add;
end;
function CheckUnique(Name: string): Boolean;
var
i: Integer;
begin
Result := True;
for i := 0 to Objects.Count - 1 do
begin
if TRMView(Objects[i]).ClassName = Name then
begin
if (TRMView(Objects[i]).Flags and flOnePerPage) <> 0 then
Result := False;
end;
end;
end;
begin
if Button <> mbLeft then Exit;
FDown := False;
ObjectInserted := FALSE;
if FDesigner.FShapeMode = smFrame then
DrawPage(dmShape);
if Cursor = crCross then // inserting a new object
begin
FMode := mdSelect;
if FDesigner.PageType = ptReport then
begin
DrawFocusRect(OldRect);
if (OldRect.Left = OldRect.Right) and (OldRect.Top = OldRect.Bottom) then
OldRect := OldRect1;
end;
NormalizeRect(OldRect);
FRFlag := False;
if DesignerRestrictions * [RMdrDontCreateObj] = [] then
begin
ObjectInserted := True;
with FDesigner.ToolbarComponent do
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TToolbarButton97 then
begin
with Controls[i] as TToolbarButton97 do
begin
if Down then
begin
if Tag = gtBand then
begin
if GetUnusedBand <> btNone then
CreateSection
else
begin
//WHF Modify
FMoved := FALSE;
FCT := ctNone;
FDesigner.OB1.Down := TRUE;
Exit;
end;
end
else if Tag = gtSubReport then
CreateSubReport
else if Tag >= gtAddIn then
begin
k := Tag - gtAddIn;
if CheckUnique(RMAddIns(k).ClassRef.ClassName) then
begin
t := RMCreateObject(gtAddIn, RMAddIns(k).ClassRef.ClassName);
Objects.Add(t);
end
else
begin
ObjectInserted := False;
Application.MessageBox(
PChar(Format(RMLoadStr(SOnePerPage), [RMAddIns(k).ClassRef.ClassName])),
PChar(RMLoadStr(SError)), mb_IconError + mb_Ok);
end;
// Objects.Add(RMCreateObject(gtAddIn, RMAddIns(k).ClassRef.ClassName));
// t := Objects.Last;
end
else
AddObject(Tag);
Break;
end;
end;
end;
end;
end;
end
else
ObjectInserted := False;
if ObjectInserted then
begin
t.CreateUniqueName;
THackView(t).AfterCreate;
if t is TRMSubReportView then
FDesigner.SetPageTitles;
with OldRect do
begin
if (Left = Right) or (Top = Bottom) then
begin
dx := 36; dy := 36;
if t is TRMMemoView then
FDesigner.GetDefaultSize(dx, dy)
else if FDesigner.PageType = ptDialog then
begin
dx := t.dx;
dy := t.dy;
end;
OldRect := Rect(Left, Top, Left + dx, Top + dy);
end;
end;
FDesigner.Unselect;
t.x := OldRect.Left; t.y := OldRect.Top;
if (t.dx = 0) and (t.dy = 0) then
begin
t.dx := OldRect.Right - OldRect.Left;
t.dy := OldRect.Bottom - OldRect.Top;
end;
if (t is TRMBandView) and (TRMBandView(t).BandType in [btCrossHeader..btCrossFooter]) and
(t.dx > Width - 10) then
t.dx := 40;
if t.Typ <> gtAddIn then
t.Prop['FrameWidth'] := LastFrameWidth;
t.Prop['FrameColor'] := LastFrameColor;
t.FillColor := LastFillColor;
t.Selected := True;
if t is TRMMemoView then
begin
with t as TRMMemoView do
begin
t.prop['FrameTyp'] := LastFrameTyp;
Font.Name := LastFontName;
Font.Size := LastFontSize;
Font.Color := LastFontColor;
Font.Style := RMSetFontStyle(LastFontStyle);
{$IFNDEF Delphi2}
Font.Charset := LastCharset;
{$ENDIF}
Alignment := LastAlignment;
end;
end;
SelNum := 1;
if t.Typ = gtBand then
Draw(10000, t.GetClipRgn(rtExtended))
else
begin
t.Draw(Canvas);
DrawSelection(t);
end;
with FDesigner do
begin
SelectionChanged;
AddUndoAction(acInsert);
if FEditAfterInsert and (not FDrag) and (not (t is TRMControl)) then
ShowEditor;
end;
end;
if not ObjRepeat then
FDesigner.OB1.Down := True
else
DrawFocusRect(OldRect);
Exit;
end;
if Cursor = crPencil then // line drawing
begin
with OldRect do
begin
if (Left = Right) and (Top = Bottom) then
Exit;
end;
if DesignerRestrictions * [RMdrDontCreateObj] <> [] then Exit;
DrawRectLine(OldRect);
AddObject(gtLine);
t.CreateUniqueName;
t.x := OldRect.Left; t.y := OldRect.Top;
t.dx := OldRect.Right - OldRect.Left; t.dy := OldRect.Bottom - OldRect.Top;
if t.dx < 0 then
begin
t.dx := -t.dx; if Abs(t.dx) > Abs(t.dy) then t.x := OldRect.Right;
end;
if t.dy < 0 then
begin
t.dy := -t.dy; if Abs(t.dy) > Abs(t.dx) then t.y := OldRect.Bottom;
end;
t.Selected := True;
t.Prop['FrameWidth'] := LastLineWidth;
t.Prop['FrameColor'] := LastFrameColor;
SelNum := 1;
t.Draw(Canvas);
DrawSelection(t);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -