editcompunit.pas
来自「一个报表控件TRepoEdit」· PAS 代码 · 共 650 行 · 第 1/2 页
PAS
650 行
end;
if (OBJ as TQRPrintable).Frame.DrawRight
then for i:=0 to k-1 do begin
Canvas.MoveTo(ClientWidth-i,0);
Self.Canvas.LineTo(ClientWidth-i,Clientheight);
end;
if (OBJ as TQRPrintable).Frame.DrawLeft
then for i:=0 to k-1 do begin
Canvas.MoveTo(i,0);
Self.Canvas.LineTo(i,Clientheight);
end;
if (OBJ is TQRShape) then begin
self.Canvas.pen:=(OBJ as TQRShape).Pen;
k1:=Self.Canvas.pen.width;
Self.Canvas.pen.width:=1;
if (OBJ as TQRShape).Shape=qrsrectangle
then for i:=0 to k1-1 do Canvas.Rectangle(ClientRect.Left+i,ClientRect.Top+i,ClientRect.Right-i,ClientRect.Bottom-i)
else if (OBJ as TQRShape).Shape=qrsCircle
then for i:=0 to k1-1 do Canvas.Ellipse(ClientRect.Left+i,ClientRect.Top+i,ClientRect.Right-i,ClientRect.Bottom-i)
else if (OBJ as TQRShape).Shape=qrsVertLine then
for i:=0 to k1-1 do begin
Canvas.MoveTo(ClientWidth div 2+i,0);
Self.Canvas.LineTo(ClientWidth div 2+i,Clientheight);
end
else if (OBJ as TQRShape).Shape=qrsHorLine then
for i:=0 to k1-1 do begin
Canvas.MoveTo(0,ClientHeight div 2+i);
Self.Canvas.LineTo(ClientWidth,Clientheight div 2+i);
end
else if (OBJ as TQRShape).Shape=qrsTopAndBottom then
for i:=0 to k1-1 do begin
Canvas.MoveTo(0,i);
Self.Canvas.LineTo(ClientWidth-Canvas.Pen.Width,i);
Canvas.MoveTo(0,ClientHeight-Canvas.Pen.Width-i);
Self.Canvas.LineTo(ClientWidth-Canvas.Pen.Width,ClientHeight-Canvas.Pen.Width-i);
end
else if (OBJ as TQRShape).Shape=qrsRightAndLeft then
for i:=0 to k1-1 do begin
Canvas.MoveTo(i,0);
Self.Canvas.LineTo(i,ClientHeight);
Canvas.MoveTo(ClientWidth-Canvas.Pen.Width-i,0);
Self.Canvas.LineTo(ClientWidth-Canvas.Pen.Width-i,ClientHeight-Canvas.Pen.Width);
end;
Self.Canvas.pen.width:=k1;
end;
end
else if OBJ is TQRBasePanel then begin
Canvas.pen.Color:=(OBJ as TQRBasePanel).Frame.Color;
Canvas.Pen.Width:=(OBJ as TQRBasePanel).Frame.Width;
if (OBJ as TQRBasePanel).Frame.DrawBottom
then begin
Canvas.MoveTo(0,ClientHeight-1);
Self.Canvas.LineTo(ClientWidth-1,Clientheight-1);
end;
if (OBJ as TQRBasePanel).Frame.DrawTop
then begin
Canvas.MoveTo(0,0);
Self.Canvas.LineTo(ClientWidth-1,0);
end;
if (OBJ as TQRBasePanel).Frame.DrawRight
then begin
Canvas.MoveTo(ClientWidth-1,0);
Self.Canvas.LineTo(ClientWidth-1,Clientheight-1);
end;
if (OBJ as TQRBasePanel).Frame.DrawLeft
then begin
Canvas.MoveTo(0,0);
Self.Canvas.LineTo(0,Clientheight-1);
end;
// if not fieldByname('Frame.Style').IsNULL
// then (ThComp as TQRBasePanel).Frame.Style:=TPenStyle(FieldByName('Frame.Style').AsInteger);
end;
if not (OBJ as TCustomControl).Enabled then begin
Canvas.Pen.Color:=clRed;
Canvas.pen.Width:=1;
Canvas.pen.Style:=psSolid;
// Canvas.Pen.Style=; //TPenMode
// Canvas.Rectangle(ClientRect.Left+1,ClientRect.Top+1,ClientRect.Right,ClientRect.Bottom);// FrameRect(Label7.Canvas.ClipRect);
Canvas.MoveTo(ClientRect.Left+1,ClientRect.Top+1);
canvas.LineTo(ClientRect.Right-1,ClientRect.Bottom-1);
Canvas.MoveTo(ClientRect.Right-1,ClientRect.Top+1);
canvas.LineTo(ClientRect.Left+1,ClientRect.Bottom-1);
end;
end;
if csClicked in ControlState then begin
Canvas.Pen.Color:=clBlue;
Canvas.pen.Width:=1;
Canvas.pen.Style:=psDot;
// Canvas.Pen.Style=; //TPenMode
Canvas.Rectangle(ClientRect.Left+1,ClientRect.Top+1,ClientRect.Right,ClientRect.Bottom);// FrameRect(Label7.Canvas.ClipRect);
end;
SetRectCoord;
// inherited;
end;
procedure TEditlabel.GetMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
// inherited MouseDown(Sender,Button,Shift,X,Y,);
if (ssLeft in Shift) then begin
OldX:=X;
OldY:=Y;
end
else if (ssRight in shift) and ((Owner as TRepoEdit).AppendObj<>nil)
then (Owner as TRepoEdit).AppendObj:=nil;
if not Selected then begin
IsChanged:=true;
Selected:=true
end
else Repaint;
end;
procedure TEditlabel.GetMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
//var Str:string;
begin
// inherited MouseMove(Sender,Shift,X,Y);
LastMouseX:=X;
LastMouseY:=Y;
if (ssLeft in Shift) then begin
// BeginDrag(false);
Left:=Left+x-OldX;
Top:=Top+y-OldY;
if Assigned(OBJ) then begin
(OBJ as TCustomControl).Left:=Left;
(OBJ as TCustomControl).Top:=Top;
end;
// EndDrag(True);
end;
end;
procedure TEditLabel.SetSelected(Value:boolean);
var iRect:TRectLab;
ThLab:TRectlabel;
i:integer;
begin
for i:=0 to Owner.ComponentCount-1 do
if not (Owner.Components[i]=Self)
and (Owner.Components[i] is TEditLabel)
and (Owner.Components[i] as TEditLabel).Selected
then (Owner.Components[i] as TEditlabel).Selected:=false;
FSelected:=Value;
for iRect:=Low(ThRect) to High(ThRect) do
if Assigned(ThRect[iRect]) then begin
ThRect[iRect].Free;
ThRect[iRect]:=nil;
end;
if Value Then for iRect:=Low(ThRect) to High(ThRect) do begin
ThLab:=TRectLabel.Create(Self);
ThLab.ID:=irect;
ThLab.Parent:=self.Parent;
ThRect[iRect]:=ThLab;
thLab.Color:=clBlack;
ThLab.Width:=5;
ThLab.Height:=5;
case iRect of
rlTopLeft:
begin
ThLab.Cursor:=crSizeNWSE;
end;
rlTop:
begin
ThLab.Cursor:=crSizeNS;
end;
rlTopRight:
begin
ThLab.Cursor:=crSizeNESW;
end;
rlRight:
begin
ThLab.Cursor:=crSizeWE;
end;
rlBottomRight:
begin
ThLab.Cursor:=crSizeNWSE;
end;
rlBottom:
begin
ThLab.Cursor:=crSizeNS;
end;
rlBottomLeft:
begin
ThLab.Cursor:=crSizeNESW;
end;
else
begin
ThLab.Cursor:=crSizeWE;
end;
end;
// ThLab.OnMouseDown:=GetRectMouseDown;
// ThLab.OnMouseMove:=GetRectMouseMove;
end;
Repaint;
end;
procedure TEditLabel.SetRectCoord;
var iRect:TRectLab;
ThLab:TRectLabel;
begin
for iRect:=Low(ThRect) to High(ThRect) do
if Assigned(ThRect[iRect]) then begin
ThLab:=ThRect[iRect];
case iRect of
rlTopLeft:
begin
ThLab.Top:=Self.Top-2;
ThLab.Left:=Self.Left-2;
end;
rlTop:
begin
ThLab.Top:=top-2;
ThLab.Left:=Left+Width div 2-2;
end;
rlTopRight:
begin
ThLab.Top:=Top-2;
ThLab.Left:=Left+width-2;
end;
rlRight:
begin
ThLab.Top:=Top+height div 2-2;
ThLab.Left:=left+width-2;
end;
rlBottomRight:
begin
ThLab.Top:=Top+Height-2;
ThLab.Left:=Left+width - 2;
end;
rlBottom:
begin
ThLab.Top:=Top+height-2;
ThLab.Left:=Left+width div 2-2;
end;
rlBottomLeft:
begin
ThLab.Top:=Top+height-2;
ThLab.Left:=Left-2;
end;
else
begin
ThLab.Top:=Top+height div 2 -2;
ThLab.Left:=Left-2;
end;
end;
if not ThLab.visible then ThLab.Visible:=true;
end;
end;
procedure TRectLabel.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ssleft in Shift then begin
OldX:=X;
OldY:=Y;
end;
inherited;
end;
procedure TRectLabel.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
inherited;
if (ssLeft in Shift) and (Owner is tEditlabel)
and ((Owner as TEditLabel).obj is TCustomControl)
then with (Owner as TEditLabel).obj as TCustomControl do begin
// BeginDrag(false);
case ID of
rlTopLeft:
begin
Left:=Left+x-Self.OldX;
width:=width-x+self.oldx;
Top:=Top+y-Self.OldY;
height:=height-y+Self.oldY;
end;
rlTop:
begin
Top:=Top+y-Self.OldY;
height:=height-y+Self.oldY;
end;
rlTopRight:
begin
width:=width+x-Self.OldX;
Top:=Top+y-Self.OldY;
height:=height-y+Self.oldY;
end;
rlRight:
begin
width:=width+x-Self.OldX;
end;
rlBottomRight:
begin
width:=width+x-Self.OldX;
height:=height+y-self.OldY;
end;
rlBottom:
begin
height:=height+y-self.OldY;
end;
rlBottomLeft:
begin
Left:=Left+x-Self.OldX;
width:=width-x+self.oldx;
height:=height+y-self.OldY;
end;
else
begin
Left:=Left+x-Self.OldX;
width:=width-x+self.oldx;
end;
end;
// endDrag(true);
(Self.Owner as TEditLabel).Repaint;
// (Self.Owner as TEditLabel).SetRectCoord;
end
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?