📄 fr_desgn.pas
字号:
if Down and (Cursor = crPencil) then
begin
kx := x - LastX;
ky := y - LastY;
if FDesigner.GridAlign and not GridCheck then Exit;
DrawRectLine(OldRect);
OldRect := Rect(OldRect.Left, OldRect.Top, OldRect.Right + kx, OldRect.Bottom + ky);
DrawRectLine(OldRect);
Inc(LastX, kx);
Inc(LastY, ky);
Exit;
end;
// check for multiple selected objects - right-bottom corner
if not Down and (SelNum > 1) and (Mode = mdSelect) then
begin
t := Objects[RightBottom];
if Cont(t.x + t.dx, t.y + t.dy, x, y) then
Cursor := crSizeNWSE
end;
// split checking
if not Down and (SelNum > 1) and (Mode = mdSelect) then
begin
for i := 0 to Objects.Count-1 do
begin
t := Objects[i];
if (t.Typ <> gtBand) and t.Selected then
if (x >= t.x) and (x <= t.x + t.dx) and (y >= t.y) and (y <= t.y + t.dy) then
begin
for j := 0 to Objects.Count - 1 do
begin
t1 := Objects[j];
if (t1.Typ <> gtBand) and (t1 <> t) and t1.Selected then
if ((t.x = t1.x + t1.dx) and ((x >= t.x) and (x <= t.x + 2))) or
((t1.x = t.x + t.dx) and ((x >= t1.x - 2) and (x <= t.x))) then
begin
Cursor := crHSplit;
with SplitInfo do
begin
SplRect := Rect(x, t.y, x, t.y + t.dy);
if t.x = t1.x + t1.dx then
begin
SplX := t.x;
View1 := t1;
View2 := t;
end
else
begin
SplX := t1.x;
View1 := t;
View2 := t1;
end;
SplRect.Left := SplX;
SplRect.Right := SplX;
end;
end;
end;
end;
end;
end;
// splitting
if Down and MRFlag and (Mode = mdSelect) and (Cursor = crHSplit) then
begin
kx := x - LastX;
ky := 0;
if FDesigner.GridAlign and not GridCheck then Exit;
with SplitInfo do
begin
DrawHSplitter(SplRect);
SplRect := Rect(SplRect.Left + kx, SplRect.Top, SplRect.Right + kx, SplRect.Bottom);
DrawHSplitter(SplRect);
end;
Inc(LastX, kx);
Exit;
end;
// sizing several objects
if Down and MRFlag and (Mode = mdSelect) and (Cursor <> crDefault) then
begin
kx := x - LastX;
ky := y - LastY;
if FDesigner.GridAlign and not GridCheck then Exit;
if FDesigner.ShapeMode = smFrame then
DrawPage(dmShape)
else
begin
hr := CreateRectRgn(0, 0, 0, 0);
hr1 := CreateRectRgn(0, 0, 0, 0);
end;
OldRect := Rect(OldRect.Left, OldRect.Top, OldRect.Right + kx, OldRect.Bottom + ky);
nx := (OldRect.Right - OldRect.Left) / (OldRect1.Right - OldRect1.Left);
ny := (OldRect.Bottom - OldRect.Top) / (OldRect1.Bottom - OldRect1.Top);
for i := 0 to Objects.Count - 1 do
begin
t := Objects[i];
if t.Selected then
begin
if FDesigner.ShapeMode = smAll then
AddRgn(hr, t);
x1 := (t.OriginalRect.Left - LeftTop.x) * nx;
x2 := t.OriginalRect.Right * nx;
dx := Round(x1 + x2) - (Round(x1) + Round(x2));
t.x := LeftTop.x + Round(x1); t.dx := Round(x2) + dx;
y1 := (t.OriginalRect.Top - LeftTop.y) * ny;
y2 := t.OriginalRect.Bottom * ny;
dy := Round(y1 + y2) - (Round(y1) + Round(y2));
t.y := LeftTop.y + Round(y1); t.dy := Round(y2) + dy;
if FDesigner.ShapeMode = smAll then
AddRgn(hr1, t);
end;
end;
if FDesigner.ShapeMode = smFrame then
DrawPage(dmShape)
else
begin
Draw(10000, hr);
Draw(10000, hr1);
end;
Inc(LastX, kx);
Inc(LastY, ky);
FDesigner.PBox1Paint(nil);
Exit;
end;
// moving
if Down and (Mode = mdSelect) and (SelNum >= 1) and (Cursor = crDefault) then
begin
kx := x - LastX;
ky := y - LastY;
if FDesigner.GridAlign and not GridCheck then Exit;
if FirstBandMove and (SelNum = 1) and ((kx <> 0) or (ky <> 0)) and
not (ssAlt in Shift) then
if TfrView(Objects[TopSelected]).Typ = gtBand then
begin
Bnd := Objects[TopSelected];
for i := 0 to Objects.Count-1 do
begin
t := Objects[i];
if t.Typ <> gtBand then
if (t.x >= Bnd.x) and (t.x + t.dx <= Bnd.x + Bnd.dx) and
(t.y >= Bnd.y) and (t.y + t.dy <= Bnd.y + Bnd.dy) then
begin
t.Selected := True;
Inc(SelNum);
end;
end;
FDesigner.SelectionChanged;
GetMultipleSelected;
end;
FirstBandMove := False;
if FDesigner.ShapeMode = smFrame then
DrawPage(dmShape)
else
begin
hr := CreateRectRgn(0, 0, 0, 0);
hr1 := CreateRectRgn(0, 0, 0, 0);
end;
for i := 0 to Objects.Count - 1 do
begin
t := Objects[i];
if not t.Selected then continue;
if FDesigner.ShapeMode = smAll then
AddRgn(hr, t);
t.x := t.x + kx;
t.y := t.y + ky;
if FDesigner.ShapeMode = smAll then
AddRgn(hr1, t);
end;
if FDesigner.ShapeMode = smFrame then
DrawPage(dmShape)
else
begin
CombineRgn(hr, hr, hr1, RGN_OR);
DeleteObject(hr1);
Draw(10000, hr);
end;
Inc(LastX, kx);
Inc(LastY, ky);
FDesigner.PBox1Paint(nil);
end;
// resizing
if Down and (Mode = mdSelect) and (SelNum = 1) and (Cursor <> crDefault) then
begin
kx := x - LastX;
ky := y - LastY;
if FDesigner.GridAlign and not GridCheck then Exit;
t := Objects[TopSelected];
if FDesigner.ShapeMode = smFrame then
DrawPage(dmShape) else
hr := t.GetClipRgn(rtExtended);
w := 3;
if Cursor = crSizeNWSE then
if (CT <> ct2) and ((CT = ct1) or Cont(t.x, t.y, LastX, LastY)) then
begin
t.x := t.x + kx;
t.dx := t.dx - kx;
t.y := t.y + ky;
t.dy := t.dy - ky;
CT := ct1;
end
else
begin
t.dx := t.dx + kx;
t.dy := t.dy + ky;
CT := ct2;
end;
if Cursor = crSizeNESW then
if (CT <> ct4) and ((CT = ct3) or Cont(t.x + t.dx, t.y, LastX, LastY)) then
begin
t.y := t.y + ky;
t.dx := t.dx + kx;
t.dy := t.dy - ky;
CT := ct3;
end
else
begin
t.x := t.x + kx;
t.dx := t.dx - kx;
t.dy := t.dy + ky;
CT := ct4;
end;
if Cursor = crSizeWE then
if (CT <> ct6) and ((CT = ct5) or Cont(t.x, t.y + t.dy div 2, LastX, LastY)) then
begin
t.x := t.x + kx;
t.dx := t.dx - kx;
CT := ct5;
end
else
begin
t.dx := t.dx + kx;
CT := ct6;
end;
if Cursor = crSizeNS then
if (CT <> ct8) and ((CT = ct7) or Cont(t.x + t.dx div 2, t.y, LastX, LastY)) then
begin
t.y := t.y + ky;
t.dy := t.dy - ky;
CT := ct7;
end
else
begin
t.dy := t.dy + ky;
CT := ct8;
end;
if FDesigner.ShapeMode = smFrame then
DrawPage(dmShape)
else
begin
CombineRgn(hr, hr, t.GetClipRgn(rtExtended), RGN_OR);
Draw(10000, hr);
end;
Inc(LastX, kx);
Inc(LastY, ky);
FDesigner.PBox1Paint(nil);
end;
end;
procedure TfrDesignerPage.DClick(Sender: TObject);
begin
Down := False;
if SelNum = 0 then
begin
FDesigner.PgB3Click(nil);
DFlag := True;
end
else if SelNum = 1 then
begin
DFlag := True;
FDesigner.ShowEditor;
end
else Exit;
end;
procedure TfrDesignerPage.CMMouseLeave(var Message: TMessage);
begin
if (Mode = mdInsert) and not Down then
begin
DrawFocusRect(OldRect);
OffsetRect(OldRect, -10000, -10000);
end;
end;
{-----------------------------------------------------------------------------}
procedure BDown(SB: TfrSpeedButton);
begin
SB.Down := True;
end;
procedure BUp(SB: TfrSpeedButton);
begin
SB.Down := False;
end;
function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
FontType: Integer; Data: Pointer): Integer; stdcall;
begin
TfrDesignerForm(frDesigner).C2.Items.AddObject(StrPas(LogFont.lfFaceName), TObject(FontType));
Result := 1;
end;
procedure TfrDesignerForm.GetFontList;
var
DC: HDC;
begin
C2.Items.Clear;
DC := GetDC(0);
EnumFonts(DC, nil, @EnumFontsProc, nil);
ReleaseDC(0, DC);
LastFontName := C2.Items[0];
if C2.Items.IndexOf('Arial') <> -1 then
LastFontName := 'Arial'
else if C2.Items.IndexOf('Arial Cyr') <> -1 then
LastFontName := 'Arial Cyr';
LastFontSize := 10;
end;
procedure TfrDesignerForm.FormCreate(Sender: TObject);
var
i: Integer;
begin
Busy := True;
FirstTime := True;
FirstInstance := FirstInst;
// these invisible panels are added to set scroll range to
// 0..Preview.Width+10 and 0..Preview.Height+10
BPanel := TPanel.Create(ScrollBox1);
BPanel.Parent := ScrollBox1;
BPanel.Height := 1; BPanel.Left := 0; BPanel.Top := ScrollBox1.Height;
BPanel.Color := ScrollBox1.Color;
RPanel := TPanel.Create(ScrollBox1);
RPanel.Parent := ScrollBox1;
RPanel.Width := 1; RPanel.Left := ScrollBox1.Width; RPanel.Top := 0;
RPanel.Color := ScrollBox1.Color;
PageView := TfrDesignerPage.Create(ScrollBox1);
PageView.FDesigner := Self;
PageView.PopupMenu := Popup1;
PageView.ShowHint := True;
ColorSelector := TColorSelector.Create(Self);
ColorSelector.OnColorSelected := ColorSelected;
for i := 0 to frAddInsCount - 1 do
with frAddIns[i] do
RegisterObject(ButtonBmp, ButtonHint, Integer(gtAddIn) + i);
if FirstInstance then
begin
frRegisterTool(LoadStr(SInsertFields), Image2.Picture.Bitmap, InsFieldsClick);
for i := 0 to frToolsCount - 1 do
with frTools[i] do
RegisterTool(Caption, ButtonBmp, OnClick);
end;
InspForm := TfrInspForm.Create(nil);
EditorForm := TfrEditorForm.Create(nil);
with InspForm do
begin
ClearItems;
Items.AddObject('Name', TProp.Create(@fld[0], csEdit, nil));
Items.AddObject('Left', TProp.Create(@fld[1], csEdit, nil));
Items.AddObject('Top', TProp.Create(@fld[2], csEdit, nil));
Items.AddObject('Width', TProp.Create(@fld[3], csEdit, nil));
Items.AddObject('Height', TProp.Create(@fld[4], csEdit, nil));
Items.AddObject('Visible', TProp.Create(@fld[5], csEdit, nil));
Items.AddObject('Memo', TProp.Create(@fld[6], csDefEditor, EditorForm));
OnModify := Self.OnModify;
end;
MenuItems := TList.Create;
ItemWidths := TStringlist.Create;
if FirstInstance then
begin
Application.OnActivate := OnActivateApp;
Application.OnDeactivate := OnDeactivateApp;
end
else
begin
PgB1.Enabled := False;
PgB2.Enabled := False;
N41.Enabled := False;
N43.Enabled := False;
N29.Enabled := False;
N30.Enabled := False;
end;
FirstInst := False;
FCaption := LoadStr(frRes + 080);
Panel1.Caption := LoadStr(frRes + 081);
Panel2.Caption := LoadStr(frRes + 082);
Panel3.Caption := LoadStr(frRes + 083);
Panel4.Caption := LoadStr(frRes + 084);
Panel5.Caption := LoadStr(frRes + 085);
Panel6.Caption := LoadStr(frRes + 086);
FileBtn1.Hint := LoadStr(frRes + 087);
FileBtn2.Hint := LoadStr(frRes + 088);
FileBtn3.Hint := LoadStr(frRes + 089);
FileBtn4.Hint := LoadStr(frRes + 090);
CutB.Hint := LoadStr(frRes + 091);
CopyB.Hint := LoadStr(frRes + 092);
PstB.Hint := LoadStr(frRes + 093);
UndoB.Hint := LoadStr(frRes + 094);
RedoB.Hint := LoadStr(frRes + 095);
ZB1.Hint := LoadStr(frRes + 096);
ZB2.Hint := LoadStr(frRes + 097);
SelAllB.Hint := LoadStr(frRes + 098);
PgB1.Hint := LoadStr(frRes + 099);
PgB2.Hint := LoadStr(frRes + 100);
PgB3.Hint := LoadStr(frRes + 101);
GB1.Hint := LoadStr(frRes + 102);
GB2.Hint := LoadStr(frRes + 103);
GB3.Hint := LoadStr(frRes + 104);
HelpBtn.Hint := LoadStr(frRes + 032);
ExitB.Caption := LoadStr(frRes + 105);
ExitB.Hint := LoadStr(frRes + 106);
AlB1.Hint := LoadStr(frRes + 107);
AlB2.Hint := LoadStr(frRes + 108);
AlB3.Hint := LoadStr(frRes + 109);
AlB4.Hint := LoadStr(frRes + 110);
AlB5.Hint := LoadStr(frRes + 111);
AlB6.Hint := LoadStr(frRes + 112);
AlB7.Hint := LoadStr(frRes + 113);
AlB8.Hint := LoadStr(frRes + 114);
FnB1.Hint := LoadStr(frRes + 115);
FnB2.Hint := LoadStr(frRes + 116);
FnB3.Hint := LoadStr(frRes + 117);
ClB2.Hint := LoadStr(frRes + 118);
HlB1.Hint := LoadStr(frRes + 119);
C3.Hint := LoadStr(frRes + 120);
C2.Hint := LoadStr(frRes + 121);
FrB1.Hint := LoadStr(frRes + 122);
FrB2.Hint := LoadStr(frRes + 123);
FrB3.Hint := LoadStr(frRes + 124);
FrB4.Hint := LoadStr(frRes + 125);
FrB5.Hint := LoadStr(frRes + 126);
FrB6.Hint := LoadStr(frRes + 127);
ClB1.Hint := LoadStr(frRes + 128);
ClB3.Hint := LoadStr(frRes + 129);
E1.Hint := LoadStr(frRes + 130);
OB1.Hint := LoadStr(frRes + 132);
OB2.Hint := LoadStr(frRes + 133);
OB3.Hint := LoadStr(frRes + 134);
OB4.Hint := LoadStr(frRes + 135);
OB5.Hint := LoadStr(frRes + 136);
OB6.Hint := LoadStr(frRes + 137);
Align1.Hint := LoadStr(frRes + 138);
Align2.Hint := LoadStr(frRes + 139);
Align3.Hint := LoadStr(frRes + 140);
Align4.Hint := LoadStr(frRes + 141);
Align5.Hint := LoadStr(frRes + 142);
Align6.Hint := LoadStr(frRes + 143);
Align7.Hint := LoadStr(frRes + 144);
Align8.Hint := LoadStr(frRes + 145);
Align9.Hint := LoadStr(frRes + 146);
Align10.Hint := LoadStr(frRes + 147);
N2.Caption := LoadStr(frRes + 148);
N1.Caption := LoadStr(frRes + 149);
N3.Caption := LoadStr(frRes + 150);
N5.Caption := LoadStr(frRes + 151);
N16.Caption := LoadStr(frRes + 152);
N6.Caption := LoadStr(frRes + 153);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -