📄 editcompunit.pas
字号:
{*********************************************}
{* RepoEdit - QuickReport Editor *}
{* for Delphi 4 *}
{* (R) Copyright *}
{* Borzov Vladimir borzov@rsm.ru *}
{*********************************************}
unit EditCompUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
db, DBTables,
QuickRPT,QRCTRLS,QRPRNTR,
extctrls,Buttons,StdCtrls,printers,
RepoEdit,menus,jpeg;
type TRectLab=(rlTopLeft,rlTop,rlTopRight,
rlRight,
rlBottomRight,rlBottom,rlBottomLeft,
rlLeft);
type
TRectLabel=class(TLabel)
private
OldX:integer;
OldY:integer;
public
ID:tRectLab;
procedure MouseDown(Button: TMouseButton;Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;
end;
type
TEditlabel = class(tLabel)
private
OldX:integer;
OldY:integer;
LastMouseX:integer;
LastMouseY:integer;
FSelected:boolean;
ThRect:array[TRectLab] of TRectlabel;
procedure SetSelected(Value:boolean);
procedure SetRectCoord;
public
OBJ:TComponent;
IsChanged:boolean;
IsDefault:boolean;
constructor CreateComp(AOwner:TComponent;AComp:TComponent;APopup:TPopupMenu);
destructor Destroy; override;
procedure Click; override;
procedure DblClick; override;
procedure DoEditor;
procedure Paint; override;
procedure GetMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
// procedure GetMouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
procedure GetMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
// procedure Move
property Selected:boolean read FSelected write SetSelected;
end;
implementation
uses EditFormUnit;
constructor TEditlabel.CreateComp(AOwner:TComponent;AComp:TComponent;APopup:TPopupMenu);
var thNotFrontBack:integer;
iRect:TRectLab;
begin
inherited Create(Aowner);
visible:=false;
OBj:=AComp;
LastMouseX:=0;
LastMouseY:=0;
Name:='Lab_'+AComp.Name;
Caption:='';
// Self.SetDesigning(True);
FSelected:=false;
for iRect:=Low(ThRect) to High(ThRect) do begin
ThRect[iRect]:=nil;
end;
Cursor:=crHandPoint;
AutoSize:=false;
WordWrap:=false;
OnMouseDown:=GetMouseDown;
OnMouseMove:=GetMouseMove;
// OnMouseUp:=GetMouseUp;
if AComp is TQRPrintable then (AComp as TCustomControl).Visible:=false;
if (AComp is TQRCustomBand)
then begin
Parent:=TWinControl(AComp);
Align:=alClient;
end
else Parent:=(AComp as TCustomControl).Parent; //(Owner as TRepoedit).ThForm;
// Self.Top:=(AComp as TCustomControl).Top;
// Self.Left:=(AComp as TCustomControl).Left;
if AComp is TQRBasePanel then Self.SendToBack
else begin
ThNotFrontBack:=(AOwner as TRepoEdit).RestoreNotFrontBack(AComp.Name);
if ThNotFrontBack=1 then Self.BringToFront
else if ThNotFrontBack=2 then Self.SendToBack;
end;
PopupMenu:=APopup;
ShowHint:=true;
if AComp is TQRLabel then Hint:='Label'
else if AComp is TQRDBText then Hint:='Field'
else if AComp is TQRMemo then Hint:='Text downloaded from file'
else if AComp is TQRImage then Hint:='Picture downloaded from file'
else if AComp is TQRDBImage then Hint:='Picture - field'
else if AComp is TQRShape then Hint:='Shape'
else if AComp is TQRExpr then Hint:='Summary data'
else if AComp is TQRSysData then Hint:='System data'
else if AComp is TQRBand then Hint:='Panel'
else if AComp is TQRSubDetail then Hint:='Subdetail panel'
else if AComp is TQRRichText then HInt:='RTF-Text'
else if AComp is TQRDBRichText then Hint:='Formatted field';
Visible:=true;
IsChanged:=false;
IsDefault:=true;
end;
destructor tEditLabel.Destroy;
begin
Selected:=false;
inherited Destroy;
end;
procedure TEditlabel.Click;
begin
if Assigned((Owner as TRepoEdit).AppendOBj) then begin
if OBJ is TQRBasePanel then begin
(Owner as TRepoEdit).AppendOBj.parent:=OBJ as TWinControl;
(Owner as TRepoEdit).AppendOBj.Left:=LastMouseX;
(Owner as TRepoEdit).AppendOBj.Top:=LastMouseY;
end
else begin
(Owner as TRepoEdit).AppendOBj.parent:=(OBJ as TWinControl).parent;
(Owner as TRepoEdit).AppendOBj.Left:=LastMouseX+(Obj as TWinControl).Left;
(Owner as TRepoEdit).AppendOBj.Top:=LastMouseY+(Obj as TWinControl).Top;
end;
with TEditlabel.CreateComp((Owner as TRepoEdit),
(Owner as TRepoEdit).AppendOBj,(Owner as TRepoEdit).ThPopupMenu) do
begin
Selected:=true;
IsChanged:=true
end;
(Owner as TRepoEdit).AppendOBj:=nil;
end
else begin
inherited Click;
IsChanged:=true;
end
end;
procedure TEditlabel.DblClick;
begin
inherited DblClick;
DoEditor;
end;
procedure TEditlabel.DoEditor;
var EdF:TEditForm;
begin
EdF:=TEditForm.Create(Application);
EdF.ThComp:=Self;
EdF.Caption:= EdF.Caption+' ('+Self.OBJ.Name+')';
EdF.ShowModal;
EdF.Free;
Repaint;
end;
procedure TEditlabel.Paint;
//var ThID:integer;
var i,k,k1:integer;
begin
inherited;
if Assigned(OBJ) {and ( not (Owner as tRepoEdit).ThPanel.EditHideDisabled.Checked or (OBJ as TCustomControl).Enabled)}
then begin
if (OBJ is TCustomControl) and (Self.Align=alNone) then begin
if Self.Top<>(OBJ as TCustomControl).Top
then Self.Top:=(OBJ as TCustomControl).Top;
if Self.Left<>(OBJ as TCustomControl).Left
then Self.Left:=(OBJ as TCustomControl).Left;
if Self.height<>(OBJ as TCustomControl).height
then Self.height:=(OBJ as TCustomControl).height;
if Self.width<>(OBJ as TCustomControl).width
then Self.width:=(OBJ as TCustomControl).width;
end;
if OBJ is TQRlabel then begin
if Self.Transparent<>(OBJ as TQRLabel).Transparent
then Self.Transparent:=(OBJ as TQRLabel).Transparent
end
else if OBJ is TQRDBText then begin
if Self.Transparent<>(OBJ as TQRDBText).Transparent
then Self.Transparent:=(OBJ as TQRDBText).Transparent
end
else if OBJ is TQRExpr then begin
if Self.Transparent<>(OBJ as TQRExpr).Transparent
then Self.Transparent:=(OBJ as TQRExpr).Transparent
end
else if OBJ is TQRSysData then begin
if Self.Transparent<>(OBJ as TQRSysData).Transparent
then Self.Transparent:=(OBJ as TQRSysData).Transparent
end
else if OBJ is TQRMemo then begin
if Self.Transparent<>(OBJ as TQRMemo).Transparent
then Self.Transparent:=(OBJ as TQRMemo).Transparent
end
else if Self.Transparent<>true then Self.Transparent:=true;
if (OBJ is TQRCustomlabel) then begin
if Self.font<>(OBJ as TQRCustomLabel).Font
then Self.font:=(OBJ as TQRCustomLabel).Font;
if Self.alignment<>(OBJ as TQRCustomLabel).Alignment
then Self.alignment:=(OBJ as TQRCustomLabel).Alignment;
end;
if OBJ is TQRMemo then begin
if Self.Caption<>'{Text}' then Self.Caption:='{Text}'
end
else if OBJ is TQRCustomLabel then begin
if Self.AutoSize<>(OBJ as TQRCustomLabel).AutoSize
then Self.AutoSize:=(OBJ as TQRCustomLabel).AutoSize;
if Self.WordWrap<>(OBJ as TQRCustomLabel).WordWrap
then Self.WordWrap:=(OBJ as TQRCustomLabel).WordWrap;
if obj is TQRDBText then begin
if Self.Caption<>(OBJ as TQRDBText).DataField
then Self.Caption:=(OBJ as TQRDBText).DataField;
end
else
if Self.Caption<>(OBJ as TQRCustomLabel).Caption
then Self.Caption:=(OBJ as TQRCustomLabel).Caption;
end
else if OBJ is TQRImage then begin
if (((OBJ as TQRImage).Picture.Graphic=nil) or ((OBJ as TQRImage).Picture.Graphic.Empty)) then begin
if (Self.Caption<>'{Picture}') then Self.Caption:='{Picture}'
end
else begin
if not ((OBJ as TQRImage).Stretch) then
if (OBJ as TQRImage).Center then
Self.Canvas.Draw(
((Self.ClientRect.Right-Self.ClientRect.Left) div 2)
-((OBJ as TQRImage).Picture.Graphic.Width div 2),
((Self.ClientRect.Bottom-Self.ClientRect.Top) div 2)
-((OBJ as TQRImage).Picture.Graphic.Height div 2),
(OBJ as TQRImage).Picture.Graphic)
else
Self.Canvas.Draw(0,0,(OBJ as TQRImage).Picture.Graphic)
else
Self.Canvas.StretchDraw(Self.ClientRect,(OBJ as TQRImage).Picture.Graphic)
end;
end
else if OBJ is TQRDBImage then begin
if Self.Caption<>(OBJ as TQRDBImage).DataField
then Self.Caption:=(OBJ as TQRDBImage).DataField;
end
else if OBJ is TQRCustomRichText then begin
// if (OBJ is TQRRichText) and ((OBJ as TQRRichText).Lines.Count>0) then begin
// ThID:= Self.Parent.Handle;
// (obj as TQRRichText).
// (obj as TQRRichText).Visible:=true;// ( self.GetDeviceContext(ThID),5,5);
// (obj as TQRRichText).PaintTo( self.GetDeviceContext(ThID),5,5);
// end
// else begin
if Self.Caption<>'{RTF}'
then Self.Caption:='{RTF}';
// end
end;
if OBJ is TQRCustomLabel then begin
Self.Color:=(OBJ as TQRCustomLabel).Color
end
else if (OBJ is TQRCustomRichText) then begin
Self.Color:=(OBJ as TQRCustomRichText).color;
end
else if (OBJ is TQRCustomBand) then begin
Self.Color:=(OBJ as TQRCustomBand).color;
end;
if OBJ is TQRPrintable then begin
Canvas.pen.Color:=(OBJ as TQRPrintable).Frame.Color;
// Canvas.Pen.Width:=(OBJ as TQRPrintable).Frame.Width;
Canvas.Pen.Width:=1;
k:=(OBJ as TQRPrintable).Frame.Width;
if (OBJ as TQRPrintable).Frame.DrawBottom
then for i:=0 to k-1 do begin
Canvas.MoveTo(0,ClientHeight-i);
Self.Canvas.LineTo(ClientWidth,Clientheight-i);
end;
if (OBJ as TQRPrintable).Frame.DrawTop
then for i:=0 to k-1 do begin
Canvas.MoveTo(0,i);
Self.Canvas.LineTo(ClientWidth,i);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -