📄 rm_desgn.pas
字号:
Objects.Add(TRMSubReportView.Create);
t := Objects.Last;
TRMSubReportView(t).SubPage := CurReport.Pages.Count;
with FDesigner.Page do
CurReport.Pages.Add.ChangePaper(pgSize, pgWidth, pgHeight, pgBin, pgOr);
CurReport.Pages[CurReport.Pages.Count - 1].pgMargins := Rect(0, 0, 0, 0);
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
Result := not TRMView(Objects[i]).POnePerPage;
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 新View
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 FDesignerRestrictions * [RMdrDontCreateObj] = [] then
begin
ObjectInserted := True;
with FDesigner.ToolbarComponent do
begin
{$IFDEF USE_TB2k}
for i := 0 to Items.Count - 1 do
{$ELSE}
for i := 0 to ControlCount - 1 do
{$ENDIF}
begin
{$IFDEF USE_TB2k}
if Items[i] is TRMToolbarButton then
{$ELSE}
if Controls[i] is TRMToolbarButton then
{$ENDIF}
begin
{$IFDEF USE_TB2k}
with Items[i] as TRMToolbarButton do
{$ELSE}
with Controls[i] as TRMToolbarButton do
{$ENDIF}
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;
end
else
AddObject(Tag);
Break;
end;
end;
end;
end;
end;
end
else
ObjectInserted := False;
if ObjectInserted then
begin
FPrevView := t;
t.CreateUniqueName;
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;
if AnsiCompareText(t.ClassName, 'TRMGRIDVIEW') = 0 then
begin
if t.dx < 615 then
t.dx := 615;
if t.dy < 150 then
t.dy := 150;
end;
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 FDesignerRestrictions * [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);
FDesigner.SelectionChanged;
FDesigner.AddUndoAction(acInsert);
Exit;
end;
// calculating which objects contains in frame (if user select it with mouse+Ctrl key)
if FRFlag then
begin
DrawFocusRect(OldRect);
FRFlag := False;
NormalizeRect(OldRect);
SelNum := 0;
for i := 0 to Objects.Count - 1 do
begin
t := Objects[i];
with OldRect do
begin
if t.Typ <> gtBand then
begin
if not ((t.x > Right) or (t.x + t.dx < Left) or
(t.y > Bottom) or (t.y + t.dy < Top)) then
begin
t.Selected := True;
Inc(SelNum);
end;
end;
end;
end;
if SelNum = 0 then
begin
for i := 0 to Objects.Count - 1 do
begin
t := Objects[i];
with OldRect do
begin
if not ((t.x > Right) or (t.x + t.dx < Left) or
(t.y > Bottom) or (t.y + t.dy < Top)) then
begin
t.Selected := True;
Inc(SelNum);
end;
end;
end;
end;
GetMultipleSelected;
FDesigner.SelectionChanged;
DrawPage(dmSelection);
if SelNum = 1 then
begin
if (ssCtrl in Shift) and (Button = mbLeft) { and (FPrevView = Objects[TopSelected])} then
begin
FPrevView := Objects[TopSelected];
InplaceEdit(FPrevView)
end
else
FPrevView := Objects[TopSelected];
end
else
FPrevView := nil;
Exit;
end;
if FMoved and MRFlag and (Cursor = crHSplit) then // splitting
begin
with FSplitInfo do
begin
dx := SplRect.Left - SplX;
if FDesignerRestrictions * [RMdrDontMoveObj, RMdrDontSizeObj] = [] then
begin
if ((View1.Restrictions and RMrfDontSize) = 0) and
((View2.Restrictions and (RMrfDontMove + RMrfDontSize)) = 0) then
begin
if (View1.dx + dx > 0) and (View2.dx - dx > 0) then
begin
Inc(View1.dx, dx);
Inc(View2.x, dx);
Dec(View2.dx, dx);
end;
end;
end;
end;
GetMultipleSelected;
Draw(TopSelected, ClipRgn);
Exit;
end;
if FMoved and MRFlag and (Cursor <> crDefault) then // resizing several objects
begin
Draw(TopSelected, ClipRgn);
Exit;
end;
if not FMoved then // redrawing all moved or resized objects
begin
FDesigner.SelectionChanged;
DrawPage(dmSelection);
end;
if (SelNum >= 1) and FMoved then
begin
if SelNum > 1 then
begin
Draw(TopSelected, ClipRgn);
GetMultipleSelected;
FDesigner.ShowPosition;
end
else
begin
t := Objects[TopSelected];
NormalizeCoord(t);
if Cursor <> crDefault then
t.Resized;
if t.PChildView then
FDesigner.RedrawPage
else
Draw(TopSelected, ClipRgn);
FDesigner.SelectionChanged;
FDesigner.ShowPosition;
end;
end;
if SelNum <> 1 then
FPrevView := nil
else if Cursor = crDefault then
FPrevView := Objects[TopSelected];
FMoved := False;
FCT := ctNone;
end;
procedure TRMDesignerPage.MMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
i, j, kx, ky, w, dx, dy: Integer;
t, t1, Bnd, Band: TRMView;
nx, ny, x1, x2, y1, y2: Double;
hr, hr1: HRGN;
FAlign: Boolean;
function Cont(px, py, x, y: Integer): Boolean;
begin
Result := (x >= px - w) and (x <= px + w + 1) and
(y >= py - w) and (y <= py + w + 1);
end;
function GridCheck: Boolean;
begin
with FDesigner do
begin
Result := (kx >= GridSizeX) or (kx <= -GridSizeX) or
(ky >= GridSizeY) or (ky <= -GridSizeY);
if Result then
begin
kx := kx - kx mod GridSizeX;
ky := ky - ky mod GridSizeY;
end;
end;
end;
procedure AddRgn(var HR: HRGN; T: TRMView);
var
tr: HRGN;
begin
tr := t.GetClipRgn(rtExtended);
CombineRgn(HR, HR, TR, RGN_OR);
DeleteObject(TR);
end;
function CheckNegative(t: TRMView): Boolean;
begin
if (t.dx < 0) or (t.dy < 0) then
begin
NormalizeCoord(t);
Result := True;
end
else
Result := False;
end;
begin
FMoved := True;
FDrag := False;
FAlign := FDesigner.GridAlign;
if ssAlt in Shift then
FAlign := not FAlign;
w := 2;
if FirstChange and FDown and not FRFlag then
begin
kx := x - FLastX;
ky := y - FLastY;
if not FDesigner.GridAlign or GridCheck then
begin
GetRegion;
FDesigner.AddUndoAction(acEdit);
end;
end;
if not FDown then
begin
if FDesigner.OB6.Down then
begin
FMode := mdSelect;
Cursor := crPencil;
end
else if FDesigner.OB1.Down then
begin
FMode := mdSelect;
Cursor := crDefault;
if SelNum = 0 then
begin
ShowSizes := False;
OldRect := Rect(x, y, x, y);
FDesigner.PBox1Paint(nil);
end;
end
else
begin
FMode := mdInsert;
if Cursor <> crCross then
begin
RoundCoord(x, y);
FDesigner.GetDefaultSize(kx, ky);
if FDesigner.OB3.Down then
kx := Width;
OldRect := Rect(x, y, x + kx, y + ky);
if FDesigner.PageType = ptReport then
DrawFocusRect(OldRect);
end;
Cursor := crCross;
end;
end;
if (FMode = mdInsert) and not FDown then
begin
if FDesigner.PageType =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -